openapi.yaml.jinjaโข6.69 kB
openapi: 3.0.3
info:
title: {{ idea.title }} API
description: {{ idea.description }}
version: {{ idea.version }}
contact:
name: API Team
email: api@{{ idea.context.project_name.lower().replace(' ', '') }}.com
servers:
- url: https://api.{{ idea.context.project_name.lower().replace(' ', '') }}.com/v1
description: Production server
- url: https://staging-api.{{ idea.context.project_name.lower().replace(' ', '') }}.com/v1
description: Staging server
- url: http://localhost:8000/v1
description: Local development server
paths:
{% for api in idea.apis %}
/{{ api.lower().replace(' ', '-') }}:
get:
summary: Get {{ api }}
description: Retrieve {{ api.lower() }} information
operationId: get{{ api.replace(' ', '') }}
tags:
- {{ api }}
security:
- BearerAuth: []
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/{{ api.replace(' ', '') }}Response'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
post:
summary: Create {{ api }}
description: Create a new {{ api.lower() }}
operationId: create{{ api.replace(' ', '') }}
tags:
- {{ api }}
security:
- BearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/{{ api.replace(' ', '') }}Request'
responses:
'201':
description: {{ api }} created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/{{ api.replace(' ', '') }}Response'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
{% endfor %}
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
description: JWT token for authentication
schemas:
{% for entity in idea.entities %}
{{ entity }}:
type: object
properties:
id:
type: string
format: uuid
description: Unique identifier
created_at:
type: string
format: date-time
description: Creation timestamp
updated_at:
type: string
format: date-time
description: Last update timestamp
{% if entity.lower() in ['user', 'customer', 'account'] %}
email:
type: string
format: email
description: Email address
name:
type: string
description: Full name
status:
type: string
enum: [active, inactive, suspended]
description: Account status
{% elif entity.lower() in ['order', 'transaction', 'payment'] %}
amount:
type: number
format: decimal
description: Transaction amount
currency:
type: string
pattern: '^[A-Z]{3}$'
description: Currency code (ISO 4217)
status:
type: string
enum: [pending, completed, failed, cancelled]
description: Transaction status
{% elif entity.lower() in ['product', 'item', 'service'] %}
name:
type: string
description: Product name
description:
type: string
description: Product description
price:
type: number
format: decimal
description: Product price
{% else %}
name:
type: string
description: Entity name
description:
type: string
description: Entity description
{% endif %}
required:
- id
- created_at
- updated_at
additionalProperties: false
{% endfor %}
{% for api in idea.apis %}
{{ api.replace(' ', '') }}Request:
type: object
properties:
{% if api.lower() in ['user', 'customer', 'account'] %}
email:
type: string
format: email
name:
type: string
{% elif api.lower() in ['order', 'transaction', 'payment'] %}
amount:
type: number
format: decimal
currency:
type: string
pattern: '^[A-Z]{3}$'
{% elif api.lower() in ['product', 'item', 'service'] %}
name:
type: string
description:
type: string
price:
type: number
format: decimal
{% else %}
name:
type: string
description:
type: string
{% endif %}
required:
{% if api.lower() in ['user', 'customer', 'account'] %}
- email
- name
{% elif api.lower() in ['order', 'transaction', 'payment'] %}
- amount
- currency
{% elif api.lower() in ['product', 'item', 'service'] %}
- name
- price
{% else %}
- name
{% endif %}
additionalProperties: false
{{ api.replace(' ', '') }}Response:
type: object
properties:
success:
type: boolean
data:
$ref: '#/components/schemas/{{ api.replace(' ', '') }}'
message:
type: string
required:
- success
- data
{% endfor %}
responses:
BadRequest:
description: Bad request
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
error:
type: string
example: "Validation failed"
Unauthorized:
description: Unauthorized
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
error:
type: string
example: "Authentication required"
NotFound:
description: Not found
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
error:
type: string
example: "Resource not found"
tags:
{% for api in idea.apis %}
- name: {{ api }}
description: {{ api }} management operations
{% endfor %}