openapi-snippet icon indicating copy to clipboard operation
openapi-snippet copied to clipboard

There are some issues that can crop up related to missing or "any type" parameter schemas

Open michaelgwelch opened this issue 3 years ago • 1 comments

I'm working on fixes for the following:

  • If a parameter is missing a type and also missing schema then 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 object but 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

michaelgwelch avatar Jul 25 '22 21:07 michaelgwelch

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/

michaelgwelch avatar Jul 25 '22 21:07 michaelgwelch