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.Solved6.1KViews0likes2Commentsv3.0 (bug?) - swagger compliance assertion fails in v3.0 but is ok in v2.8
Hi, I recently update to v3.0 of readyAPI. Looks nice! However, I notice a difference in behavior on the Swagger Compliance Assertion. Might this be a bug at your end or is this assertion suddenly more strict in the v3.0? And if the latter, why does it flags this a failure? Scenario: Applying swagger compliance assertion to a rest response. In the assertion, I have a swagger url which contains a relative path to a yaml file. Strict validation is enabled (disabling this makes no diffrence to this issue). The validation happens and provides now these failures (note: some items are renamed for privacy reasons): 1) Instance failed to match all required schemas (matched only 0 out of 1) checked node: [/references] corresponding schema: [/properties/references] If this is a valid assertion failure then it is not a clear error message in my opinion. In my JSON response I get back the following for the reference node: Response of my usedResource: "references" : { "aReference" : "93269491-e89b-4f19-9d12-ec09b71aeaec", "bReference" : null, "cReference" : null } Is the error saying that bReference and cReference cannot be null? In my swagger/yaml file reference is defined as: usedResource: type: object description: Description of the request properties: ... references: readOnly: true description: References description allOf: - $ref: '#/definitions/ourReferences' ... ... ourReferences: type: object description: Contains the references properties: aReference: type: string description: The reference a bReference: type: string description: The reference b cReference: type: string description: The reference c 2) Instance type (string) does not match any allowed primitive type (allowed: ["object"]) checked node [/priority] corresponding schema [properties/priority] In my JSON response I get back the following for the reference node: Response of my usedResource: "priority" : "NORMAL" In my swagger/yaml file priority is defined as: usedResource: type: object description: Description of the request properties: ... priority: description: The urgency. allOf: - $ref: '#/definitions/RequestPriority' ... RequestPriority: type: string enum: - NORMAL - URGENT I cannot see what's wrong with this. Other similar nodes with similar type & enum are not resulting in a failure. Again, also v2.8 did not flag this as a failed compliance. I could provide more examples, but I hope these suffice.Solved5.8KViews0likes6CommentsHow 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.7KViews0likes2CommentsObject 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.8KViews0likes0CommentsHow to create SoapUI NG project from Swagger over HTTPS?
How do Icreate a SoapUI NG project from Swagger over HTTPS? I tried an see an error message An error of type SSLHandshakeException occurred. javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present Any help is appreciated. Thanks in advance.Solved3.8KViews0likes5Comments