swagger-2.0

How to break swagger 2.0 JSON file into multiple modules

三世轮回 提交于 2019-11-27 09:35:10
问题 I'm trying to break my API document up into multiple JSON files that can be edited independently. All the examples I've been able to find use the Swagger 1.2 schema which has a "api":{} object for breaking it down. That appears to be missing from the 2.0 schema (http://json.schemastore.org/swagger-2.0). All that defines is a single "paths" array where it bundles all the API endpoints into that single array. The effect of this in the swagger-ui is there is a single "default" category that

Swagger editor dictionary parameter definition

£可爱£侵袭症+ 提交于 2019-11-27 08:25:54
问题 I'm struggling with how to define a dictionary type in swagger editor. One of the parameters to my POST method is called 'roles' and it's value is a dictionary where the key is the email address and the value is an integer. 回答1: Swagger supports associative arrays/hashmaps/dictionaries where keys are strings. A dictionary is defined by using an object schema with the additionalProperties keyword specifying the value type of key/value pairs. The key type is not mentioned because keys are

Swagger 2.0 Anyof

笑着哭i 提交于 2019-11-27 07:41:10
问题 What is the equivalent of anyof in Swagger version 2.0, Please tell me how to update my json file because I want to upgrade my documentation from swagger 1.0 to 2.0. Thank You for your Help. 回答1: I don't think there is one and it feels like a big shortcoming. It's definitely not mentioned in the Schema Object portion of the specification. They call out the elements there that have been adopted from the JSON Schema and anyOf isn't among them: The following properties are taken directly from

Swagger schema properties ignored when using $ref - why?

岁酱吖の 提交于 2019-11-27 07:05:14
问题 I'm trying to build a Swagger model for a time interval, using a simple string to store the time (I know that there is also datetime): definitions: Time: type: string description: Time in 24 hour format "hh:mm". TimeInterval: type: object properties: lowerBound: $ref: "#/definitions/Time" description: Lower bound on the time interval. default: "00:00" upperBound: $ref: "#/definitions/Time" description: Upper bound on the time interval. default: "24:00" For some reason the generated HTML does

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",

How to organise/build a Swagger UI interface for a directory which contains many Swagger definition .json/.yml files

杀马特。学长 韩版系。学妹 提交于 2019-11-27 06:19:10
问题 I am trying to document, via Swagger UI, for internal company consumption, existing API services which are developed in a vendor product (WSO2 ESB). The vendor product does not support swagger. I plan to programmatically inspect/process the source code for my API services (written in the vendor product) and generate a directory/folder/library of swagger definition files in .json or .yml format. That is fine, I can do that. Each of these api defintion files will render nicely in swagger UI, I

Swagger: Reusing an enum definition as query parameter

瘦欲@ 提交于 2019-11-27 04:41:05
问题 I would like to use an enum defined in definitions as part of my parameter definitions in a query string. I'm defining the Swagger Enum in the definitions part of my Swagger 2.0 spec file. OperationType: type: string enum: - registration - renewal I can create references to it in other definitions: Operation: type: object properties: name: type: string type: $ref: '#/definitions/OperationType' I can use the schema tag to make a reference to it when the parameter is in: body , but not when it

Return an array of object in Swaggerhub

青春壹個敷衍的年華 提交于 2019-11-27 02:11:13
I am defining an API specification in swaggerhub. The /contacts request returns an array of contacts. The definition is below: /contacts: get: tags: - contacts summary: Get all the contacts description: This displays all the contacts present for the user. operationId: getContact produces: - application/json - application/xml responses: 200: description: successful operation schema: $ref: '#/definitions/AllContacts' 400: description: Invalid id supplied 404: description: Contact not found 500: description: Server error definitions: AllContacts: type: array items: - $ref: '#/definitions

How can I represent 'Authorization: Bearer <token>' in a Swagger Spec (swagger.json)

£可爱£侵袭症+ 提交于 2019-11-27 00:01:25
I am trying to convey that the authentication/security scheme requires setting a header as follows: Authorization: Bearer <token> This is what I have based on the swagger documentation : securityDefinitions: APIKey: type: apiKey name: Authorization in: header security: - APIKey: [] David Lopez Maybe this can help: swagger: '2.0' info: version: 1.0.0 title: Based on "Basic Auth Example" description: > An example for how to use Auth with Swagger. host: basic-auth-server.herokuapp.com schemes: - http - https securityDefinitions: Bearer: type: apiKey name: Authorization in: header paths: /: get:

Schema object without a type attribute in Swagger 2.0

天大地大妈咪最大 提交于 2019-11-26 23:39:02
问题 Does a Schema object in Swagger/OpenAPI 2.0 have to have the type attribute or not? On the one hand, according to the JSON Schema Draft 4 spec, not specifying the type attribute is OK and means that the instance can be of any type (an object, an array or a primitive). On the other hand, I've seen a lot of Swagger schemas which contain Schema objects without the type attribute, but with the properties attribute, which makes it clear that the schema author wants the instance to be a proper