Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][JAVA][SPRING] referencing multiple external files in one OpenAPI file results in broken builds or code #15104

Open
5 of 6 tasks
mlemnian opened this issue Apr 1, 2023 · 2 comments

Comments

@mlemnian
Copy link

mlemnian commented Apr 1, 2023

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

Currently, I'm working on migrating our old swagger 2.0 APIs to OpenAPI 3.0.1.
The migration process itself runs pretty smoothly.

Unfortunately, I've encountered many issues with OpenAPI 3.0.1 files referencing external YAML files (using relative paths) and it's relatively difficult to describe all of them within this ticket.
Therefore I created a GitHub repository for all the problems I've encountered (so far)

https://github.com/mlemnian/openapi-generator-issues

openapi-generator version

Tested with 6.4.0, 6.5.0 and 6.6.0-SNAPSHOT at 3d7c173

OpenAPI declaration file content or URL

I've created a dedicated GitHub repository for all the problems I've encountered (so far)

https://github.com/mlemnian/openapi-generator-issues

Generation Details

In my examples, I'm using always the following configs:

  • maven 3.9.0
  • java 17
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <generatorName>spring</generatorName>
                            <generateSupportingFiles>false</generateSupportingFiles>
                            <generateAliasAsModel>false</generateAliasAsModel>
                            <inputSpec>${project.basedir}/open-api.yaml</inputSpec>
                            <modelPackage>api.model</modelPackage>
                            <modelNameSuffix>DTO</modelNameSuffix>
                            <apiPackage>api</apiPackage>
                            <skipValidateSpec>false</skipValidateSpec>
                            <configOptions>
                                <useSpringBoot3>true</useSpringBoot3>
                                <performBeanValidation>true</performBeanValidation>
                                <interfaceOnly>true</interfaceOnly>
                                <skipDefaultInterface>true</skipDefaultInterface>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
Steps to reproduce

follow the description in the repo examples

Related issues/PRs

#11151
#3848
#1976
#8844

Suggest a fix
@mlemnian mlemnian changed the title [BUG][JAVA][SPRING] referencing multiple external files in one OpenAPI file results in broken code [BUG][JAVA][SPRING] referencing multiple external files in one OpenAPI file results in broken build or code Apr 1, 2023
@mlemnian mlemnian changed the title [BUG][JAVA][SPRING] referencing multiple external files in one OpenAPI file results in broken build or code [BUG][JAVA][SPRING] referencing multiple external files in one OpenAPI file results in broken builds or code Apr 1, 2023
@awais-latif
Copy link

Still facing this issue. Is it fixed?

code generator considering relative path with respect to entry root folder.

@mlemnian
Copy link
Author

@awais-latif I've retested it today with 6.6.0 and all the issues still persist.

What do you exactly mean by:

code generator considering relative path with respect to entry root folder.

all my paths are relative to the main open-api.yaml (which is in the root folder).

A simple example is my example-2:

open-api.yaml
|-- $ref: '#/components/parameters/Authorization'
|   `-- $ref: './shared-api-spec/components/parameters/header/Authorization/pv1.2.yaml#/Authorization'
|
|-- $ref: '#/components/parameters/limit'
|   `-- $ref: './shared-api-spec/components/parameters/query/limit/pv1.2.yaml#/limit'
|
|-- $ref: '#/components/parameters/offset'
|   `-- $ref: './shared-api-spec/components/parameters/query/offset/pv1.2.yaml#/offset'
|
|-- $ref: '#/components/parameters/partial_stuff_name'
|
|-- $ref: '#/components/schemas/paged_stuff_ov1_0'
|   `-- $ref: '#/components/schemas/stuff_ov1_0'
|       `-- $ref: './shared-api-spec/attributes/city/ov1.3.yaml'
|
`-- $ref: '#/components/schemas/error_code_ov1_2'
    `-- $ref: './shared-api-spec/components/schemas/error_code/ov1.2.yaml'

This doesn't contain any transitive refs.

Still, the generator is creating duplicated classes.

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

No branches or pull requests

2 participants