Skip to content

Commit 62cf54e

Browse files
committed
Improve documentation and DevUI
1 parent 3959998 commit 62cf54e

File tree

25 files changed

+245
-328
lines changed

25 files changed

+245
-328
lines changed

docs/modules/ROOT/pages/mock.adoc renamed to docs/modules/ROOT/pages/moqu.adoc

Lines changed: 83 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -87,52 +87,44 @@ Example:
8787

8888
[source,yaml]
8989
----
90-
"/frameworks/{id}":
90+
openapi: 3.0.3
91+
info:
92+
title: "Users API"
93+
version: 1.0.0-alpha
94+
servers:
95+
- url: http://localhost:8888
96+
paths:
97+
/users/{id}:
9198
get:
99+
description: Get user by ID
92100
parameters:
93101
- name: id
94102
in: path
103+
required: true
104+
schema:
105+
type: number
95106
examples:
96-
quarkus: <1>
107+
john: <1>
97108
value: 1 <2>
98109
responses:
99-
200:
110+
"200":
111+
description: Ok
100112
content:
101113
"application/json":
102114
examples:
103-
quarkus: <3>
104-
$ref: "#/components/schemas/Framework"
105-
description: Ok
106-
components:
107-
schemas:
108-
Framework:
109-
type: object
110-
properties:
111-
name:
112-
type: string
113-
example: "Quarkus"
114-
versions:
115-
type: array
116-
example: ["999-SNAPSHOT", "3.15.1"]
117-
supportsJava:
118-
type: boolean
119-
example: true
120-
contributors:
121-
type: integer
122-
example: 1000
123-
rules:
124-
type: object
125-
example:
126-
hello: world
115+
john: <3>
116+
value:
117+
'{"id": 1, "name": "John Doe"}'
127118
----
128119

129-
<1> Defines an example named `quarkus`.
130-
<2> Specifies that the request `/frameworks/1` will match the `quarkus` example.
131-
<3> Maps the response for the `quarkus` example.
120+
<1> Defines an example named `john` for request
121+
<2> Maps the request for path `/users/1` should use the response named as `john`
122+
<2> Defines an example named `john` for response
132123

133-
In other words, if the user accesses `/frameworks/1` (using the `quarkus` example), the response will be the one mapped for the `quarkus` example, which in this case references the Framework schema defined in the OpenAPI specification.
134124

135-
The Wiremock created using the OpenAPI specification above looks like this one:
125+
In other words, if the user accesses `/users/1`, the response will be the one mapped for the `john` example in response.
126+
127+
The Wiremock definition using the OpenAPI specification above, looks something like this:
136128

137129
[source,json]
138130
----
@@ -141,14 +133,71 @@ The Wiremock created using the OpenAPI specification above looks like this one:
141133
{
142134
"request": {
143135
"method": "GET",
144-
"url": "/frameworks/1"
136+
"url": "/users/1"
145137
},
146138
"response": {
147139
"status": 200,
148-
"body": "{\"supportsJava\":true,\"versions\":[\"999-SNAPSHOT\",\"3.15.1\"],\"name\":\"Quarkus\",\"rules\":{\"hello\":\"world\"},\"contributors\":1000}",
140+
"body": "{\"name\":\"John\",\"age\": 80}",
149141
"headers": {}
150142
}
151143
}
152144
]
153145
}
146+
----
147+
148+
=== Response as Schema
149+
150+
You can use the `$ref` to reference a schema for mapping a response:
151+
152+
[source,yaml]
153+
----
154+
paths:
155+
"/users/{id}":
156+
get:
157+
parameters:
158+
- name: id
159+
in: path
160+
examples:
161+
alice:
162+
value: 1
163+
responses:
164+
200:
165+
content:
166+
"application/json":
167+
examples:
168+
alice:
169+
$ref: "#/components/schemas/User"
170+
description: Ok
171+
components:
172+
schemas:
173+
User:
174+
type: object
175+
properties:
176+
name:
177+
type: string
178+
example: "Alice"
179+
age:
180+
type: number
181+
example: 80
182+
----
183+
184+
The Wiremock definition using the OpenAPI specification above, looks something like this:
185+
186+
[source,json]
187+
----
188+
{
189+
"mappings": [
190+
{
191+
"request": {
192+
"method": "GET",
193+
"url": "/users/1"
194+
},
195+
"response": {
196+
"status": 200,
197+
"body": "{\"name\":\"Alice\",\"age\":80}",
198+
"headers": {}
199+
}
200+
}
201+
]
202+
}
154203
----

moqu/deployment/src/main/java/io/quarkiverse/openapi/generator/devui/Mock.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

moqu/integration-tests/pom.xml

Lines changed: 0 additions & 99 deletions
This file was deleted.

moqu/integration-tests/src/main/java/io/quarkiverse/openapi/generator/moqu/GreetingResource.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

moqu/integration-tests/src/main/openapi/hello.yaml

Lines changed: 0 additions & 45 deletions
This file was deleted.

moqu/integration-tests/src/main/resources/application.properties

Whitespace-only changes.

moqu/integration-tests/src/test/java/io/quarkiverse/openapi/generator/moqu/GreetingResourceIT.java

Lines changed: 0 additions & 8 deletions
This file was deleted.

moqu/integration-tests/src/test/java/io/quarkiverse/openapi/generator/moqu/GreetingResourceTest.java

Lines changed: 0 additions & 21 deletions
This file was deleted.

moqu/deployment/pom.xml renamed to moqu/moqu-wiremock/deployment/pom.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,24 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<parent>
5-
<artifactId>quarkus-openapi-generator-moqu-parent</artifactId>
5+
<artifactId>quarkus-openapi-generator-moqu-wiremock-parent</artifactId>
66
<groupId>io.quarkiverse.openapi.generator</groupId>
77
<version>3.0.0-SNAPSHOT</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

12-
<artifactId>quarkus-openapi-generator-moqu-deployment</artifactId>
13-
<name>Quarkus - Openapi Generator - Moqu - Deployment</name>
12+
<artifactId>quarkus-openapi-generator-moqu-wiremock-deployment</artifactId>
13+
<name>Quarkus - Openapi Generator - Moqu - Wiremock - Deployment</name>
1414

1515
<dependencies>
16-
<!-- Quarkus -->
1716
<dependency>
1817
<groupId>io.quarkus</groupId>
1918
<artifactId>quarkus-core-deployment</artifactId>
2019
</dependency>
2120
<dependency>
2221
<groupId>io.quarkiverse.openapi.generator</groupId>
23-
<artifactId>quarkus-openapi-generator-moqu</artifactId>
22+
<artifactId>quarkus-openapi-generator-moqu-wiremock</artifactId>
2423
<version>${project.version}</version>
2524
</dependency>
2625
<dependency>

0 commit comments

Comments
 (0)