openapi

Swagger: take one or more values from enum

时间秒杀一切 提交于 2019-11-28 09:37:47
问题 I am working on a swagger file, where a query parameter can take none, or n values. How can I write this in Swagger Yaml? The url I give: /sort=field1,field2 The parameter declared in swagger file - name: sort in: query schema: type: string enum: [field1,field2,field3] allowEmptyValue: true required: false description: Sort the results by attributes. (See http://jsonapi.org/format/1.1/#fetching-sorting) Have a nice day/night. 回答1: A query parameter containing a comma-separated list of values

How to refer to enclosing type definition recursively in OpenAPI / Swagger?

拜拜、爱过 提交于 2019-11-28 02:52:30
问题 I'm writing an OpenAPI definition in Swagger Editor. One of my type definitions contains an array containing child elements of the same type as the parent. I.e. something like this: definitions: TreeNode: type: object properties: name: type: string description: The name of the tree node. children: type: array items: $ref: '#/definitions/TreeNode' However, Swagger Editor doesn't pick up the recursive reference in the children array, which is simply shown as an array of "undefined" elements.

Post a json body with swagger

☆樱花仙子☆ 提交于 2019-11-27 20:08:47
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": "password", "in": "query", "description": "The password of the user", "required": true, "type": "string",

Sending cookie session id with Swagger 3.0

醉酒当歌 提交于 2019-11-27 16:16:40
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 don't see the cookie sent in the Headers (Chrome Developer tool) I tried also to put that in cookie

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

回眸只為那壹抹淺笑 提交于 2019-11-27 14:57:21
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 matter which one, the others can be left blank. Is there a way to represent this in Swagger?

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

六眼飞鱼酱① 提交于 2019-11-27 12:50:38
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? Paolo Vigori It seems Swashbuckle doesn't implement polymorphism correctly and I understand the point of view of the author about subclasses as

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

微笑、不失礼 提交于 2019-11-27 11:37:51
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? Ron This feature already exists in Swagger 2.0. The linked ticket talks about some specific mechanics of it

How to write OpenAPI 3 (Swagger) specification for property name in `map` object?

大憨熊 提交于 2019-11-27 09:33:28
The API I'm trying to describe has a structure where the root object can contain an arbitrary number of child objects (properties that are themselves objects). The "key", or property in the root object, is the unique identifier of the child object, and the value is the rest of the child object's data. { "child1": { ... bunch of stuff ... }, "child2": { ... bunch of stuff ... }, ... } This could similarly be modeled as an array, e.g.: [ { "id": "child1", ... bunch of stuff ... }, { "id": "child2", ... bunch of stuff ... }, ... ] but this both makes it structurally less clear what the

Re-using model with different required properties

柔情痞子 提交于 2019-11-27 09:02:58
I have a path that uses complex models with almost identical properties for each http method. The problem is that I want to define some required properties for the request of PUT and POST, while no properties are required in GET response (as the server always returns all properties and it's mentioned elsewhere in the documentation). I created a simple cat API to demonstrate what I've tried. The idea is that for GET response the response model doesn't have anything marked as required, but the request of PUT must have a name for the cat. swagger: "2.0" info: title: "Cat API" version: 1.0.0 paths

How to generate JSON examples from OpenAPI/Swagger model definition?

可紊 提交于 2019-11-27 06:19:24
问题 I'm building a fuzzer for a REST API that has an OpenAPI (Swagger) definition. I want to test all available path from the OpenAPI definition, generate data to test the servers, analyse responses code and content, and to verify if the responses are conform to the API definition. I'm looking for a way to generate data (JSON object) from model definitions. For example, given this model: ... "Pet": { "type": "object", "required": [ "name", "photoUrls" ], "properties": { "id": { "type": "integer",