[BUG] 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
Free-form query param spec generated spring @RequestParam
annotation when it should not.
openapi-generator version
Using version 6.4.0
Technically not a regression since the issue which was supposed to fix it did fix it only partially (see #8080 (closed)).
OpenAPI declaration file content or url
Could be reproduce with both definitions below
Inline schema definition
openapi: 3.0.0
servers:
- url: 'localhost:8080'
info:
version: 1.0.0
title: OpenAPI Petstore
license:
name: Apache-2.0
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
paths:
/pony:
get:
operationId: list
parameters:
- in: query
name: pageQuery
schema:
type: object
additionalProperties:
type: string
Separate schema definition
openapi: 3.0.0
servers:
- url: 'localhost:8080'
info:
version: 1.0.0
title: OpenAPI Petstore
license:
name: Apache-2.0
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
paths:
/pony:
get:
operationId: list
parameters:
- in: query
name: pageQuery
required: false
style: form
explode: true
schema:
$ref: '#/components/schemas/SearchCriteria'
components:
schemas:
SearchCriteria:
type: object
additionalProperties:
type: string
Generation Details
Maven plugin
Steps to reproduce
Run KotlinSpringServerCodegenTest.doNotGenerateRequestParamForObjectQueryParam
with either of the definitions listed above.
The test will fail.
Related issues/PRs
Issue #8080 (closed) was supposed to fix it but it only works when the model definition is fixed.
We target a dynamic Map<String, String>
(hence the additionalProperties
) to implement a dynamic search: we can't possibly list all possible criteria.
Suggest a fix
Looks like the mustache template is src/main/resources/kotlin-spring/queryParams.mustache
but my knowledge ends there. I don't know how to add additional condition to mustache.
A condition which would involve something along the lines:
- query parameter
- schema is an object no matter how it's defined