OpenAPITools / OpenAPITools/openapi-generator
[BUG] Query param content type does not pass validation
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)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
According to https://swagger.io/docs/specification/describing-parameters/#schema-vs-content we can use content along with a nested schema to specify that query params are encoded as JSON objects. OpenAPIGenerator does not seem to respect this and gives the following error:
Execution failed for task ':openApiGenerate'.
> There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
| Error count: 1, Warning count: 0
Errors:
-attribute paths.'/foobar'(get).[jsonFilter].content is unexpected
openapi-generator version
4.3.0 Gradle plugin
OpenAPI declaration file content or url
{"swagger":"3.0.1", "info": {"title": "Content test"}, "host":"localhost","basePath":"/","tags":[{"name":"FooAPI"}],"paths":{"/foobar":{"get":{"tags":["FooAPI"],"operationId":"getFoobar","produces":["application/json"],"parameters":[{"name": "jsonFilter", "in": "query", "type": "object", "content": {"application/json": {"schema": {"type": "object", "properties": {"wheeee": "string"}}}}}],"responses":{"200":{"description":"Ok","schema":{"type":"string"}},"400":{"description":"Bad Request","schema":{"type":"string"}}}}}}}
Command line used for generation
openApiGenerate {
generatorName = "java"
library = "okhttp-gson"
inputSpec = "myswagger.yaml"
}
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 by reproducing the validation failure with the provided OpenAPI declaration and the Gradle openApiGenerate configuration using generatorName "java". Trace how query parameters using content are validated, then verify that the same specification passes validation while preserving the expected JSON query-parameter behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100