-
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
12 changed files
with
277 additions
and
1,255 deletions.
There are no files selected for viewing
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
4 changes: 3 additions & 1 deletion
4
...in/java/io/quarkiverse/openapi/wiremock/generator/deployment/wiremock/model/Response.java
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
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: quarkus-openapi-generator | ||
title: Openapi Generator | ||
version: dev | ||
nav: | ||
- modules/ROOT/nav.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
* xref:index.adoc[Quarkus - Openapi Generator - Wiremock] |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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]] | ||
=== Request Matching | ||
|
||
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. | ||
|
||
[[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" | ||
---- | ||
|
||
The extension will generate the following Wiremock Response templating: | ||
|
||
[source,json] | ||
---- | ||
{ | ||
"response": { | ||
"status": 500 | ||
} | ||
} | ||
---- | ||
|
||
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. | ||
|
81 changes: 81 additions & 0 deletions
81
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
Add the following dependency to your project's `pom.xml` file: | ||
|
||
[source,xml] | ||
---- | ||
<dependency> | ||
<groupId>io.quarkiverse.openapi.generator</groupId> | ||
<artifactId>quarkus-openapi-generator-wiremock</artifactId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
</dependency> | ||
---- | ||
|
||
You will also need to add or update the `quarkus-maven-plugin` configuration with the following: | ||
|
||
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,xml] | ||
---- | ||
<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> | ||
---- | ||
|
||
Now, create the directory `openapi` under your `src/main/` path and add the OpenAPI spec files there. We support JSON, YAML and YML extensions. | ||
|
||
[source,yaml] | ||
---- | ||
openapi: 3.0.2 | ||
info: | ||
title: Simple OpenAPI | ||
version: 0.0.1-SNAPSHOT | ||
paths: | ||
/users: | ||
get: | ||
responses: | ||
"200": | ||
description: "OpenAPI Generator Wiremock Success" | ||
content: | ||
"application/json": | ||
schema: | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
example: 1 | ||
name: | ||
type: string | ||
example: "John Doe" | ||
---- | ||
|
||
Run `mvn compile` to generate your classes in `target/generated-sources/wiremock/mappings` path: | ||
|
||
[source,json] | ||
---- | ||
{ | ||
"mappings": [ | ||
{ | ||
"request": { | ||
"urlPathTemplate": "/users", | ||
"method": "GET" | ||
}, | ||
"response": { | ||
"status": 200, | ||
"body": "{\"name\":\"John Doe\",\"id\":1}" | ||
} | ||
} | ||
] | ||
} | ||
---- | ||
|
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
= Quarkus - Openapi Generator - Wiremock | ||
:extension-status: preview | ||
|
||
|
||
WARNING: This is the instructions for the latest SNAPSHOT version (main branch). Please, see the https://docs.quarkiverse.io/quarkus-openapi-generator/dev/index.html[latest **released** documentation] if you are looking for instructions. | ||
Quarkus' extension for generation of server Stubs based on OpenAPI specification files. | ||
|
||
This extension is for Wiremock Stubs generation for Dev Services only. | ||
|
||
**Want to contribute? Great!** We try to make it easy, and all contributions, even the smaller ones, are more than welcome. This includes bug reports, fixes, documentation, examples... But first, read https://github.com/quarkiverse/quarkus-openapi-generator/blob/main/CONTRIBUTING.md[this page]. | ||
|
||
[[getting-started]] | ||
== Getting Started | ||
|
||
include::./includes/getting-started.adoc[leveloffset=+1, opts=optional] | ||
|
||
[[features]] | ||
== Wiremock Extension Features | ||
|
||
include::./includes/features.adoc[leveloffset=+1, opts=optional] | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?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> | ||
<parent> | ||
<artifactId>quarkus-openapi-generator-wiremock-parent</artifactId> | ||
<groupId>io.quarkiverse.openapi.generator</groupId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>quarkus-openapi-generator-wiremock-docs</artifactId> | ||
<dependencies> | ||
<!-- Make sure the doc is built after the other artifacts --> | ||
<dependency> | ||
<groupId>io.quarkiverse.openapi.generator</groupId> | ||
<artifactId>quarkus-openapi-generator-deployment</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>it.ozimov</groupId> | ||
<artifactId>yaml-properties-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>initialize</phase> | ||
<goals> | ||
<goal>read-project-properties</goal> | ||
</goals> | ||
<configuration> | ||
<files> | ||
<file>${project.basedir}/../../.github/project.yml</file> | ||
</files> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>copy-resources</id> | ||
<phase>generate-resources</phase> | ||
<goals> | ||
<goal>copy-resources</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${project.basedir}/modules/ROOT/pages/includes/</outputDirectory> | ||
<resources> | ||
<resource> | ||
<directory>${project.basedir}/../target/asciidoc/generated/config/</directory> | ||
<include>quarkus-openapi-generator.adoc</include> | ||
<filtering>false</filtering> | ||
</resource> | ||
</resources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.asciidoctor</groupId> | ||
<artifactId>asciidoctor-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Oops, something went wrong.