Replies: 5 comments 15 replies
-
Sounds good to me. Questions:
|
Beta Was this translation helpful? Give feedback.
-
@hbelmiro not sure if the generator supports test classes, I believe it does. We can ask on Zulip. +1 for generating those stubs, but on a separate module/extension. Is that the proposal? |
Beta Was this translation helpful? Give feedback.
-
RFC: OpenAPI to WiremockStatus: In ProgressObjectiveThe objective of this proposal is to establish a method for converting OpenAPI specifications into Wiremock stubs, MotivationPresently, there lacks a straightforward approach to translate an OpenAPI specification into Wiremock stubs (in either For Quarkus users aiming to develop integration tests, the process involves a considerable time investment or an User BenefitThe proposed solution aims to provide Quarkus users with a streamlined process for generating Wiremock stubs dire Design ProposalThe proposal initially suggests providing the client with only two methods: Initial interfaceThe proposal is initially give to the client only two methods: interface OpenApiWiremock {
String generate(final String openApiSpec);
String generate(final String openApiSpec, final OutputMode outputMode);
} Initially we will only supports JSON Wiremock stubs. If the client sets OutputMode.JAVA_STUB, they will receive the following Java code based into OpenAPI specification. public class QuarkusOpenApiWiremockStubs {
/** ... */
} If the user sets OutputMode.JSON_STUB, they will receive the following JSON: {
"mappings": [
{
"request": {
"method": "GET",
"url": "/applications"
},
"response": {
"status": 200,
"body": "Hello from Quarkus"
}
}
]
} Strategy to Selecting the appropriate Wiremock StubsFirst, we need to know that the library will respect the Content Negotiation, it means that we will add to It will serve to differentiate multiples Stubs, if the Media Type is not valid the library will ignore the
Stub generation will be based on the following rules with descending priorities: 1. 2xx request with example in parameters and example in responses. parameters:
- name: appName
in: query
schema:
type: string
example: 62e61768-90bb-11ee-b9d1-0242ac120002
responses:
"200":
description: Get
content:
"application/json":
schema:
type: object
properties:
id:
type: string
description: The Application ID
example: 62e61768-90bb-11ee-b9d1-0242ac120002
name:
type: string
description: The Application Name
example: Platform Core Application In this case the stub will be: public class QuarkusOpenApiWiremockStubs {
private static final String QUARKUS_APPLICATIONS_APP_ID_GET_RESPONSE = "{ \"id\": \"62e61768-90bb-11ee-b9d1-0242ac120002\", \"name\": \"Platform Core Application\"}";
public static final MappingBuilder QUARKUS_APPLICATIONS_APP_ID_GET = WireMock.get(WireMock.urlEqualTo("/applications/62e61768-90bb-11ee-b9d1-0242ac120002"))
.willReturn(aResponse().withStatus(200).withBody(QUARKUS_APPLICATIONS_APP_ID_GET_RESPONSE));
}
GET{
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/xml": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
},
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Pet not found"
},
"405": {
"description": "Validation exception"
}
}
} Having in mind that the user wants to |
Beta Was this translation helpful? Give feedback.
-
H @hbelmiro @ricardozanini The WireMock for Java was delivered 4 days ago, se here: OpenAPITools/openapi-generator@092463a 😢 |
Beta Was this translation helpful? Give feedback.
-
@mcruzdev I think we can then review this issue/discussion to upgrade the inner generator and verify if it works. If so, we add a note in our docs. 👍 |
Beta Was this translation helpful? Give feedback.
-
Introduction
Hi everyone, I want to share an old idea here.
I talked with @hbelmiro one time about this idea for helping in contract testing and integration tests, but I decided to propose this idea later because I am new in the project and I went to learn more about. I saw today that there is an extension called quarkus-wiremock and this idea can help both projects.
Propose
The idea is to generate Wiremock specification from OpenAPI specifications. Finding through the internet I just found two ways to do it, the first one is using Wiremock Cloud (paid) and using a CLI writen in Javascript called Prism is necessary to install NodeJS and the integration could be hard.
There is no way to it with another way (I could be wrong).
Features
Given a OpenAPI spec:
Generate an Wiremock stub:
What do you think? @gastaldi @hbelmiro @ricardozanini
Beta Was this translation helpful? Give feedback.
All reactions