-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
55 deletions.
There are no files selected for viewing
80 changes: 25 additions & 55 deletions
80
wiremock/docs/modules/ROOT/pages/includes/getting-started.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,36 @@ | ||
The OpenAPI Generator Wiremock extensions maps OpenAPI specification and transform it into a https://wiremock.org/docs/stubbing/#bulk-importing-stubs[Bulk Importing Stubs] JSON file. | ||
|
||
[[request-matching-section]] | ||
== Request Matching | ||
Add the following dependency to your project's `pom.xml` file: | ||
|
||
To build the Wiremock https://wiremock.org/docs/request-matching/[Request Matching], this extension looks just to https://swagger.io/docs/specification/paths-and-operations/[Paths and Operations] OpenAPI fields. | ||
|
||
The OpenAPI path is converted to https://swagger.io/docs/specification/paths-and-operations/[path template] following the https://www.rfc-editor.org/rfc/rfc6570[RFC 6570] standard: | ||
[source,yaml] | ||
---- | ||
paths: | ||
/users/{userId}/cars/{carId}: | ||
[source,xml] | ||
---- | ||
|
||
Will be converted to: | ||
|
||
[source,json] | ||
<dependency> | ||
<groupId>io.quarkiverse.openapi.generator</groupId> | ||
<artifactId>quarkus-openapi-generator-wiremock</artifactId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
</dependency> | ||
---- | ||
{ | ||
"mappings": [ | ||
{ | ||
"request": { | ||
"urlPathTemplate": "/users/{userId}/cars/{cardId}" | ||
} | ||
} | ||
] | ||
} | ||
---- | ||
|
||
[[responses]] | ||
== Responses | ||
|
||
This extension will get the first Response status code Operation. For example, if you have the following OpenAPI Response: | ||
|
||
[source,yaml] | ||
---- | ||
responses: | ||
"500": | ||
description: "Internal Server Error" | ||
"200": | ||
description: "Ok" | ||
---- | ||
You will also need to add or update the `quarkus-maven-plugin` configuration with the following: | ||
|
||
The extension will generate the following Wiremock Response templating: | ||
WARNING: You probably already have this configuration if you created your application with https://code.quarkus.io/[Code Quarkus]. That said, double-check your configuration not to add another `plugin` entry. | ||
|
||
[source,json] | ||
[source,xml] | ||
---- | ||
{ | ||
"response": { | ||
"status": 200 | ||
} | ||
} | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<extensions>true</extensions> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
<goal>generate-code</goal> | ||
<goal>generate-code-tests</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
---- | ||
|
||
NOTE: If your Response entry does not contain `content` the Wiremock Stub `$.response.body` will be ignored. | ||
|
||
[[media-type]] | ||
== Media type | ||
|
||
IMPORTANT: This extension only supports `"application/json"` media type. | ||
|
||
[[schema-type]] | ||
|
||
For the first release, we chose to looks for the https://swagger.io/docs/specification/data-models/[Schema] `type` and supports only https://swagger.io/docs/specification/data-models/data-types/[Data Types] `object`, `string` and `integer` types. | ||
|
||
IMPORTANT: The root schema must have the type `object`. | ||
Now, create the directory `openapi` under your `src/main` path and add the OpenAPI spec files there. We support JSON, YAML and YML extensions. |