-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Incorrect formatters being used for Ajv in Validation #280
Comments
If you just want to add date-time support you can use: const api = new OpenAPIBackend({
definition: '...........',
customizeAjv: (ajv, ajvOpts, validationContext) => {
let dtFormat = {
type: 'string',
validate: /^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,
};
ajv.addFormat("date-time", dtFormat);
return ajv;
}
}); The regex above was copied from the "ajv-formats" module, here: |
Hi @ak683517, That snippet returned an error with
|
I'd cast it as ajv.addFormat("date-time", dtFormat as any); |
Any updates when this is going to be fixed? |
Would also like to get an update -> so we should add the formatter ourselves if needed? |
The following worked for me: import { fullFormats } from 'ajv-formats/dist/formats'
const api = new OpenAPIBackend({
definition: '...........',
ajvOpts: {
formats: fullFormats,
},
}) |
@anttiviljami |
#1270) Fix warn "unknown format X ignored in schema at path Y" During backstage startup there are warnings like `unknown format "date-time" ignored in schema at path "#/oneOf/0/properties/ended"` due to a bug in OpenAPIBackend[1]. Resolve https://issues.redhat.com/browse/FLPATH-1045 Based on Yaron Dayagi <[email protected]> work in notification plugin[2] [1] openapistack/openapi-backend#280 [2] https://github.com/janus-idp/backstage-plugins/blob/903c7f37a1cf138ac96ef3f631f951866c2014fa/plugins/notifications-backend/src/service/router.ts#L45-L52 Signed-off-by: Gloria Ciavarrini <[email protected]>
I am getting errors on run from ajv that is being loaded in
openapi-backend
.The fix is this snippet that should go into the validation file.
The text was updated successfully, but these errors were encountered: