How to describe this POST JSON request body in OpenAPI (Swagger)?

I made it work with: post: consumes: – application/json produces: – application/json – text/xml – text/html parameters: – name: body in: body required: true schema: # Body schema with atomic property examples type: object properties: testapi: type: object properties: messageId: type: string example: kkkk8 messageDateTime: type: string example: ‘2014-08-17T14:07:30+0530’ testapiBody: type: object properties: cameraServiceRq: type: … Read more

Springfox swagger-ui.html unable to infer base URL – Caused by missing cookies

Add in the security config — following URLS that are skipped for authentication :: private static final String[] AUTH_WHITELIST = { “/swagger-resources/**”, “/swagger-ui.html”, “/v2/api-docs”, “/webjars/**” }; @Override public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers(AUTH_WHITELIST); }

Why `additionalProperties` is the way to represent Dictionary/Map in Swagger/OpenAPI 2.0

Chen, I think your answer is correct. Some further background that might be helpful: In JavaScript, which was the original context for JSON, an object is like a hash map of strings to values, where some values are data, others are functions. You can think of each name-value pair as a property. But JavaScript doesn’t … Read more

Swagger: map of

Using additionalPropertiesis the proper way to describe hashmap with OpenAPI (fka. Swagger) Specification but Swagger UI do not render them for now. The issue is tracked here https://github.com/swagger-api/swagger-ui/issues/1248 Meanwhile you can use this trick: define a non required property (defaultin the example below) of the same type of the map’s objects and give some hint … Read more

swagger @ApiModelProperty example value for List property

I managed to get this to work, generating a List of Strings. Within the ApiModelProperty with springfox 2, write your example as follows: example = “[\”AddLine1\”,\”AddLine2\”,\”AddLine3\”,\”AddLine4\”]” Here is my example: @ApiModelProperty(value = “Address”, name = “addLines”, example = “[\”AddLine1\”,\”AddLine2\”,\”AddLine3\”,\”AddLine4\”]”) When I render the swagger page, I get the following output: “addLines”: [ “AddLine1”, “AddLine2”, “AddLine3”, … Read more

Enable bearer token in Swashbuckle (Swagger document)

Update The issue detailed below is now resolved in Swashbuckle v5.5.0. Issue Just ran into the exact same issue. I think the root cause is this line in Swashbuckle’s source code: var key = encodeURIComponent($(‘#input_apiKey’)[0].value); This is where the value from the HTML input field goes through URL encoding turning the space into %20. I’m … Read more

Specify an array of strings as body parameter in swagger API

Your description of an array of string is correct, but the parameter definition misses the name property to be valid. Here’s a full working example: swagger: “2.0” info: title: A dummy title version: 1.0.0 paths: /path: post: parameters: – in: body description: xxx required: true name: a name schema: type: array items: type: string responses: … Read more

Actions require unique method/path combination for Swagger

You can resolve it as follows: services.AddSwaggerGen (c => { other configs; c.ResolveConflictingActions (apiDescriptions => apiDescriptions.First ()); }); //in the Startup.cs class in the ConfigureServices method or you can put routes to differentiate your methods, for example: [HttpGet(“~/getsomething”)] [HttpGet(“~/getothersomething”)]

Added Springfox Swagger-UI and it’s not working, what am I missing?

Springfox 3.0.0 only works with Spring Boot <= 2.6.0-M2 but not with versions above it Options for Spring Boot 2.6 M2 < 1. spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER #-> App.properties     –    But without Actuator 2. @EnableWebMvc 3. Migrate to springdoc-openapi-ui – same steps as io.springfox >= 3.X io.springfox >= 2.X io.springfox >= 3.X <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version></dependency><dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> … Read more

How to generate a Swagger #definition from sample JSON

You can use this JSON-to-OpenAPI schema converter: https://roger13.github.io/SwagDefGen/ (GitHub project) I haven’t used it personally though, so I’m not sure how good it is. Since OpenAPI uses a subset of JSON Schema, you could also use one of the JSON Schema generators, however you may need to manually tweak the generated definition to make it … Read more

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