swagger-codegen-ts icon indicating copy to clipboard operation
swagger-codegen-ts copied to clipboard

feat!: oneOf now has more strict validation, it actually checks that exactly one schema matches

Open kokovtsev opened this issue 1 year ago • 1 comments

fixes #179

kokovtsev avatar Jan 10 '24 10:01 kokovtsev

AI-Generated Summary: This pull request introduces a more rigorous validation for the oneOf schema; it now verifies that exactly one schema matches when processing the inputs. The current state of the oneOf schema behaves more like an anyOf schema where it checks if the input matches any of the schemas, rather the being strictly 'one' schema as the name implies.

This patch implements this change by introducing a new AnyOfSchemaObjectCodec and its associated types and modifications in the related files. It also updates various test files, and introduces new utility functions related to handling Union Types, and a bundle for handling validations based on various schemas in utils.bundle.ts.

Two new tests have been added to the utils.bundle.spec.ts file for comprehensive testing of the modified behavior. Similarly, code in schema-object.spec.ts has been updated to reflect these changes in how the oneOf schemas are handled.

In summary, the changes made improve the overall accuracy of the schema validation, ensuring that it meets the expectations reflected in its naming (i.e., oneOf should only match exactly one schema).

reviewpad[bot] avatar Jan 10 '24 10:01 reviewpad[bot]