Spring Boot & Swagger UI. Set JWT token

Original answer Support for Authorization: Bearer [JWT_TOKEN] header is working as of version 2.9.2 Added the following dependencies to build.gradle compile(“io.springfox:springfox-swagger2:2.9.2”) { exclude module: ‘mapstruct’ // necessary in my case to not end up with multiple mapstruct versions } compile “io.springfox:springfox-bean-validators:2.9.2” compile “io.springfox:springfox-swagger-ui:2.9.2” Configured Swagger via @Configuration @EnableSwagger2 @Import(springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration.class) public class SwaggerConfiguration { public static … Read more

Swagger complex response model with dynamic key value hash maps

Your usage of additionalProperties is correct and your model is correct. additionalProperties In Swagger/OpenAPI, hashmap keys are assumed to be strings, so the key type is not defined explicitly. additionalProperties define the type of hashmap values. So, this schema type: object additionalProperties: type: string defines a string-to-string map such as: { “en”: “English text”, “de”: … 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

Use JWT (Authorization: Bearer) in Swagger in ASP.NET Core

I struggled with the same problem and found a working solution in this blogpost: http://blog.sluijsveld.com/28/01/2016/CustomSwaggerUIField It comes down to adding this in your configurationoptions services.ConfigureSwaggerGen(options => { options.OperationFilter<AuthorizationHeaderParameterOperationFilter>(); }); and the code for the operationfilter public class AuthorizationHeaderParameterOperationFilter : IOperationFilter { public void Apply(Operation operation, OperationFilterContext context) { var filterPipeline = context.ApiDescription.ActionDescriptor.FilterDescriptors; var isAuthorized = … Read more

Multi-line literals in swagger editor?

I believe the problem is the way you started the text on your description block. It must be indented one level to the right of description: Here’s an example of something that works for me: /{user-id}: get: summary: Facebook User description: | Displays all information about a Facebook user, depending on access privileges. Displays all … Read more

Swagger with Spring Boot 2.0 leads to 404 error page

I was able to make it work with Spring boot version 2.0.4.RELEASE and this blog post: I added these dependencies: <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency> And this configuration file: import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; @Configuration @EnableSwagger2 public class SpringFoxConfig { @Bean … Read more

How to refer to enclosing type definition recursively in OpenAPI / Swagger?

Your definition is perfectly fine. It’s a known issue with rendering recursive schemas in Swagger Editor and Swagger UI: https://github.com/swagger-api/swagger-ui/issues/3325 To work around the “Example Value” showing null/”string”/undefined instead of a recursive element, you can add a custom example to your schema: definitions: TreeNode: type: object properties: name: type: string description: The name of the … Read more

OpenAPI 3.0 Generic Data types

I search for generic types much time, but there is no way to define a generic type in OpenAPI3. The simplest way is using allOf and $ref at the same time. Suppose there is a list schema as follow: List: type: object properties: page_number: type: integer page_count: type: integer And the book schema is Book: … Read more

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