Open Api Generator having issues with api.github.com.json
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
Start with the api.github.com.json schema referenced in the issue and reproduce generation using OpenAPI Generator 7.11.0 with the shown Java configuration. Compare the generated ContentDirectory model with the original and modified content-directory declarations; done means generation no longer produces the wrong-named utility model.
Written by the indexing model from the issue text.
Description
Issue
We were using the Open Api Generator(OAG) to generate some Java models based on the current OAS schema JSON . This generates a wrong-named model when it's doing the ContentDirectory Schema Model, which is called from here
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/content-directory"
},
{
"$ref": "#/components/schemas/content-file"
},
{
"$ref": "#/components/schemas/content-symlink"
},
{
"$ref": "#/components/schemas/content-submodule"
}
],
"discriminator": {
"propertyName": "type",
"mapping": {
"array": "#/components/schemas/content-directory",
"file": "#/components/schemas/content-file",
"symlink": "#/components/schemas/content-symlink",
"submodule": "#/components/schemas/content-submodule"
}
}
}
Possible solution
To patch the bug, I've changed the definition of the schema to avoid the wrong-named model issue. This happens because when OAG couldn't figure out the logic or a declaration, it generates a utility model to patch this issue.
Here is the original ContentDirectory declaration:
"content-directory": {
"title": "Content Directory",
"description": "A list of directory items",
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"dir",
"file",
"submodule",
"symlink"
]
},
"size": {
"type": "integer"
},
"name": {
"type": "string"
},
"path": {
"type": "string"
},
"content": {
"type": "string"
},
"sha": {
"type": "string"
},
"url": {
"type": "string",
"format": "uri"
},
"git_url": {
"type": "string",
"format": "uri",
"nullable": true
},
"html_url": {
"type": "string",
"format": "uri",
"nullable": true
},
"download_url": {
"type": "string",
"format": "uri",
"nullable": true
},
"_links": {
"type": "object",
"properties": {
"git": {
"type": "string",
"format": "uri",
"nullable": true
},
"html": {
"type": "string",
"format": "uri",
"nullable": true
},
"self": {
"type": "string",
"format": "uri"
}
},
"required": [
"git",
"html",
"self"
]
}
},
"required": [
"_links",
"git_url",
"html_url",
"download_url",
"name",
"path",
"sha",
"size",
"type",
"url"
]
}
}
And here is the modified declaration that we used to patch the issue.
"content-directory": {
"title": "Content Directory",
"description": "A list of directory items",
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"array"
]
},
"size": {
"type": "integer"
},
"name": {
"type": "string"
},
"path": {
"type": "string"
},
"content": {
"type": "string"
},
"sha": {
"type": "string"
},
"url": {
"type": "string",
"format": "uri"
},
"git_url": {
"type": "string",
"format": "uri",
"nullable": true
},
"html_url": {
"type": "string",
"format": "uri",
"nullable": true
},
"download_url": {
"type": "string",
"format": "uri",
"nullable": true
},
"_links": {
"type": "object",
"properties": {
"git": {
"type": "string",
"format": "uri",
"nullable": true
},
"html": {
"type": "string",
"format": "uri",
"nullable": true
},
"self": {
"type": "string",
"format": "uri"
}
},
"required": [
"git",
"html",
"self"
]
}
},
"required": [
"_links",
"git_url",
"html_url",
"download_url",
"name",
"path",
"sha",
"size",
"type",
"url"
]
}
This is the OAG version used to generate the model: 7.11.0
and the config used in the generator:
openApiGenerate {
generatorName.set("java")
inputSpec.set("$projectDir/src/main/resources/api.github.com.fixed.json")
outputDir.set("$buildDir")
apiPackage.set("com.github.client.api")
modelPackage.set("com.github.client.model")
configOptions.put("dateLibrary", "java8")
ignoreFileOverride.value("$projectDir/.openapi-generator-ignore")
configOptions.put("library", "apache-httpclient")
configOptions.put("sourceFolder", "generated/main/java")
configOptions.put("openApiNullable", "false")
configOptions.put("invokerPackage", "com.github.client")
}
- Dominant language
- No language data
- Stars
- 1.6k
- Forks
- 342
- Avg merge
- 3h 33m
- Merged PRs (30d)
- 51
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.
More from github/rest-api-description
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
github/rest-api-description#7201 ·
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
github/rest-api-description#7163 ·
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
github/rest-api-description#7162 ·
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
github/rest-api-description#7135 ·
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
github/rest-api-description#7111 · 1 comment ·
All issues in github/rest-api-description
Similar issues
-
area/sessions comp/cron comp/gateway P2 sweeper:risk-message-delivery sweeper:risk-session-state type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NousResearch/hermes-agent#118863 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
use-agent-os/agent-os#3312 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
needs-acceptance wg/data-plane-networking
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vllm-project/semantic-router#4024 · 1 comment ·