swagger-editor

How to define Swagger 2.0 JSON to populate default body parameter object in Swagger UI?

不羁的心 提交于 2019-12-01 05:54:49
问题 Our current deployment patterns require me to manually write my swagger json output that will be consumed by the Swagger-based UI in use at my company. I'd like the json I'm writing to provide 'default' values to populate the Swagger UI for all input fields, including the body input parameter. My body parameter is a referenced object as seen below. How do I define the returned swagger JSON to auto populate the body portion of the request when the "Try this operation" is clicked? An example

nullable fields in swagger on node.js

非 Y 不嫁゛ 提交于 2019-12-01 03:03:34
I've spent a bunch of time trying to find a solution for creating swagger docs in Node.JS. The main library is swagger-node, in which you create a swagger yaml file and then add your controllers to it. It automatically provides swagger ui docs in your app and does validation on the request & response against the models you specify in your yaml. This is neat, however I have a requirement that some fields I want to explicitly be able to return or accept null as a value, for instance: { id: 123, description: "string", date_sent: null } I don't want to delete the date_sent key, I want to

Swagger Editor shows the “Schema error: should NOT have additional properties” error for a path parameter

血红的双手。 提交于 2019-11-30 10:58:50
I'm using http://editor.swagger.io to design an API and I get an error which I don't know how to address: Schema error at paths['/employees/{employeeId}/roles'].get.parameters[0] should NOT have additional properties additionalProperty: type, format, name, in, description Jump to line 24 I have other endpoints defined in a similar way, and don't get this error. I wondered if I had some issue with indentation or unclosed quotes, but that doesn't seem to be the case. Google also did not seem to provide any useful results. swagger: "2.0" info: description: Initial draft of the API specification

How to make a field in a definition required for some operations and not others

拜拜、爱过 提交于 2019-11-30 07:54:36
问题 I'm writing my swagger definition in yaml. Say I have a definition that looks something like this. paths: /payloads: post: summary: create a payload ... parameters: - in: body name: payload description: New payload required: true schema: $ref: "#/definitions/payload" put: summary: update a payload ... parameters: - in: body name: payload description: Updated existing payload required: true schema: $ref: "#/definitions/payload" ... definitions: payload: properties: id: type: string

Can I create a stub swagger model definition from a json file

南楼画角 提交于 2019-11-29 16:56:21
Is there a tool that lets me generate a Swagger yaml definition model from sample JSON? I would go in and and edit and clean up the yaml, but would be nice if there was something out there that would stub out the structure of a yaml based on a large or complex sample json object. You can use Apigee's API Studio that has this feature: http://apistudio.io/ Click on Insert menu and then New Model . Form a JSON example you can create all of the paths and operations you want. 来源: https://stackoverflow.com/questions/36774452/can-i-create-a-stub-swagger-model-definition-from-a-json-file

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 Editor shows the “Schema error: should NOT have additional properties” error for a path parameter

丶灬走出姿态 提交于 2019-11-29 16:28:38
问题 I'm using http://editor.swagger.io to design an API and I get an error which I don't know how to address: Schema error at paths['/employees/{employeeId}/roles'].get.parameters[0] should NOT have additional properties additionalProperty: type, format, name, in, description Jump to line 24 I have other endpoints defined in a similar way, and don't get this error. I wondered if I had some issue with indentation or unclosed quotes, but that doesn't seem to be the case. Google also did not seem to

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

How to format Swagger 2.0 text descriptions?

独自空忆成欢 提交于 2019-11-28 22:43:34
I would like to format my Swagger API descriptions so that they are not simple paragraphs of text. Preferably, I'd like to add a small table to it. I did not find an online reference about text formatting in Swagger descriptions. If I launch the Swagger Editor , and open the Instagram example (File \ Open Example \ Instagram.yaml), I see the the first description in the yaml file shows some formatting including a hyperlink and bounding box: [registered your client](http://instagram.com/developer/register/) it's easy to start requesting data from Instagram. ``` https://api.instagram.com/v1

“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