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

"loose mode" to avoid erring on invalid type/parameter #33

Open
philsturgeon opened this issue Aug 5, 2019 · 2 comments

Comments

@philsturgeon
Copy link

commented Aug 5, 2019

Can we add an flag to disable throwing on invalid types, or any other cases InvalidInputError? I'm volunteering to do it, just checking its something you'd want. I'm also not sure what to call it. "loose mode", "compat mode", etc.

Background

Throwing on invalid types was introduced in v2.0.0, and it was a great feature to add to help people avoid writing invalid OpenAPI.

Working at Stoplight we deal with all sorts of specs, and sometimes folks have invalid OpenAPI which contains all sorts of JSON Schema-only stuff.

We try to guide people towards creating correct OpenAPI and JSON Schema with tools like Spectral providing general validation and specific guidance (no oneOf in OpenAPI v2, etc.) but having hard and early errors like this make it tough to use the tooling.

We need to convert OpenAPI to JSON Schema in various parts, so having it do the best conversion it can but just keep on trucking if it spots a problem would be really useful for us.

LMK what you think it should be called and I'll get it done. :)

@mikunn

This comment has been minimized.

Copy link
Owner

commented Aug 7, 2019

This sounds like a valid addition.

Can you see a case where someone would want to throw InvalidInputError but not InvalidTypeError or vice versa? I was just thinking if one flag is enough.

Also, there might be a use case for doing something else in case of an error rather than just ignoring it. This would cause a mess if we add just one boolean flag now.

For now, the simplest solution would probably be to add one flag strictMode and setting it to true by default. If there comes a need to do something other than throwing in case of invalid type etc., we could just introduce a breaking change and bump up the version.

What do you think? :)

@philsturgeon

This comment has been minimized.

Copy link
Author

commented Aug 10, 2019

Yeah what you said! Agree that strictMode: true is a good non breaking default and if people wanna get all particular they can suggest more options in the future.

I'm on a 12 hour train so I'll knock it out today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.