Skip to content

[BUG] [Rust] SIMPLIFY_ONEOF_ANYOF=false causes NullPointerException: ... "name" is null in AbstractRustCodegen.sanitizeIdentifier #21192

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

Open
4 of 6 tasks
JMLX42 opened this issue Apr 30, 2025 · 0 comments

Comments

@JMLX42
Copy link

JMLX42 commented Apr 30, 2025

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Exception in thread "main" java.lang.RuntimeException: Could not process model 'list_accessor_sparse_indices_4XX_response_allOf_errors_inner_source'.Please make sure that your schema is correct!
        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:518)
        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:443)
        at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:1293)
        at org.openapitools.codegen.cmd.Generate.execute(Generate.java:535)
        at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
        at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.NullPointerException: Cannot invoke "String.replaceAll(String, String)" because "name" is null
        at org.openapitools.codegen.languages.AbstractRustCodegen.sanitizeIdentifier(AbstractRustCodegen.java:187)
        at org.openapitools.codegen.languages.AbstractRustCodegen.toModelName(AbstractRustCodegen.java:349)
        at org.openapitools.codegen.languages.RustClientCodegen.fromModel(RustClientCodegen.java:295)
        at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1755)
        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:513)
        ... 5 more
openapi-generator version

7.13.0

OpenAPI declaration file content or url
{
  "openapi": "3.1.0",
  "paths": {
    "/api/accessor-sparse-indices/": {
      "get": {
        "tags": [
          "Accessor Sparse Indices"
        ],
        "operationId": "list_accessor_sparse_indices",
        "parameters": [
          {
            "name": "fields[accessor-sparse-indices]",
            "in": "query",
            "description": "Specifies which fields should be returned. The value **MUST** be a comma-separated\n(U+002C COMMA, “,”) list that refers to the name(s) of the fields to be returned.\n\nAn empty value indicates that no fields should be returned.\n\nOmitting this parameter indicates that all fields should be returned.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "bufferView",
                  "byteOffset",
                  "componentType"
                ]
              }
            },
            "explode": false
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "bufferView"
                ]
              }
            },
            "explode": false
          },
          {
            "name": "page[number]",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "default": 1
            },
            "allowReserved": true,
            "example": 1
          },
          {
            "name": "page[size]",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "default": 100
            },
            "allowReserved": true,
            "example": 100
          }
        ],
        "responses": {
          "4XX": {
            "description": "Client error response.",
            "content": {
              "application/vnd.api+json": {
                "schema": {
                  "allOf": [
                    {
                      "type": "object",
                      "required": [
                        "errors"
                      ],
                      "properties": {
                        "errors": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "required": [
                              "status",
                              "title",
                              "detail"
                            ],
                            "properties": {
                              "status": {
                                "type": "string",
                                "example": "404"
                              },
                              "title": {
                                "type": "string",
                                "example": "Not found"
                              },
                              "detail": {
                                "type": "string",
                                "example": "The requested resource cannot be found."
                              },
                              "source": {
                                "oneOf": [
                                  {
                                    "type": "null"
                                  },
                                  {
                                    "$ref": "#/components/schemas/Source"
                                  }
                                ]
                              }
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": "\n{\n  \"errors\": [\n    {\n      \"status\": \"404\",\n      \"title\": \"Resource not found\",\n      \"detail\": \"The requested resource could not be found.\"\n    }\n  ]\n}\n"
              }
            }
          },
Generation Details
$ java -DloggerPath=conf/log4j.properties -jar openapi-generator-cli.jar generate -i ${INPUT_FILE} \
        -g rust \
        -o ${TMP_PATH} \
        --openapi-normalizer=SIMPLIFY_ONEOF_ANYOF=false \
        --additional-properties=avoidBoxedModels=true
Steps to reproduce
$ java -DloggerPath=conf/log4j.properties -jar openapi-generator-cli.jar generate -i ${INPUT_FILE} \
        -g rust \
        -o ${TMP_PATH} \
        --openapi-normalizer=SIMPLIFY_ONEOF_ANYOF=false \
        --additional-properties=avoidBoxedModels=true
Related issues/PRs
@JMLX42 JMLX42 changed the title [BUG] Description [BUG] [Rust] SIMPLIFY_ONEOF_ANYOF=false causes NullPointerException: ... "name" is null in AbstractRustCodegen.sanitizeIdentifier Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant