Openapi-generator: Maven goal from example does not work

Created on 21 Feb 2019  路  5Comments  路  Source: OpenAPITools/openapi-generator

Hi guys,

I am using the example from the maven plugin page which looks like:

<plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>3.3.4</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.build.directory}/generatedtest/openapi.yaml</inputSpec>
                            <output>${project.build.directory}/generated-sources</output>
                            <generatorName>java</generatorName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

But running the plugin throws:

Failed to execute goal org.openapitools:openapi-generator-maven-plugin:3.3.4:generate (default-cli) on project jax-rs-2.1-openapi: The parameters 'inputSpec' for goal org.openapitools:openapi-generator-maven-plugin:3.3.4:generate are missing or invalid -> [Help 1]

What麓s wrong with the example? I just can't fix it.
Also tried the petstore generator - same result. Seems to be related to the plugin.
The workaround would be to use node.js with npm as maven plugin and call the node.js generator. But that麓s ugly i think.

Kind regards.

Bug

Most helpful comment

I think this needs to be documented more prominently or the plugin should give a different error message. This was very confusing to me and cost me way too much time before I found this issue. :(

I do not even really understand why it would work as part of the compile phase and not when called directly.

All 5 comments

Can be closed. The trick is, not to call the plugin directly, but instead call "mvn clean compile".
It麓s a little but confusing about maven, but okay for me. Sorry guys.

I think this needs to be documented more prominently or the plugin should give a different error message. This was very confusing to me and cost me way too much time before I found this issue. :(

I do not even really understand why it would work as part of the compile phase and not when called directly.

Just leaving a comment here to say I also fell into this trap and spent quite a while trying to figure out what was wrong. My experience with other generator plugins lead me to believe I could call the plugin directly, as opposed to having to run a compile.

This also helps me control better when I want to execute the generator, as its not common I want to run a generator on every build. My solution is to simply leave it as a commented part of the POM until I want to regenerate.

I have not tested it recently. Is it still the case @crtab ?

Hi @dragetd !
Yes, literally just run into this myself with 4.3.1
[ERROR] Failed to execute goal org.openapitools:openapi-generator-maven-plugin:4.3.1:generate (default-cli) on project connector-xyz: The parameters 'inputSpec' for goal org.openapitools:openapi-generator-maven-plugin:4.3.1:generate are missing or invalid

Probably this will fall through the cracks (being a closed ticket) but getting to know what the rationale behind it is would be interesting, especially given some of the usecases mentioned in this thread.

Was this page helpful?
0 / 5 - 0 ratings