Created
November 8, 2024 00:16
-
-
Save ydatech/32e82933c8367d8376fc8f0579509288 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| openapi: 3.0.3 | |
| info: | |
| title: Cool VLab RESTful API | |
| version: 1.0.0 | |
| description: API for vlab. | |
| servers: | |
| - url: https://api.domain.example | |
| description: Production server | |
| - url: https://api-dev.domain.example | |
| description: Staging server | |
| tags: | |
| - name: Authentication | |
| description: Operations related to user authentication. | |
| - name: Protected | |
| description: Operations related to protected resources that require authentication. | |
| components: | |
| securitySchemes: | |
| BearerAuth: | |
| type: http | |
| scheme: bearer | |
| bearerFormat: JWT | |
| description: Use a Bearer token for authentication. | |
| paths: | |
| /login: | |
| post: | |
| summary: User login | |
| description: Authenticates a user with a username and password. | |
| tags: | |
| - Authentication | |
| requestBody: | |
| required: true | |
| content: | |
| application/json: | |
| schema: | |
| type: object | |
| properties: | |
| username: | |
| type: string | |
| description: Username for authentication. | |
| example: "example_user" | |
| password: | |
| type: string | |
| description: Password for authentication. | |
| example: "password123" | |
| required: | |
| - username | |
| - password | |
| responses: | |
| '200': | |
| description: Successfully authenticated. | |
| content: | |
| application/json: | |
| schema: | |
| type: object | |
| properties: | |
| access_token: | |
| type: string | |
| description: Access token for the session. | |
| example: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." | |
| expired_at: | |
| type: string | |
| format: date-time | |
| description: Expiration date and time for the access token. | |
| example: "2024-11-08T15:20:00Z" | |
| '401': | |
| description: Unauthorized | |
| content: | |
| application/json: | |
| schema: | |
| type: object | |
| properties: | |
| message: | |
| type: string | |
| example: "Unauthorized" | |
| description: Error message indicating failed authentication. | |
| /protected: | |
| get: | |
| summary: Protected resource | |
| description: Access to this resource requires a valid Bearer token. | |
| tags: | |
| - Protected | |
| security: | |
| - BearerAuth: [] # This path requires Bearer authentication | |
| responses: | |
| '200': | |
| description: Successfully accessed protected resource. | |
| content: | |
| application/json: | |
| schema: | |
| type: object | |
| properties: | |
| message: | |
| type: string | |
| example: "Access granted to the protected resource." | |
| '401': | |
| description: Unauthorized, invalid or missing Bearer token. | |
| content: | |
| application/json: | |
| schema: | |
| type: object | |
| properties: | |
| message: | |
| type: string | |
| example: "Unauthorized" | |
| description: Error message indicating failed authentication. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment