openapi

Specifying multiple types for additionalProperties through Swagger/OpenAPI

眉间皱痕 提交于 2019-12-06 06:00:44
问题 I am looking to represent the following JSON Object in OpenAPI: { "name": "Bob", "age": 4, ... } The number of properties and the property names are not fully predetermined, so I look to use additionalProperties. However, I'm not too certain how it would be represented through OpenAPI/Swagger 2.0. I tried this: Person: type: object additionalProperties: type: - int - string or the JSON equivalent: { "Person": { "type": "object", "additionalProperties": { "type": ["int", "string"] } } } but

BeanConfig (or similar?) in Swagger 2.0 (OpenApi 3.0)

大城市里の小女人 提交于 2019-12-06 04:10:06
问题 I am currently migrating our API docs (which were Swagger 1.5) to Swagger 2.0 (OpenApi 3.0) The API docs are Swagger docs which get generated with java annotations using maven packages swagger-annotations and swagger-jaxrs . I have already updated the pom.xml with new versions so it looks like: <dependency> <groupId>io.swagger.core.v3</groupId> <artifactId>swagger-annotations</artifactId> <version>2.0.6</version> </dependency> <dependency> <groupId>io.swagger.core.v3</groupId> <artifactId

How to generate JSON examples from OpenAPI 3.0 yaml file?

百般思念 提交于 2019-12-06 01:50:27
I have my openapi: 3.0.0 YAML file, I'm looking for a way to generate test data response (JSON object) from schema. This is what I am looking for, but I can't get it working for openapi: 3.0.0, the code works perfectly for "swagger": "2.0" definitions. I have tried to get the code working with Swagger Java libraries 2.x, which support OpenAPI 3.0. I know I need to use version 2.x of Swagger. import io.swagger.parser.SwaggerParser; import io.swagger.models.*; import io.swagger.inflector.examples.*; import io.swagger.inflector.examples.models.Example; import io.swagger.inflector.processors

API Platform - how to document authentication routes

两盒软妹~` 提交于 2019-12-06 01:12:59
I'm using API Platform v2.2.5 in a Symfony 4 Flex application, consisting of a functioning API with JWT Authentication , a number of resources and the default Open API/Swagger documentation page that is accessible via the /api route. Each API resource is included in the documentation automatically via the platform configuration, as per the library docs . How do you generate documentation for custom operations such as the security component's auth routes? The API Platform Documentation does not seem to include these instructions. I found the answer thanks to this comment in a Github issue .

Swagger/Openapi-Annotations: How to produce allOf with $ref?

拜拜、爱过 提交于 2019-12-05 22:51:46
I'm generating Rest endpoints including adding Openapi/Swagger annotations to the generated code. While it works quite well with basic types, I have some problems with custom classes. Right now I have a lot of duplicate schema entries for the custom classes (using @Schema(implementation = MyClass.class)) but at least the needed information is there. However I'd like to find a way to remove the duplicate schema entries while retaining the additional information . On a github-issue discussing the $ref and lack of sibling properties I found an example how you would write it manually in yaml in

Refer to self in OpenAPI 3.0

自作多情 提交于 2019-12-05 22:33:17
I have a data model definition in OpenAPI 3.0, using SwaggerHub to display the UI. I want one of the properties of a model to be related , which is an array of properties of the same model. Foo: properties: title: type: string related: type: array items: $ref: '#/components/schemas/Foo' The parser doesn't seem to like this - the UI shows the related property as an empty array. Is this kind of self-reference possible in OpenAPI 3.0? Your definition is correct, it's just Swagger UI currently does not render circular-referenced definitions properly. See issue #3325 for details. What you can do is

How to define an array of another schema in OpenAPI 3? [duplicate]

。_饼干妹妹 提交于 2019-12-05 21:51:09
This question already has an answer here : Return an array of object in Swaggerhub (1 answer) Closed last year . I have this schema defined: User: type: object required: - id - username properties: id: type: integer format: int32 readOnly: true xml: attribute: true description: The user ID username: type: string readOnly: true description: The username first_name: type: string description: Users First Name last_name: type: string description: Users Last Name avatar: $ref: '#/components/schemas/Image' example: id: 10 username: jsmith first_name: Jessica last_name: Smith avatar: image goes here

Swagger/OpenAPI 3.0 issue with example on responses

↘锁芯ラ 提交于 2019-12-05 21:50:56
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: string example: A string responses: 401: $ref: '#/components/responses/Unauthorized' 403: $ref: '#

How to define global parameters that will apply to all paths?

北战南征 提交于 2019-12-05 02:53:37
I want to make the account parameter to be applied to all paths, without any exceptions. Is there any way to do this with Swagger 2? I don't want apply the account parameter for every path. { "swagger": "2.0", "info": { "version": "1.0", "title": "Doc" }, "host": "localhost", "schemes": [ "http" ], "produces": [ "application/json" ], "parameters": { "account": { "in": "header", "name": "X-ACCOUNT", "description": "Account id", "type": "string", "required": true } }, "paths": { "/account": { "get": { "summary": "Get account", "operationId": "getAccount", "responses": { "200": { "description":

Tell Swagger that the request body can be a single object or a list of objects

独自空忆成欢 提交于 2019-12-05 01:27:07
I am using Swagger with Scala to document my REST API. I want to enable bulk operations for POST, PUT and DELETE and want the same route to accept either a single object or a collection of objects as body content. Is there a way to tell Swagger that a param is either a list of values of type A or a single value of type A? Something like varargs for REST. Mohsen Is there a way to tell Swagger that a param is either a list of values of type A or a single value of type A? This depends on whether you use OpenAPI 3.0 or OpenAPI (Swagger) 2.0. OpenAPI uses an extended subset of JSON Schema to