cdwv / oas3-api-snippet-enricher

Enrich your OpenAPI 3.0 JSON with code samples
MIT License
90 stars 13 forks source link

Error when secDefinition does not exists #8

Closed RolphH closed 4 years ago

RolphH commented 4 years ago

When you parse OAS3 files without secDefintion.scheme, the script will fail. Opeapi-to-har expects a scheme.

 authScheme = secDefinition.scheme.toLowerCase();
                                          ^
TypeError: Cannot read property 'toLowerCase' of undefined
at getHeadersArray (/node_modules/openapi-snippet/openapi-to-har.js:287:43)
    at Object.createHar [as getEndpoint] (//node_modules/openapi-snippet/openapi-to-har.js:44:14)
    at Object.getEndpointSnippets (/node_modules/openapi-snippet/index.js:31:28)
    at enrichSchema (/node_modules/snippet-enricher-cli/index.js:18:39)
    at fs.readFile (node_modules/snippet-enricher-cli/index.js:52:12)
    at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
andrzejwp commented 4 years ago

True, although I'm not sure if this is something that we should be fixing inside this repo, as it's only a thin wrapper for ErikWittern/openapi-snippet.

We've hit a similar issue for API key schemes when integrating this into Flotiq's user API docs and filed a PR against ErikWittern/openapi-snippet. I believe you already traced that yours is a similar case and that there already is a PR for that in the respective repository.

RolphH commented 4 years ago

True found that issue. Will close it.