Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

NullReferenceException when generating code for a parameter with no schema

Closed
#501 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

A pull request for this has already been merged.

  • #502 by @github-actions — merged

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
fsharp
Domain
api

Research direction

Start with OperationCompiler.fs around line 206 to trace how a parameter with Content is represented, then follow the call into DefinitionCompiler.fs around line 440 where schemaObj is null. Run the provider against the OpenAPI document in the issue and verify code generation completes for the parameter whose schema is nested under Content.

Written by the indexing model from the issue text.

Description

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 https://github.com/fsprojects/SwaggerProvider/blob/4e299fd52e64fc2354a99e2acec3420078c4f7f0/src/SwaggerProvider.DesignTime/DefinitionCompiler.fs#L440 and then throws because schemaObj is null.

Looking higher up the callstack around https://github.com/fsprojects/SwaggerProvider/blob/4e299fd52e64fc2354a99e2acec3420078c4f7f0/src/SwaggerProvider.DesignTime/OperationCompiler.fs#L206, 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.

Dominant language
F#
Stars
278
Forks
60
Avg merge
18h 21m
Merged PRs (30d)
10

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fsprojects/SwaggerProvider

All issues in fsprojects/SwaggerProvider

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.