OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Rust] Cannot invoke "String.replaceAll(String, String)" because "name" is null
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Exception in thread "main" java.lang.RuntimeException: Could not process model 'custom_fields_attributes'.Please make sure that your schema is correct!
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:519)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:444)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:1292)
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:353)
at org.openapitools.codegen.languages.RustClientCodegen.fromModel(RustClientCodegen.java:307)
at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1754)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:514)
... 5 more
openapi-generator version
Tried 7.16.0 and latest master branch.
OpenAPI declaration file content or url
openapi: 3.1.0
info:
title: Example
version: 1.0.0
paths:
"/example":
patch:
requestBody:
required: true
content:
application/json:
schema:
contact:
type: object
properties:
custom_fields_attributes:
$ref: "#/components/schemas/custom_fields_attributes"
responses:
"200":
description: "Success"
content:
application/json:
schema:
type: object
components:
schemas:
custom_fields_attributes:
oneOf:
- type: object
additionalProperties:
type: object
properties:
id:
type:
- integer
- string
value:
type: string
required:
- id
- value
- type: array
items:
type: object
properties:
id:
type:
- integer
- string
value:
type: string
Generation Details
openapi-generator-cli generate -i example.yaml -o /tmp/example -g rust --package-name example
Steps to reproduce
openapi-generator-cli generate -i example.yaml -o /tmp/example -g rust --package-name example
Related issues/PRs
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with org.openapitools.codegen.languages.AbstractRustCodegen.sanitizeIdentifier and toModelName, then inspect RustClientCodegen.fromModel and reproduce with the supplied OpenAPI YAML and rust generation command. Done means generation no longer fails with the reported null-pointer exception and the regression is covered by an appropriate generator test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, rust
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100