相同端点但角色不同的swaggerhub api文档

时间:2018-10-10 01:25:01

标签: swagger swagger-2.0 openapi swagger-editor

如何在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。所以我可以将相同的资源与其他验证字段一起使用。我想为不同的角色使用相同的注册资源。

有人对此有想法吗?

0 个答案:

没有答案