kogosoftwarellc / open-api

A Monorepo of various packages to power OpenAPI in node
MIT License
895 stars 237 forks source link

Incorrect type for componentSchemas in OpenAPIRequestValidator #820

Open aldex32 opened 2 years ago

aldex32 commented 2 years ago

Hello,

the componentSchemas field in OpenAPIRequestValidator is declared as:

componentSchemas?: IJsonSchema[];

But looking to the tests, you are always passing an object instead of an array. When I pass an object it works fine, but if I pass the schemas as array it fails to resolve references, with an error like:

Error: can't resolve reference #/components/schemas/TestItem from id #

Is it an idea to change the type to something like:

componentSchemas?: {[key: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject;}
aldex32 commented 2 years ago

Hi @jsdevel , perhaps you have an opinion?

jsdevel commented 2 years ago

not really sure. if you feel the current types are out of sync with the OAI spec, please open a PR.

aldex32 commented 2 years ago

Maybe also @mbsimonovic , I see you have contributed in adding componentSchemas for OAS v3, could you perhaps have a look to this issue and the PR I created?

mbsimonovic commented 2 years ago

ah this was years ago, i havent used kogos since