reqres.yaml 6.37 KB
Newer Older
openapi: 3.0.0
info:
  title: ReqRes API
  description: Fake data CRUD API
  version: 1.00
servers:
  - url: https://reqres.in/api
components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: integer
        email:
          type: string
        first_name:
          type: string
        last_name:
          type: string
        avatar:
          type: string
    UnknownResource:
      type: object
      properties:
        id: 
          type: integer
        name:
          type: string
        year:
          type: integer
        color:
          type: string
        pantone_value:
          type: string
paths:
  /{resource}:
    get:
      summary: Fetches a resource list
      parameters:
        - in: query
          name: page
          schema:
            type: integer
        - in: query
          name: per_page
          schema:
            type: integer
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  page: 
                    type: integer
                  per_page:
                    type: integer
                  total:
                    type: integer
                  total_pages:
                    type: integer
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/UnknownResource"
  /users:
    get:
      summary: Fetches a user list
      parameters:
        - in: query
          name: page
          schema:
            type: integer
        - in: query
          name: per_page
          schema:
            type: integer
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  page: 
                    type: integer
                  per_page:
                    type: integer
                  total:
                    type: integer
                  total_pages:
                    type: integer
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/User"
  /users/{id}:
    get:
      summary: Fetches a user
      parameters:
        - in: path
          name: id
          schema:
            type: integer
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  data: 
                    $ref: "#/components/schemas/User"
    put:
      summary: Updates a user
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  updatedAt:
                    type: string
    patch:
      summary: Updates a user
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  updatedAt:
                    type: string
    delete:
      summary: Deletes a user
      responses:
        '204':
          description: Success
  /{resource}/{id}:
    get:
      summary: Fetches an unknown resource
      parameters:
        - in: path
          name: id
          schema:
            type: integer
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  data: 
                    $ref: "#/components/schemas/UnknownResource"
    put:
      summary: Updates an unknown resource
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  updatedAt:
                    type: string
    patch:
      summary: Updates an unknown resource
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  updatedAt:
                    type: string
    delete:
      summary: Deletes an unknown resource
      responses:
        '204':
          description: Success
  /login:
    post:
      summary: Creates a session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                username:
                  type: string
                email:
                  type: string
                password:
                  type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: 
                type: object
                properties:
                  token:
                    type: string
        '400':
          description: Login error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  /register:
    post:
      summary: Creates a user
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                username:
                  type: string
                email:
                  type: string
                password:
                  type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: 
                type: object
                properties:
                  id:
                    type: string
                  token:
                    type: string
        '400':
          description: Register error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  /logout:
    post:
      summary: Ends a session
      responses:
        '200':
          description: Success