openapi-snippet
openapi-snippet copied to clipboard
There are some issues that can crop up related to missing or "any type" parameter schemas
I'm working on fixes for the following:
-
If a parameter is missing a
typeand also missingschemathen a TypeError is thrown:/openapi-snippet/openapi-to-har.js:441 'SOME_' + (param.type || param.schema.type).toUpperCase() + '_VALUE'; ^ TypeError: Cannot read properties of undefined (reading 'type') at getParameterValues (/Users/cwelchmi/emu/metasys-rest-api/node_modules/openapi-snippet/openapi-to-har.js:441:43) -
the method parseParametersToQuery checks the schema type and if it is undefined then the type is defaulted to
objectbut it should just leave it undefined.A schema without a type matches any data type – numbers, strings, objects, and so on. {} is shorthand syntax for an arbitrary-type schema
Quoted from any type
I'm not even sure why the code checks for param.type. The spec does not call out a type field on the Parameter Object. I see that some of the tests cases like (Instagram) use a type field on parameter. But I'm not convinced that's not an error. I'm going to test with Swagger API. Maybe it used to allow it in older version of the spec. Yep that's the case: OpenAPI 2.0 allowed that: https://swagger.io/docs/specification/2-0/describing-parameters/