openapi

How to define a JSON array with concrete item definition for every index (i.e. a tuple) in OpenAPI?

纵饮孤独 提交于 2021-02-19 07:45:08
问题 I need to define in OpenAPI a JSON response with an array. The array always contains 2 items and the first one is always a number and second one is always a string. [1, "a"] //valid ["a", 1] //invalid [1] //invalid [1, "a", 2] //invalid I've found out that JSON schema does support that by passing a list of items in items instead of single object (source), but OpenAPI explicitly forbids that and accepts only a single object (source). How can that be expressed in OpenAPI? 回答1: OpenAPI 3.1

OpenAPI 3.0 - allOf inside oneOf

帅比萌擦擦* 提交于 2021-02-17 03:33:19
问题 The following YAML: openapi: 3.0.0 info: title: test version: 1.0.0 paths: /test: get: summary: test responses: '200': description: Test content: application/json: schema: oneOf: - allOf: - type: object properties: firstA: type: string - type: object properties: firstB: type: string - allOf: - type: object properties: secondA: type: string - type: object properties: secondB: type: string Does not render at all in the swagger editor. In ReDoc it also fails to render properly: If nesting

Mutually excluding properties in swagger

我与影子孤独终老i 提交于 2021-02-17 03:19:58
问题 How do I indicate that in my_object you can have property_1 or property_2, but not both? my_object: type: object properties: property_1: type: string property_2: type: string 回答1: You may want to switch to OpenAPI 3.0, which supports oneOf keyword to define mutually exclusive conditions: here is an example : my_object: type: object properties: property_1: type: string property_2: type: integer oneOf: - required: [property_1] - required: [property_2] 回答2: In OpenAPI 3.0 ( openapi: 3.0.0 ), you

Mutually excluding properties in swagger

我怕爱的太早我们不能终老 提交于 2021-02-17 03:19:45
问题 How do I indicate that in my_object you can have property_1 or property_2, but not both? my_object: type: object properties: property_1: type: string property_2: type: string 回答1: You may want to switch to OpenAPI 3.0, which supports oneOf keyword to define mutually exclusive conditions: here is an example : my_object: type: object properties: property_1: type: string property_2: type: integer oneOf: - required: [property_1] - required: [property_2] 回答2: In OpenAPI 3.0 ( openapi: 3.0.0 ), you

Test endpoints compliance against openapi contract in Spring Boot Rest

谁都会走 提交于 2021-02-11 15:24:58
问题 I am looking for a nice way to write tests to make sure that enpoints in Spring Boot Rest (ver. 2.1.9) application follows the contract in openapi contract. In the project I moved recently there is following workflow: architects write contract openapi.yml and developers have to implement endpoint to compliance the contract. Unfortunately a lot of differences happen and this test have to catch such situation and it is not possible to change this :( I was thinking about the solution to generate

How to add Jackson annotations to specific fields on swagger generated model classes for Spring

余生颓废 提交于 2021-02-11 00:04:11
问题 Folks, With swagger 2.0 does anyone know if it's possible to add Jackson annotations to specific fields on swagger generated model classes when using swagger codegen with 'spring' as the 'language' <language>spring</language> ? I want to use Jackson JSON Views & would like to add the view annotations to provide different views of the generated models when I return them from the various REST endpoints. However, I could not find any documentation if any on this on swagger. I see this slightly

How to add Jackson annotations to specific fields on swagger generated model classes for Spring

耗尽温柔 提交于 2021-02-10 23:58:11
问题 Folks, With swagger 2.0 does anyone know if it's possible to add Jackson annotations to specific fields on swagger generated model classes when using swagger codegen with 'spring' as the 'language' <language>spring</language> ? I want to use Jackson JSON Views & would like to add the view annotations to provide different views of the generated models when I return them from the various REST endpoints. However, I could not find any documentation if any on this on swagger. I see this slightly

Getting “inject() must be called from an injection context” after upgrading to Angular 11

半世苍凉 提交于 2021-02-10 18:01:25
问题 After upgrading to Angular 11, I am not able to ng serve my web application anymore. I am generating the client using Spring Doc and the latest OpenAPI generator gradle-plutin (5.0.0). The problem appears to be related to my (generated) REST-client. Opening https://localhost:4200 will write the following into the console: main.ts:12 Error: inject() must be called from an injection context at injectInjectorOnly (core.js:4901) [angular] at Module.ɵɵinject (core.js:4911) [angular] at Object

How can I denote decimal floating point in swagger specs?

ぃ、小莉子 提交于 2021-02-08 13:53:55
问题 I would like to denote decimal with 2 places and decimal with 1 place in my api documentation. I'm using swagger 2.0, Is there inbuilt defined type or any other 'round' parameter in the specs, or my only option is to use 'x-' extension? 回答1: OpenAPI (fka Swagger) Specification uses a subset of JSON Schema to describe the data types. If the parameter is passed as a number, you can try using multipleOf as suggested in this Q&A: type: number multipleOf: 0.1 # up to 1 decimal place, e.g. 4.2 #

OpenApi required property in nested objects not working

断了今生、忘了曾经 提交于 2021-02-07 06:44:06
问题 I need to describe an api having in request body an object with required fields and one of these fields it's an object itself having another set of required fields. I'm using open api v3 and swagger editor (https://editor.swagger.io/) After i put my .yaml file onto the editor I generate an html client (> generate client > html). Then I open the static page index.html generated in the .zip file obtaning this schema: Table of Contents body secureoauthservicesv2Nested_nestedobj body id Integer