Untitled

 avatar
unknown
plain_text
a year ago
4.4 kB
5
Indexable
openapi: "3.0.0"
info:
  title: User Service API
  version: "1.0"

paths:
  /users:
    post:
      summary: Create a new user
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/User'
      responses:
        '201':
          description: User created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
    
    get:
      summary: Retrieve a list of users
      responses:
        '200':
          description: A list of users
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/User'

  /users/{id}:
    patch:
      summary: Update a user
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                username:
                  type: string
                name:
                  type: string
                role_id:
                  type: integer
                password:
                  type: string
      responses:
        '200':
          description: User updated successfully
    
    delete:
      summary: Delete a user
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '204':
          description: User deleted successfully

  /roles:
    get:
      summary: Retrieve a list of roles
      responses:
        '200':
          description: A list of roles
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Role'

  /grant-methods/{userId}:
    get:
      summary: Retrieve grant methods for a user
      parameters:
        - name: userId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: A list of grant methods
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/GrantMethod'

  /auth/{id}:
    get:
      summary: Retrieve auth information for a specific ID
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Auth information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Auth'

  /auth:
    post:
      summary: Create a new auth
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Auth'
      responses:
        '201':
          description: Auth created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Auth'

components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        username:
          type: string
        name:
          type: string
        role_id:
          type: integer
        password:
          type: string
      required:
        - username
        - role_id
        - password

    Role:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        name:
          type: string
      required:
        - name

    GrantMethod:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        name:
          type: string
      required:
        - name

    Auth:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        user_id:
          type: integer
        value:
          type: string
      required:
        - user_id
        - value