openapi: 3.0.0 info: title: <%= projectName %> API version: 1.0.0 description: API documentation for <%= projectName %> servers: - url: http://localhost:3000 description: Local Server components: <%_ if (auth.includes('JWT')) { -%> securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT <%_ } -%> schemas: User: type: object required: - name - email <% if (auth.includes('JWT')) { %>- password<% } %> properties: id: type: integer description: The auto-generated id of the user name: type: string description: The name of the user email: type: string description: The email of the user <% if (auth.includes('JWT')) { %> password: type: string writeOnly: true description: The password of the user <% } %> example: id: 1 name: John Doe email: john@example.com tags: - name: Users description: The users managing API - name: Health description: Health check and maintenance endpoints <%_ if (auth.includes('JWT')) { -%> - name: Auth description: Authentication API <%_ } -%> paths: /health: get: summary: Health check endpoint tags: - Health responses: '200': description: System is UP <%_ if (typeof backgroundJobs !== 'undefined' && backgroundJobs) { -%> /health/test-job: post: summary: Enqueue a test background job tags: - Health responses: '200': description: Job enqueued successfully <%_ } -%> <%_ if (auth.includes('JWT')) { -%> <%_ const authPath = "/api/auth"; _%> <%= authPath %>/login: post: summary: Login and receive a JWT token tags: - Auth requestBody: required: true content: application/json: schema: type: object required: - email - password properties: email: type: string password: type: string responses: '200': description: Login successful content: application/json: schema: type: object properties: token: type: string accessToken: type: string refreshToken: type: string '401': description: Invalid credentials <%= authPath %>/refresh: post: summary: Refresh access token using a refresh token tags: - Auth requestBody: required: true content: application/json: schema: type: object required: - refreshToken properties: refreshToken: type: string responses: '200': description: Token refreshed successfully content: application/json: schema: type: object properties: accessToken: type: string refreshToken: type: string '401': description: Invalid refresh token <%= authPath %>/logout: post: summary: Logout and revoke refresh token tags: - Auth security: - bearerAuth: [] requestBody: content: application/json: schema: type: object properties: refreshToken: type: string responses: '200': description: Logged out successfully content: application/json: schema: type: object properties: message: type: string <%_ if (socialAuth && socialAuth.filter(a => a !== 'None').length > 0) { -%> <%= authPath %>/social/exchange: post: summary: Exchange social auth code for JWT tokens tags: - Auth requestBody: required: true content: application/json: schema: type: object required: - code - provider properties: code: type: string provider: type: string enum: [Google, GitHub] redirectUri: type: string responses: '200': description: Exchange successful content: application/json: schema: type: object properties: accessToken: type: string refreshToken: type: string '401': description: Invalid social profile or code <%_ if (socialAuth.includes('Google')) { -%> <%= authPath %>/google: get: summary: Redirect to Google OAuth tags: - Auth responses: '302': description: Redirect to Google <%_ } -%> <%_ if (socialAuth.includes('GitHub')) { -%> <%= authPath %>/github: get: summary: Redirect to GitHub OAuth tags: - Auth responses: '302': description: Redirect to GitHub <%_ } -%> <%_ } -%> <%_ } -%> /api/users: get: summary: Returns the list of all the users tags: - Users responses: '200': description: The list of the users content: application/json: schema: type: array items: $ref: '#/components/schemas/User' <%_ if (auth.includes('JWT')) { -%> security: - bearerAuth: [] <%_ } -%> post: summary: Create a new user tags: - Users requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/User' responses: '201': description: The created user. content: application/json: schema: $ref: '#/components/schemas/User' '500': description: Some server error /api/users/{id}: get: summary: Get a user by ID tags: - Users parameters: - in: path name: id schema: type: string required: true description: The user id responses: '200': description: The user details content: application/json: schema: $ref: '#/components/schemas/User' '404': description: User not found '500': description: Some server error <%_ if (auth.includes('JWT')) { -%> security: - bearerAuth: [] <%_ } -%> patch: summary: Update an existing user tags: - Users parameters: - in: path name: id schema: type: string required: true description: The user id requestBody: required: true content: application/json: schema: type: object properties: name: type: string email: type: string responses: '200': description: The updated user content: application/json: schema: $ref: '#/components/schemas/User' '404': description: User not found '500': description: Some server error <%_ if (auth.includes('JWT')) { -%> security: - bearerAuth: [] <%_ } -%> delete: summary: Delete an existing user tags: - Users parameters: - in: path name: id schema: type: string required: true description: The user id responses: '200': description: User deleted successfully '404': description: User not found '500': description: Some server error <%_ if (auth.includes('JWT')) { -%> security: - bearerAuth: [] <%_ } -%>