Skip to content

Commit 8cacd44

Browse files
committed
Add support for json
1 parent 6bfe6cf commit 8cacd44

File tree

7 files changed

+141
-6
lines changed

7 files changed

+141
-6
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[.configuration-legend]
2+
icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime
3+
[.configuration-reference.searchable, cols="80,.^10,.^10"]
4+
|===
5+
6+
h|[.header-title]##Configuration property##
7+
h|Type
8+
h|Default
9+
10+
a|icon:lock[title=Fixed at build time] [[quarkus-openapi-generator-moqu-wiremock_quarkus-openapi-generator-moqu-resource-dir]] [.property-path]##link:#quarkus-openapi-generator-moqu-wiremock_quarkus-openapi-generator-moqu-resource-dir[`quarkus.openapi-generator.moqu.resource-dir`]##
11+
ifdef::add-copy-button-to-config-props[]
12+
config_property_copy_button:+++quarkus.openapi-generator.moqu.resource-dir+++[]
13+
endif::add-copy-button-to-config-props[]
14+
15+
16+
[.description]
17+
--
18+
Path to the Moqu (relative to the project).
19+
20+
21+
ifdef::add-copy-button-to-env-var[]
22+
Environment variable: env_var_with_copy_button:+++QUARKUS_OPENAPI_GENERATOR_MOQU_RESOURCE_DIR+++[]
23+
endif::add-copy-button-to-env-var[]
24+
ifndef::add-copy-button-to-env-var[]
25+
Environment variable: `+++QUARKUS_OPENAPI_GENERATOR_MOQU_RESOURCE_DIR+++`
26+
endif::add-copy-button-to-env-var[]
27+
--
28+
|string
29+
|`openapi`
30+
31+
|===
32+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[.configuration-legend]
2+
icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime
3+
[.configuration-reference.searchable, cols="80,.^10,.^10"]
4+
|===
5+
6+
h|[.header-title]##Configuration property##
7+
h|Type
8+
h|Default
9+
10+
a|icon:lock[title=Fixed at build time] [[quarkus-openapi-generator-moqu-wiremock_quarkus-openapi-generator-moqu-resource-dir]] [.property-path]##link:#quarkus-openapi-generator-moqu-wiremock_quarkus-openapi-generator-moqu-resource-dir[`quarkus.openapi-generator.moqu.resource-dir`]##
11+
ifdef::add-copy-button-to-config-props[]
12+
config_property_copy_button:+++quarkus.openapi-generator.moqu.resource-dir+++[]
13+
endif::add-copy-button-to-config-props[]
14+
15+
16+
[.description]
17+
--
18+
Path to the Moqu (relative to the project).
19+
20+
21+
ifdef::add-copy-button-to-env-var[]
22+
Environment variable: env_var_with_copy_button:+++QUARKUS_OPENAPI_GENERATOR_MOQU_RESOURCE_DIR+++[]
23+
endif::add-copy-button-to-env-var[]
24+
ifndef::add-copy-button-to-env-var[]
25+
Environment variable: `+++QUARKUS_OPENAPI_GENERATOR_MOQU_RESOURCE_DIR+++`
26+
endif::add-copy-button-to-env-var[]
27+
--
28+
|string
29+
|`openapi`
30+
31+
|===
32+

moqu/core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111

1212
<artifactId>quarkus-openapi-generator-moqu-core</artifactId>
13-
<name>Quarkus - Openapi Generator - Moqu - Core</name>
13+
<name>Quarkus :: Openapi Generator :: Moqu :: Core</name>
1414

1515
<properties>
1616
<commons.io.version>2.16.1</commons.io.version>
@@ -51,4 +51,4 @@
5151
<artifactId>jboss-logmanager</artifactId>
5252
</dependency>
5353
</dependencies>
54-
</project>
54+
</project>

moqu/core/src/main/java/io/quarkiverse/openapi/moqu/marshall/ObjectMapperFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
public class ObjectMapperFactory {
99

10-
private static ObjectMapper objectMapper = new ObjectMapper();
10+
private static final ObjectMapper objectMapper = new ObjectMapper();
1111

1212
public static ObjectMapper getInstance() {
1313
return objectMapper;

moqu/deployment/src/main/java/io/quarkiverse/openapi/generator/MoquProjectProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class MoquProjectProcessor {
2626

2727
private static final Logger LOGGER = Logger.getLogger(MoquProjectProcessor.class);
2828

29-
private static final Set<String> SUPPORTED_EXTENSIONS = Set.of("yaml", "yml");
29+
private static final Set<String> SUPPORTED_EXTENSIONS = Set.of("yaml", "yml", "json");
3030

3131
@BuildStep
3232
MoquProjectBuildItem generate(MoquConfig config) {

moqu/deployment/src/test/java/io/quarkiverse/openapi/generator/MoquProjectProcessorTest.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ public class MoquProjectProcessorTest {
1111

1212
@RegisterExtension
1313
static final QuarkusDevModeTest unitTest = new QuarkusDevModeTest()
14-
.withApplicationRoot(javaArchive -> javaArchive.addAsResource(
15-
"api.yaml", "openapi/openapi.yaml"));
14+
.withApplicationRoot(javaArchive -> javaArchive
15+
.addAsResource("api.yaml", "openapi/openapi.yaml")
16+
.addAsResource("apiv2.json", "openapi/api.json"));
1617

1718
@Test
1819
void testModeAsSee() {
@@ -33,4 +34,14 @@ void testModeAsDownload() {
3334
.body(Matchers.containsString("Alice"))
3435
.log().ifError();
3536
}
37+
38+
@Test
39+
void testModeAsDownloadUsingJson() {
40+
RestAssured.given()
41+
.when().get("/q/moqu/json/api/wiremock-mappings.json")
42+
.then()
43+
.statusCode(200)
44+
.body(Matchers.containsString("Alice"))
45+
.log().ifError();
46+
}
3647
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"openapi": "3.0.3",
3+
"servers": [
4+
{
5+
"url": "http://localhost:8888"
6+
}
7+
],
8+
"info": {
9+
"version": "999-SNAPSHOT",
10+
"title": "Method GET one path param"
11+
},
12+
"paths": {
13+
"/users/{id}": {
14+
"get": {
15+
"parameters": [
16+
{
17+
"name": "id",
18+
"in": "path",
19+
"examples": {
20+
"alice": {
21+
"value": 1
22+
}
23+
}
24+
}
25+
],
26+
"responses": {
27+
"200": {
28+
"description": "Ok",
29+
"content": {
30+
"application/json": {
31+
"examples": {
32+
"quarkus": {
33+
"$ref": "#/components/schemas/User"
34+
}
35+
}
36+
}
37+
}
38+
}
39+
}
40+
}
41+
}
42+
},
43+
"components": {
44+
"schemas": {
45+
"User": {
46+
"type": "object",
47+
"properties": {
48+
"name": {
49+
"type": "string",
50+
"example": "Alice"
51+
},
52+
"age": {
53+
"type": "number",
54+
"example": 80
55+
}
56+
}
57+
}
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)