Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.
This repository was archived by the owner on Jun 6, 2024. It is now read-only.

Support schema introspection #12

@jmcarp

Description

@jmcarp

The envelope used to serialize responses is implemented in a set of helper methods (format_items, wrap_response, etc.) that could be challenging to introspect (e.g. for building swagger docs). Implementing the envelope using fields and nested schemas would be more amenable to introspection--it should Just Work with apispec.

One option would be adding some magic to Schema--for example, overriding get_declared_fields to replace the original fields with attributes, a Nested that wraps the original fields. This might be too opaque, so we could also define primary schemas separately and explicitly wrap them in JsonSchema classes.

Or maybe this complicates the implementation too much, and it's best to sacrifice purity and just introspect schemas manually--it shouldn't be too hard to write an apispec hook that generates the appropriate markup. The only other caveat there would be that introspection would be brittle, and likely stop working if users subclass Schema and change the envelopes.

Help @sloria!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions