Openapi development

From VilnaCRM-Org/user-service · View interactive version

Openapi development is an AI agent skill from the GitHub repository VilnaCRM-Org/user-service. Guide for contributing to the OpenAPI layer at src/Shared/Application/OpenApi/. Use when adding endpoint factories, processors, updating OpenAPI generation logic, or fixing OpenAPI validation errors (Spectral, OpenAPI diff, Schemathesis).

How to use this skill

Skill file

OpenAPI Development Skill

Context (Input)

Task (Function)

Develop and maintain OpenAPI specification generation in a way that:

Success Criteria:


Architecture Overview

This service uses a layered OpenAPI customization approach:

src/Shared/Application/OpenApi/
├── Builder/               # Build common OpenAPI pieces
├── Extractor/             # Extract example values / payload fragments
├── Factory/               # Endpoint/Request/Response/Schema/UriParameter factories
├── Transformer/           # Transform/modify OpenAPI operations, parameters, responses
├── ValueObject/ + Enum/   # Strongly typed OpenAPI-related value objects
└── Factory/OpenApiFactory.php  # Main coordinator (decorator)

config/services.yaml decorates API Platform’s OpenAPI factory with:


Key Principles (Keep Complexity Low)

  1. Single Responsibility: one class = one transformation.
  2. Immutability: prefer with*() methods; avoid mutating nested arrays unless API Platform forces it.
  3. OPERATIONS constant: avoid chaining withGet/withPost/... repeatedly.
  4. Readable guard clauses: prefer early returns over deep nesting.
  5. Functional style: array_map, array_filter, array_keys over procedural mutation.

See: reference/processor-patterns.md


How to Add New Components

Adding a New Transformer

Adding a New Endpoint Factory


Testing / Validation

Run locally (preferred order):

make generate-openapi-spec
make validate-openapi-spec
make openapi-diff
make schemathesis-validate

Notes:


Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.