swagger-2.0

Avoiding default basic-error-controller from swagger api [duplicate]

淺唱寂寞╮ 提交于 2019-12-12 07:14:38
问题 This question already has answers here : Remove Basic Error Controller In SpringFox SwaggerUI (7 answers) Closed 5 months ago . I'm using swagger2 in my spring boot project. It's working well, but I need to exclude the basic-error-controller from the api. Currently I'm using the following code using regex. It's working but is there any perfect way to do this. CODE : @Bean public Docket demoApi() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.any())

How to get swagger json separately?

∥☆過路亽.° 提交于 2019-12-12 05:44:27
问题 I try to generate swagger.json from my java rest endpoints. pom <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-jaxrs</artifactId> <version>1.5.9</version> </dependency> Applicationpath import javax.ws.rs.ApplicationPath; @ApplicationPath("/rest") public class RestApplication extends Application { public RestApplication() { BeanConfig beanConfig = new BeanConfig(); //beanConfig.setVersion("1.0"); beanConfig.setSchemes(new String[] { "http" }); beanConfig.setTitle("My API");

swashbuckle mediatype application/octetstream

我怕爱的太早我们不能终老 提交于 2019-12-11 17:05:57
问题 I have an endpoint that produces mediatype as application/octet-stream. However, when I generated the swagger json, it specifies "produces" as "application/json" I did not do any special configs in swagger. All I did was import swagger nuget and just kept the default configuration as is. Please find below the endpoint: [HttpPost] [Route("document/method1")] public HttpResponseMessage method1([FromBody]SomeModel SomeModelValue) { // code that generates the file if (File.Exists(outputFilePath))

Set List of Objects in Swagger API response

别等时光非礼了梦想. 提交于 2019-12-11 15:37:38
问题 I want to send a list of objects in the response of an API using Swagger. @ApiResponse(code = 200, message = ApiResponseMessages.ITEM_FETCHED, response = "") I have a class - class Item{ int id; String item_name; } I want a response like - { { "id" : 0, "item_name" : "" } { "id" : 0, "item_name" : "" } { "id" : 0, "item_name" : "" } } How can i do this. Any help would be appreciated. 回答1: You also can set a ApiReponse like this: @ApiResponse(code = 200, message = ApiResponseMessages.ITEM

How to overcome “Conflicting setter definitions for property ”?

隐身守侯 提交于 2019-12-11 13:32:48
问题 I use com.fasterxml.jackson and io.swagger libraries. In my REST endpoint I use org.javamoney.moneta.Money type for a GET query. When deploying the war i get following exception 1; I have followed this reference and wrote following code[2]; and registered it at @ApplicationPath. But still getting same issue. Any guide would be really helpful? @ApplicationPath("/rest") public class RestApplication extends Application { @Override public Set<Class<?>> getClasses() { HashSet<Class<?>> set = new

How to add several examples to response in Swagger without breaking Codegen?

人盡茶涼 提交于 2019-12-11 13:15:30
问题 I've been trying to add examples to my Swagger API according to the official docs (see last codeblock of Request and Response Body Examples ) but it does not seem to work as expected. Considering the following minimal example: swagger: "2.0" info: description: Desc version: "1" title: Title paths: /stuff: post: produces: - application/json responses: 201: description: It worked content: application/json: schema: $ref: "#/definitions/StatusMessage" examples: Success without message: value:

Swagger Schema error should NOT have additional properties

时间秒杀一切 提交于 2019-12-11 08:52:44
问题 I am trying to create swagger json and trying to check it's validity in http://editor.swagger.io Upon validating the json, the above mentioned editor gives the following error: Schema error should NOT have additional properties additionalProperty: components Jump to line 0 If for some reason I can't define an element named components at root level where i am going to have some sort of json schema, what is the right way to do a $ref on the schema for requestBody for an API operation as I

Server response is empty on Swagger UI

假如想象 提交于 2019-12-11 04:54:43
问题 I have a REST API that is integrated with Swagger UI. However, when I try to execute a request from Swagger UI, the interface only shows me the curl command but provides no server response. The curl command returns the expected response when run from the command line, but nothing shows up in the UI itself. What could I do to resolve this? 回答1: I have the same issue and it seems to be a bug. The good news is that the request is actually sent and you can see the response in you developer

Swagger composition / inheritance

大城市里の小女人 提交于 2019-12-11 02:46:38
问题 I'm trying to document a REST API using Swagger. A simplified JSON response from our API looks like: { "data": { "type": "person" "id": "1" "attributes": { "name": "Joe" "age": 32 ... } "links": { ... } } } or { "data": { "type": "job" "id": "22" "attributes": { "name": "Manager" "location": "Somewhere" ... } "links": { ... } } } Their Swagger definitions for a successful GET might look like: '200': description: OK. schema: type: object properties: data: type: object properties: id: type:

Use multiple Json files in swagger-ui

拟墨画扇 提交于 2019-12-11 02:13:22
问题 I am using Swagger-ui version 2.1.4, i have hosted it locally and provided it my own Json file and API it opens the document fine and lists all the method in the json file, but the json file become very big, i want to use multiple json files and want to open one at a time, i do not know how to provide it multiple json files and use them, because the single file i have provided it in the index page was like this: var url = window.location.search.match(/url=([^&]+)/); if (url && url.length > 1)