首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Swagger生成重复的模型类

Swagger生成重复的模型类
EN

Stack Overflow用户
提问于 2017-06-02 19:44:24
回答 0查看 3.5K关注 0票数 0

使用springjaxrs-specthis minimal example生成服务器代码会创建两个模型类:Pet.javaInlineResposne200.java。除了类名之外,它们都是相同的。

响应/pets的控制器返回一个List<InlineResponse200>而不是List<Pet>,并且Pet类实际上从未在任何地方使用过,即使yaml定义使用了$ref: "#/definitions/Pet"。为什么会发生这种情况?

代码语言:javascript
复制
---
  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"
EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44328132

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档