openapi

How to convert OpenAPI 2.0 to OpenAPI 3.0?

China☆狼群 提交于 2020-01-30 08:07:08
问题 Are there any tools/libraries to convert OpenAPI 2.0 definitions to OpenAPI 3.0, without doing it one per row? I googled but found none. 回答1: Swagger Editor Paste your OpenAPI 2.0 definition into https://editor.swagger.io and select Edit > Convert to OpenAPI 3 from the menu. Swagger Converter Converts OpenAPI 2.0 and Swagger 1.x definitions to OpenAPI 3.0. https://converter.swagger.io/api/convert?url=OAS2_YAML_OR_JSON_URL This gives you JSON. If you want YAML, send the request with the Accept

Cannot reference a component schema defined in a separate file in Swagger

无人久伴 提交于 2020-01-24 15:05:28
问题 I have the following api documentation: swagger: "3.0" info: version: 0.0.1 title: Test API paths: /users: get: summary: Get all registered users produces: - application/json responses: 200: description: Users successfully returned 403: description: User not authorised to call this API schema: $ref: 'components.yaml#/components/schemas/AuthError' Where the AuthError schema is defined in a separate yaml file called components.yaml: components: schemas: AuthError: type: object properties: error

Cannot reference a component schema defined in a separate file in Swagger

荒凉一梦 提交于 2020-01-24 15:05:18
问题 I have the following api documentation: swagger: "3.0" info: version: 0.0.1 title: Test API paths: /users: get: summary: Get all registered users produces: - application/json responses: 200: description: Users successfully returned 403: description: User not authorised to call this API schema: $ref: 'components.yaml#/components/schemas/AuthError' Where the AuthError schema is defined in a separate yaml file called components.yaml: components: schemas: AuthError: type: object properties: error

Convert OpenAPI 3.0 to Swagger 2.0

99封情书 提交于 2020-01-24 03:51:26
问题 Is there a generator to convert openapi 3.0 to swagger 2.0? Mashery, an API gateway, requires swagger 2.0 format on input to open endpoint. 回答1: LucyBot api-spec-converter (online version, GitHub repo, Node.js module) can convert from OpenAPI 3.0 to 2.0. API Transformer also claims to be able to convert OpenAPI 3.0 back to OpenAPI 2.0. There's a command-line version too. Keep in mind that OAS3→OAS2 convertion is lossy in general, because OAS3 has features that did not exist in OAS2 (such as

OpenApi 3 request validation with Python

試著忘記壹切 提交于 2020-01-24 03:19:05
问题 There seems to be number of python libraries dedicated to validate the correctness of an OpenApi schema. While this might be useful, I can frankly just write my OpenApi schema here it in https://editor.swagger.io and have it validated / converted / pretty formatted. I'm then left with clients potentially sending any kind of dirty data to my OpenApi documented endpoint. So, what I can't find is a library that given an OpenApi schema and a JSON (typically from an HTTP request) validates the

How to reuse swagger definitions and remove some of the parameters in it? [duplicate]

妖精的绣舞 提交于 2020-01-21 20:45:10
问题 This question already has answers here : Re-using model with different required properties (2 answers) Closed 6 months ago . This is my code: definitions: User: type: object properties: id: type: integer username: type: string first_name: type: string last_name: type: string password: type: string created_at: type: string format: date-time updated_at: type: string format: date-time required: - username - first_name - last_name - password /api/users: post: description: Add a new user

How to reuse swagger definitions and remove some of the parameters in it? [duplicate]

霸气de小男生 提交于 2020-01-21 20:42:06
问题 This question already has answers here : Re-using model with different required properties (2 answers) Closed 6 months ago . This is my code: definitions: User: type: object properties: id: type: integer username: type: string first_name: type: string last_name: type: string password: type: string created_at: type: string format: date-time updated_at: type: string format: date-time required: - username - first_name - last_name - password /api/users: post: description: Add a new user

How to create secrets using Kubernetes Python client?

白昼怎懂夜的黑 提交于 2020-01-15 11:53:41
问题 I have been trying to play around with creating secrets for Kubernetes cluster using the python client. I keep getting an error that says Traceback (most recent call last): File "create_secrets.py", line 19, in <module> api_response = v1.create_namespaced_secret(namespace, body) File "/usr/local/lib/python3.6/site-packages/kubernetes/client/apis/core_v1_api.py", line 7271, in create_namespaced_secret (data) = self.create_namespaced_secret_with_http_info(namespace, body, **kwargs) File "/usr

In Swagger, how to define an API that consumes a file along with a schema parameter?

偶尔善良 提交于 2020-01-14 09:38:54
问题 I am trying to use Swagger to define an API that accepts an actual file and a schema object that describes the contents of a file. Here is a snippet of the Swagger YAML. However it won't validate in the Swagger Editor. /document: post: summary: Api Summary description: Api Description consumes: - multipart/form-data parameters: - name: documentDetails in: formData description: Document Details required: true schema: $ref: '#/definitions/Document' - name: document in: formData description: The

How to define constant string in Swagger open api 3.0

浪尽此生 提交于 2020-01-13 09:24:57
问题 How to define constant string variable in swagger open api 3.0 ? If I define enum it would be like as follows "StatusCode": { "title": "StatusCode", "enum": [ "success", "fail" ], "type": "string" } But enums can be list of values, Is there any way to define string constant in swagger open api 3.0 code can be executed form the http://editor.swagger.io/ 回答1: As @Helen already pointed out, and as you can read in the linked answer, currently it does not seem to get any better than an enum with