openapi: 3.0.3
servers:
  - url: http://localhost:5000/
    description: Local development
info:
  title: {{application.raw_name}}
  version: 3.0.3
paths:
  /healthcheck:
    get:
      description: "Check whether the application is running."
      operationId: "{{application.module_name}}.endpoints.application.healthcheck"
      parameters: []
      responses:
        "200":
          content:
            application/json:
              schema:
                type: string
          description: "Application is running correctly."
      summary: "A simple method that returns 200 as long as the application is running."
  {% for operation in endpoints|map(attribute="operation") %}
  /{{operation.url_path_name}}:
    get:
      {% if module.database %}
      description: "Get all entries in the {{operation.module_name}} table."
      {% else %}
      description: "Hello, {{operation.url_path_name}}!"
      {% endif %}
      operationId: "{{application.module_name}}.endpoints.{{operation.module_name}}.get_{{operation.module_name}}"
      responses:
        "200":
          content:
            application/json:
              schema:
                type: string
          description: "Endpoint is working correctly."
      summary: "A simple method that returns 200 as long as the endpoint is working correctly."
    {% if module.database %}
    post:
      description: Add a new {{operation.module_name.capitalize()}} to the {{operation.module_name}} table.
      operationId: "{{application.module_name}}.endpoints.{{operation.module_name}}.add_{{operation.module_name}}"
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
      responses:
        201:
          description: "The new {{operation.module_name.capitalize()}} was successfully added to the {{operation.module_name}} table."
          content:
            application/json:
              schema:
                type: string
    {% endif %}
  {% endfor %}
