是否可以在包含特定值的范围内定义字段

时间:2018-11-26 17:01:09

标签: swagger openapi

我的API包含字段result,其类型为string,但只能包含以下值之一-successerror。如何在Swagger中定义它?

不用说

ServerResponse: #{result: ..., additional-info: ...}
      type: object
      properties: 
        result: 
          type: string #generic type, could be any string
        additional-info: 
          type: string
      required:
        - result
        - additional-info

我想说

ServerResponse: #{result: ..., additional-info: ...}
      type: object
      properties: 
        result: 
          type: 'success' or 'error'#<-- something like this with specific list of possible value
        additional-info: 
          type: string
      required:
        - result
        - additional-info

0 个答案:

没有答案