OpenAPITools / OpenAPITools/openapi-generator
[BUG] 'oneOf' attribute not working for schema properties
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
Exception in thread "main" java.lang.RuntimeException: Could not generate model 'Pet_address'
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:554)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:911)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:465)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at java.lang.String.substring(String.java:1963)
at org.openapitools.codegen.templating.mustache.TitlecaseLambda.titleCase(TitlecaseLambda.java:64)
at org.openapitools.codegen.templating.mustache.TitlecaseLambda.execute(TitlecaseLambda.java:80)
at com.samskivert.mustache.Mustache$SectionSegment.execute(Mustache.java:874)
at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
at com.samskivert.mustache.Mustache$SectionSegment.execute(Mustache.java:870)
at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
at com.samskivert.mustache.Mustache$InvertedSegment.execute(Mustache.java:910)
at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
at com.samskivert.mustache.Mustache$SectionSegment.execute(Mustache.java:866)
at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
at com.samskivert.mustache.Mustache$SectionSegment.execute(Mustache.java:881)
at com.samskivert.mustache.Template.executeSegs(Template.java:157)
at com.samskivert.mustache.Mustache$IncludedTemplateSegment.execute(Mustache.java:774)
at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
at com.samskivert.mustache.Mustache$SectionSegment.execute(Mustache.java:870)
at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
at com.samskivert.mustache.Mustache$SectionSegment.execute(Mustache.java:866)
at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
at com.samskivert.mustache.Mustache$InvertedSegment.execute(Mustache.java:910)
at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
at com.samskivert.mustache.Mustache$SectionSegment.execute(Mustache.java:881)
at com.samskivert.mustache.Mustache$BlockSegment.executeSegs(Mustache.java:845)
at com.samskivert.mustache.Mustache$SectionSegment.execute(Mustache.java:866)
at com.samskivert.mustache.Template.executeSegs(Template.java:157)
at com.samskivert.mustache.Template.execute(Template.java:134)
at com.samskivert.mustache.Template.execute(Template.java:125)
at org.openapitools.codegen.templating.MustacheEngineAdapter.compileTemplate(MustacheEngineAdapter.java:65)
at org.openapitools.codegen.TemplateManager.write(TemplateManager.java:163)
at org.openapitools.codegen.DefaultGenerator.processTemplateToFile(DefaultGenerator.java:1057)
at org.openapitools.codegen.DefaultGenerator.processTemplateToFile(DefaultGenerator.java:1044)
at org.openapitools.codegen.DefaultGenerator.generateModel(DefaultGenerator.java:393)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:545)
... 4 more
openapi-generator version : 6.0.1
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: One Of Array Troubleshooting
version: 0.0.0
servers:
- url: https://petstore3.swagger.io/api/v3
paths:
/pet:
put:
tags:
- pet
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/Pet'
required: true
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid ID supplied
'404':
description: Pet not found
'405':
description: Validation exception
components:
schemas:
Pet:
type: object
properties:
id:
type: integer
format: int64
example: 10
name:
type: string
example: doggie
address:
oneOf:
- type: array
items:
$ref: '#/components/schemas/Address'
minItems: 1
xml:
name: pet
Address:
type: object
properties:
id:
type: integer
format: int64
example: 10
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
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
Reproduce the failure with the supplied OpenAPI 3.0.3 declaration using openapi-generator 6.0.1, then inspect TitlecaseLambda.titleCase in org.openapitools.codegen.templating.mustache.TitlecaseLambda.java at the reported stack-trace line. Follow the generation path through DefaultGenerator.generateModels and OpenAPIGenerator; done means the Pet_address model generation completes without the StringIndexOutOfBoundsException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100