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] Maven plugin incorrectly marks inputSpec as a required field #16955

Closed
5 of 6 tasks
jack-handley opened this issue Nov 1, 2023 · 1 comment · Fixed by #18000
Closed
5 of 6 tasks

[BUG] Maven plugin incorrectly marks inputSpec as a required field #16955

jack-handley opened this issue Nov 1, 2023 · 1 comment · Fixed by #18000

Comments

@jack-handley
Copy link

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

When using the maven plugin, I can specify an Open API Spec file using the <inputSpec>./filename.yaml</inputSpec> tag, or I can specify an <inputSpecRootDirectory>./directory-of-specs/</inputSpecRootDirectory> for it to merge the files before generating the code. When I choose the latter option, I get an error saying inputSpec is required, despite the generator ignoring the input when the inputSpecRootDirectory is specified:

        if (StringUtils.isNotBlank(inputSpecRootDirectory)) {
            inputSpec = new MergedSpecBuilder(inputSpecRootDirectory, mergedFileName)
                .buildMergedSpec();
            LOGGER.info("Merge input spec would be used - {}", inputSpec);
        }

        File inputSpecFile = new File(inputSpec);

As such, the inputSpec parameter should be optional, and validation should check that one of inputSpec or inputSpecRootDirectory is specified (perhaps with a warning if both are given)

openapi-generator version

Latest (7.0.1)

Maven pom.xml
            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <!-- RELEASE_VERSION -->
                <version>7.0.1</version>
                <!-- /RELEASE_VERSION -->
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
<!--                            <inputSpec>${project.basedir}/src/main/resources/openapi/api.yaml</inputSpec>-->
                            <inputSpecRootDirectory>${project.basedir}/src/main/resources/openapi</inputSpecRootDirectory>
                            <generatorName>java</generatorName>
                            <configOptions>
                                <sourceFolder>src/gen/java/main</sourceFolder>
                            </configOptions>
                            <skipValidateSpec>true</skipValidateSpec>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

https://github.com/fullstack-jack/openapi-generator-maven-plugin-example

Steps to reproduce
  1. Clone example repo: https://github.com/fullstack-jack/openapi-generator-maven-plugin-example
  2. Run mvn generate-sources to see required field error
  3. Edit pom.xml to pass an arbitrary inputSpec e.g. <inputSpec>xxx</inputSpec>
  4. Rerun mvn generate-sources to see it create sources correctly despite useless inputSpec
Related issues/PRs

none

Suggest a fix

I might get round to creating a PR some time this week but support from anyone else is very welcome.

@wing328
Copy link
Member

wing328 commented Nov 5, 2023

cc @borsch - author of #14387

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

Successfully merging a pull request may close this issue.

2 participants