Questions tagged [openapi]

The OpenAPI Specification, originally known as the Swagger Specification, is a specification for machine-readable interface files for describing, producing, consuming, and visualizing RESTful Web services.

A variety of tools can generate code, documentation and test cases given an interface file. Development of the OpenAPI Specification (OAS) is overseen by the Open API Initiative, an open source collaborative project of the Linux Foundation.

Ref: https://en.wikipedia.org/wiki/OpenAPI_Specification

Related tags

4284 questions
22
votes
1 answer

How to specify examples for GET parameters in Swagger?

I'm using the online Swagger Editor to create a Swagger spec for my API. My API has a single GET request endpoint, and I'm using the following YAML code to describe the input parameters: paths: /fooBar: get: tags: - foobar …
Devdatta Tengshe
  • 4,015
  • 10
  • 46
  • 59
21
votes
2 answers

How to define an array of objects in OpenAPI 3.0?

I'm trying to add an object in an array, but this seems not be possible. I've tried the following, but I get always the error: Property Name is not allowed. This is shown for all items defined in the devices array. How can I define items in an…
Irgendw Pointer
  • 1,770
  • 3
  • 30
  • 67
21
votes
2 answers

Using Swashbuckle 5.x specify nullable = true on a Generic T Parameter reference property

I recently upgraded my API to a .net core 3.1 server using Swashbuckle 5 with the newtonsoft json nuget, which produces an openapi 3 schema. I then use NSwag to generate a C# API. Previously I had a .net core 2.2 server with swashbuckle 4, producing…
Adam Diament
  • 4,290
  • 3
  • 34
  • 55
21
votes
3 answers

springdoc-openapi apply default global SecurityScheme possible?

I have the following SecurityScheme definition using springdoc-openapi for java SpringBoot RESTful app: @Bean public OpenAPI customOpenAPI() { return new OpenAPI() .components(new…
Cortlendt
  • 2,190
  • 4
  • 29
  • 50
21
votes
3 answers

Displaying of FastAPI validation errors to end users

I'm looking for some library or example of code to format FastAPI validation messages into human-readable format. E.g. this endpoint: @app.get("/") async def hello(name: str): return {"hello": name} Will produce the next json output if we miss…
imbolc
  • 1,620
  • 1
  • 19
  • 32
21
votes
1 answer

OpenAPI multiple types inside an array

I'm having trouble defining a reusable schema component using OpenAPI 3 which would allow for an array that contains multiple types. Each item type inherits from the same parent class but has specific child properties. This seems to work alright in…
Bobbake4
  • 24,509
  • 9
  • 59
  • 94
21
votes
2 answers

Swagger: wildcard path parameters

I have an API which allows any arbitrary path to be passed in, for example all of these: /api/tags /api/tags/foo /api/tags/foo/bar/baz Are valid paths. I tried to describe it as follows: /tags{tag_path}: get: parameters: - name:…
Dmitry Frank
  • 10,417
  • 10
  • 64
  • 114
21
votes
4 answers

How to define different query parameters for same path in OpenAPI (Swagger)?

I am starting a REST service, using Swagger Codegen. I need to have different responses for different parameters. Example: /path can use ?filter1= or ?filter2=, and these parameters should produce different response messages. I want my…
Anil Pediredla
  • 704
  • 2
  • 8
  • 20
21
votes
3 answers

Defining enum for array in Swagger 2.0

type": "array", "items": { "type": "string", "enum": ["MALE","FEMALE","WORKER"] } or type": "array", "items": { "type": "string", }, "enum": ["MALE","FEMALE","WORKER"] ? Nothing in the spec about this. The goal is of course to get…
Esko Piirainen
  • 1,296
  • 2
  • 14
  • 28
21
votes
2 answers

Swagger HashMap property type

Is there any way to define a HashMap or Generic Object type in the models section? I have a REST service that returns products and those products can have different options. The options property are basically a HashMap, where the id is the option…
jplaza
  • 256
  • 1
  • 3
  • 5
20
votes
3 answers

Generating POJOs using OpenAPI generator with Lombok Annotations

I am using OpenAPI generator maven plugin like one below for generating Java client code for models . org.openapitools openapi-generator-maven-plugin 4.3.1
Saurabh Chaturvedi
  • 2,028
  • 2
  • 18
  • 39
20
votes
2 answers

how to indicate that a parameter is conditionally required when another parameter is used in Swagger Open API 3.0

I have created a RESTful API, and I am now defining the Open API 3.0 JSON representation for the usage of this API. I am requiring usage of a parameter conditionally, when another parameter is present. So I can't really use either required: true or…
JohnRDOrazio
  • 1,358
  • 2
  • 15
  • 28
20
votes
6 answers

How to validate openapi 3.0.0 yaml spec?

I have a yaml specification that has been updated from swagger 2.0 to openapi 3.0.0 The file itself is about 7,000 lines so it is challenging to validate by hand. I need to figure out which tags I have are no longer compatible with openapi 3.0.0.…
William Ross
  • 3,568
  • 7
  • 42
  • 73
20
votes
2 answers

How to declare a $ref property as readOnly in OpenAPI (Swagger)?

I am trying to add a read-only field for 'House' in this example. The house is another model that I want to be read-only. In this example, the array of Dogs can be set to readOnly without an error, but when I set the single definition of House to…
Mark Hayward
  • 424
  • 1
  • 5
  • 9
19
votes
6 answers

Wrong "Generated server url" in springdoc-openapi-ui (Swagger UI) deployed behind proxy

Spring Boot 2.2 application with springdoc-openapi-ui (Swagger UI) runs HTTP port. The application is deployed to Kubernetes with Ingress routing HTTPS requests from outside the cluster to the service. In this case Swagger UI available at…
Eugene Khyst
  • 9,236
  • 7
  • 38
  • 65