生成服务器代码中使用this minimal examplespring
或jaxrs-spec
创建2分模型类为:Pet.java
和InlineResposne200.java
。除了班级名称,他们是相同的。扬鞭生成复制模型类
,响应/pets
回报List<InlineResponse200>
代替List<Pet>
和类Pet
实际上从来没有在任何地方使用,即使YAML定义使用$ref: "#/definitions/Pet"
控制器。这是为什么发生?
---
swagger: "2.0"
info:
version: "1.0.0"
title: "Swagger Petstore"
description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification"
termsOfService: "http://swagger.io/terms/"
contact:
name: "Swagger API Team"
license:
name: "MIT"
host: "petstore.swagger.io"
basePath: "/api"
schemes:
- "http"
consumes:
- "application/json"
produces:
- "application/json"
paths:
/pets:
get:
description: "Returns all pets from the system that the user has access to"
produces:
- "application/json"
responses:
"200":
description: "A list of pets."
schema:
type: "array"
items:
$ref: "#/definitions/Pet"
definitions:
Pet:
type: "object"
required:
- "id"
- "name"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
tag:
type: "string"
从我的机器生成使用v2.2.2工作正常,谢谢!我使用'http:// editor.swagger.io'上的那个 – cahen