Skip to content

Common parameters are not handled #241

Description

@mfodor

Official docs:
https://swagger.io/docs/specification/describing-parameters/#common

My valid configuration:

paths:
  /posts/{id}:
    # This is considered as a request method then trows error
    parameters:
      - name: id
        in: path
        description: id
        required: true
        schema:
          type: integer
          format: int32
    get:
      # ...

Error on console:

TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at MethodGenerator.includesSuccessResponse (node_modules/swaxios/dist/generators/MethodGenerator.js:62:54)
    at new MethodGenerator (node_modules/swaxios/dist/generators/MethodGenerator.js:49:18)
    at new ResourceGenerator (node_modules/swaxios/dist/generators/ResourceGenerator.js:40:42)
    at node_modules/swaxios/dist/Swaxios.js:45:34
    at Generator.next (<anonymous>)
    at node_modules/swaxios/dist/Swaxios.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (node_modules/swaxios/dist/Swaxios.js:4:12)
    at exportServices (node_modules/swaxios/dist/Swaxios.js:34:12)
// new MethodGenerator (node_modules/swaxios/dist/generators/MethodGenerator.js:49:18)
const postFix = parameterMatch ? `By${StringUtil.camelCase(parameterMatch.splice(1), true)}` : 'All';
this.parameterMethod = this.operation.operationId || `${this.method}${postFix}`;
if (this.includesSuccessResponse(this.responses)) {
// where
//  - postFix: ById
//  - parameterMethod: propertiesById
//  - this.responses: undefined

// MethodGenerator.includesSuccessResponse (node_modules/swaxios/dist/generators/MethodGenerator.js:62:54
includesSuccessResponse(responses) {
    for (const [successCode, response] of Object.entries(responses)) { // <- response is undefined here

So, common parameters should be added to parameters as well, and if common parameters are defined it should be skipped when trying to process methods (operations).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions