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

JSON validation based on Swagger Schema #18

Merged
merged 20 commits into from
Feb 1, 2016
Merged

JSON validation based on Swagger Schema #18

merged 20 commits into from
Feb 1, 2016

Conversation

fizruk
Copy link
Member

@fizruk fizruk commented Dec 10, 2015

Closes #12.

This PR is incomplete, TODOs:

  • validate object schemas;
  • validate string regex patterns;
  • add tests ensuring that ToSchema matches ToJSON;
  • display better error messages;
  • add documentation.

TODOs after #17 is merged:

  • validate ParamSchema separately;
  • add tests ensuring that ToParamSchema matches ToHttpApiData.

@fizruk
Copy link
Member Author

fizruk commented Dec 10, 2015

So validation tests reveal two problems:

  • schema for () is incomplete (it lacks necessary items schema, but it's unclear what it should be);
  • validation of Maybe a schema is wrong, we should accept null there; but then how do we know which schemas allow nulls and which don't?

@dmjio any thoughts?

@fizruk
Copy link
Member Author

fizruk commented Dec 12, 2015

This PR raises too many design questions so far:

  • which validation library to use (validation, these or home-grown)?
  • should we maybe reuse validation from hjsonschema (probably not since Swagger Schema is a bit different)?
  • what should we do about ToSchema ()? some swagger spec validation tools accept our schema without items, so should we go against what's written in the spec and allow it?
  • what should we do about Maybe a? should we always allow null (maybe with a warning)?

Since it is not critical to servant-swagger, I postpone this PR until after v1.0.

@fizruk
Copy link
Member Author

fizruk commented Jan 20, 2016

Of the above the ToSchema () instance has been fixed recently with items: [] (in 4139a57).
This only works for Schema, not ParamSchema though.

@fizruk
Copy link
Member Author

fizruk commented Jan 22, 2016

Going with home-grown validation. Not using hjsonschema.

The only problem so far is schema for Maybe a. However it is only a problem when it is not a property of an Swagger object (e.g. Haskell record fields are okay being Maybe).

I am going to finish this to include in 2.0 release.

@fizruk fizruk force-pushed the validate-#12 branch 2 times, most recently from 7201bca to 0385d5e Compare January 28, 2016 16:12
fizruk added a commit that referenced this pull request Feb 1, 2016
JSON validation based on Swagger Schema
@fizruk fizruk merged commit 87906b0 into master Feb 1, 2016
@fizruk fizruk deleted the validate-#12 branch February 1, 2016 14:56
maksbotan added a commit to biocad/swagger2 that referenced this pull request Dec 12, 2021
…opTV#18)

* Try actions & GHC-9.0.1

* Fix doctests to allow newer hashable

* Allow fail for 9.0.1
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