Skip to content

WIP json:api helpers #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed

Conversation

moxley
Copy link
Contributor

@moxley moxley commented Jun 16, 2020

In response to #12

This is a feasibility study into supporting json:api helpers. It is only a partial solution.

Description

This solution provides a function that returns a %Schema{} struct, which can then be passed to the Operation spec. The struct defines a json:api "document", which is the object representing a json:api request or response body.

The ability to pass a %Schema{} to the Operation spec is also new in this PR. Often, it was necessary to create a schema module that did very little except wrap around another schema that was of interest. The key to making this work is to leverage the "x-struct" attribute in %Schema{}. If this attribute has a value, that tells SchemaResolver to add it to the /components/schemas/* in the Open API document. Using "x-struct" feels like a hack, so I'm eager to hear opinions on a better approach.

Check out OpenApiSpexTest.JsonApiController in this PR for top-level usage.

@mbuhot
Copy link
Collaborator

mbuhot commented Jun 16, 2020

I like the general approach of generating OpenApi schemas by transforming a more natural description of the JSON:API resource.

Also the ability to have inline schemas with titles without needing to define a module looks useful 👍

@moxley
Copy link
Contributor Author

moxley commented Sep 15, 2020

Replaced with #289

@moxley moxley closed this Sep 15, 2020
@moxley moxley deleted the json-api-helpers branch September 15, 2020 14:19
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.

2 participants