Tag: springfox

如何更改Swagger中成功操作的响应状态代码?

如图所示,它为添加操作显示“响应类(状态200)”。 但是,添加操作的实现方式是永远不会返回200.成功时返回201。 我的问题是如何将(状态200)更改为(状态201)? 该部分的代码如下: @RequestMapping(method = RequestMethod.PUT, value = “/add”) @ApiOperation(value = “Creates a new person”, code = 201) @ApiResponses(value = { @ApiResponse(code = 201, message = “Record created successfully”), @ApiResponse(code = 409, message = “ID already taken”) }) public ResponseEntity add(@RequestParam(value = “name”, required = true) String name, @RequestParam(value = “id”, required = true) […]

使用springfox和Swagger2时,为什么v2 / api-docs是默认URL?

我刚开始按照这个指南开始使用招摇,但我发现了一些非常奇怪的东西对我来说毫无意义。 据我所知,当您拥有API版本号为2的文档时,应使用v2 / api-docs。 所以,默认应该只是api-docs,但由于一些奇怪的原因,我发现默认是v2 / api-docs。 检查库文档我发现了这个 。 如何在不能使用v2的情况下覆盖该值? (当我的API将达到v2但我也想展示旧版文档)。 或许我使用v2的概念是错误的? 有人可以帮我弄这个吗?

如何在Spring启动rest应用程序中使用Swagger ui使用密码流配置oAuth2

我有使用另一个Spring启动授权服务器的spring boot rest api(resources),我已经将Swagger配置添加到资源应用程序中,以便为其余的API获得一个漂亮而快速的文档/测试平台。 我的Swagger配置如下所示: @Configuration @EnableSwagger2 public class SwaggerConfig { @Autowired private TypeResolver typeResolver; @Value(“${app.client.id}”) private String clientId; @Value(“${app.client.secret}”) private String clientSecret; @Value(“${info.build.name}”) private String infoBuildName; public static final String securitySchemaOAuth2 = “oauth2”; public static final String authorizationScopeGlobal = “global”; public static final String authorizationScopeGlobalDesc = “accessEverything”; @Bean public Docket api() { List list […]

Swagger 2接受xml而不是json

我有一个带有spring boot的项目,我想使用swagger2来记录我的json Web服务。 我有这个配置: @Configuration @EnableSwagger2 public class Swagger2Config { @Bean public Docket welcomeMessageApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title(“My API”) .description(“Lorem Ipsum is simply dummy text of …”) .termsOfServiceUrl(“an url”) .contact(“contact”) .license(“”) .licenseUrl(“”) .version(“2.0”) .build(); } 要阅读文档,我使用以下链接: http:// localhost:9081 / v2 / […]

如何生成离线Swagger API文档?

我有一个Spring Boot MVC java Web应用程序。 我已经能够集成Springfox for API文档。 当服务器启动并运行时,我可以直观地看到所有API。 如何生成OFFLINE swagger API文档? 注意:我不想使用asciidoc或markdown文档,但我想在html文件中使用相同的swagger API用户界面。 我想这样链接是相对于本地目录而不是本地主机服务器链接。 谢谢

swagger @ApiModelProperty List 属性的示例值

我有一个类,其中有一个属性是List public class MyClass { …. @ApiModelProperty(position = 2) private List productIdentifiers; …. } 此代码生成示例值,如下所示: { “customerId”: “1001”, “productIdentifiers”: [ “string” ], “statuses”: [ “NEW” ] } 此处显示的示例值无效。 我期望的示例值应该是: { “customerId”: “1001”, “productIdentifiers”: [ “PRD1”, “PRD2”, “PRD3” ], “statuses”: [ “NEW” ] } 我尝试传递示例属性如下,但它没有生成正确的值: @ApiModelProperty(position = 2, example = “PRD1, PRD2, PRD3”) // This generates […]