使用spring或jaxrs-spec为this minimal example生成服务器代码会创建两个模型类: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"https://stackoverflow.com/questions/44328132
复制相似问题