swagger
swagger .net core API ambiguous HTTP method for Action Error
This can occur when a method is declared public in a controller, but without REST attributes. Changing the method to protected may address the issue. I have seen this kind of error before and usually the error message points to the culprit: EBisAPI.Controllers._class.HandleError I guess HandleError is a public method in your base class, right? … Read more
Keycloak integration in Swagger
Swagger-ui can integrate with keycloak using the implicit authentication mode. You can setup oauth2 on swagger-ui so that it will ask you to authenticate instead of giving swagger-ui the access token directly. 1st thing, your swagger need to reference a Security definition like: “securityDefinitions”: { “oauth2”: { “type”:”oauth2″, “authorizationUrl”:”http://172.17.0.2:8080/auth/realms/master/protocol/openid-connect/auth”, “flow”:”implicit”, “scopes”: { “openid”:”openid”, “profile”:”profile” } … Read more
How can I set a description and an example in Swagger with Swagger annotations?
I have similar issue with generating examples for body objects – annotation @Example and @ExampleProperty simply doesn’t work for no reason in swagger 1.5.x. (I use 1.5.16) My current solution is: use @ApiParam(example=”…”) for non-body objects, e.g.: public void post(@PathParam(“userId”) @ApiParam(value = “userId”, example = “4100003”) Integer userId) {} for body objects create new class … Read more
How do you turn off swagger-ui in production
Put your swagger configuration into separate configuration class and annotate it with @Profile annotation -> so that it will be scanned into Spring context only in certain profiles. Example: @Configuration @EnableSwagger2 @Profile(“dev”) public class SwaggerConfig { // your swagger configuration } You can than define profile your Spring Boot app is operating in via command … Read more
What is Swagger, Swashbuckle and Swashbuckle UI
Swagger is a notation/rules to write documentation. But why is it called a framework(Like angular/MVC)? It is probably called a “framework” because its’ purpose is to offer a systematic way of notating the interface of any RESTful service under the OpenAPI Specification. This is a big deal to developers because the spec is overseen by … Read more
What is Swagger and does it relate to OData?
Swagger is a specification for documenting APIs. By creating a swagger document for your API, you can pass it to an instance of Swagger UI, which renders the document in a neat, readable format and provides tooling to invoke your APIs. See the swagger.io website for further information. OData is a specification for creating data … Read more
How to generate basic TypeScript interfaces from Swagger schema?
Not sure if that’s a sane way to do this, it’s the first time I’m playing around with Swagger. I bumped into the following link and pasted the schema from the project I integrate with. From the top ‘Generate Client’ menu I chose one of the TypeScript presets and it generated a minimal project where … Read more
Swagger Editor shows the “Schema error: should NOT have additional properties” error for a path parameter
The error message is misleading. The actual error is that your path parameter is missing required: true. Path parameters are always required, so remember to add required: true to them.
InvalidOperationException: Can’t use schemaId .. The same schemaId is already used for type
Try this John: https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1607#issuecomment-607170559 helped me. I can understand what is happening; i have several enums with ‘Status’ or ‘Type’. Using options.CustomSchemaIds( type => type.ToString() ); solved this.