Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

NullReferenceException when generating code for a parameter with no schema

Cerrado
#501 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Ya se ha fusionado un pull request relacionado.

  • #502 de @github-actions — fusionado

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
fsharp
Área
api

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
F#
Estrellas
278
Forks
60
Merge medio
18 h 21 min
PR fusionados (30 d)
10

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de fsprojects/SwaggerProvider

Todos los issues de fsprojects/SwaggerProvider

Issues similares

Más issues de Backend & API Design

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.