swagger-editor

Write swagger doc that consumes multiple content types e.g. application/json AND application/x-www-form-urlencoded (w/o duplication)

好久不见. 提交于 2020-02-19 06:01:23
问题 I'm looking for an elegant way to define an api that can consume JSON data as well as form data. The following snippet works, but it's not elegant and requires all kind of ugly code in the backend. Is there a better way to define this? What works right now: paths: /pets: post: consumes: - application/x-www-form-urlencoded - application/json parameters: - name: nameFormData in: formData description: Updated name of the pet required: false type: string - name: nameJSON in: body description:

How to specify columns in Swagger

≯℡__Kan透↙ 提交于 2020-02-04 09:02:24
问题 How to specify 3 columns in a swagger editor so the output should look like: a b c x y z swagger: '2.0' info: description: > This is a sample server Petstore server. [Learn about Swagger](http://swagger.io) or join the IRC channel `#swagger` on irc.freenode.net. For this sample, you can use the api key `special-key` to test the authorization filters **Here I want to specify 3 columns** 回答1: This is essentially a Markdown question. To make a table in Markdown use a tool like this or following

Overloading description in Swagger file (YAML)

你离开我真会死。 提交于 2020-01-15 10:15:33
问题 I have an issue writing my swagger file. When I describe a parameter the description is overloaded by the description of the $ref of this same parameter (see the example bellow). a-body: description: The body type: object properties: my_param: description: Full description $ref: '#/definitions/reference' definitions: reference: type: object required: [req] description: an http reference properties: req: type: string The result: the description is overloaded Can somebody help me get through

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

放肆的年华 提交于 2020-01-10 05:29:09
问题 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":

Swagger/OpenAPI 3.0 issue with example on responses

时光总嘲笑我的痴心妄想 提交于 2020-01-02 07:15:09
问题 This is a simplified version of my OpenAPI 3.0 definition I'm viewing on the Swagger Editor online. I am trying to have the two responses for error codes 401 and 403, that share the same schema, show different examples - this doesn't seem to work and I still see the referenced type as example. Can you help me figuring out what's wrong with the definitions? openapi: 3.0.0 info: version: '1.0' title: A service paths: /doSomething: post: requestBody: content: application/json: schema: type:

How to document dynamic query parameter names in OpenAPI (Swagger)?

家住魔仙堡 提交于 2019-12-28 04:26:19
问题 Is there any way to document the following query? GET api/v1/users?name1=value1&name2=value where the query parameter names are dynamic and will be received from the client. I'm using the latest Swagger API. 回答1: Free-form query parameters can be described using OpenAPI 3.0, but not OpenAPI 2.0 (Swagger 2.0). The parameter should have type: object with the serialization method style: form and explode: true . The object will serialized as ?prop1=value1&prop2=value2&... , where individual prop

How Can I add basic auth in swagger 3.0 automatically with out the user to type in at authorize button?

前提是你 提交于 2019-12-24 12:00:38
问题 I am using swagger 3.0 and have multiple endpoints in swagger docs. I want user not to type in credentials at authorize button every time. Is there any way I can include authentication in index.html or in my yaml files to automatically authorize the user. Thanks. 回答1: Swagger UI 3.13.0+ provides the preauthorizeBasic method for this purpose. Assuming your API definition includes a security scheme for Basic auth: swagger: '2.0' ... securityDefinitions: basicAuth: type: basic security: -

How to send a JSON object as part of a multipart request in Swagger Editor?

谁说胖子不能爱 提交于 2019-12-24 09:07:35
问题 I'm writing API documentation using Swagger Editor, but having a problem with a multipart POST request containing a JSON object. Here is my Swagger YAML file: swagger: '2.0' info: version: 1.0.0 title: Documentation API paths: /agent: post: consumes: - multipart/form-data produces: - text/html parameters: - in: query name: method description: name of method to access required: true type: string - in: body name: param description: parameter to send required: true schema: $ref: "#/definitions

Swagger 3.0 schema error “should NOT have additional properties”

一世执手 提交于 2019-12-23 01:35:22
问题 What does this error below mean? (Running in Swagger Editor) Schema error should NOT have additional properties additionalProperty: /buildinfo, /clearcache, /countries/{countryId}/cinemas/{theatreid}/screens/{screenid}/layout, /countries/{countryId}/cinemas/{theatreid}/screens Jump to line 0 Below is my yaml file. openapi: "3.0.1" info: title: Mobile backend version: 1.0.0 license: name: Apache 2.0 paths: /buildinfo: get: description: Returns the build information (Version and Time stamp).

Possible to change the package name when generating client code

百般思念 提交于 2019-12-22 04:05:57
问题 I am generating the client scala code for an API using the Swagger Edtior. I pasted the json then did a Generate Client/Scala. It gives me a default root package of io.swagger.client I can't see any obvious way of specifying something different. Can this be done? 回答1: Step (1): Create a file config.json and add following lines and define package names: { "modelPackage" : "com.xyz.model", "apiPackage" : "com.xyz.api" } Step (2): Now, pass the above file name along with codegen command with -c