ErikWittern / openapi-snippet

Generates code snippets for given Swagger / Open API documents
MIT License
115 stars 66 forks source link

The method getHeadersArray doesn't seem to check the path.parameters object it just skips to path path[method].parameters #85

Closed michaelgwelch closed 2 years ago

michaelgwelch commented 2 years ago

This can be seen here:

https://github.com/ErikWittern/openapi-snippet/blob/2e6c2c91859c56442f134ced22ef609e7b4b36cd/openapi-to-har.js#L369-L386

Another issue is that the getFullPath method assumes that only one or the other will have entries.

https://github.com/ErikWittern/openapi-snippet/blob/2e6c2c91859c56442f134ced22ef609e7b4b36cd/openapi-to-har.js#L335-L338

Finally getQueryStrings appears to do it correctly and checks both:

https://github.com/ErikWittern/openapi-snippet/blob/2e6c2c91859c56442f134ced22ef609e7b4b36cd/openapi-to-har.js#L302-L316

I don't think I'll fix this in #82 as that's too large already. This is just a defect I found while testing #82.

michaelgwelch commented 2 years ago

There's some duplication between getFullPath, getQueryStrings and getHeadersArray this can probably be solved by extracting all of the common logic into one method (Probably getQueryStrings) and then have getFullPath and getHeadersArray delegate to getQueryStrings and customize as needed. For example getFullPath needs to replace a parameter place holder with an actual value.

michaelgwelch commented 2 years ago

Resolved in #86