Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #14983
Closed
Open
Issue created Mar 17, 2023 by lgsicpa@lgsicpa5 of 6 checklist items completed5/6 checklist items

[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
Assignee
Assign to
Time tracking