Skip to content

[BUG][JAVA] Maven Plugin CodeGenMojo.strictSpecBehavior does not match parameter name 'strictSpec' #3070

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

Closed
karlbennett opened this issue Jun 3, 2019 · 1 comment

Comments

@karlbennett
Copy link

karlbennett commented Jun 3, 2019

Description

The maven plugin does not work for version 4.0.* because the strictSpecBehavior field does not match it's parameter name strictSpec. It seems maven ignores the name specified in the annotation and just uses reflection to look for a field that has the same name as the parameter.

[ERROR] Failed to execute goal org.openapitools:openapi-generator-maven-plugin:4.0.1:generate (default) on project test-client: Unable to parse configuration of mojo org.openapitools:openapi-generator-maven-plugin:4.0.1:generate for parameter strictSpec: Cannot find 'strictSpec' in class org.openapitools.codegen.plugin.CodeGenMojo -> [Help 1]
openapi-generator version

4.0.*

OpenAPI declaration file content or url

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java#L248

/**
 * To treat a document strictly against the spec.
 */
@Parameter(name = "strictSpec", property = "openapi.generator.maven.plugin.strictSpec", required = false)
private Boolean strictSpecBehavior;
Steps to reproduce

Try to generate a client with the maven plugin above version 4.0.*.

<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>4.0.1</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec>${project.basedir}/src/main/resources/api.yaml</inputSpec>
                <generatorName>java</generatorName>
                <configOptions>
                   <sourceFolder>src/gen/java/main</sourceFolder>
                </configOptions>
            </configuration>
        </execution>
    </executions>
</plugin>
Suggest a fix

Simply fix the field name.

/**
 * To treat a document strictly against the spec.
 */
@Parameter(name = "strictSpec", property = "openapi.generator.maven.plugin.strictSpec", required = false)
private Boolean strictSpec;
Zomzog added a commit to Zomzog/openapi-generator that referenced this issue Jun 3, 2019
@wing328
Copy link
Member

wing328 commented Jun 4, 2019

@karlbennett thanks for reporting the issue. Please use v4.0.0 for the time being while we're reviewing the option naming for a permanent fix.

I'm also working on better CIs to catch the issue moving forward as part of the build.

@wing328 wing328 added this to the 4.0.2 milestone Jun 4, 2019
@wing328 wing328 modified the milestones: 4.0.2, 4.0.3 Jun 20, 2019
@wing328 wing328 closed this as completed Jun 20, 2019
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