# PhoenixSpec

Generates an OpenAPI 3.1 specification for a Phoenix application automatically, by reading its Ecto schemas, JSON views and router instead of a separate spec file.

PhoenixSpec produces an OpenAPI 3.1 specification from parts of a Phoenix API that already exist: it reads field types from Ecto schemas, the fields a JSON view module exposes and how they nest, and the routes, HTTP verbs and path parameters from the router.

Running its Mix task introspects the router, finds the associated JSON views, reads the Ecto schemas they reference, and writes an openapi.json or openapi.yaml file, plus an optional api.d.ts. It infers types such as strings, integers, datetimes and enums, resolves associations such as belongs_to, follows the standard phx.gen.json controller and context-module patterns to build request bodies, and generates a oneOf schema when a JSON view has multiple clauses for different structs.

It is an Elixir library added as a development-only Mix dependency.

Website: https://github.com/dannote/phoenix_spec
