Skip to content
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

Remove useReferences from SchemaOptions #23

Merged
merged 16 commits into from
Dec 18, 2015
Merged

Conversation

fizruk
Copy link
Member

@fizruk fizruk commented Dec 12, 2015

Closes #21.

@fizruk
Copy link
Member Author

fizruk commented Dec 13, 2015

@dmjio can you review this, please?

@fizruk fizruk modified the milestone: v1.0 Dec 14, 2015
@fizruk
Copy link
Member Author

fizruk commented Dec 17, 2015

I will try to outline the changes in this PR, since the code is not very self-explanatory.

The goal of this PR is to

  • remove useReferences option from SchemaOptions and
  • always use references for generic schemas;
  • provide means to inline any schema references as an after effect.

Since schema references appear in different data structures I am using Data.Data.Lens.template to traverse any Data and inline references. This is particularly useful for inlining schemas globally for Swagger spec (e.g. it will inline schemas used in definitions, parameters and responses too).

I have added some documentation here to make it clear what different helpers are for.

In order for generic inlining to work, we need Data instances for all the types contained in Swagger. Although it can be derived for most of the types, some I had to write manually:

  • Host, MimeList, Example — all use types with hidden constructors;
  • SwaggerType, CollectionFormatData can't be derived for GADTs.

@dmjio these Data instances are what I'd like to be reviewed (since it's the first time I deal with Data).

There are also two minor changes in this PR:

  • time schemas don't have minLength property anymore since I think it's actually useless;
  • Travis now builds swagger2 with -O0 for a considerably faster builds; I suspect the slowdown was due to optimizing Generic and Data code (and probably TH code); if you happen to know a better way of doing things, I am open to suggestions!

This is necessary to forbid (at runtime) using file as null:

>>> fromConstr (toConstr (SwaggerFile :: SwaggerType ParamOtherSchema)) :: SwaggerType Schema
SwaggerNull

It also simplifies Data instances a bit.
@fizruk
Copy link
Member Author

fizruk commented Dec 18, 2015

OK, I have played with Data instances, made some improvements and tiny fixes.

I am going to merge this PR now.

fizruk added a commit that referenced this pull request Dec 18, 2015
Remove useReferences from SchemaOptions
@fizruk fizruk merged commit 0eb35c7 into master Dec 18, 2015
@fizruk fizruk deleted the remove-useReferences-#21 branch December 18, 2015 21:18
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.

None yet

1 participant