swagger

SpringBoot集成Swagger2中遇到的问题

老子叫甜甜 提交于 2019-12-14 03:56:37
我们在使用SpringBoot集成Swagger2中,访问: http://127.0.0.1:8188/swagger-ui.html 问题描述 可能出现两种错误: 1.页面显示默认报错页面。后台报错: No handler found for GET /swagger-ui.html 2.显示Swagger空白页面: 后台报错: No mapping found for HTTP request with URI [/swagger-resources/configuration/ui] in DispatcherServlet with name 'dispatcherServlet' 解决方案 这个错误,是因为资源映射问题导致。 我们在访问 http://127.0.0.1:8188/swagger-ui.html 时,这个swagger-ui.html相关的所有前端静态文件都在springfox-swagger-ui-2.6.1.jar里面。目录如下: Spring Boot自动配置本身不会自动把/swagger-ui.html这个路径映射到对应的目录META-INF/resources/下面。我们加上这个映射即可。代码如下: @Configuration class WebMvcConfig extends WebMvcConfigurerAdapter {

How to link to another endpoint in Swagger

孤街醉人 提交于 2019-12-14 03:46:49
问题 I'm writing a Swagger specification for an future public API that requires a very detailed and clean documentation. Is there a way to reference/link/point to another endpoint at some other location in the swagger.yml file? For example, here is what I am trying to achieve: paths: /my/endpoint: post: tags: - Some tag summary: Do things description: > This endpoint does things. See /my/otherEndpoint for stuff # Here I would like to have some kind of hyperlink operationId: doThings consumes: -

Google Cloud Endpoints - Method does not exist - OpenAPI yaml specification

烈酒焚心 提交于 2019-12-14 02:20:16
问题 I'm trying to setup a NodeJS REST API using Google Cloud Endpoints and Google App Engine. I've cloned the offical sample project from GitHub and set up Google Cloud Endpoints using the Quickstart. Out of the box, it works fine,but I tried adding another API endpoint for a GET request at / , but the response I get after I deploy and make the request is as follows: { "code": 5, "message": "Method does not exist.", "details": [ { "@type": "type.googleapis.com/google.rpc.DebugInfo", "stackEntries

Using Springfox to document jax-rs services in a Spring app

不羁岁月 提交于 2019-12-14 01:26:14
问题 I want to document the API of an existing app using Springfox. I added these dependencies to pom.xml: <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.2.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.2.2</version> </dependency> I've added the swagger package to the jersey packages in web.xml so that Swagger2Controller is picked up: <?xml version="1.0" encoding=

How to define different query parameters for same path in OpenAPI (Swagger)?

允我心安 提交于 2019-12-14 00:58:21
问题 I am starting a REST service, using Swagger Codegen. I need to have different responses for different parameters. Example: <baseURL>/path can use ?filter1= or ?filter2= , and these parameters should produce different response messages. I want my OpenAPI YAML file to document these two query params separately. Is this possible? 回答1: It is not supported in the 2.0 spec, and not in 3.0 either. Here are the corresponding proposals in the OpenAPI Specification repository: Accommodate legacy APIs

Why not to consider models in REST API versioning?

冷暖自知 提交于 2019-12-14 00:04:42
问题 There was an answer to similar question but that was too specific to an example and doesn't answer in general. Can any one please tell how to handle the below scenario if models are not versioned? PUT /v1/users username (string) email (string) (required) password (string) (required) POST /v2/users username (string) (required) email (string) required password (string) (required) Assuming the model name is UserModel , in v1 version username is optional but in V2 it's required. If we use a

Show maximum, minimum and default in Swagger for Django Rest Framework

血红的双手。 提交于 2019-12-13 18:50:30
问题 I am developing a v2 for my API, and I would like to document it properly. Since I use Django Rest Framework (3.1.1), and it is recommended in their docs to use Swagger, I am using it. In the documentation, I see that one of its features is to show "Field default values, minimum, maximum, read-only and required attributes". However, in my example, I only see "Description", "Parameter Type" and "Data Type", as in the image: I would like to see more columns, such as minimum, maximum, and

Add new column in responses(Swagger-ui)

大城市里の小女人 提交于 2019-12-13 15:51:52
问题 I am using Swagger-ui for the api documentation, when i come to responses i want to add a new column of any name in every response, screen shot is attached, highlighted text is ok, i want to add a new column at place of the circle. My response JSON is "responses" : { "400" : { "description" : "Invalid ID Supplied" }, "404" : { "description" : "Order not found" } } how to add new column in it? Is there any way type of Intellisense provided for Swagger-ui JSON? 回答1: You can extend the API

Hide some fields dynamically before marshalling (java to json)

旧城冷巷雨未停 提交于 2019-12-13 15:20:41
问题 I have a jax-rs endpoint that should return a JSON object but i want to select some fields and hide some others, my code is like this : import javax.ws.rs.BadRequestException; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import org.apache.commons.lang3.StringUtils; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import io.swagger.annotations.Api; import io

How to enable swagger in ServiceStack?

点点圈 提交于 2019-12-13 13:02:06
问题 I found mention of swagger in the Introductory Slides. But nowhere else. Is is something not finished yet? Edit: Apparently it's on To Do List. Is there any good way to document the RestAPI automatically? 回答1: According to Trello it was a "Doing" but has then been moved back to "To Do"; and there's a Swagger.Api module in the github repo, so assuming it's only partially finished. Edit As pointed out already (but for the sake of completeness, as this was the accepted answer), SwaggerUI is