Skip to content

[spring/spring-boot] API generation fails when specification refs a requestBody with object type schema #10435

@rhamiltonsf

Description

@rhamiltonsf
Description

Using the following schema, the openapi-generator-maven-plugin fails to recognize the model in the requestBody schema, and instead tries to import and use a model named UNKNOWN_BASE_TYPE. This only happens when I use a ref to the requestBody and if the requestBody schema is of type object.

openapi-generator version

5.2.1
5.1.0
4.3.1

OpenAPI declaration file content or URL

Here is a minimum spec that reproduces the issue.

However note that this spec and this other spec both work.

Command line used for generation

This occurred using the openapi-generator-maven-plugin. See example pom here for configurations.

Steps to reproduce
  1. create a new maven project using this pom.
  2. Create src/main/resources directory and, add api.yaml to it
  3. run mvn clean install from the pom directory

Expected Results:
The command should execute successfully and generate default API models, interfaces, and delegate.

Actual Results:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] ~/testproject/target/generated-sources/openapi/api/org/openapitools/api/DefaultApi.java:[8,30] package org.openapitools.model does not exist
[ERROR] ~/testproject/target/generated-sources/openapi/api/org/openapitools/api/DefaultApiDelegate.java:[3,30] package org.openapitools.model does not exist
[ERROR] ~/testproject/target/generated-sources/openapi/api/org/openapitools/api/DefaultApi.java:[43,106] cannot find symbol
  symbol:   class UNKNOWN_BASE_TYPE
  location: interface org.openapitools.api.DefaultApi
[ERROR] ~/testproject/target/generated-sources/openapi/api/org/openapitools/api/DefaultApiDelegate.java:[33,43] cannot find symbol
  symbol:   class UNKNOWN_BASE_TYPE
  location: interface org.openapitools.api.DefaultApiDelegate
Related issues/PRs
Suggest a fix/enhancement

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions