validation error even if format declared in unknownFormats
See original GitHub issueDescribe the bug Title says it. Trying to verify schema with custom format. Error is thrown even if the format name is included in unknownFormats array.
To Reproduce run with supplied .yaml
Actual behavior See error output
Expected behavior No errors, rest of schema is valid
Examples and context
YAML:
servers:
- url: http://localhost:3010/api
description: Sandbox
openapi: "3.0.0"
info:
title: Example API
description: example
version: v1
contact:
email: examle@example.com
tags:
- name: Account Service
paths:
/get-should-have-no-body:
uuid: accounts
get:
tags:
- Account Service
summary: get without a schema
responses:
"200":
description: OK
ERROR:
error: openapi.validator: Validating schema
error: openapi.validator: validation errors [
{
"keyword": "additionalProperties",
"dataPath": ".paths['/get-should-have-no-body']",
"schemaPath": "#/additionalProperties",
"params": {
"additionalProperty": "uuid"
},
"message": "should NOT have additional properties"
}
]
error: openapi.validator: Validating schema
error: openapi.validator: validation errors [
{
"keyword": "additionalProperties",
"dataPath": ".paths['/get-should-have-no-body']",
"schemaPath": "#/additionalProperties",
"params": {
"additionalProperty": "uuid"
},
"message": "should NOT have additional properties"
}
]
error: (node:11795) UnhandledPromiseRejectionWarning: Error: openapi.validator: args.apiDoc was invalid. See the output.
at OpenAPIFramework.initialize (removedPath/node_modules/express-openapi-validator/dist/framework/index.js:31:23)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async OpenApiSpecLoader.discoverRoutes (removedPath/node_modules/express-openapi-validator/dist/framework/openapi.spec.loader.js:46:39)
error: (node:11795) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
error: (node:11795) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
JS
new OpenApiValidator({
apiSpec: apiGatewayConfigurator._configPath,
validateResponses: false, // <-- to validate responses
unknownFormats: ["uuid"], // <-- to provide custom formats
}).install(app);
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
ajv-cli can't see regex format in ajv-formats · Issue #188 - GitHub
I get lots of unknown formats, as expected (I guess). ... process.exit(0); } else { console.log(validator.errors); process.exit(1); } ...
Read more >Strict mode - Ajv JSON schema validator
Unknown formats. By default unknown formats throw exception during schema compilation (and fail validation in case format keyword value is $data reference). It ......
Read more >ValidationError when submitting a form with custom date format
You need to set formats on DateInput widget when you declare your variable on the form, plus input_formats, like: data_quota = forms.
Read more >Ajv: Another JSON Schema Validator - npm
Validates schema. This method should be used to validate schemas rather than validate due to the inconsistency of uri format in JSON-Schema ...
Read more >Resolve template validation or template format errors in ... - AWS
I receive an error message when I try to create my AWS ... Confirm that resource logical IDs and parameters are defined in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Great! 🥇 👏
Appreciate the swift support!
fixed the issue with vendor extension declared in path. see
v3.12.9