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

fix: request schema preprocessor and multipart middleware custom formats #452

Merged
merged 3 commits into from Nov 9, 2020

Conversation

LEI
Copy link
Contributor

@LEI LEI commented Nov 8, 2020

Not sure about this, but the formats seems required for the request schema preprocessor and the multipart middleware ajv instances.

Moreover, I could not catch the RequestSchemaPreprocessor error (unhandled rejection):

Error: unknown format "bigint" is used in schema at path "#/properties/id"
    at Object.generate_format [as code] (./node_modules/ajv/lib/dotjs/format.js:69:15)
    at Object.generate_validate [as validate] (./node_modules/ajv/lib/dotjs/validate.js:374:35)
    at Object.generate_properties [as code] (./node_modules/ajv/lib/dotjs/properties.js:201:26)
    at generate_validate (./node_modules/ajv/lib/dotjs/validate.js:374:35)
    at localCompile (./node_modules/ajv/lib/compile/index.js:88:22)
    at Ajv.compile (./node_modules/ajv/lib/compile/index.js:55:13)
    at Ajv._compile (./node_modules/ajv/lib/ajv.js:348:27)
    at Ajv.getSchema (./node_modules/ajv/lib/ajv.js:204:54)
    at RequestSchemaPreprocessor.traverse (./node_modules/express-openapi-validator/dist/middlewares/parsers/request.schema.preprocessor.js:88:30)
    at RequestSchemaPreprocessor.cleanseContentSchema (./node_modules/express-openapi-validator/dist/middlewares/parsers/request.schema.preprocessor.js:82:14)

Finally, I updated the MultipartOpts type in the second commit to accept the ajv options as a property (ajvOpts).

@LEI LEI changed the title fix: request schema preprocessor custom formats fix: request schema preprocessor and multipart middleware custom formats Nov 8, 2020
@cdimascio
Copy link
Owner

@LEI thanks. this is definitely the right idea. i ended building upon you change to extract the ajv options into common handler class, so that future modifications can be made more easily across the various internal middlewares.

@cdimascio cdimascio merged commit cf37281 into cdimascio:master Nov 9, 2020
@cdimascio
Copy link
Owner

@all-contributors add @LEI for code

@allcontributors
Copy link
Contributor

@cdimascio

I've put up a pull request to add @LEI! 🎉

@LEI LEI deleted the fix-preprocessor-formats branch November 9, 2020 09:49
ex1st pushed a commit to ex1st/express-openapi-validator that referenced this pull request Dec 9, 2020
…ats (cdimascio#452)

* fix: request schema preprocessor unknown format error

* fix: multipart middleware ajv options formats and types

* common ajv options handler

Co-authored-by: Carmine DiMascio <cdimascio@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants