OpenAPITools / OpenAPITools/openapi-generator
[BUG] [JAVA] [ASCIIDOC] Bug with filtering nulls in examples
Nobody has claimed this yet.
- 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 (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
Examples in models are always presented despite an existence test. If the element does not exist, null is represented as a value.
The marking of the required fields correctly displays non-existent elements as an empty values.
openapi-generator version
7.0.1
OpenAPI declaration file content or url
A json-example like this
...
"Content": {
"type": "object",
"properties": {
"content": {
"type": "array",
"description": "Content of Document in Bytes",
"items": {
"type": "string",
"description": "Content of Document in Bytes",
"format": "byte"
}
}
},
"description": "Content of Document"
}
...
with a mustache-template like this
[#{{classname}}]
=== _{{classname}}_ {{title}}
{{unescapedDescription}}
[.fields-{{classname}}]
[cols="2,3,1,2,2"]
|===
| Name| Description| Required| Type| Example
{{#vars}}
| {{baseName}}
| {{description}}
| {{#required}}✓{{/required}}
| {{dataType}} {{#isContainer}} of <<{{complexType}}>>{{/isContainer}}
| {{#example}}{{.}}{{/example}}
{{/vars}}
|===
creates a asciidoc-output like this
[#Content]
=== _Content_
Content of Document
[.fields-Content]
[cols="2,3,1,2,2"]
|===
| Name| Description| Required| Type| Example
| content
| Content of Document in Bytes
|
| List of <<ByteArray>>
| null
|===
but expected should it be like this
[#Content]
=== _Content_
Content of Document
[.fields-Content]
[cols="2,3,1,2,2"]
|===
| Name| Description| Required| Type| Example
| content
| Content of Document in Bytes
|
| List of <<ByteArray>>
|
|===
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 the supplied OpenAPI declaration and Mustache template, then reproduce the Java Asciidoc output using generator version 7.0.1. Compare fields whose examples are absent with fields marked required; done means absent examples render blank rather than null, while existing example and required-field behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100