0.0.0 • Published 3 years ago
openapi-to-wiremock v0.0.0
OpenAPI to Wiremock
!!This is a work in progress!!
This is a command line tool that will translate OpenAPI spec to Wiremock mappings.
The runnable can be found in Maven Central or NPM.
Run it with:
npx openapi-to-wiremock --from openapi.yaml --to wiremock-mappings
The mappings can be run with the Wiremock NPM package:
npx wiremock --root-dir ./wiremock-mappings --port 8081
Usage
The tool can take the following arguments:
Usage: Main [Arguments]
Arguments:
-f, --from <string> The OpenAPI spec to translate from.
<string>: any string
Default:
-h, --help <argument-to-print-help-for> <argument-to-print-help-for>: an argument to print help for
Default: If no specific parameter is given the whole usage text is given
-mp, --mappings-prefix <string> A prefix added to mapping files. So
that you can have generated files in .
gitignore.
<string>: any string
Default: openapi-to-wiremock-
-t, --to <string> The folder where mappings should be
stored.
<string>: any string
Default: wiremock-mappings
In Node projects
Can be used in Node projects with the Wiremock NPM package:
{
"scripts": {
"create-mocks": "openapi-to-wiremock --from openapi.yaml --to wiremock-mappings",
"start-mock": "wiremock --root-dir ./wiremock-mappings --port 8081",
"mock": "npm run create-mocks && npm run start-mocks"
},
"devDependencies": {
"wiremock": "^a.b.c",
"openapi-to-wiremock": "^a.b.c"
}
}
In Java projects
This tool can be executed by the build tool as a command line execution.
npx openapi-to-wiremock --from openapi.yaml --to wiremock-mappings
The mappings can be used in Java projects by loading mappings from classpath:
final WireMockConfiguration wmConfig =
wireMockConfig() //
.port(8081);
final WireMockServer wireMockServer = new WireMockServer(wmConfig);
wireMockServer.loadMappingsUsing(new JsonFileMappingsSource(new ClasspathFileSource("wiremock-mappings")));
wireMockServer.start();
0.0.0
3 years ago