openapi

How to post files in Swagger (OpenAPI)?

强颜欢笑 提交于 2019-11-30 05:35:06
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: Illegal operation on WrappedNative prototype object in jquery-1.8.0.min.js (line 2) The page is continuously

How to define parameters with square brackets in OpenAPI (Swagger)?

人盡茶涼 提交于 2019-11-30 04:19:15
问题 I have an endpoint with query parameters that use square brackets: GET /info?sort[name]=1&sort[age]=-1 Here, name and age are the field names from my model definition. How can I write an OpenAPI (Swagger) definition for these parameters? 回答1: It depends on which version of OpenAPI (Swagger) you use. OpenAPI 3.0 The sort parameter can be defined an an object with the name and age properties. The parameter serialization method should be style: deepObject and explode: true . openapi: 3.0.0 ...

How to describe this POST JSON request body in OpenAPI (Swagger)?

烂漫一生 提交于 2019-11-30 02:42:30
I have a POST request that uses the following JSON request body. How can I describe this request body using OpenAPI (Swagger)? { "testapi": { "testapiContext": { "messageId": "kkkk8", "messageDateTime": "2014-08-17T14:07:30+0530" }, "testapiBody": { "cameraServiceRq": { "osType": "android", "deviceType": "samsung555" } } } } So far I tried the following, but I'm stuck at defining the body schema . swagger: "2.0" info: version: 1.0.0 title: get camera license: name: MIT host: localhost basePath: /test/service schemes: - http consumes: - application/json produces: - application/json paths:

How to avoid CORS errors (“Failed to fetch” or “Server not found or an error occurred”) when making requests from Swagger Editor?

十年热恋 提交于 2019-11-29 16:47:18
I have the following OpenAPI definition: swagger: "2.0" info: version: 1.0.0 title: Simple API description: A simple API to learn how to write OpenAPI Specification schemes: - https host: now.httpbin.org paths: /: get: summary: Get date in rfc2822 format responses: 200: schema: type: object items: properties: now: type: object rfc2822: type: string I would like to retrieve rfc2822 from the response : {"now": {"epoch": 1531932335.0632613, "slang_date": "today", "slang_time": "now", "iso8601": "2018-07-18T16:45:35.063261Z", "rfc2822": "Wed, 18 Jul 2018 16:45:35 GMT", "rfc3339": "2018-07-18T16:45

Swagger: take one or more values from enum

本秂侑毒 提交于 2019-11-29 16:18: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. A query parameter containing a comma-separated list of values is defined as an array . If the values are predefined, then it's an array of enum . By default, an array may

What does 'required' in OpenAPI really mean

假装没事ソ 提交于 2019-11-29 15:07:41
问题 Given the following OpenAPI definition which of the below objects are valid. Just 1. or 1. and 2.? Person: required: - id type: object properties: id: type: string {"id": ""} {"id": null} {} This boils down to the question whether "required = true" means "non-null value " or " property must be present". The JSON schema validator at https://json-schema-validator.herokuapp.com/ says that 2. be invalid because null doesn't satisfy the type: string constraint. Note that it doesn't complain

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

六眼飞鱼酱① 提交于 2019-11-29 09:35:32
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. Does anybody have an idea on how to do this?` Your definition is perfectly fine. It's a known issue issue

“discriminator” in polymorphism, OpenAPI 2.0 (Swagger 2.0)

戏子无情 提交于 2019-11-28 11:54:25
Referencing OpenAPI 2.0, Schema Object , or Swagger 2.0, Schema Object , and the definition of discriminator field as: Adds support for polymorphism. The discriminator is the schema property name that is used to differentiate between other schema that inherit this schema. The property name used MUST be defined at this schema and it MUST be in the required property list. When used, the value MUST be the name of this schema or any schema that inherits it. My confusions/ questions: It is ambiguous to me, what role exactly it plays in inheritance or polymorphism. Could some one please explain

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

若如初见. 提交于 2019-11-28 11:48:13
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", "format": "int64" }, "category": { "$ref": "#/definitions/Category" }, "name": { "type": "string",

Using `default` with `required` parameters for OpenAPI

馋奶兔 提交于 2019-11-28 10:37:02
问题 The documentation says: Using default with required parameters or properties, for example, with path parameters. This does not make sense – if a value is required, the client must always send it, and the default value is never used. But this is common idiom for databases when column IS NOT NULL and have DEFAULT , is not? Why for OpenAPI this makes no sense? 回答1: Think of function declarations. Consider JavaScript string method indexOf: "string".indexOf(searchValue[, fromIndex]) The