Skip to content

Link json_schema extra_state to OpenAPI requestBody and responses#52

Merged
Taure merged 1 commit intonovaframework:masterfrom
Taure:feat/openapi-json-schema-refs
Feb 27, 2026
Merged

Link json_schema extra_state to OpenAPI requestBody and responses#52
Taure merged 1 commit intonovaframework:masterfrom
Taure:feat/openapi-json-schema-refs

Conversation

@Taure
Copy link
Copy Markdown
Contributor

@Taure Taure commented Feb 27, 2026

Summary

  • Routes with extra_state => #{json_schema => "./schemas/post.json"} now generate $ref links in the OpenAPI spec
  • POST/PUT/PATCH methods get a requestBody with application/json content referencing the schema
  • All methods with a schema get response 200 content with the $ref
  • Routes without json_schema in extra_state are unchanged

Example

{"/posts", fun posts_controller:create/1, #{
    methods => [post],
    extra_state => #{json_schema => "./schemas/post.json"}
}}

Produces:

"post": {
  "operationId": "posts_controller.create",
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": { "$ref": "#/components/schemas/post" }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Successful response",
      "content": {
        "application/json": {
          "schema": { "$ref": "#/components/schemas/post" }
        }
      }
    }
  }
}

Test plan

  • Compiled clean with rebar3 compile
  • rebar3 xref passes
  • rebar3 dialyzer — no new warnings (all 9 are pre-existing)
  • Tested with openapi_test project: routes with json_schema get $ref links, routes without are unchanged

🤖 Generated with Claude Code

…sponses

Routes with `extra_state => #{json_schema => "./schemas/post.json"}` now
generate $ref links in the OpenAPI spec — requestBody for POST/PUT/PATCH
and response content schemas for all methods with a schema.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Taure Taure merged commit 333154c into novaframework:master Feb 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant