Skip to content

NullReferenceException when generating code for a parameter with no schema #501

Description

@Numpsy

Hi,

I tried pointing the provider at an OpenApi schema on a new project at work, and got a NullReferenceException from it, causing the build to fail.

Trying to minimise the issue, it looks like if I have something like

{
  "openapi": "3.1.1",
  "info": {
    "title": "Testing | v1",
    "version": "0.2.0.0"
  },
  "paths": {
    "/api/v1/catalogues/scan": {
      "post": {
        "tags": [
          "Catalogue"
        ],
        "summary": "Testing",
        "description": "Testing",
        "operationId": "Scan",
        "parameters": [
          {
            "name": "properties",
            "in": "header",
            "description": "header description",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "stage-location": {
                      "type": "string",
                      "description": "location"
                    },
                    "file-size": {
                      "minimum": 0,
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                }
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}

The the provider gets to

and then throws because schemaObj is null.

Looking higher up the callstack around

, current.Schema is null, but it does have a 'Content' property, and that does contain a schema.

This is as far as I've got looking at it so far, will have another look next week if no one else of repo assist gets to it first.

Thanks.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions