Skip to content

Conversation

@rpanackal
Copy link
Member

@rpanackal rpanackal commented Nov 19, 2025

Context

When OpenAPI generator find the following schema in input spec file, particularly the mention string+binary, it maps the response to type File.

responses:
  '200':
    description: Successful response
    content:
      application/octet-stream:
        schema:
          type: string
          format: binary

Unfortunately, while invoking any API method that returns File type, we will run into the following error. (Find the bug report in linked BLI)

UnknownContentType Could not extract response: no suitable HttpMessageConverter found for response type [class java.io.File] and content type [application/octet-stream]

The issue above suggests that the mapped type File is simply unsupported and should be changed. We have had similar issues in the past which could have simply been resolved with a different type mapping. So instead of a per-type fix, we can resort to a more generic solution. To do so, we can take advantage of the <typeMappings> and <importMappings> features of OpenAPI generator. They are can be set via the OpenAPI generator CLI or through the pom.xml .

  • <typeMappings> : allow you to override OpenAPI type with some custom type
  • <importMappings> : allows you to replace the file imports for any type with another qualified path. Often used in tandem with defined <typeMappings> to correct the import statements.

Problem:

Our OpenAPI generator wrapper and corresponding maven plugin, does not accept <typeMappings> and <importMappings>. The goal of this PR is to propagate their configuration down to the OpenAPI generator.

Feature scope:

  • Accept <typeMappings>
  • Accept <importMappings>
  • Test the mojo and propagation of the mappings.
  • Add a test in openapi-api-sample to demo fix for related bug report

Definition of Done

  • Functionality scope stated & covered
  • Tests cover the scope above
  • Error handling created / updated & covered by the tests above
  • Documentation updated
  • Release notes updated

@rpanackal rpanackal changed the title Feat/openapi/type and import mapping feat: [OpenAPI] Type and Import mapping support Nov 19, 2025
Copy link
Contributor

@newtork newtork left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.
Please only merge once you confirmed it's working on AI SDK.

@newtork
Copy link
Contributor

newtork commented Nov 21, 2025

competitive PR
SAP/ai-sdk-java#660

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants