feat: add OpenAPI mapping validation and schema support#2
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces schema-based validation for the OpenAPI mapping file, ensuring that mapping documents conform to a defined structure before processing. It also updates documentation and tests to reflect and support this new validation step, and adds a JSON schema file for the mapping format. The main changes are grouped below:
Schema validation and enforcement:
src/openapi-mapping.schema.jsondefining the allowed structure for OpenAPI mapping files, including properties likeserver_url,default_tags,include,exclude,defaults,operations, andworkflow.src/index.jsusingajvand the new schema, with fast failure and detailed error reporting. The mapping file is now always validated before transformation. [1] [2]buildProjectFromOpenApi(src/openapi.js) for key mapping properties (include,exclude,operations,defaults) to ensure correct types are provided.Documentation updates:
README.mdto document schema validation, including schema references, YAML language server integration, and a new section describing validation behavior and error output. [1] [2] [3]Test coverage:
test/openapi.test.jsto verify that improper types forinclude,operations, anddefaultsin the mapping file result in appropriate errors.Example and schema usage:
api/apim-mapping.yaml) and documentation examples to reference the schema for editor integration and validation. [1] [2]These changes collectively ensure that mapping files are validated early, errors are clear, and documentation and examples are up-to-date with the new validation process.