首页 > 解决方案 > OpenAPI 3.0:字段的可编辑性 - 动态

问题描述

是否可以在 openapi 3.0 中动态设置字段的可编辑性?

以下是解决方法的示例:

    FooBar:
      description: |
        This type defines a type FooBar.
      type: object
      properties:
        myNumber:
          type: EditableNumber
          description: The number that should be editable dynamically.

    EditableNumber:
      description: |
        This type defines an editable number.
      type: object
      properties:
        value:
          type: number
          description: The actual value
        editable:
          type: boolean
          description: whether the field is editable.
      required:
        - value

但是做这样的事情会更好:

    FooBar:
      description: |
        This type defines a type FooBar.
      type: object
      properties:
        myNumber:
          type: number
          description: The number that should be editable dynamically.
          readonly: true/false

但是真/假不能动态设置,对吧?

或者在没有解决方法的情况下还有其他可能吗?

谢谢

标签: swaggeropenapi

解决方案


推荐阅读