swaggerhub api 文档用于相同端点但具有不同角色

问题描述 投票:0回答:1

如何在 swaggerhub api 文档中定义具有不同角色的相同端点。

/register:
    post:
      summary: Creates a new Driver.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/User'

      responses:
        200:
           description: OK  
        201:
          description: 'User created successfully.'
          content:
              application/json:
                schema:
                  type: object
                  properties:
                    success:
                      type: boolean
                      example: true
                    code:
                      type: integer
                      example: 201
                    message:
                      type: string
                      example: User Registered Successfully.
                    data:
                      type: object
                      properties:
                        user_id:
                          type: integer
                        name: 
                          type: string
                        full_name:
                          type: string
                        email:
                          type: string
                        mobile_number:
                          type: string
                        is_verified:
                          type: boolean
                        is_active:
                          type: boolean


components:
  schemas:
    User:
      properties:
        mobile_number:
          type: string
        email:
          type: string
        gender:
          type: string
          enum: ['male','female','others']
        password:
          type: string
        full_name:
          type: string
        role_id:
          type: integer
        vehicle_type:
          type: string
          enum: ['Bike','Car','Bicycle','Other']


      # All properties are required
      required:  
        - mobile_number
        - gender
        - full_name
        - role_id
        - password
        - vehicle_type

现在,有没有办法对不同的 role_id 使用相同的端点。所以我可以将相同的资源与其他验证字段一起使用。我想为不同的不同角色使用相同的注册资源。

有人对此有想法吗?

swagger swagger-2.0 openapi swagger-editor
1个回答
0
投票

OpenAPI 的开发负责人声明了这一点:https://flic.kr/p/2keNR8v

© www.soinside.com 2019 - 2024. All rights reserved.