Skip to content

Make schema dispatch and maybe_codec_schema format-agnostic #124

Description

@andreashasse

Context

spectra:schema/4 pattern-matches on json_schema as a literal format atom (lines ~421-424), and maybe_codec_schema/2 hardcodes json_schema when calling M:schema/3.

This means adding a second schema format (e.g. OpenAPI 3.1 as a distinct format atom) requires duplicating those clauses.

Proposed change

  • Replace hardcoded json_schema atoms with a dynamic format parameter threaded through schema/4 and maybe_codec_schema.
  • Each format module registers or is dispatched to based on the format atom, rather than being baked into spectra.erl clauses.

Benefit

New schema formats can be added without modifying spectra.erl.

Raised from PR #122 review (comments on lines 423 and 451).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions