Skip to content

OpenAPI

Snaapi automatically generates OpenAPI 3.1.0 specifications for every enabled resource. These specs describe all available endpoints, request and response schemas, query parameters, and authentication requirements — making it easy to explore your API with standard tooling.

Auto-Generated Specs

Each resource gets its own OpenAPI specification generated from the resource definition. The spec includes:

  • All CRUD endpoints (GET, POST, PUT, PATCH, DELETE)
  • Server-Sent Events streaming endpoint
  • Request body schemas derived from field definitions
  • Response schemas with data and meta wrappers
  • Query parameter definitions with defaults (e.g., _limit: 50, _offset: 0)
  • Filter operator documentation per field
  • Bearer token (JWT) security scheme

Specs are regenerated whenever a resource definition changes, so they always reflect the current state of your API.

Accessing Specs

Every resource exposes its OpenAPI spec at two endpoints:

Format Endpoint Content-Type
JSON /v1/:resourceName/openapi.json application/json
YAML /v1/:resourceName/openapi.yaml text/yaml

Example:

GET /v1/posts/openapi.json
GET /v1/posts/openapi.yaml

No authentication is required to access the OpenAPI spec endpoints.

Using with Swagger UI

You can point Swagger UI (or any OpenAPI-compatible tool) at the spec endpoint to get an interactive API explorer.

Hosted Swagger UI

Use the public Swagger UI by passing your spec URL as a query parameter:

https://petstore.swagger.io/?url=https://your-domain.com/v1/posts/openapi.json

Self-Hosted Swagger UI

If you prefer to host Swagger UI locally, use the Docker image:

docker run -p 8080:8080 \
  -e SWAGGER_JSON_URL=https://your-domain.com/v1/posts/openapi.json \
  swaggerapi/swagger-ui

Then open http://localhost:8080 in your browser.

Other Compatible Tools

The generated specs work with any tool that supports OpenAPI 3.1.0, including:

  • Redoc — Clean, responsive API documentation
  • Insomnia — Import the spec to generate request templates
  • Postman — Import as an OpenAPI collection
  • openapi-generator — Generate client SDKs in multiple languages