4

Productという定義と別のという定義を作成しましたText(コードを参照)。

定義で作成した型parameterspaths使えません。Text定義Productでは、私は呼び出されたプロパティを持っており、messageそのプロパティもタイプにしたいですText

(...)

paths:
  /products:
    get:
      summary: Product Types
      description: |
        Description text
      parameters:
        - name: latitude
          in: query
          description: Latitude component of location.
          required: true
          ### The type Text was not found here
          type: Text ### The type Text was not found here
(...)

definitions:

  Product:
    properties:
      message:
        ### The type Text was not found here
        type: Text ### Compilation Error in this line ####
      name:
        type: string
        description: Data description.


  Text:
    properties:
      code:
        type: string

しかし、このエラーが発生します:

Swagger エラー: データが「anyOf」のスキーマと一致しません。

Texttype のtypeを参照するにはどうすればよいProductですか?

4

1 に答える 1

3

$ref代わりに使用してください。ここに例があります

type: object
required:
- name
properties:
  name:
    type: string
  address:
    $ref: '#/definitions/Address'
  age:
    type: integer
    format: int32
    minimum: 0

参照: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#simple-model

于 2015-09-11T02:51:35.760 に答える