OpenAPITools / OpenAPITools/openapi-generator

[BUG] Maven plugin - Error in spec validation does not fail build

Open
#14,922 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

With skipValidateSpec=false the Maven build succeeds even though spec validation logs errors.

openapi-generator version
<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>6.4.0</version>
</plugin>
OpenAPI declaration file content or url
components:
  schemas:
    ContainerItemResponse:
      properties:
        container:
          type: object
          $ref: '#/components/schemas/Container'
    Container:
      properties:
        containerType:
          type: string

provokes

[ERROR] Illegal schema found with $ref combined with other properties, no properties should be defined alongside a $ref:

Yet, the Maven build succeeds.

Generation Details
<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>xs2r-api-generation</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec>${project.basedir}/../spec/api.yml</inputSpec>
                <generatorName>spring</generatorName>
                <auth>true</auth>
                <supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
                <skipValidateSpec>false</skipValidateSpec>
                <generateModels>false</generateModels>
                <configOptions>
                    <languageSpecificPrimitives>
                        OrderStatus
                    </languageSpecificPrimitives>
                    <delegatePattern>true</delegatePattern>
                </configOptions>
                <typeMappings>
                    <typeMapping>string+date-time=Instant</typeMapping>
                </typeMappings>
                <importMappings>
                    Instant=java.time.Instant
                </importMappings>
            </configuration>
        </execution>
    </executions>
</plugin>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Maven plugin's generate execution and the skipValidateSpec=false validation path, using the supplied schema as a reproduction. Trace how validation errors are reported and verify that the build fails for the invalid $ref/property combination with a Maven-plugin regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.