Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SchemaPreprocessor.handleSerDes: Cannot read property 'type' of undefined #509

Closed
mpuhacz opened this issue Jan 5, 2021 · 4 comments
Closed

Comments

@mpuhacz
Copy link

mpuhacz commented Jan 5, 2021

Describe the bug
After upgrading to the version that includes: e08f45a we've noticed an issue in handleSerDes

(node:346) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'type' of undefined
    at SchemaPreprocessor.handleSerDes (/codebuild/output/src116/src/s3/00/node_modules/express-openapi-validator/dist/middlewares/parsers/schema.preprocessor.js:244:24)

Examples and context

openapi-definition.json
{
    "openapi": "3.0.1",
    "info": {
      "title": "service",
      "version": "v1"
    },
    "security": [
      {
        "Authorizer": []
      }
    ],
    "servers": [
      {
        "url": "https://example.com/v1",
        "description": "NA"
      },
      {
        "url": "https://example.com/v1",
        "description": "NA"
      }
    ],
    "tags": [
      {
        "name": "Users",
        "description": "NA"
      }
    ],
    "paths": {
      "/users/{user_id}": {
        "parameters": [
          {
            "in": "path",
            "name": "user_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "get": {
          "tags": [
            "Users"
          ],
          "description": "NA",
          "summary": "NA",
          "operationId": "get-user",
          "responses": {
            "200": {
              "description": "NA",
              "content": {
                "application/json": {
                  "schema": {
                    "type": "object",
                    "properties": {
                      "user_id": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string",
                        "format": "email"
                      }
                    },
                    "required": [
                      "user_id",
                      "email"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "components": {
      "parameters": {
        "MemberId": {
          "in": "path",
          "name": "member_id",
          "required": true,
          "schema": {
            "$ref": "#/components/schemas/MemberId"
          }
        },
        "PartnerId": {
          "in": "path",
          "name": "partner_id",
          "required": true,
          "schema": {
            "$ref": "#/components/schemas/PartnerId"
          }
        }
      },
      "schemas": {
        "Deleted": {
          "type": "object",
          "properties": {
            "deleted": {
              "type": "boolean",
              "description": "NA",
              "enum": [
                true
              ]
            }
          },
          "required": [
            "deleted"
          ]
        },
        "MemberId": {
          "description": "NA",
          "type": "string",
          "format": "uuid"
        },
        "Role": {
          "type": "string",
          "description": "NA"
        },
        "Roles": {
          "description": "NA",
          "type": "array",
          "items": {
            "$ref": "#/components/schemas/Role"
          }
        },
        "ApiKeyDescription": {
          "description": "NA",
          "type": "string"
        },
        "Member": {
          "allOf": [
            {
              "$ref": "#/components/schemas/Resource"
            },
            {
              "type": "object",
              "properties": {
                "member_id": {
                  "$ref": "#/components/schemas/MemberId"
                },
                "organization_id": {
                  "$ref": "#/components/schemas/OrganizationId"
                },
                "roles": {
                  "$ref": "#/components/schemas/Roles"
                }
              },
              "required": [
                "member_id",
                "organization_id",
                "roles"
              ]
            }
          ]
        },
        "Resource": {
          "type": "object",
          "properties": {
            "created_at": {
              "type": "string",
              "format": "date-time"
            },
            "updated_at": {
              "type": "string",
              "format": "date-time"
            }
          },
          "required": [
            "created_at",
            "updated_at"
          ]
        }
      },
      "securitySchemes": {
        
      },
      "responses": {
        "UnprocessableEntity": {
          "description": "NA",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Error"
              }
            }
          }
        },
        "NotFound": {
          "description": "NA",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Error"
              }
            }
          }
        }
      }
    }
  
@ahoehn
Copy link

ahoehn commented Jan 5, 2021

same for me. I had to rollback to 4.9.5

@cdimascio
Copy link
Owner

cdimascio commented Jan 6, 2021

thanks all. i'll have a look.

@mpuhacz can you provide the rest of your spec.
the snippet you provided is incomplete. i did comment out the pieces that referenced the missing schemas. however, once i did that, the remaining spec successfully ran through the preprocessor.

im hoping with the rest of your spec, i can reproduce this.

@ahoehn, if you are able to provide your spec, or at least a canonical form that shows that error, that will also help me to reproduce it. thanks!

@cdimascio
Copy link
Owner

i created a new test that uses @mpuhacz 's spec. The test is passing. will look at @jrosmithMG 's spec next

@cdimascio
Copy link
Owner

fixed in v4.10.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants