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

Fix: Support nullable validations #1782

Merged
merged 1 commit into from
Apr 20, 2021
Merged

Fix: Support nullable validations #1782

merged 1 commit into from
Apr 20, 2021

Conversation

chohmann
Copy link
Contributor

I've been receiving validation errors when using nullable: true in my OpenAPI schema.
This extends @nulltoken 's work here #1734 -- with the option described here.

Manually testing this locally appears to work as previously failing validations now pass 🥳 -- This unblocks us from using Prism in our E2E test suite.

@chohmann chohmann requested review from a team and pytlesk4 and removed request for a team April 20, 2021 17:49
@chohmann chohmann mentioned this pull request Apr 20, 2021
@philipbjorge
Copy link

Thanks @chohmann -- Excited to get access to this functionality!

@Amjcraft Amjcraft self-requested a review April 20, 2021 20:06
@@ -7,8 +7,14 @@ import type { ErrorObject } from 'ajv';
import { JSONSchema } from '../../';
import * as AjvOAI from 'ajv-oai';

const ajv = new AjvOAI({ allErrors: true, messages: true, schemaId: 'auto' });
const ajvNoCoerce = new AjvOAI({ allErrors: true, messages: true, schemaId: 'auto', coerceTypes: false });
const ajv = new AjvOAI({ allErrors: true, nullable: true, messages: true, schemaId: 'auto' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chohmann

I still keep receiving notifications — I hope you do not mind me chiming in.

The only reason we are using Ajv OAI is for the formats that it includes, not for the transformation capabilities. All the OpenAPI Specific schemas should be transformed by Http Spec, and that has been correctly (as far as I remember) happening until stoplightio/http-spec#128 landed in.

The idea was not to let OAS-specific data to leak in Prism; Http Spec should be the piece of software handling that part, and that's where the bug should be fixed.

Additionally, I have received an email from NPM with an attempt to republish the fix; not too sure what happened, but the version currently published might not be the one you intended to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@XVincentX your concerns are already being addressed in #1783.

Additionally, I have received an email from NPM with an attempt to republish the fix; not too sure what happened, but the version currently published might not be the one you intended to.

🤔 Hmm that is strange. Well the binaries and source code attached to 4.1.3 tag all look correct, and the 4.1.3 version in NPM wasn't published until we published those, so I'm thinking it's correct.

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.

4 participants