How to remove/hide body parameter from Swagger UI in file upload API
Hello, I'm newbie to swagger UI development using jersey framework. I'm looking out for the resolution for below mentioned issue. Issue: Unable to remove/hide body parameter from Swagger UI Please find my Java source code: @POST @Path("/createSchedule") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(httpMethod = HttpMethod.POST, value = "Create a new export schedule(s)") @ApiImplicitParams({ @ApiImplicitParam(name = "file", value = "Upload the template (.xlsx) to create schedule(s).", required = true, dataType = "file", paramType = "formData") }) public Response createSchedule(@FormDataParam(value="file") InputStream inputStream, @FormDataParam(value="file") FormDataContentDisposition fileMetaData) throws ScheduleException { } I have used Jersey 2.29.1(jersey-container-servlet) & Swagger 1.5.0 (swagger-jaxrs) API's. Also do let me know how to allow only specific file extensions (like .xlsx) to upload from swagger ui. Thanks in advance! Cheers!Solved15KViews0likes2CommentsSwagger UI not showing operations with same Path but different HTTP method
For example I have 2 API operations: GET v1/people/{id} POST v1/people/{id} Only one of these operations is shown in my Swagger UI API docs but I want both of them displayed. I have many examples where this is the case. In the Swagger documentation it states: "Swagger defines a unique operation as a combination of a path and an HTTP method." This would make me think what I want to do is possible as they are uniquely identified by the HTTP method. If I change the path parameter for one in my swagger.yaml file they will both show. eg: GET v1/people/{personid} POST v1/people/{id} But I would rather keep them all standard otherwise my API docs will appear messy. I am using swagger-ui-express 4.1.4. Please see StackOverflow post with code:https://stackoverflow.com/questions/62769866/swagger-ui-not-showing-operations-with-same-path-but-different-http-method Thanks for your help.SolvedHow to have a custom status code in response
responses: '777': description: My Custom content: application/json: schema: type: string If I have "777" like fieldName for the status code in OAS3.0 spec YAML, then the editor.swagger.io throws an error as "should only have three-digit status codes, `default`, and vendor extensions (`x-*`) as properties" If I have the same status code in Swagger2.0 spec YAML, as below, then it doesn't throw an error. responses: '777': description: custom schema: type: string PS: I checked the indentation, it seems correct because if I change "777" in OAS3.0 spec YAML to standard status code like "400", "200" then it doesn't throw an error.SolvedHow to generate the same Bearer token as Swagger?
I have given an API which uses Basic_auth for Authentication. it requires 'username', 'password', (type:basic_auth), 'ClientId' and 'secret'. I use the Swagger UI to authenticate and it works perfectly fine: the Curl will look like this: curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1ZR0FtX2hHeWRvYWhrSGtlcjRlaTRiTXRSUSIsImtpZCI6Ik1ZR0FtX2hHeWRvYWhrSGtlcjRlaTRiTXRSUSJ9.eyJpc3MiOiJDdXN0b21lckNsdWJXZWJTZXJ2aWNlIiwiYXVkIjoiQ3VzdG9tZXJDbHViV2ViU2VydmljZS9yZXNvdXJjZXMiLCJleHAiOjE1NjM4NzY2MTEsIm5iZiI6MTU2MzI3MTgxMSwiY2xpZW50X2lkIjoiY3VzdG9tZXJjbHViIiwic2NvcGUiOlsib3BlbmlkIiwicHJvZmlsZSIsInVzZXJfaW5mbyJdLCJzdWIiOiJjdXN0b21lcmNsdWIiLCJhdXRoX3RpbWUiOjE1NjMyNzE4MTEsImlkcCI6Imlkc3J2IiwicHJpbWFyeV9zaWQiOiJjdXN0b21lcmNsdWIiLCJ1cG4iOiJjdXN0b21lcmNsdWIiLCJuYW1lIjoiY3VzdG9tZXJjbHViIiwiZ2l2ZW5fbmFtZSI6ImN1c3RvbWVyY2x1YiIsImp0aSI6IjRhMGUyZjNkYjUzYjY2ZGQxMDIwMmJkNmVmNzM4OWJjIiwiYW1yIjpbImN1c3RvbSJdfQ.YY1CzHzWPK_E1S7y8TDrwRT0orCS9zfN-4n5pTC1zYMomkOkJOdpvmSZyrabirBeLpGi870T9H-z9ufkYX5B1bPZlQlQRAAaDPeq_pV7Gls9EPLhAK8uXK4i5jaF1aNN5hiBP6fAJZxhZnHsmUevXs6y5s9FJeVZ1vPpDfJ69d3rrTvte_2A6hEE6fpkYeZGUKRS8eTaWHSrdZh9-18FaQN4VGbCCtsHR7x-A2HMLIG8q9MWp6iu_KDJ95wOHO_tp--AER4CoGta0HrleI7CNUBz43TN-kEklmzVCODuFA7varUIAiee4Zd2PKG7MlGEdkOBA5qwoX1HhsobGOI5ZA' ' The problem is, every time the token expires, I have to come back and use the Swagger UI to authenticate, and copy the Bearer token to my app. I would like to know, how Swagger is creating it? And how could I implement it on my machine so that everytime it expires, my app creates it itself instead of getting an error and changing it? I tried many ways, but I couldn't get the Bearer token the way Swagger gets it. It only works when Swagger creates it.5.6KViews0likes2CommentsObject property name as UUID
In the given API response how would you write the schema yaml to support UUIDs as a property name { "results": { "11b17cd8-0000-0000-0000-2092b242027f": [ { "id": "0000", "type": "Home", "ownership": "", "monthly": "0", "address_1": "23299 Address Parts", "address_2": "", "city": "Some City", "state": "ZZ", "zip": "00000", "active": "1", "primary": "1" } ] } } Here is my attempt (schema portion): components: schemas: uuid: type: string format: uuid description: UUID example: 00000000-0000-0000-0000-000000000000 pattern: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}' CustomerAddresses: type: object properties: '#/components/schemas/uuid': type: array items: $ref: '#/components/schemas/CustomerAddress' CustomerAddress: type: object properties: id: type: string example: "3014" type: type: string enum: ['Home', 'Work'] ownership: type: string example: "" monthly: type: string example: "0" address_1: type: string example: "23444 Address Parts" address_2: type: string example: "Unit 42" city: type: string example: "Some City" state: type: string maxLength: 2 minLength: 2 example: "ZZ" zip: type: string format: int32 example: "00000" active: type: string enum: ["0", "1"] primary: type: string enum: ["0", "1"]SolvedOAuth2.0 Client Credentials Parameters
Hi Team, I'm fairly new to Swagger Editor and API documentation and I have to add a parameter to pass my access token in the API documentation.I am using OAuth 2.0 with Grant Type- Client Credentials. I am able to lock the APIs using the Authorize button on my Swagger's interactive UI but I need to view the generated access token on my interactive UI.and send it as a header parameter to specific APIs. This is the security component I have added to my document: components: securitySchemes: oAuth2ClientCredentials: type: oauth2 flows: clientCredentials: tokenUrl: 'https://localhost:8081/oauth/token' scopes: {} Thanks in advance!SolvedUpload a file to server using NodeJS and Swagger
I want to upload a file to a server using Swagger. I have created the YAML to upload file as follows: /Upload: post: summary: Uploads a file. operationId: bulkUpload consumes: - multipart/form-data parameters: - in: formData name: upfile type: file description: The file to upload. responses: 200: description: "File Uploaded" x-swagger-router-controller: "Default" My DefaultService.js file contaians the function: var fs = require('fs'); exports.bulkUpload = function(args, res, next) { var stream = fs.createWriteStream("UploadedFile.txt"); stream.once('open', function () { stream.write('blah blah'); //works - writes 'blah blah' to file stream.write(JSON.stringify(args.upfile.value));//bombs out after a while stream.write(args.upfile); //does not work stream.write(args.upfile.value); //does not work stream.end(); }); res.setHeader('Content-Type', 'application/json'); res.statusCode = 200; res.end(JSON.stringify('File Uploaded')); } I want to upload the original file without having to create my own test file. How can I do this? You will see that I am trying to write the uploaded file to a test file "UploadedFile.txt". It is currently failing as you can see from my attempts.3.7KViews0likes0CommentsAdd Upload button for OpenAPI 2.0 file as Octet-Stream
Context I am using OpenAPI ver 2.0 I have API which consumesapplication/octet-stream(JavaInputStream) Issue In OpenAPI ver 2.0 I can only set input type asmultipart/form-data(link) to have upload button. When I have applied this solution for my swagger: <code> "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "in": "formData", "name": "messageFile", "description": "Description...", "required": true, "type": "file" } ] </code> I am getting following error:Unsupported Media Typeafter sending a file - itis normal due to my API wants octet-stream. Question Is it possible to have upload button using OpenAPI ver 2.0 andapplication/octet-streamlike: If no, then what will be better solution / workaround for this?Solved3.5KViews0likes3Comments