Skip to content

Commit ced7387

Browse files
committed
feat: initial implementation of microprofile-openapi-3
1 parent 7a5cb07 commit ced7387

File tree

22 files changed

+1300
-2
lines changed

22 files changed

+1300
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
- support `<skipAbstractTypes>` flag to exclude abstract types (not interfaces)
2020
- support `<skipInterfaces>` flag to exclude interface types
2121

22+
### `jsonschema-module-microprofile-openapi-3`
23+
#### Added
24+
***NOTE: `org.eclipse.microprofile.openapi:microprofile-openapi-api` minimum version is `3.1.1`!***
25+
- Initial implementation of `MicroProfileOpenApi3Module` for deriving schema attributes from MicroProfile OpenAPI 3 `@Schema` annotations.
26+
2227
## [4.36.0] - 2024-07-20
2328
### `jsonschema-generator`
2429
#### Added

jsonschema-examples/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@
6464
<groupId>io.swagger.core.v3</groupId>
6565
<artifactId>swagger-annotations</artifactId>
6666
</dependency>
67+
<!-- Microprofile OpenAPI 3 Module dependencies -->
68+
<dependency>
69+
<groupId>com.github.victools</groupId>
70+
<artifactId>jsonschema-module-microprofile-openapi-3</artifactId>
71+
</dependency>
72+
<dependency>
73+
<groupId>org.eclipse.microprofile.openapi</groupId>
74+
<artifactId>microprofile-openapi-api</artifactId>
75+
</dependency>
6776
<dependency>
6877
<groupId>io.github.classgraph</groupId>
6978
<artifactId>classgraph</artifactId>

jsonschema-generator-bom/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@
8484
<artifactId>jsonschema-module-swagger-2</artifactId>
8585
<version>${project.version}</version>
8686
</dependency>
87+
<dependency>
88+
<groupId>com.github.victools</groupId>
89+
<artifactId>jsonschema-module-microprofile-openapi-3</artifactId>
90+
<version>${project.version}</version>
91+
</dependency>
8792
</dependencies>
8893
</dependencyManagement>
8994

jsonschema-generator-parent/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
<version.javax.validation>2.0.1.Final</version.javax.validation>
165165
<version.swagger-1.5>1.6.7</version.swagger-1.5>
166166
<version.swagger-2>2.2.5</version.swagger-2>
167+
<version.microprofile-openapi-3>3.1.1</version.microprofile-openapi-3>
167168
<!-- maven plugin runtime dependencies -->
168169
<version.classgraph>4.8.149</version.classgraph>
169170
</properties>
@@ -212,6 +213,11 @@
212213
<artifactId>classgraph</artifactId>
213214
<version>${version.classgraph}</version>
214215
</dependency>
216+
<dependency>
217+
<groupId>org.eclipse.microprofile.openapi</groupId>
218+
<artifactId>microprofile-openapi-api</artifactId>
219+
<version>${version.microprofile-openapi-3}</version>
220+
</dependency>
215221
</dependencies>
216222
</dependencyManagement>
217223
<dependencies>

jsonschema-maven-plugin/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,13 @@ When you want to have more control over the modules that are to be used during g
187187
```
188188
This configuration will generate the schema using the Jackson module.
189189

190-
There are five standard modules that can be used:
190+
There are six standard modules that can be used:
191191
- `Jackson`
192192
- `JakartaValidation`
193193
- `JavaxValidation`
194194
- `Swagger15`
195195
- `Swagger2`
196+
- `MicroProfileOpenApi3`
196197

197198
### Defining options for a module
198199
```xml

jsonschema-maven-plugin/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@
129129
<groupId>io.swagger.core.v3</groupId>
130130
<artifactId>swagger-annotations</artifactId>
131131
</dependency>
132+
<!-- Microprofile OpenAPI 3 Module dependencies -->
133+
<dependency>
134+
<groupId>com.github.victools</groupId>
135+
<artifactId>jsonschema-module-microprofile-openapi-3</artifactId>
136+
</dependency>
137+
<dependency>
138+
<groupId>org.eclipse.microprofile.openapi</groupId>
139+
<artifactId>microprofile-openapi-api</artifactId>
140+
</dependency>
132141
</dependencies>
133142

134143
<build>

jsonschema-maven-plugin/src/main/java/com/github/victools/jsonschema/plugin/maven/SchemaGeneratorMojo.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.github.victools.jsonschema.module.jakarta.validation.JakartaValidationOption;
3232
import com.github.victools.jsonschema.module.javax.validation.JavaxValidationModule;
3333
import com.github.victools.jsonschema.module.javax.validation.JavaxValidationOption;
34+
import com.github.victools.jsonschema.module.microprofile.openapi3.MicroProfileOpenApi3Module;
3435
import com.github.victools.jsonschema.module.swagger15.SwaggerModule;
3536
import com.github.victools.jsonschema.module.swagger15.SwaggerOption;
3637
import com.github.victools.jsonschema.module.swagger2.Swagger2Module;
@@ -522,9 +523,14 @@ private void addStandardModule(GeneratorModule module, SchemaGeneratorConfigBuil
522523
this.getLog().debug("- Adding Swagger 2.x Module");
523524
configBuilder.with(new Swagger2Module());
524525
break;
526+
case "MicroProfileOpenApi3":
527+
this.getLog().debug("- Adding MicroProfile OpenAPI 3.x Module");
528+
configBuilder.with(new MicroProfileOpenApi3Module());
529+
break;
525530
default:
526531
throw new MojoExecutionException("Error: Module does not have a name in "
527-
+ "['Jackson', 'JakartaValidation', 'JavaxValidation', 'Swagger15', 'Swagger2'] or does not have a custom classname.");
532+
+ "['Jackson', 'JakartaValidation', 'JavaxValidation', 'Swagger15', 'Swagger2', 'MicroProfileOpenApi3']"
533+
+ " or does not have a custom classname.");
528534
}
529535
}
530536

jsonschema-maven-plugin/src/test/java/com/github/victools/jsonschema/plugin/maven/SchemaGeneratorMojoTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public void setUp() throws Exception {
5757
"JakartaValidationModule",
5858
"Swagger15Module",
5959
"Swagger2Module",
60+
"MicroProfileOpenApi3Module",
6061
"Complete"
6162
})
6263
public void testGeneration(String testCaseName) throws Exception {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<project>
2+
<build>
3+
<plugins>
4+
<plugin>
5+
<groupId>com.github.victools</groupId>
6+
<artifactId>jsonschema-maven-plugin</artifactId>
7+
<configuration>
8+
<classNames>com.github.victools.jsonschema.plugin.maven.TestClass</classNames>
9+
<schemaFilePath>target/generated-test-sources/MicroProfileOpenApi3Module</schemaFilePath>
10+
<modules>
11+
<module>
12+
<name>MicroProfileOpenApi3</name>
13+
</module>
14+
</modules>
15+
</configuration>
16+
</plugin>
17+
</plugins>
18+
</build>
19+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema" : "http://json-schema.org/draft-07/schema#",
3+
"type" : "object",
4+
"properties" : {
5+
"anInt" : {
6+
"type" : "integer"
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)