openapi: 3.0.3
info:
  title: Shoehorn Manifests API
  description: |
    Create, validate, analyze, and convert catalog manifests
    (`.shoehorn/manifest.yml`).
  version: 1.0.0

servers:
  - url: https://shoehorn.example.com/api/v1
    description: Production

paths:
  /manifests:
    get:
      summary: List manifests
      tags: [Manifests]
      responses:
        '200':
          description: All manifests

    post:
      summary: Create manifest
      tags: [Manifests]
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/ManifestInput' }
      responses:
        '201':
          description: Manifest created

  /manifests/{id}:
    get:
      summary: Get manifest
      tags: [Manifests]
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: string }
      responses:
        '200':
          description: Manifest details

    put:
      summary: Update manifest
      tags: [Manifests]
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: string }
      responses:
        '200':
          description: Manifest updated

    delete:
      summary: Delete manifest
      tags: [Manifests]
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: string }
      responses:
        '204':
          description: Manifest deleted

  /manifests/validate:
    post:
      summary: Validate manifest
      description: Validates a manifest YAML against the schema without creating it.
      tags: [Manifests]
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/ManifestInput' }
      responses:
        '200':
          description: Validation results
          content:
            application/json:
              schema:
                type: object
                properties:
                  valid: { type: boolean }
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        field: { type: string }
                        message: { type: string }

  /manifests/analyze:
    post:
      summary: Analyze manifest quality
      description: Returns quality score and improvement suggestions.
      tags: [Manifests]
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/ManifestInput' }
      responses:
        '200':
          description: Quality analysis

  /manifests/convert:
    post:
      summary: Convert Backstage catalog-info.yaml
      description: Converts a Backstage catalog-info.yaml to Shoehorn manifest format.
      tags: [Manifests]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                content: { type: string, description: Raw YAML content }
      responses:
        '200':
          description: Converted manifest

components:
  schemas:
    ManifestInput:
      type: object
      required: [content]
      properties:
        content: { type: string, description: YAML manifest content }
        format: { type: string, enum: [shoehorn, backstage], default: shoehorn }
