Skip to content

[BUG][Rust] NullPointerException naming a oneOf member that has no title or type #25016

Description

@HardMax71

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • 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?
Description

RustClientCodegen.fromModel names an inline oneOf member from its title, falling back to its type. A member with neither, such as allOf with a single $ref plus required, gets toModelName(null), and generation stops with a NullPointerException. GitHub's current REST description hits this on actions-policy-repo-conditions, so the rust generator can't produce a client for it.

The frame is the same as #21192, but that issue's own repro (a 3.1 anyOf with type: "null") generates fine on 7.25.0. This is a different trigger reaching the same line.

openapi-generator version

7.25.0, and master at 10e6c21.

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: oneOf member without a type
  version: "1"
paths:
  /conditions:
    get:
      operationId: getConditions
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Conditions"
components:
  schemas:
    Conditions:
      type: object
      oneOf:
        - type: object
          maxProperties: 0
        - allOf:
            - $ref: "#/components/schemas/WorkflowPathCondition"
          required:
            - workflow_path
          maxProperties: 1
    WorkflowPathCondition:
      type: object
      properties:
        workflow_path:
          type: string
Generation Details
java -jar openapi-generator-cli-7.25.0.jar generate -g rust -i spec.yaml -o out
Steps to reproduce
Exception in thread "main" java.lang.RuntimeException: Could not process model 'Conditions'.Please make sure that your schema is correct!
Caused by: java.lang.NullPointerException: Cannot invoke "String.replaceAll(String, String)" because "name" is null
	at org.openapitools.codegen.languages.AbstractRustCodegen.sanitizeIdentifier(AbstractRustCodegen.java:189)
	at org.openapitools.codegen.languages.AbstractRustCodegen.toModelName(AbstractRustCodegen.java:355)
	at org.openapitools.codegen.languages.RustClientCodegen.fromModel(RustClientCodegen.java:324)

Expected: a variant named after the member's base type, WorkflowPathCondition(Box<models::WorkflowPathCondition>).

Related issues/PRs

#21192 (same NullPointerException site).

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