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
17
votes
3 answers

swagger-ui hangs on big responses

One of my endpoints returns a JSON (not huge, around 2MB). Trying to run GET on this endpoint in swagger-ui results in the browser hanging for a few minutes. After this time, it finally displays the JSON. Is there a way to define that the response…
idetyp
  • 486
  • 1
  • 3
  • 13
17
votes
1 answer

How to define byte array in OpenAPI 3.0

I'm migrating my API from Swagger 2.0 to OpenAPI 3.0. In a DTO I have a field specified as a byte array. Swagger definition of the DTO: Job: type: object properties: body: type: string format: binary Using the…
Michael Dz
  • 3,655
  • 8
  • 40
  • 74
17
votes
1 answer

OpenApi required property in nested objects not working

I need to describe an api having in request body an object with required fields and one of these fields it's an object itself having another set of required fields. I'm using open api v3 and swagger editor (https://editor.swagger.io/) After i put…
mbianchidev
  • 472
  • 1
  • 7
  • 18
17
votes
1 answer

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

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:…
Rudziankoŭ
  • 10,681
  • 20
  • 92
  • 192
17
votes
1 answer

How not to copy-paste 3 generic error responses in almost all paths?

I want almost all my paths to have the following 3 generic error responses. How do I describe that in Swagger without copypasting these lines everywhere? 401: description: The requester is unauthorized. schema: $ref:…
CrabMan
  • 1,578
  • 18
  • 37
16
votes
2 answers

Is there any way to have multiple response models in FastAPI/OpenAPI?

I am writing an app where I need to have two completely different set of response structures depending on logic. Is there any way to handle this so that I can have two different response models serialized, validated and returned and reflect in…
Dhaval Savalia
  • 495
  • 5
  • 17
16
votes
2 answers

Significance of Delegate Design Pattern in Swagger Generated Code?

When i generate code for Spring from my swagger yaml , usually controller layer is generated using delegate pattern , such that for a single model three files are generated . For example , if i defined a model named Person in my swagger/open API…
Saurabh Chaturvedi
  • 2,028
  • 2
  • 18
  • 39
16
votes
1 answer

Case Insensitive String parameter in schema of openApi

I have an open API spec with a parameter like this:  - name: platform in: query description: "Platform of the application" required: true schema: type: string enum: - "desktop" - "online" when I get the "platform"…
frdsprtrdr
  • 384
  • 1
  • 2
  • 11
16
votes
10 answers

SpringDoc openAPI tool not scanning for APIs in Spring Boot Project

I'm having trouble getting this to work. I've started with a working SpringBoot (v2.2.2) app with a working @RestController. To get springdoc to work I've included the following dependency in my pom: org.springdoc
Vincent Fumo
  • 361
  • 1
  • 2
  • 9
16
votes
6 answers

How to Integrate Open API 3 with Spring project (not Spring Boot) using springdoc-openapi

My Existing Project is on Spring Framework not Spring Boot. I want to integrate Open API 3 with it. I want to integrate using springdoc-openapi not using Jersey.
Ashish Kumar
  • 409
  • 1
  • 4
  • 12
16
votes
1 answer

How to use $ref to reference a path from another OpenAPI file?

Here it says I could refer to the definition in another file for an individual path, but the example seems to refer to a whole file, instead of a single path definition under the paths object. How to assign an individual path in another file's paths…
Tiina
  • 4,285
  • 7
  • 44
  • 73
16
votes
5 answers

How to generate openAPI code using multiple yaml file

I have two yaml file, customer.yaml and employee.yaml. How do I generate java code from these two yaml file in single project. I'm using gradle, I know the task specification for single yaml but how do I specify multiple yaml. Should I specify…
Nicolas
  • 554
  • 2
  • 11
  • 27
16
votes
2 answers

OpenApi 3 import schemas from external files

I am defining common schemas for Web services and I want to import them in the components/schema section of the specification. I want to create a canonical data model that is common across multiple services to avoid redefining similar objects in…
Aldo
  • 163
  • 1
  • 1
  • 5
16
votes
1 answer

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

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: …
Old Man Walter
  • 629
  • 2
  • 7
  • 16
16
votes
3 answers

How to generate JSON examples from OpenAPI/Swagger model definition?

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…
Youssouf Maiga
  • 6,701
  • 7
  • 26
  • 42