Skip to content

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

Merged
cdimascio merged 3 commits intocdimascio:masterfrom
LEI:fix-preprocessor-formats
Nov 9, 2020
Merged

fix: request schema preprocessor and multipart middleware custom formats#452
cdimascio merged 3 commits intocdimascio:masterfrom
LEI:fix-preprocessor-formats

Conversation

@LEI
Copy link
Copy Markdown
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 force-pushed the fix-preprocessor-formats branch from 72253ce to e60315e Compare November 8, 2020 23:14
@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
Copy Markdown
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
Copy Markdown
Owner

@all-contributors add @LEI for code

@allcontributors
Copy link
Copy Markdown
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>
cdimascio added a commit that referenced this pull request Mar 2, 2025
…ats (#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.

2 participants