toomuchdesign/openapi-ts-json-schema

Security schema fails on `type: http`

Closed this issue ยท 1 comments

๐Ÿ› Bug Report

Generator validates incorrectly security schemas with type: http and scheme: bearer and rejects it.

To reproduce, I've created a test repository and a test workflow. The issue happens both on windows and linux.

Reproduction

Expected behavior

Specification should be considered valid and schemas should be generated normally.

Actual behavior

InvalidTypeError: Type "http" is not a valid type
      at validateType (C:\Users\marek\GitHub\openapi-ts-json-schema-poc\node_modules\@openapi-contrib\openapi-schema-to-json-schema\dist\lib\converters\schema.js:93:15)
      at convertSchema (C:\Users\marek\GitHub\openapi-ts-json-schema-poc\node_modules\@openapi-contrib\openapi-schema-to-json-schema\dist\lib\converters\schema.js:75:9)
      at convertProperties (C:\Users\marek\GitHub\openapi-ts-json-schema-poc\node_modules\@openapi-contrib\openapi-schema-to-json-schema\dist\lib\converters\schema.js:112:22)
      at convertSchema (C:\Users\marek\GitHub\openapi-ts-json-schema-poc\node_modules\@openapi-contrib\openapi-schema-to-json-schema\dist\lib\converters\schema.js:58:39)
      at convertFromSchema (C:\Users\marek\GitHub\openapi-ts-json-schema-poc\node_modules\@openapi-contrib\openapi-schema-to-json-schema\dist\lib\converters\schema.js:14:23)
      at openapiSchemaToJsonSchema (C:\Users\marek\GitHub\openapi-ts-json-schema-poc\node_modules\@openapi-contrib\openapi-schema-to-json-schema\dist\index.js:52:37)
      at convertOpenApiToJsonSchema (C:\Users\marek\GitHub\openapi-ts-json-schema-poc\node_modules\openapi-ts-json-schema\dist\utils\convertOpenApiToJsonSchema.js:16:71)
      at openapiToTsJsonSchema (C:\Users\marek\GitHub\openapi-ts-json-schema-poc\node_modules\openapi-ts-json-schema\dist\openapiToTsJsonSchema.js:30:70)
      at async waitForActual (node:assert:800:5)
      at async Function.doesNotReject (node:assert:941:33)

Run npx envinfo --preset jest

Paste the results here:

System:
    OS: Windows 11 10.0.22631
    CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700K
  Binaries:
    Node: 21.6.2 - ~\scoop\apps\nodejs\current\node.EXE
    Yarn: 1.22.19 - ~\scoop\apps\nodejs\current\yarn.CMD
    npm: 10.2.4 - ~\scoop\apps\nodejs\current\npm.CMD
    pnpm: 8.15.3 - ~\scoop\apps\nodejs\current\pnpm.CMD

This specific issue and possibly a few more should have been "fixed" with #197.

The JSON schema conversion presents a few challenges which I documented here, for which I haven't found a properly satisfying solution, yet.