Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 135 additions & 72 deletions modules/openapi-generator-maven-plugin/README.md

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion modules/openapi-generator-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
<version>${maven.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>3.3.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
Expand Down Expand Up @@ -102,7 +107,12 @@
<version>4.8.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
Expand Down Expand Up @@ -174,6 +184,10 @@
<failIfNoProjects>true</failIfNoProjects>
<postBuildHookScript>verify</postBuildHookScript>
<streamLogsOnFailures>true</streamLogsOnFailures>
<pomIncludes>
<pomInclude>*/pom.xml</pomInclude>
<pomInclude>validate-harness/*/pom.xml</pomInclude>
</pomIncludes>
</configuration>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
invoker.goals = validate
invoker.systemProperties = openapi.generator.inputSpec=valid_api.yaml,unused_model_api.yaml
invoker.buildResult = success
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools.it</groupId>
<artifactId>cli-comma-separated-override</artifactId>
<version>1.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>@project.version@</version>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
openapi: 3.0.3
info:
title: API with Style Recommendations
version: 1.0.0
description: Valid spec syntax, but contains an isolated component model that triggers an unused schema warning.
paths:
/users:
get:
summary: Get active users
operationId: getUsers
responses:
'200':
description: Success
content:
application/json:
schema:
type: array
items:
type: string
components:
schemas:
UnusedModel:
type: object
properties:
legacyField:
type: integer
description: This model is declared but never referenced anywhere in any operation or path parameter.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
openapi: 3.0.3
info:
title: Healthy Test API
version: 1.0.0
description: A completely valid specification with no errors or recommendations.
paths:
/ping:
get:
summary: Simple healthcheck endpoint
operationId: pingCheck
responses:
'200':
description: Server is operational
content:
application/json:
schema:
$ref: '#/components/schemas/Pong'
components:
schemas:
Pong:
type: object
properties:
status:
type: string
example: healthy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals = validate
invoker.buildResult = success
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools.it</groupId>
<artifactId>input-directory-merge</artifactId>
<version>1.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>validate</goal>
</goals>
<configuration>
<inputSpecRootDirectory>${project.basedir}/specs</inputSpecRootDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
openapi: 3.0.3
info:
title: Part 1
version: 1.0.0
paths:
/part1:
get:
responses:
'200':
description: OK
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
openapi: 3.0.3
info:
title: Part 2
version: 1.0.0
paths:
/part2:
get:
responses:
'200':
description: OK
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
openapi: 3.0.3
info:
title: First XML API Element
version: 1.0.0
paths:
/first:
get:
responses:
'200':
description: OK
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
openapi: 3.0.3
info:
title: Second XML API Element
version: 1.0.0
paths:
/second:
get:
responses:
'200':
description: OK
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals = validate
invoker.buildResult = success
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools.it</groupId>
<artifactId>multi-file-xml-list</artifactId>
<version>1.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>validate</goal>
</goals>
<configuration>
<inputSpec>
<param>api_first.yaml</param>
<param>api_second.yaml</param>
</inputSpec>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
openapi: 3.0.3
info:
title: Completely Broken Spec
# Missing required 'version' field!
paths:
/broken-endpoint:
get:
responses:
# Invalid response code type syntax or completely missing details
'invalid_code':
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
invoker.goals = validate
# Mandate that the plugin properly drops the build execution lifecycle hammer!
invoker.buildResult = failure
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools.it</groupId>
<artifactId>strict-spec-failure</artifactId>
<version>1.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>validate</goal>
</goals>
<configuration>
<inputSpec>invalid_api.yaml</inputSpec>
<strictSpec>true</strictSpec> </configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import java.io.*

// 1. Locate the build log file
File logFile = new File(basedir, "build.log")
assert logFile.exists() : "The build.log file was not found!"

String logContent = logFile.text

// 2. Assert the true root cause strings
// Check for the exact exception message thrown by the Mojo wrapper
assert logContent.contains("Validation has error(s). See above for the details.") : "Build failed, but not due to the expected validation exception wrapper!"

// Check for the swagger/openapi parser's structural complaint about our broken yaml
assert logContent.contains("attribute info.version is missing") || logContent.contains("missing") : "The logs do not contain the specific OpenAPI specification structural violations!"

return true
Loading