FastAPI’s RedirectResponse doesn’t work as expected in Swagger UI

To start with, the HTTP OPTIONS, in CORS, is a preflight request that is automatically issued by the browser, before the actual request—is not the one that returns the File response. It requests the permitted communication options for a given server, and the server responds with an Access-Control-Allow-Methods header including a set of permitted methods … Read more

Swagger: “equivalent path already exists” despite different parameters

That’s because the two paths can be identical. I understand that the parameters may uniquely identify them, but OpenAPI 2.0 (Swagger 2.0), 3.0 and 3.1 do not support full URI templates, and the path portion alone is inspected for uniqueness. So these: /{foo} /{bar} are identical, even if foo must be a string, and bar … Read more

Swagger API which is having query string

You can’t describe query parameters as part of the path in Swagger. You have to declare those explicitly as query parameters. “/v1/products”:{ “get”:{ “tags”:[ “Search Text” ], “summary”:”Get Products by searching text, countrycode, page number, pagesize, project and country(optional)”, “description”:”Get Products by searching text, countrycode, page number, pagesize, project and country(optional)”, “operationId”:”getProductName”, “produces”:[ “application/json”, “application/xml” … Read more

Post a json body with swagger

You need to use the body parameter: “parameters”: [ { “in”: “body”, “name”: “body”, “description”: “Pet object that needs to be added to the store”, “required”: false, “schema”: { “$ref”: “#/definitions/Pet” } } ], and #/definitions/Pet is defined as a model: “Pet”: { “required”: [ “name”, “photoUrls” ], “properties”: { “id”: { “type”: “integer”, “format”: … Read more

How do I combine multiple OpenAPI 3 specification files together?

I wrote a quick tool to do this recently. I call it openapi-merge. There is a library and an associated CLI tool: https://www.npmjs.com/package/openapi-merge https://www.npmjs.com/package/openapi-merge-cli In order to use the CLI tool you just write a configuration file and then run npx openapi-merge-cli. The configuration file is fairly simple and would look something like this: { … Read more

How do I include subclasses in Swagger API documentation/ OpenAPI specification using Swashbuckle?

It seems Swashbuckle doesn’t implement polymorphism correctly and I understand the point of view of the author about subclasses as parameters (if an action expects an Animal class and behaves differently if you call it with a dog object or a cat object, then you should have 2 different actions…) but as return types I … Read more

Combining defintions in Swagger docs

Indeed, the example you give here is invalid because $ref can’t co-exist with other properties in the same object. $ref is a JSON Reference, and by definition, will cause the other properties to be ignored. From your question, I assume you’re looking for basic composition (rather than inheritance). This is achievable using the allOf keyword. … Read more