Tag: swagger 2.0

如何在swagger yml中定义HashMap <String,List >属性?

我正在使用swagger在Java和Type脚本中生成类。 我有问题定义map属性与对象列表作为值。 我试着定义如下: DataMap type: object additionalProperties: #type: array — This config does not work. $ref: ‘#/definitions/Data’ 在java中生成以下代码的yml定义: class DataMap extends HashMap { } 如何配置yml以生成包含数据列表的密钥? 类似下面的课: class DataMap extends HashMap<String, List> { } 要么 class DataInfo { Map<String, List> dataMap; } swagger 2.0有可能吗? 我正在考虑定义另一个扩展ArrayList的DataList类,然后将此类用作Map的值。 ————–更新和答案———– 谢谢@nickb 我使用swagger-codegen-maven-plugin版本2.2.1和yml定义来生成map,如下所示: DataInfo type: object properties: dataMap: type: object additionalProperties: […]

如何更改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) […]

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 1.5不显示我的1.2的@Api描述?

我最近将一个项目从Swagger API 1.2升级到2.0(或者用Swagger核心术语,从1.3升级到1.5)。 由于他们出色的移民指南 ,我设法在很短的时间内完成了这项工作,几乎没有任何障碍。 唯一困扰我的是缺乏对@Api注释的description值的支持。 端点被精心记录 – 包括顶级API端点 – 但它们的描述不再在UI中显示: 请注意,缺少某些东西? 一些研究(意思是,阅读源代码)产生了相同的description现在已经过时,为更@Tag注释@Tag 。 但是我找不到有关如何应用它们的信息,因此描述仍然存在于每个端点类中。 使用Dropwizard,有没有办法以编程方式在Swagger 1.5中实现这一点?