openapi: 3.0.0 info: version: 1.0.0 title: golang-rest-example license: name: MIT url: https://opensource.org/license/MIT/ description: > Example OpenAPI Golang server. servers: - url: http://localhost:1234 description: Local server tags: - name: health description: Health check - name: users description: User management - name: groups description: Group management paths: /healthz: description: Health check get: tags: - health responses: '200': $ref: '#/components/responses/Ok' default: $ref: '#/components/responses/UnexpectedError' /users: get: description: Get all users tags: - users responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/User' default: $ref: '#/components/responses/UnexpectedError' post: description: Create user tags: - users requestBody: description: User object required: true content: application/json: schema: $ref: '#/components/schemas/UserUpdate' responses: '201': description: OK content: application/json: schema: $ref: '#/components/schemas/User' default: $ref: '#/components/responses/UnexpectedError' /users/{id}: get: description: Get user by id tags: - users parameters: - name: id in: path required: true schema: $ref: '#/components/schemas/Id' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/User' '404': $ref: '#/components/responses/NotFound' default: $ref: '#/components/responses/UnexpectedError' put: description: Update user by id tags: - users parameters: - name: id in: path required: true schema: $ref: '#/components/schemas/Id' requestBody: description: User object required: true content: application/json: schema: $ref: '#/components/schemas/UserUpdate' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/User' '404': $ref: '#/components/responses/NotFound' default: $ref: '#/components/responses/UnexpectedError' delete: description: Delete user by id tags: - users parameters: - name: id in: path required: true schema: $ref: '#/components/schemas/Id' responses: '200': $ref: '#/components/responses/Ok' '404': $ref: '#/components/responses/NotFound' default: $ref: '#/components/responses/UnexpectedError' /groups: get: description: Get all groups tags: - groups responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/Group' default: $ref: '#/components/responses/UnexpectedError' post: description: Create group tags: - groups requestBody: description: Group object required: true content: application/json: schema: $ref: '#/components/schemas/GroupUpdate' responses: '201': description: OK content: application/json: schema: $ref: '#/components/schemas/Group' default: $ref: '#/components/responses/UnexpectedError' /groups/{id}: get: description: Get group by id tags: - groups parameters: - name: id in: path required: true schema: $ref: '#/components/schemas/Id' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Group' '404': $ref: '#/components/responses/NotFound' default: $ref: '#/components/responses/UnexpectedError' put: description: Update group by id tags: - groups parameters: - name: id in: path required: true schema: $ref: '#/components/schemas/Id' requestBody: description: Group object required: true content: application/json: schema: $ref: '#/components/schemas/GroupUpdate' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Group' '404': $ref: '#/components/responses/NotFound' default: $ref: '#/components/responses/UnexpectedError' delete: description: Delete group by id tags: - groups parameters: - name: id in: path required: true schema: $ref: '#/components/schemas/Id' responses: '200': $ref: '#/components/responses/Ok' '404': $ref: '#/components/responses/NotFound' default: $ref: '#/components/responses/UnexpectedError' components: responses: Ok: description: OK content: application/json: schema: $ref: '#/components/schemas/Ok' NotFound: description: Not found content: application/json: schema: $ref: '#/components/schemas/Error' UnexpectedError: description: Unexpected error content: application/json: schema: $ref: '#/components/schemas/Error' schemas: Ok: type: object required: - message properties: message: type: string example: OK Error: type: object required: - message - code properties: message: type: string example: Not found code: type: integer example: 404 Id: type: integer format: int64 example: 1 User: type: object required: - id - name - email - group_id properties: id: $ref: '#/components/schemas/Id' name: type: string example: John email: type: string example: john@example.com group_id: $ref: '#/components/schemas/Id' UserUpdate: type: object required: - name - email - group_id properties: name: type: string example: John email: type: string example: john@example.com group_id: $ref: '#/components/schemas/Id' Group: type: object required: - id - name - user_ids properties: id: $ref: '#/components/schemas/Id' name: type: string example: admins user_ids: type: array items: $ref: '#/components/schemas/Id' GroupUpdate: type: object required: - name properties: name: type: string example: admins