Swagger TypeError: Failed to execute ‘fetch’ on ‘Window’: Request with GET/HEAD method cannot have body

I ran into this issue. Here is how I resolved it: I had a method like this: [HttpGet] public IEnumerable<MyObject> Get(MyObject dto) { … } and I was getting the error. I believe swagger UI is interpreting the Get parameters as FromBody, so it uses the curl -d flag. I added the [FromQuery] decorator and … Read more

Swagger Inheritance and Composition

As a beginner in swagger I don’t find the official documentation about polimorphism and composition easy to undestand, because it lacks an example. When I searched the net, there are lots of good examples refering to swagger 1.2 when extends was valid. For swagger 2.0 I found a good example in swagger spec sources on … Read more

Swagger/OpenAPI – use $ref to pass a reusable defined parameter

This feature already exists in Swagger 2.0. The linked ticket talks about some specific mechanics of it which doesn’t affect the functionality of this feature. At the top level object (referred to as the Swagger Object), there’s a parameters property where you can define reusable parameters. You can give the parameter any name, and refer … Read more

Swagger/OpenAPI mock server

An easy way to create simple mock from an OpenAPI (fka Swagger) spec without code is to use a tool call prism available at http://github.com/stoplightio/prism written in Typescript. This command line is all you need: ./prism run –mock –list –spec <your swagger spec file> The mock server will return a dynamic response based on the … Read more

How to export swagger.json (or yaml)

The URL of the API definiton is displayed in the top bar of Swagger UI – in your example it’s /v2/api-docs?group=full-petstore-api So the full URL appears to be http://localhost:8080/v2/api-docs?group=full-petstore-api In newer versions of Swagger UI, the link to the API definition is often displayed below the API title, so you can right-click the link and … Read more

ASP.NET Core – Swashbuckle not creating swagger.json file

I had the same problem. Check http://localhost:XXXX/swagger/v1/swagger.json. If you get any a errors, fix them. For example, I had an ambiguous route in a base controller class and I got the error: “Ambiguous HTTP method for action. Actions require an explicit HttpMethod binding for Swagger 2.0.”. If you use base controllers make sure your public … Read more

Converting Swagger specification JSON to HTML documentation

Try to use redoc-cli. I was using bootprint-openapi by which I was generating a bunch of files (bundle.js, bundle.js.map, index.html, main.css and main.css.map) and then you can convert it into a single .html file using html-inline to generate a simple index.html file. Then I found redoc-cli very easy to to use and output is really-2 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)