openapi

Why `additionalProperties` is the way to represent Dictionary/Map in Swagger/OpenAPI 2.0

南楼画角 提交于 2019-11-27 04:47:37
Although I have seen the examples in the OpenAPI spec : type: object additionalProperties: $ref: '#/definitions/ComplexModel' it isn't obvious to me why the use of additionalProperties is the correct schema for a Map/Dictionary. It also doesn't help that the only concrete thing that the spec has to say about additionalProperties is: The following properties are taken from the JSON Schema definition but their definitions were adjusted to the Swagger Specification. Their definition is the same as the one from JSON Schema, only where the original definition references the JSON Schema definition,

How to define a property that can be string or null in OpenAPI (Swagger)?

旧巷老猫 提交于 2019-11-27 02:08:01
I have JSON schema file where one of the properties is defined as either string or null : "type":["string", "null"] When converted to YAML (for use with OpenAPI/Swagger), it becomes: type: - 'null' - string but the Swagger Editor shows an error: Schema "type" key must be a string What is the correct way to define a nullable property in OpenAPI? type as an array of types type: - string - 'null' is NOT valid in OpenAPI/Swagger (even though it's valid in JSON Schema). OpenAPI's type keyword requires a single type and cannot be an array of types. Support for null depends on which version of

Post a json body with swagger

若如初见. 提交于 2019-11-26 22:54:14
问题 I would like to POST a json body with Swagger, like this : curl -H "Content-Type: application/json" -X POST -d {"username":"foobar","password":"xxxxxxxxxxxxxxxxx", "email": "foo@bar.com"}' http://localhost/user/register Currently, I have this definition : "/auth/register": { "post": { "tags": [ "auth" ], "summary": "Create a new user account", "parameters": [ { "name": "username", "in": "query", "description": "The username of the user", "required": true, "type": "string" }, { "name":

Sending cookie session id with Swagger 3.0

强颜欢笑 提交于 2019-11-26 18:35:42
问题 It is said that "To define cookie authentication, use API keys instead." in the official documentation https://swagger.io/docs/specification/describing-parameters/#cookie-parameters The fact is we tried with components: securitySchemes: cookieAuth: type: apiKey in: cookie name: sessionId ... security: - cookieAuth: [] Using the above code, in Swagger UI we are able to click on the padlock to set the value of the sessionId. But when we execute the method, the value of the cookie is NULL and we

How do I include subclasses in Swagger API documentation/ OpenAPI specification using Swashbuckle?

血红的双手。 提交于 2019-11-26 18:12:04
问题 I have an Asp.Net web API 5.2 project in c# and generating documentation with Swashbuckle. I have model that contain inheritance something like having an Animal property from an Animal abstract class and Dog and Cat classes that derive from it. Swashbuckle only shows the schema for the Animal class so I tried to play with ISchemaFilter (that what they suggest too) but I couldn't make it work and also I cannot find a proper example. Anybody can help? 回答1: It seems Swashbuckle doesn't implement

How to add multiple example values in swagger propertise?

送分小仙女□ 提交于 2019-11-26 17:20:59
问题 I am using Swagger OpenAPI Specification tool, I have a string array property in one of the definitions as follows : cities: type: array items: type: string example: "Pune" My API produce JSON result so for above object following result appears in response : { "cities": [ "Pune" ] } Tried comma separated strings like below : cities: type: array items: type: string example: "Pune", "Mumbai", "Bangaluru" Expecting result as : { "cities": [ "Pune", "Mumbai", "Bangaluru" ] } But the editor shows

How to define mutually exclusive query parameters in Swagger (OpenAPI)?

对着背影说爱祢 提交于 2019-11-26 16:58:18
问题 I have a series of parameters in Swagger like this "parameters": [ { "name": "username", "description": "Fetch username by username/email", "required": false, "type": "string", "paramType": "query" }, { "name": "site", "description": "Fetch username by site", "required": false, "type": "string", "paramType": "query" }, { "name": "survey", "description": "Fetch username by survey", "required": false, "type": "string", "paramType": "query" } ], One parameter MUST be filled out but it doesn't

Swagger/OpenAPI - use $ref to pass a reusable defined parameter

╄→尐↘猪︶ㄣ 提交于 2019-11-26 15:36:45
问题 Let's say I've got a parameter like limit . This one gets used all over the place and it's a pain to have to change it everywhere if I need to update it: parameters: - name: limit in: query description: Limits the number of returned results required: false type: number format: int32 Can I use $ref to define this elsewhere and make it reusable? I came across this ticket which suggests that someone wants to change or improve feature, but I can't tell if it already exists today or not? 回答1: This

Why `additionalProperties` is the way to represent Dictionary/Map in Swagger/OpenAPI 2.0

我只是一个虾纸丫 提交于 2019-11-26 11:12:45
问题 Although I have seen the examples in the OpenAPI spec: type: object additionalProperties: $ref: \'#/definitions/ComplexModel\' it isn\'t obvious to me why the use of additionalProperties is the correct schema for a Map/Dictionary. It also doesn\'t help that the only concrete thing that the spec has to say about additionalProperties is: The following properties are taken from the JSON Schema definition but their definitions were adjusted to the Swagger Specification. Their definition is the

How to define a property that can be string or null in OpenAPI (Swagger)?

别来无恙 提交于 2019-11-26 09:54:13
问题 I have JSON schema file where one of the properties is defined as either string or null : \"type\":[\"string\", \"null\"] When converted to YAML (for use with OpenAPI/Swagger), it becomes: type: - \'null\' - string but the Swagger Editor shows an error: Schema \"type\" key must be a string What is the correct way to define a nullable property in OpenAPI? 回答1: type as an array of types type: - string - 'null' is NOT valid in OpenAPI/Swagger (even though it's valid in JSON Schema). OpenAPI's