12,424 questions
310
votes
16
answers
232k
views
How to omit methods from Swagger documentation on WebAPI using Swashbuckle
I have a C# ASP.NET WebAPI application with API documentation being automatically generated using Swashbuckle. I want to be able to omit certain methods from the documentation but I can't seem to ...
203
votes
1
answer
233k
views
How to define a property that can be string or null in OpenAPI (Swagger)?
I have JSON schema file where one of the properties is defined as either string or null:
"type":["string", "null"]
When converted to YAML (for use with OpenAPI/Swagger), it becomes:
type:
- 'null'
...
178
votes
6
answers
393k
views
What is the correct way to declare a date in an OpenAPI / Swagger-file?
What is the correct way to declare a date in a swagger-file object? I would think it is:
startDate:
type: string
description: Start date
example: "2017-01-01"
format: date
...
154
votes
37
answers
351k
views
Swashbuckle/Swagger + ASP.Net Core: "Failed to load API definition"
I develop an ASP.NET Core 2 application and included Swagger. Everything worked fine until I introduced a method without explicitly defining the HTTP action:
public class ErrorController : Controller
{...
140
votes
16
answers
309k
views
How to configure Spring Security to allow Swagger URL to be accessed without authentication
My project has Spring Security.
Main issue: Not able to access swagger URL at http://localhost:8080/api/v2/api-docs. It says Missing or invalid Authorization header.
Screenshot of the browser window
...
128
votes
13
answers
234k
views
Converting Swagger specification JSON to HTML documentation
For some REST APIs written in PHP, I was asked to create Swagger documentation, and since I was not aware of any easy way of annotating those existing APIs and create such a documentation, I used this ...
123
votes
3
answers
152k
views
How can I generate swagger based off of existing postman collection? [closed]
I am developing a REST API. during development I have used postman (chrome extension) to use and document my API. It is a wonderful tool and I have most of my API endpoints in it.
However, as we near ...
118
votes
15
answers
373k
views
Swagger TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body
I have added Swagger to my Spring Boot 2 application:
This is my Swagger config:
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
// @...
112
votes
2
answers
76k
views
Swagger/OpenAPI - use $ref to pass a reusable defined parameter
Let's say I've got a parameter like limit. This one gets used all over the place and it's a pain to have to change it everywhere if I need to update it:
parameters:
- name: limit
in: query
...
103
votes
23
answers
204k
views
Swagger..Unable to render this definition The provided definition does not specify a valid version field
Unable to render this definition The provided definition does not
specify a valid version field.
Please indicate a valid Swagger or OpenAPI version field. Supported
version fields are swagger: "2....
100
votes
20
answers
256k
views
How to open local files in Swagger-UI
I'm trying to open my self generated swagger specification file my.json with swagger-ui on my local computer.
So I downloaded the latest tag v2.1.8-M1 and extracted the zip. Then I went inside the ...
96
votes
9
answers
63k
views
InvalidOperationException: Can't use schemaId .. The same schemaId is already used for type
I receive the following error.
InvalidOperationException: Can't use schemaId "$Registration" for type "$PortalService.Models.Registration". The same schemaId is already used for ...
95
votes
7
answers
141k
views
How to generate JSON-Schema from Swagger API Declaration
I have Swagger API Declaration for services using Swagger v 1.2.
My original feeling about Swagger was that it is very close to JSON Schema (Draft 3 and lately Draft 4) and it shall be relatively easy ...
93
votes
12
answers
109k
views
Generate static docs with swagger
Is there a method for creating static documentation for swagger 2.0?
Perhaps like the 'preview' on editor.swagger.io.
I need to get static html files so I can include them in some static documents.
...
90
votes
12
answers
185k
views
Web Api How to add a Header parameter for all API in Swagger
I searched for possible ways to add a request header parameter that would be added automatically to every method in my web-api but I couldn't find a clear one.
While searching I found that the method ...
89
votes
5
answers
86k
views
Swagger 2.0 - how to make "one or the other" parameter required?
I have a swagger 2.0 resource defined below. How can I make "param1 or param2" required? Caller has to pass either param1 or param2.
/some/res:
put:
summary: some resource
responses:
200:
...
88
votes
3
answers
106k
views
A 'simple' way to implement Swagger in a Spring MVC application
I have a ReSTFul API written in simple Spring (no Spring Boot, no fancy stuff!). I need to implement Swagger into this. So far, EVERY page on the internet has only driven me crazy with confusing ...
82
votes
7
answers
227k
views
How to describe a model in Swagger for an array with simple objects?
I have a REST services to document,
some of them accepts simple array like:
[
{ "name":"a" },
{ "name":"b" },
{ "name":"c" }
]
How do I describe this in Swagger model section ? I can only ...
81
votes
5
answers
101k
views
Validating JSON against Swagger API schema
I created an API spec from some JSON files and I am trying to test if the files validate against the API spec.
There are some good tools to validate against JSON Schema, but I did not have chance to ...
78
votes
10
answers
81k
views
swagger .net core API ambiguous HTTP method for Action Error
Implementing Swashbuckle/Swagger with .net Core 2 API I am now receiving the 500 error when accessing swagger.json:
NotSupportedException: Ambiguous HTTP method for action -
EBisAPI.Controllers....
74
votes
7
answers
74k
views
JWT Authentication and Swagger with .NET Core 3.0
I am developing some Web API with .NET Core 3.0 and want to integrate it with SwashBuckle.Swagger.
It is working fine, but when I add JWT authentication, it does not work as I expect.
To do that, I ...
71
votes
6
answers
68k
views
Why there are no themes for swagger-ui? [closed]
I like swagger for documenting Restful APIs very much, especially "Try it out!" button, but swagger-ui interface doesn't look very cool.
And I cannot believe there are no templates for such amazing ...
69
votes
10
answers
93k
views
Actions require unique method/path combination for Swagger
I have 2 HTTP GET method in same controller and give me this error
HTTP method "GET" & path "api/DataStore" overloaded by actions - DPK.HostApi.Controllers.DataStoreController.GetByIdAsync (DPK....
67
votes
1
answer
108k
views
How to convert OpenAPI 2.0 to OpenAPI 3.0?
I have some API definitions in OpenAPI 2.0 format, but my tooling requires OpenAPI 3.0 format. How do I convert OpenAPI 2.0 to OpenAPI 3.0? Ideally I want to be able to script the process to avoid ...
64
votes
2
answers
97k
views
Why `additionalProperties` is the way to represent Dictionary/Map in Swagger/OpenAPI 2.0
Although I have seen the examples in the OpenAPI spec:
type: object
additionalProperties:
$ref: '#/definitions/ComplexModel'
it isn't obvious to me why the use of additionalProperties is the ...