Skip to content

[BUG] [JAVA] Wildcard Content-Types used in request without validation #24118

Description

@claudiusnuss
Description

I use the OpenApi generator to write classes that use the spring boot resttemplate and restclient.
I want to send requests with a variable amount of content-types. These include: all of the application, image and text content-types. To achieve this I included wildcards in the definition of the openapi-spec yaml-file.
When I use wildcards in the definition of the requests bodies, these wildcards are put into the content-type of the request without any validation.
This causes an IllegalArgumentException(Content-Type cannot contain wildcard type/subtype '*').

There should be a verification if a content-type includes a wildcard and if that is the case a default value or something else should be used instead.

openapi-generator version

v7.22.0

OpenAPI declaration file content or url
components:
  requestBodies:
    AkzeptierteDateitypenRequest:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AkzeptierteDateitypen'
    DateiUploadRequest:
      content:
        application/*:
          schema:
            $ref: '#/components/schemas/Datei'
        text/*:
          schema:
            $ref: '#/components/schemas/Datei'
        image/*:
          schema:
            $ref: '#/components/schemas/Datei'
Steps to reproduce
  • Write a put method into the openapi-spec.yaml
  • in the request body of the method include a wildcard in the content-type oder content-subtype
  • generate the code
  • use the generated code to send a request
  • the content-type of the request should be filled with the wildcard from the requestbody
  • Illegalargumentexception gets thrown

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions