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

Strict mode for library #298

Open
batyshkaLenin opened this issue Nov 8, 2023 · 1 comment
Open

Strict mode for library #298

batyshkaLenin opened this issue Nov 8, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@batyshkaLenin
Copy link

Are you using OpenAPI 2, 3.0.X, or 3.1.0?
Version 3.0.0, but it doesn't matter, such functionality will be useful for all versions.

Would this solve a problem or make something easier?
Not only will I be able to enforce existing contracts using tests and Swagger, but I will also be able to "force" a developer to describe Swagger if they add a new field.

What would you like to happen?
Strict mode will allow you to check not only the fields that will return an endpoint when tested, but also those that are not described in the schema. That is, if I get extra fields that are not described in the schema, I want to get an error, and not get an error only if the fields described in Swagger have not changed.

Describe alternatives you've considered
Honestly, I don't see any alternatives

Additional context or screenshots
To enable this mode, for example, you could do the following

jestOpenAPI(path.resolve(__dirname, '../../src/openapi.yaml'), { mode: 'strict' });

Are you going to resolve the issue?
I'm not sure if I'm gonna make it

@batyshkaLenin batyshkaLenin added the enhancement New feature or request label Nov 8, 2023
@DetachHead
Copy link
Contributor

do you have "additionalProperties": false in your schema? when i do, it correctly fails to validate when an additional field is present.

https://json-schema.org/understanding-json-schema/reference/object#additional-properties

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants