openapi

How to remove the “Examples” combobox or change its text in Swagger UI?

寵の児 提交于 2019-12-01 14:21:52
I have a problem with Swagger UI where it displays an empty "Examples" combobox (marked yellow on the image below) which does not look good. Is there a way to remove it or change its text to something useful? I tried adding the example tag, but it won't work. The operation definition looks like this: post: tags: - pet summary: Add a new pet to the store operationId: addPet requestBody: description: Pet object that needs to be added to the store content: application/json: schema: $ref: '#/components/schemas/Pet' application/xml: schema: $ref: '#/components/schemas/Pet' required: true responses:

Additional properties not allowed: nullable swagger

谁说胖子不能爱 提交于 2019-12-01 14:19:12
I am using swagger 2.0 with node.js express 4.12.3 and mysql db. I have created following schema - Country: type: "object" properties: id: type: "integer" readOnly: true description: "Country Id" country: type: "string" description: "Country name" created_at: type: "string" readOnly: true format: "date-time" description: "Country record creation date" deleted_at: type: "string" format: "date-time" description: "Country record delete date" required: - country Here deleted_at field will be null and will not be present in db until the record is deleted. My express based nodejs server returns the

Additional properties not allowed: nullable swagger

◇◆丶佛笑我妖孽 提交于 2019-12-01 13:54:23
问题 I am using swagger 2.0 with node.js express 4.12.3 and mysql db. I have created following schema - Country: type: "object" properties: id: type: "integer" readOnly: true description: "Country Id" country: type: "string" description: "Country name" created_at: type: "string" readOnly: true format: "date-time" description: "Country record creation date" deleted_at: type: "string" format: "date-time" description: "Country record delete date" required: - country Here deleted_at field will be null

How to remove the “Examples” combobox or change its text in Swagger UI?

社会主义新天地 提交于 2019-12-01 12:54:49
问题 I have a problem with Swagger UI where it displays an empty "Examples" combobox (marked yellow on the image below) which does not look good. Is there a way to remove it or change its text to something useful? I tried adding the example tag, but it won't work. The operation definition looks like this: post: tags: - pet summary: Add a new pet to the store operationId: addPet requestBody: description: Pet object that needs to be added to the store content: application/json: schema: $ref: '#

OpenAPI or swagger.json auto discovery

做~自己de王妃 提交于 2019-12-01 08:35:34
Is there any spec or convention on URL where one should place swagger.json (or whatever name it is agreed) so that public API of my site can be automatically discovered? Updated 19 April 2017: The OpenAPI Wiki answer I gave previously is "for a very very very old version of the spec" . The same source states that for 2.0 the standard is swagger.json , for 3.0 it changes to openapi.json . Original answer: The OpenAPI Wiki recommends using an /api-docs endpoint, at least for server APIs. I've seen several sites in the wild that use that, and it's our shop standard. Hope that helps. How about

OpenAPI or swagger.json auto discovery

送分小仙女□ 提交于 2019-12-01 05:40:45
问题 Is there any spec or convention on URL where one should place swagger.json (or whatever name it is agreed) so that public API of my site can be automatically discovered? 回答1: Updated 19 April 2017: The OpenAPI Wiki answer I gave previously is "for a very very very old version of the spec". The same source states that for 2.0 the standard is swagger.json , for 3.0 it changes to openapi.json . Original answer: The OpenAPI Wiki recommends using an /api-docs endpoint, at least for server APIs. I

How to define different responses for same HTTP status code in OpenAPI (Swagger)?

橙三吉。 提交于 2019-12-01 05:16:49
I'm writing an OpenAPI spec for an existing API. This API returns status 200 for both success and failure, but with a different response structure. For example, in the signup API, if the user signed up successfully, the API sends status 200 with the following JSON: { "result": true, "token": RANDOM_STRING } And if there is a duplicated user, the API also sends status 200, but with the following JSON: { "result": false, "errorCode": "00002", // this code is duplicated error "errorMsg": "duplicated account already exist" } In this case, how to define the response? This is possible in OpenAPI 3.0

How to run swagger-codegen for OpenAPI 3.0.0

巧了我就是萌 提交于 2019-12-01 03:37:22
looks like official swagger for openapi specification V3 support is near release https://blog.readme.io/an-example-filled-guide-to-swagger-3-2/ , and the swagger-codegen has 3.0.0 support developed and passing some level of testing https://github.com/swagger-api/swagger-codegen on the 3.0.0 branch I have a swagger spec (generated from my existing 2.0 spec via https://github.com/mermade/swagger2openapi , output looks good) Is there an easy way to run the swagger-codegen without having to package the jar myself? this is the single result i found: https://oss.sonatype.org/content/repositories

How to define different responses for same HTTP status code in OpenAPI (Swagger)?

空扰寡人 提交于 2019-12-01 02:28:49
问题 I'm writing an OpenAPI spec for an existing API. This API returns status 200 for both success and failure, but with a different response structure. For example, in the signup API, if the user signed up successfully, the API sends status 200 with the following JSON: { "result": true, "token": RANDOM_STRING } And if there is a duplicated user, the API also sends status 200, but with the following JSON: { "result": false, "errorCode": "00002", // this code is duplicated error "errorMsg":

How to post files in Swagger (OpenAPI)?

橙三吉。 提交于 2019-11-30 13:07:27
问题 I am using Swagger to document my REST services. One of my services requires a CSV file to be uploaded. I added the following to the parameters section in my JSON API definition: { "name": "File", "description": "The file in zip format.", "paramType": "body", "required": true, "allowMultiple": false, "dataType": "file" } and now I see the file upload option on my Swagger UI page. But when I select a file and click "try it out", I get the following error: NS_ERROR_XPC_BAD_OP_ON_WN_PROTO: