voidMainReturn
voidMainReturn

Reputation: 3517

openapi-generator-maven-plugin not able to correctly generate codde from the spec using allOf

Im' using openapi-generator-maven-plugin 7.9.0 in a spring boot 3.3.4 project. Here's my example spec :

/scripts/search:
    post:
      operationId: getScriptByFilter
      requestBody:
        description: JSON Request Data
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/ScriptSearchRequest"
                - $ref: "HttpServletRequest"

and my pom.xml plugin config as follows :

<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>${openapi.generator.maven.plugin}</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec>${project.basedir}/api-spec/ApiSpec.yaml</inputSpec>
                <generatorName>spring</generatorName>
                <output>${project.build.directory}/generated-sources/</output>
                <generateSupportingFiles>false</generateSupportingFiles>
                <apiPackage>${default.package}.api</apiPackage>
                <modelPackage>${default.package}.models</modelPackage>
                <configOptions>
                    <skipDefaultInterface>true</skipDefaultInterface>
                    <interfaceOnly>true</interfaceOnly>
                    <useSpringBoot3>true</useSpringBoot3>
                    <schemaInheritanceSupport>true</schemaInheritanceSupport>
                    <modelInheritance>true</modelInheritance>
                </configOptions>
                <openapiNormalizer>REF_AS_PARENT_IN_ALLOF=true</openapiNormalizer>
                <importMappings>
                    <importMapping>HttpServletRequest=jakarta.servlet.http.HttpServletRequest</importMapping>
                </importMappings>
            </configuration>
        </execution>
    </executions>
</plugin>

But the generator is not generating the correct contract in the .java file. The contract generated is like this :

ResponseEntity<> getScriptByFilter(
        @Parameter(name = "GetScriptByFilterRequest", description = "JSON Request Data", required = true) @Valid @RequestBody GetScriptByFilterRequest getScriptByFilterRequest
    );

Has anybody faced similar situation ? Any leads on how to tackle this ?

Upvotes: 0

Views: 41

Answers (0)

Related Questions