[kotlin-wiremock] New generator for generating WireMock stubs using Kotlin (#18705)

* [kotlin] Target correct library in jvm-spring-webclient sample

* [kotlin] Fixed warning in jvm-spring-restclient

* [kotlin-wiremock] added generator and sample

* [kotlin-wiremock] First version with petstore

* [kotlin-wiremock] Small typo

* [kotlin-wiremock] Added echo-api test

* [kotlin-wiremock] Split stub and stub builder

* [kotlin-wiremock] Added default values and jackson annotations to models

* [kotlin-wiremock] Small default value fix

* [kotlin-wiremock] Use Gradle wrapper version in samples-kotlin-server GitHub workflow

* [kotlin-wiremock] Added default artifact name

* [kotlin-wiremock] Added kotlin docs

* [kotlin-wiremock] Fixed capitalization in kotlin docs

* [kotlin-wiremock] Added kotlin-wiremock echo_api sample to GitHub workflow

* [kotlin-wiremock] Added new generator to README.md

* [kotlin-wiremock] Generated docs

* [kotlin-wiremock] Generated docs (missed commit)

* [kotlin-wiremock] Explicit Gradle wrapper version in kotlin server generators

* Revert "[kotlin-wiremock] Explicit Gradle wrapper version in kotlin server generators"

This reverts commit 71e1c47def93fdcb9c7e4efe999fc34e21d7518c.

* [kotlin-wiremock] Revert Gradle in workflow samples-kotlin-server and moved kotlin-wiremock samples to separate workflow

* [kotlin-wiremock] Use Java 11 instead of Java 8

* [kotlin-wiremock] ensure-up-to-date
This commit is contained in:
Stefan Koppier 2024-05-21 07:53:44 +02:00 committed by GitHub
parent 9a35914f0c
commit 27120357aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
78 changed files with 5930 additions and 3 deletions

View File

@ -0,0 +1,44 @@
name: Samples Kotlin WireMock
on:
push:
branches:
- samples/server/petstore/kotlin-wiremock/**
- samples/server/echo_api/kotlin-wiremock/**
pull_request:
paths:
- samples/server/petstore/kotlin-wiremock/**
- samples/server/echo_api/kotlin-wiremock/**
jobs:
build:
name: Build Kotlin WireMock
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sample:
- samples/server/petstore/kotlin-wiremock
- samples/server/echo_api/kotlin-wiremock
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 11
- name: Cache maven dependencies
uses: actions/cache@v4
env:
cache-name: maven-repository
with:
path: |
~/.gradle
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
- name: Install Gradle wrapper
uses: eskatos/gradle-command-action@v3
with:
build-root-directory: ${{ matrix.sample }}
arguments: wrapper
- name: Build
working-directory: ${{ matrix.sample }}
run: ./gradlew build -x test

View File

@ -1091,6 +1091,7 @@ Here is a list of template creators:
* Kotlin (Spring Boot): @dr4ke616
* Kotlin (Vertx): @Wooyme
* Kotlin (JAX-RS): @anttileppa
* Kotlin WireMock: @stefankoppier
* NodeJS Express: @YishTish
* PHP Flight: @daniel-sc
* PHP Laravel: @renepardon

View File

@ -0,0 +1,4 @@
generatorName: kotlin-wiremock
outputDir: samples/server/echo_api/kotlin-wiremock
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/echo_api.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-wiremock

View File

@ -0,0 +1,4 @@
generatorName: kotlin-wiremock
outputDir: samples/server/petstore/kotlin-wiremock
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-wiremock

View File

@ -120,6 +120,7 @@ The following generators are available:
* [kotlin-server](generators/kotlin-server.md)
* [kotlin-spring](generators/kotlin-spring.md)
* [kotlin-vertx (beta)](generators/kotlin-vertx.md)
* [kotlin-wiremock (beta)](generators/kotlin-wiremock.md)
* [nodejs-express-server (beta)](generators/nodejs-express-server.md)
* [php-flight (experimental)](generators/php-flight.md)
* [php-laravel](generators/php-laravel.md)

View File

@ -11,7 +11,7 @@ title: Documentation for the java-wiremock Generator
| generator type | SERVER | |
| generator language | Java | |
| generator default templating engine | mustache | |
| helpTxt | Generates Java Wiremock stubs, requests and responses samples. | |
| helpTxt | Generates Java WireMock stubs, requests and responses samples. | |
## CONFIG OPTIONS
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.

View File

@ -0,0 +1,277 @@
---
title: Documentation for the kotlin-wiremock Generator
---
## METADATA
| Property | Value | Notes |
| -------- | ----- | ----- |
| generator name | kotlin-wiremock | pass this to the generate command after -g |
| generator stability | BETA | |
| generator type | SERVER | |
| generator language | Kotlin | |
| generator default templating engine | mustache | |
| helpTxt | Generates Kotlin WireMock stub request and response samples. | |
## CONFIG OPTIONS
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|apiSuffix|suffix for api classes| |Api|
|artifactId|Generated artifact id (name of jar).| |null|
|artifactVersion|Generated artifact's package version.| |1.0.0|
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |original|
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|modelMutable|Create mutable models| |false|
|packageName|Generated artifact package name.| |org.openapitools|
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|serializableModel|boolean - toggle "implements Serializable" for generated models| |null|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |null|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |null|
|sourceFolder|source folder for generated code| |src/main/kotlin|
## IMPORT MAPPING
| Type/Alias | Imports |
| ---------- | ------- |
|BigDecimal|java.math.BigDecimal|
|Date|java.time.LocalDate|
|DateTime|java.time.OffsetDateTime|
|File|java.io.File|
|LocalDate|java.time.LocalDate|
|LocalDateTime|java.time.LocalDateTime|
|LocalTime|java.time.LocalTime|
|Timestamp|java.sql.Timestamp|
|URI|java.net.URI|
|UUID|java.util.UUID|
## INSTANTIATION TYPES
| Type/Alias | Instantiated By |
| ---------- | --------------- |
|array|kotlin.collections.ArrayList|
|list|kotlin.collections.ArrayList|
|map|kotlin.collections.HashMap|
## LANGUAGE PRIMITIVES
<ul class="column-ul">
<li>kotlin.Array</li>
<li>kotlin.Boolean</li>
<li>kotlin.Byte</li>
<li>kotlin.ByteArray</li>
<li>kotlin.Char</li>
<li>kotlin.Double</li>
<li>kotlin.Float</li>
<li>kotlin.Int</li>
<li>kotlin.Long</li>
<li>kotlin.Short</li>
<li>kotlin.String</li>
<li>kotlin.collections.List</li>
<li>kotlin.collections.Map</li>
<li>kotlin.collections.MutableList</li>
<li>kotlin.collections.MutableMap</li>
<li>kotlin.collections.MutableSet</li>
<li>kotlin.collections.Set</li>
</ul>
## RESERVED WORDS
<ul class="column-ul">
<li>ApiResponse</li>
<li>abstract</li>
<li>actual</li>
<li>annotation</li>
<li>as</li>
<li>break</li>
<li>class</li>
<li>companion</li>
<li>const</li>
<li>constructor</li>
<li>continue</li>
<li>contract</li>
<li>crossinline</li>
<li>data</li>
<li>delegate</li>
<li>do</li>
<li>dynamic</li>
<li>else</li>
<li>enum</li>
<li>expect</li>
<li>external</li>
<li>false</li>
<li>field</li>
<li>final</li>
<li>finally</li>
<li>for</li>
<li>fun</li>
<li>if</li>
<li>import</li>
<li>in</li>
<li>infix</li>
<li>init</li>
<li>inline</li>
<li>inner</li>
<li>interface</li>
<li>internal</li>
<li>is</li>
<li>it</li>
<li>lateinit</li>
<li>noinline</li>
<li>null</li>
<li>object</li>
<li>open</li>
<li>operator</li>
<li>out</li>
<li>override</li>
<li>package</li>
<li>param</li>
<li>private</li>
<li>property</li>
<li>protected</li>
<li>public</li>
<li>receiver</li>
<li>reified</li>
<li>return</li>
<li>sealed</li>
<li>setparam</li>
<li>super</li>
<li>suspend</li>
<li>tailrec</li>
<li>this</li>
<li>throw</li>
<li>true</li>
<li>try</li>
<li>typealias</li>
<li>typeof</li>
<li>val</li>
<li>value</li>
<li>var</li>
<li>vararg</li>
<li>when</li>
<li>where</li>
<li>while</li>
</ul>
## FEATURE SET
### Client Modification Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasePath|✗|ToolingExtension
|Authorizations|✗|ToolingExtension
|UserAgent|✗|ToolingExtension
|MockServer|✗|ToolingExtension
### Data Type Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Custom|✗|OAS2,OAS3
|Int32|✓|OAS2,OAS3
|Int64|✓|OAS2,OAS3
|Float|✓|OAS2,OAS3
|Double|✓|OAS2,OAS3
|Decimal|✓|ToolingExtension
|String|✓|OAS2,OAS3
|Byte|✓|OAS2,OAS3
|Binary|✓|OAS2,OAS3
|Boolean|✓|OAS2,OAS3
|Date|✓|OAS2,OAS3
|DateTime|✓|OAS2,OAS3
|Password|✓|OAS2,OAS3
|File|✓|OAS2
|Uuid|✗|
|Array|✓|OAS2,OAS3
|Null|✗|OAS3
|AnyType|✗|OAS2,OAS3
|Object|✓|OAS2,OAS3
|Maps|✓|ToolingExtension
|CollectionFormat|✓|OAS2
|CollectionFormatMulti|✓|OAS2
|Enum|✓|OAS2,OAS3
|ArrayOfEnum|✓|ToolingExtension
|ArrayOfModel|✓|ToolingExtension
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|ArrayOfCollectionOfModel|✓|ToolingExtension
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|MapOfEnum|✓|ToolingExtension
|MapOfModel|✓|ToolingExtension
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|MapOfCollectionOfModel|✓|ToolingExtension
|MapOfCollectionOfEnum|✓|ToolingExtension
### Documentation Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Readme|✗|ToolingExtension
|Model|✓|ToolingExtension
|Api|✓|ToolingExtension
### Global Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Host|✓|OAS2,OAS3
|BasePath|✓|OAS2,OAS3
|Info|✓|OAS2,OAS3
|Schemes|✗|OAS2,OAS3
|PartialSchemes|✓|OAS2,OAS3
|Consumes|✓|OAS2
|Produces|✓|OAS2
|ExternalDocumentation|✓|OAS2,OAS3
|Examples|✓|OAS2,OAS3
|XMLStructureDefinitions|✗|OAS2,OAS3
|MultiServer|✗|OAS3
|ParameterizedServer|✗|OAS3
|ParameterStyling|✗|OAS3
|Callbacks|✓|OAS3
|LinkObjects|✗|OAS3
### Parameter Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Path|✓|OAS2,OAS3
|Query|✓|OAS2,OAS3
|Header|✓|OAS2,OAS3
|Body|✓|OAS2
|FormUnencoded|✓|OAS2
|FormMultipart|✓|OAS2
|Cookie|✓|OAS3
### Schema Support Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Simple|✓|OAS2,OAS3
|Composite|✓|OAS2,OAS3
|Polymorphism|✓|OAS2,OAS3
|Union|✗|OAS3
|allOf|✗|OAS2,OAS3
|anyOf|✗|OAS3
|oneOf|✗|OAS3
|not|✗|OAS3
### Security Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasicAuth|✓|OAS2,OAS3
|ApiKey|✓|OAS2,OAS3
|OpenIDConnect|✗|OAS3
|BearerToken|✓|OAS3
|OAuth2_Implicit|✓|OAS2,OAS3
|OAuth2_Password|✓|OAS2,OAS3
|OAuth2_ClientCredentials|✓|OAS2,OAS3
|OAuth2_AuthorizationCode|✓|OAS2,OAS3
|SignatureAuth|✗|OAS3
|AWSV4Signature|✗|ToolingExtension
### Wire Format Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|JSON|✓|OAS2,OAS3
|XML|✓|OAS2,OAS3
|PROTOBUF|✗|ToolingExtension
|Custom|✗|OAS2,OAS3

View File

@ -767,7 +767,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), LOWERCASE_FIRST_LETTER);
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize("call_" + operationId), LOWERCASE_FIRST_LETTER);
operationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
}

View File

@ -23,7 +23,7 @@ public class JavaWiremockServerCodegen extends AbstractJavaCodegen implements Co
}
public String getHelp() {
return "Generates Java Wiremock stubs, requests and responses samples.";
return "Generates Java WireMock stubs, requests and responses samples.";
}
public JavaWiremockServerCodegen() {

View File

@ -0,0 +1,138 @@
package org.openapitools.codegen.languages;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.meta.features.GlobalFeature;
import org.openapitools.codegen.meta.features.ParameterFeature;
import org.openapitools.codegen.meta.features.SecurityFeature;
import org.openapitools.codegen.meta.features.WireFormatFeature;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import java.io.File;
import java.util.EnumSet;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class KotlinWiremockServerCodegen extends AbstractKotlinCodegen {
protected static final String VENDOR_EXTENSION_BASE_NAME_LITERAL = "x-base-name-literal";
@Override
public CodegenType getTag() {
return CodegenType.SERVER;
}
@Override
public String getName() {
return "kotlin-wiremock";
}
@Override
public String getHelp() {
return "Generates Kotlin WireMock stub request and response samples.";
}
public KotlinWiremockServerCodegen() {
super();
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.BETA)
.build();
setArtifactId("kotlin-wiremock");
setApiPackage(packageName + ".apis");
setModelPackage(packageName + ".models");
}
@Override
public void processOpts() {
super.processOpts();
modifyFeatureSet(features -> features
.securityFeatures(EnumSet.allOf(SecurityFeature.class))
.excludeWireFormatFeatures(
WireFormatFeature.XML,
WireFormatFeature.PROTOBUF
)
.excludeGlobalFeatures(
GlobalFeature.XMLStructureDefinitions,
GlobalFeature.Callbacks,
GlobalFeature.LinkObjects
)
.excludeParameterFeatures(
ParameterFeature.Cookie
)
);
typeMapping.put("array", "kotlin.collections.List");
reservedWords.remove("ApiResponse");
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage());
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage());
apiTemplateFiles.put("api-stub.mustache", "Stubs.kt");
apiTemplateFiles.put("api-stub-builder.mustache", "StubBuilders.kt");
modelTemplateFiles.put("model.mustache", ".kt");
supportingFiles.addAll(List.of(
new SupportingFile("build.gradle.kts.mustache", "", "build.gradle.kts"),
new SupportingFile("settings.gradle.kts.mustache", "", "settings.gradle.kts"),
new SupportingFile("libs.versions.toml.mustache", "gradle", "libs.versions.toml"),
new SupportingFile("gradlew.mustache", "", "gradlew"),
new SupportingFile("gradlew.bat.mustache", "", "gradlew.bat"),
new SupportingFile("gradle-wrapper.properties.mustache", "gradle" + File.separator + "wrapper", "gradle-wrapper.properties"),
new SupportingFile("gradle-wrapper.jar", "gradle" + File.separator + "wrapper", "gradle-wrapper.jar")
)
);
supportingFiles.add(
new SupportingFile(".gitignore.mustache", "", ".gitignore")
);
}
@Override
public ModelsMap postProcessModels(ModelsMap objs) {
var objects = super.postProcessModels(objs);
for (ModelMap model : objects.getModels()) {
var cm = model.getModel();
var vars = Stream.of(
cm.vars,
cm.allVars,
cm.optionalVars,
cm.requiredVars,
cm.readOnlyVars,
cm.readWriteVars,
cm.parentVars
)
.flatMap(List::stream)
.collect(Collectors.toList());
for (CodegenProperty var : vars) {
var.vendorExtensions.put(VENDOR_EXTENSION_BASE_NAME_LITERAL, var.baseName.replace("$", "\\$"));
}
}
return objects;
}
@Override
public void postProcess() {
System.out.println("################################################################################");
System.out.println("# Thanks for using OpenAPI Generator. #");
System.out.println("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
System.out.println("# https://opencollective.com/openapi_generator/donate #");
System.out.println("# #");
System.out.println("# This generator's contributed by Stefan Koppier (https://github.com/stefankoppier)#");
System.out.println("################################################################################");
}
}

View File

@ -43,6 +43,7 @@ org.openapitools.codegen.languages.KotlinClientCodegen
org.openapitools.codegen.languages.KotlinServerCodegen
org.openapitools.codegen.languages.KotlinSpringServerCodegen
org.openapitools.codegen.languages.KotlinVertxServerCodegen
org.openapitools.codegen.languages.KotlinWiremockServerCodegen
org.openapitools.codegen.languages.KtormSchemaCodegen
org.openapitools.codegen.languages.HaskellHttpClientCodegen
org.openapitools.codegen.languages.HaskellServantCodegen

View File

@ -0,0 +1,106 @@
./bin/
# Created by https://www.gitignore.io/api/java,intellij,gradle
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Gradle ###
.gradle
/build/
# Ignore Gradle GUI config
gradle-app.setting
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
# Cache of project
.gradletasknamecache
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties
# End of https://www.gitignore.io/api/java,intellij,gradle

View File

@ -0,0 +1,78 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package {{apiPackage}}
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import {{modelPackage}}.*
{{#operations}}
{{#operation}}
/**
* Builder for WireMock stubs of operation {{operationId}}.
*/
class {{operationIdCamelCase}}StubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
{{#responses}}
{{^wildcard}}
/**
* Let the stub for {{operationId}} respond with HTTP status code {{code}}.
*
{{#returnType}}
* @param body response body for the [MappingBuilder].
{{/returnType}}
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith{{code}}(
{{#returnType}}
body: {{{.}}},
{{/returnType}}
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus({{code}})
{{#returnType}}
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
{{/returnType}}
.configurer()
)
{{/wildcard}}
{{/responses}}
/**
* Let the stub for {{operationId}} respond with HTTP status code [code].
*
{{#returnType}}
* @param body response body for the [MappingBuilder].
{{/returnType}}
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
{{/operation}}
{{/operations}}

View File

@ -0,0 +1,47 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package {{apiPackage}}
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import {{modelPackage}}.*
{{#operations}}
/**
* WireMock stub request builder.
*/
open class {{classname}}Stubs(private val objectMapper: ObjectMapper) {
{{#operation}}
/**
* Construct a stub for the operation {{operationId}}.
*
{{#pathParams}}
* @param {{paramName}} path parameter {{paramName}} pattern.
{{/pathParams}}
{{#queryParams}}
* @param {{paramName}} query parameter {{paramName}} pattern.
{{/queryParams}}
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [{{operationIdCamelCase}}StubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun {{operationId}}({{#pathParams}}{{paramName}}: StringValuePattern, {{/pathParams}}{{#queryParams}}{{paramName}}: StringValuePattern? = null, {{/queryParams}}configurer: MappingBuilder.() -> MappingBuilder = { this }): {{operationIdCamelCase}}StubBuilder =
{{operationIdCamelCase}}StubBuilder(objectMapper, {{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}(urlPathTemplate("{{path}}"))
{{#pathParams}}
.withPathParam("{{paramName}}", {{paramName}})
{{/pathParams}}
{{#queryParams}}
.apply { {{paramName}}?.let { withQueryParam("{{paramName}}", it) } }
{{/queryParams}}
.configurer()
)
{{/operation}}
}
{{/operations}}

View File

@ -0,0 +1,21 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
group = "{{groupId}}"
version = "{{artifactVersion}}"
tasks.wrapper {
gradleVersion = "8.7"
}
plugins {
alias(libs.plugins.kotlin.jvm)
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
dependencies {
implementation(libs.wiremock)
implementation(libs.jackson.databind)
}

View File

@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -0,0 +1,249 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View File

@ -0,0 +1,249 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View File

@ -0,0 +1,10 @@
[versions]
kotlin = "1.9.23"
wiremock = "3.5.4"
[libraries]
wiremock = { module = "org.wiremock:wiremock", version.ref = "wiremock" }
jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version = "2.17.1" }
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

View File

@ -0,0 +1,33 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package {{modelPackage}}
import com.fasterxml.jackson.annotation.JsonProperty
{{#models}}
{{#model}}
{{#isEnum}}
enum class {{classname}} {
{{#allowableValues}}
{{#enumVars}}
@JsonProperty(value = {{#lambda.doublequote}}{{{value}}}{{/lambda.doublequote}}) {{&name}},
{{/enumVars}}
{{/allowableValues}}
}
{{/isEnum}}
{{^isEnum}}
data class {{classname}}(
{{#allVars}}
@field:JsonProperty("{{{vendorExtensions.x-base-name-literal}}}")
val {{{name}}}: {{{dataType}}}{{^required}}?{{/required}}{{!
!}}{{^required}} = {{^defaultValue}}null{{/defaultValue}}{{#defaultValue}}{{{.}}}{{/defaultValue}}{{/required}}{{!
}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}},
{{/allVars}}
)
{{/isEnum}}
{{/model}}
{{/models}}

View File

@ -0,0 +1,7 @@
rootProject.name = "{{artifactId}}"
dependencyResolutionManagement {
repositories {
mavenCentral()
}
}

View File

@ -0,0 +1,106 @@
./bin/
# Created by https://www.gitignore.io/api/java,intellij,gradle
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Gradle ###
.gradle
/build/
# Ignore Gradle GUI config
gradle-app.setting
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
# Cache of project
.gradletasknamecache
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties
# End of https://www.gitignore.io/api/java,intellij,gradle

View File

@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -0,0 +1,29 @@
.gitignore
build.gradle.kts
gradle/libs.versions.toml
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
gradlew.bat
settings.gradle.kts
src/main/kotlin/org/openapitools/apis/AuthApiStubBuilders.kt
src/main/kotlin/org/openapitools/apis/AuthApiStubs.kt
src/main/kotlin/org/openapitools/apis/BodyApiStubBuilders.kt
src/main/kotlin/org/openapitools/apis/BodyApiStubs.kt
src/main/kotlin/org/openapitools/apis/FormApiStubBuilders.kt
src/main/kotlin/org/openapitools/apis/FormApiStubs.kt
src/main/kotlin/org/openapitools/apis/HeaderApiStubBuilders.kt
src/main/kotlin/org/openapitools/apis/HeaderApiStubs.kt
src/main/kotlin/org/openapitools/apis/PathApiStubBuilders.kt
src/main/kotlin/org/openapitools/apis/PathApiStubs.kt
src/main/kotlin/org/openapitools/apis/QueryApiStubBuilders.kt
src/main/kotlin/org/openapitools/apis/QueryApiStubs.kt
src/main/kotlin/org/openapitools/models/Bird.kt
src/main/kotlin/org/openapitools/models/Category.kt
src/main/kotlin/org/openapitools/models/DefaultValue.kt
src/main/kotlin/org/openapitools/models/NumberPropertiesOnly.kt
src/main/kotlin/org/openapitools/models/Pet.kt
src/main/kotlin/org/openapitools/models/Query.kt
src/main/kotlin/org/openapitools/models/StringEnumRef.kt
src/main/kotlin/org/openapitools/models/Tag.kt
src/main/kotlin/org/openapitools/models/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.kt

View File

@ -0,0 +1 @@
7.6.0-SNAPSHOT

View File

@ -0,0 +1,21 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
group = "org.openapitools"
version = "1.0.0"
tasks.wrapper {
gradleVersion = "8.7"
}
plugins {
alias(libs.plugins.kotlin.jvm)
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
dependencies {
implementation(libs.wiremock)
implementation(libs.jackson.databind)
}

View File

@ -0,0 +1,10 @@
[versions]
kotlin = "1.9.23"
wiremock = "3.5.4"
[libraries]
wiremock = { module = "org.wiremock:wiremock", version.ref = "wiremock" }
jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version = "2.17.1" }
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

View File

@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -0,0 +1,249 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View File

@ -0,0 +1,249 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View File

@ -0,0 +1,7 @@
rootProject.name = "kotlin-wiremock"
dependencyResolutionManagement {
repositories {
mavenCentral()
}
}

View File

@ -0,0 +1,109 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* Builder for WireMock stubs of operation testAuthHttpBasic.
*/
class TestAuthHttpBasicStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testAuthHttpBasic respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testAuthHttpBasic respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation testAuthHttpBearer.
*/
class TestAuthHttpBearerStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testAuthHttpBearer respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testAuthHttpBearer respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}

View File

@ -0,0 +1,42 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* WireMock stub request builder.
*/
open class AuthApiStubs(private val objectMapper: ObjectMapper) {
/**
* Construct a stub for the operation testAuthHttpBasic.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestAuthHttpBasicStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testAuthHttpBasic(configurer: MappingBuilder.() -> MappingBuilder = { this }): TestAuthHttpBasicStubBuilder =
TestAuthHttpBasicStubBuilder(objectMapper, post(urlPathTemplate("/auth/http/basic"))
.configurer()
)
/**
* Construct a stub for the operation testAuthHttpBearer.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestAuthHttpBearerStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testAuthHttpBearer(configurer: MappingBuilder.() -> MappingBuilder = { this }): TestAuthHttpBearerStubBuilder =
TestAuthHttpBearerStubBuilder(objectMapper, post(urlPathTemplate("/auth/http/bearer"))
.configurer()
)
}

View File

@ -0,0 +1,391 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* Builder for WireMock stubs of operation testBinaryGif.
*/
class TestBinaryGifStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testBinaryGif respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: java.io.File,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testBinaryGif respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation testBodyApplicationOctetstreamBinary.
*/
class TestBodyApplicationOctetstreamBinaryStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testBodyApplicationOctetstreamBinary respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testBodyApplicationOctetstreamBinary respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation testBodyMultipartFormdataArrayOfBinary.
*/
class TestBodyMultipartFormdataArrayOfBinaryStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testBodyMultipartFormdataArrayOfBinary respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testBodyMultipartFormdataArrayOfBinary respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation testBodyMultipartFormdataSingleBinary.
*/
class TestBodyMultipartFormdataSingleBinaryStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testBodyMultipartFormdataSingleBinary respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testBodyMultipartFormdataSingleBinary respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation testEchoBodyFreeFormObjectResponseString.
*/
class TestEchoBodyFreeFormObjectResponseStringStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testEchoBodyFreeFormObjectResponseString respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testEchoBodyFreeFormObjectResponseString respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation testEchoBodyPet.
*/
class TestEchoBodyPetStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testEchoBodyPet respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: Pet,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testEchoBodyPet respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation testEchoBodyPetResponseString.
*/
class TestEchoBodyPetResponseStringStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testEchoBodyPetResponseString respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testEchoBodyPetResponseString respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation testEchoBodyTagResponseString.
*/
class TestEchoBodyTagResponseStringStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testEchoBodyTagResponseString respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testEchoBodyTagResponseString respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}

View File

@ -0,0 +1,108 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* WireMock stub request builder.
*/
open class BodyApiStubs(private val objectMapper: ObjectMapper) {
/**
* Construct a stub for the operation testBinaryGif.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestBinaryGifStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testBinaryGif(configurer: MappingBuilder.() -> MappingBuilder = { this }): TestBinaryGifStubBuilder =
TestBinaryGifStubBuilder(objectMapper, post(urlPathTemplate("/binary/gif"))
.configurer()
)
/**
* Construct a stub for the operation testBodyApplicationOctetstreamBinary.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestBodyApplicationOctetstreamBinaryStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testBodyApplicationOctetstreamBinary(configurer: MappingBuilder.() -> MappingBuilder = { this }): TestBodyApplicationOctetstreamBinaryStubBuilder =
TestBodyApplicationOctetstreamBinaryStubBuilder(objectMapper, post(urlPathTemplate("/body/application/octetstream/binary"))
.configurer()
)
/**
* Construct a stub for the operation testBodyMultipartFormdataArrayOfBinary.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestBodyMultipartFormdataArrayOfBinaryStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testBodyMultipartFormdataArrayOfBinary(configurer: MappingBuilder.() -> MappingBuilder = { this }): TestBodyMultipartFormdataArrayOfBinaryStubBuilder =
TestBodyMultipartFormdataArrayOfBinaryStubBuilder(objectMapper, post(urlPathTemplate("/body/application/octetstream/array_of_binary"))
.configurer()
)
/**
* Construct a stub for the operation testBodyMultipartFormdataSingleBinary.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestBodyMultipartFormdataSingleBinaryStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testBodyMultipartFormdataSingleBinary(configurer: MappingBuilder.() -> MappingBuilder = { this }): TestBodyMultipartFormdataSingleBinaryStubBuilder =
TestBodyMultipartFormdataSingleBinaryStubBuilder(objectMapper, post(urlPathTemplate("/body/application/octetstream/single_binary"))
.configurer()
)
/**
* Construct a stub for the operation testEchoBodyFreeFormObjectResponseString.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestEchoBodyFreeFormObjectResponseStringStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testEchoBodyFreeFormObjectResponseString(configurer: MappingBuilder.() -> MappingBuilder = { this }): TestEchoBodyFreeFormObjectResponseStringStubBuilder =
TestEchoBodyFreeFormObjectResponseStringStubBuilder(objectMapper, post(urlPathTemplate("/echo/body/FreeFormObject/response_string"))
.configurer()
)
/**
* Construct a stub for the operation testEchoBodyPet.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestEchoBodyPetStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testEchoBodyPet(configurer: MappingBuilder.() -> MappingBuilder = { this }): TestEchoBodyPetStubBuilder =
TestEchoBodyPetStubBuilder(objectMapper, post(urlPathTemplate("/echo/body/Pet"))
.configurer()
)
/**
* Construct a stub for the operation testEchoBodyPetResponseString.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestEchoBodyPetResponseStringStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testEchoBodyPetResponseString(configurer: MappingBuilder.() -> MappingBuilder = { this }): TestEchoBodyPetResponseStringStubBuilder =
TestEchoBodyPetResponseStringStubBuilder(objectMapper, post(urlPathTemplate("/echo/body/Pet/response_string"))
.configurer()
)
/**
* Construct a stub for the operation testEchoBodyTagResponseString.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestEchoBodyTagResponseStringStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testEchoBodyTagResponseString(configurer: MappingBuilder.() -> MappingBuilder = { this }): TestEchoBodyTagResponseStringStubBuilder =
TestEchoBodyTagResponseStringStubBuilder(objectMapper, post(urlPathTemplate("/echo/body/Tag/response_string"))
.configurer()
)
}

View File

@ -0,0 +1,109 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* Builder for WireMock stubs of operation testFormIntegerBooleanString.
*/
class TestFormIntegerBooleanStringStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testFormIntegerBooleanString respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testFormIntegerBooleanString respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation testFormOneof.
*/
class TestFormOneofStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testFormOneof respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testFormOneof respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}

View File

@ -0,0 +1,42 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* WireMock stub request builder.
*/
open class FormApiStubs(private val objectMapper: ObjectMapper) {
/**
* Construct a stub for the operation testFormIntegerBooleanString.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestFormIntegerBooleanStringStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testFormIntegerBooleanString(configurer: MappingBuilder.() -> MappingBuilder = { this }): TestFormIntegerBooleanStringStubBuilder =
TestFormIntegerBooleanStringStubBuilder(objectMapper, post(urlPathTemplate("/form/integer/boolean/string"))
.configurer()
)
/**
* Construct a stub for the operation testFormOneof.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestFormOneofStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testFormOneof(configurer: MappingBuilder.() -> MappingBuilder = { this }): TestFormOneofStubBuilder =
TestFormOneofStubBuilder(objectMapper, post(urlPathTemplate("/form/oneof"))
.configurer()
)
}

View File

@ -0,0 +1,62 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* Builder for WireMock stubs of operation testHeaderIntegerBooleanStringEnums.
*/
class TestHeaderIntegerBooleanStringEnumsStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testHeaderIntegerBooleanStringEnums respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testHeaderIntegerBooleanStringEnums respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}

View File

@ -0,0 +1,31 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* WireMock stub request builder.
*/
open class HeaderApiStubs(private val objectMapper: ObjectMapper) {
/**
* Construct a stub for the operation testHeaderIntegerBooleanStringEnums.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestHeaderIntegerBooleanStringEnumsStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testHeaderIntegerBooleanStringEnums(configurer: MappingBuilder.() -> MappingBuilder = { this }): TestHeaderIntegerBooleanStringEnumsStubBuilder =
TestHeaderIntegerBooleanStringEnumsStubBuilder(objectMapper, get(urlPathTemplate("/header/integer/boolean/string/enums"))
.configurer()
)
}

View File

@ -0,0 +1,62 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* Builder for WireMock stubs of operation testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath.
*/
class TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}

View File

@ -0,0 +1,39 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* WireMock stub request builder.
*/
open class PathApiStubs(private val objectMapper: ObjectMapper) {
/**
* Construct a stub for the operation testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath.
*
* @param pathString path parameter pathString pattern.
* @param pathInteger path parameter pathInteger pattern.
* @param enumNonrefStringPath path parameter enumNonrefStringPath pattern.
* @param enumRefStringPath path parameter enumRefStringPath pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(pathString: StringValuePattern, pathInteger: StringValuePattern, enumNonrefStringPath: StringValuePattern, enumRefStringPath: StringValuePattern, configurer: MappingBuilder.() -> MappingBuilder = { this }): TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathStubBuilder =
TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathStubBuilder(objectMapper, get(urlPathTemplate("/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}"))
.withPathParam("pathString", pathString)
.withPathParam("pathInteger", pathInteger)
.withPathParam("enumNonrefStringPath", enumNonrefStringPath)
.withPathParam("enumRefStringPath", enumRefStringPath)
.configurer()
)
}

View File

@ -0,0 +1,297 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* Builder for WireMock stubs of operation testEnumRefString.
*/
class TestEnumRefStringStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testEnumRefString respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testEnumRefString respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation testQueryDatetimeDateString.
*/
class TestQueryDatetimeDateStringStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testQueryDatetimeDateString respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testQueryDatetimeDateString respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation testQueryIntegerBooleanString.
*/
class TestQueryIntegerBooleanStringStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testQueryIntegerBooleanString respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testQueryIntegerBooleanString respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation testQueryStyleDeepObjectExplodeTrueObject.
*/
class TestQueryStyleDeepObjectExplodeTrueObjectStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testQueryStyleDeepObjectExplodeTrueObject respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testQueryStyleDeepObjectExplodeTrueObject respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation testQueryStyleFormExplodeTrueArrayString.
*/
class TestQueryStyleFormExplodeTrueArrayStringStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testQueryStyleFormExplodeTrueArrayString respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testQueryStyleFormExplodeTrueArrayString respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation testQueryStyleFormExplodeTrueObject.
*/
class TestQueryStyleFormExplodeTrueObjectStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for testQueryStyleFormExplodeTrueObject respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for testQueryStyleFormExplodeTrueObject respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}

View File

@ -0,0 +1,108 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* WireMock stub request builder.
*/
open class QueryApiStubs(private val objectMapper: ObjectMapper) {
/**
* Construct a stub for the operation testEnumRefString.
*
* @param enumNonrefStringQuery query parameter enumNonrefStringQuery pattern.
* @param enumRefStringQuery query parameter enumRefStringQuery pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestEnumRefStringStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testEnumRefString(enumNonrefStringQuery: StringValuePattern? = null, enumRefStringQuery: StringValuePattern? = null, configurer: MappingBuilder.() -> MappingBuilder = { this }): TestEnumRefStringStubBuilder =
TestEnumRefStringStubBuilder(objectMapper, get(urlPathTemplate("/query/enum_ref_string"))
.apply { enumNonrefStringQuery?.let { withQueryParam("enumNonrefStringQuery", it) } }
.apply { enumRefStringQuery?.let { withQueryParam("enumRefStringQuery", it) } }
.configurer()
)
/**
* Construct a stub for the operation testQueryDatetimeDateString.
*
* @param datetimeQuery query parameter datetimeQuery pattern.
* @param dateQuery query parameter dateQuery pattern.
* @param stringQuery query parameter stringQuery pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestQueryDatetimeDateStringStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testQueryDatetimeDateString(datetimeQuery: StringValuePattern? = null, dateQuery: StringValuePattern? = null, stringQuery: StringValuePattern? = null, configurer: MappingBuilder.() -> MappingBuilder = { this }): TestQueryDatetimeDateStringStubBuilder =
TestQueryDatetimeDateStringStubBuilder(objectMapper, get(urlPathTemplate("/query/datetime/date/string"))
.apply { datetimeQuery?.let { withQueryParam("datetimeQuery", it) } }
.apply { dateQuery?.let { withQueryParam("dateQuery", it) } }
.apply { stringQuery?.let { withQueryParam("stringQuery", it) } }
.configurer()
)
/**
* Construct a stub for the operation testQueryIntegerBooleanString.
*
* @param integerQuery query parameter integerQuery pattern.
* @param booleanQuery query parameter booleanQuery pattern.
* @param stringQuery query parameter stringQuery pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestQueryIntegerBooleanStringStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testQueryIntegerBooleanString(integerQuery: StringValuePattern? = null, booleanQuery: StringValuePattern? = null, stringQuery: StringValuePattern? = null, configurer: MappingBuilder.() -> MappingBuilder = { this }): TestQueryIntegerBooleanStringStubBuilder =
TestQueryIntegerBooleanStringStubBuilder(objectMapper, get(urlPathTemplate("/query/integer/boolean/string"))
.apply { integerQuery?.let { withQueryParam("integerQuery", it) } }
.apply { booleanQuery?.let { withQueryParam("booleanQuery", it) } }
.apply { stringQuery?.let { withQueryParam("stringQuery", it) } }
.configurer()
)
/**
* Construct a stub for the operation testQueryStyleDeepObjectExplodeTrueObject.
*
* @param queryObject query parameter queryObject pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestQueryStyleDeepObjectExplodeTrueObjectStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testQueryStyleDeepObjectExplodeTrueObject(queryObject: StringValuePattern? = null, configurer: MappingBuilder.() -> MappingBuilder = { this }): TestQueryStyleDeepObjectExplodeTrueObjectStubBuilder =
TestQueryStyleDeepObjectExplodeTrueObjectStubBuilder(objectMapper, get(urlPathTemplate("/query/style_deepObject/explode_true/object"))
.apply { queryObject?.let { withQueryParam("queryObject", it) } }
.configurer()
)
/**
* Construct a stub for the operation testQueryStyleFormExplodeTrueArrayString.
*
* @param queryObject query parameter queryObject pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestQueryStyleFormExplodeTrueArrayStringStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testQueryStyleFormExplodeTrueArrayString(queryObject: StringValuePattern? = null, configurer: MappingBuilder.() -> MappingBuilder = { this }): TestQueryStyleFormExplodeTrueArrayStringStubBuilder =
TestQueryStyleFormExplodeTrueArrayStringStubBuilder(objectMapper, get(urlPathTemplate("/query/style_form/explode_true/array_string"))
.apply { queryObject?.let { withQueryParam("queryObject", it) } }
.configurer()
)
/**
* Construct a stub for the operation testQueryStyleFormExplodeTrueObject.
*
* @param queryObject query parameter queryObject pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [TestQueryStyleFormExplodeTrueObjectStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun testQueryStyleFormExplodeTrueObject(queryObject: StringValuePattern? = null, configurer: MappingBuilder.() -> MappingBuilder = { this }): TestQueryStyleFormExplodeTrueObjectStubBuilder =
TestQueryStyleFormExplodeTrueObjectStubBuilder(objectMapper, get(urlPathTemplate("/query/style_form/explode_true/object"))
.apply { queryObject?.let { withQueryParam("queryObject", it) } }
.configurer()
)
}

View File

@ -0,0 +1,17 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Bird(
@field:JsonProperty("size")
val propertySize: kotlin.String? = null,
@field:JsonProperty("color")
val color: kotlin.String? = null,
)

View File

@ -0,0 +1,17 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Category(
@field:JsonProperty("id")
val id: kotlin.Long? = null,
@field:JsonProperty("name")
val name: kotlin.String? = null,
)

View File

@ -0,0 +1,35 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
data class DefaultValue(
@field:JsonProperty("array_string_enum_ref_default")
val arrayStringEnumRefDefault: kotlin.collections.List<StringEnumRef>? = null,
@field:JsonProperty("array_string_enum_default")
val arrayStringEnumDefault: kotlin.collections.List<kotlin.String>? = null,
@field:JsonProperty("array_string_default")
val arrayStringDefault: kotlin.collections.List<kotlin.String>? = arrayListOf("failure","skipped"),
@field:JsonProperty("array_integer_default")
val arrayIntegerDefault: kotlin.collections.List<kotlin.Int>? = arrayListOf(1,3),
@field:JsonProperty("array_string")
val arrayString: kotlin.collections.List<kotlin.String>? = null,
@field:JsonProperty("array_string_nullable")
val arrayStringNullable: kotlin.collections.List<kotlin.String>? = null,
@field:JsonProperty("array_string_extension_nullable")
val arrayStringExtensionNullable: kotlin.collections.List<kotlin.String>? = null,
@field:JsonProperty("string_nullable")
val stringNullable: kotlin.String? = null,
)

View File

@ -0,0 +1,20 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
data class NumberPropertiesOnly(
@field:JsonProperty("number")
val number: java.math.BigDecimal? = null,
@field:JsonProperty("float")
val float: kotlin.Float? = null,
@field:JsonProperty("double")
val double: kotlin.Double? = null,
)

View File

@ -0,0 +1,29 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Pet(
@field:JsonProperty("name")
val name: kotlin.String,
@field:JsonProperty("photoUrls")
val photoUrls: kotlin.collections.List<kotlin.String>,
@field:JsonProperty("id")
val id: kotlin.Long? = null,
@field:JsonProperty("category")
val category: Category? = null,
@field:JsonProperty("tags")
val tags: kotlin.collections.List<Tag>? = null,
@field:JsonProperty("status")
val status: kotlin.String? = null,
)

View File

@ -0,0 +1,17 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Query(
@field:JsonProperty("id")
val id: kotlin.Long? = null,
@field:JsonProperty("outcomes")
val outcomes: kotlin.collections.List<kotlin.String>? = null,
)

View File

@ -0,0 +1,14 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
enum class StringEnumRef {
@JsonProperty(value = "success") success,
@JsonProperty(value = "failure") failure,
@JsonProperty(value = "unclassified") unclassified,
}

View File

@ -0,0 +1,17 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Tag(
@field:JsonProperty("id")
val id: kotlin.Long? = null,
@field:JsonProperty("name")
val name: kotlin.String? = null,
)

View File

@ -0,0 +1,14 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
data class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(
@field:JsonProperty("values")
val propertyValues: kotlin.collections.List<kotlin.String>? = null,
)

View File

@ -0,0 +1,106 @@
./bin/
# Created by https://www.gitignore.io/api/java,intellij,gradle
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Gradle ###
.gradle
/build/
# Ignore Gradle GUI config
gradle-app.setting
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
# Cache of project
.gradletasknamecache
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties
# End of https://www.gitignore.io/api/java,intellij,gradle

View File

@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -0,0 +1,20 @@
.gitignore
build.gradle.kts
gradle/libs.versions.toml
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
gradlew.bat
settings.gradle.kts
src/main/kotlin/org/openapitools/apis/PetApiStubBuilders.kt
src/main/kotlin/org/openapitools/apis/PetApiStubs.kt
src/main/kotlin/org/openapitools/apis/StoreApiStubBuilders.kt
src/main/kotlin/org/openapitools/apis/StoreApiStubs.kt
src/main/kotlin/org/openapitools/apis/UserApiStubBuilders.kt
src/main/kotlin/org/openapitools/apis/UserApiStubs.kt
src/main/kotlin/org/openapitools/models/ApiResponse.kt
src/main/kotlin/org/openapitools/models/Category.kt
src/main/kotlin/org/openapitools/models/Order.kt
src/main/kotlin/org/openapitools/models/Pet.kt
src/main/kotlin/org/openapitools/models/Tag.kt
src/main/kotlin/org/openapitools/models/User.kt

View File

@ -0,0 +1 @@
7.6.0-SNAPSHOT

View File

@ -0,0 +1,21 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
group = "org.openapitools"
version = "1.0.0"
tasks.wrapper {
gradleVersion = "8.7"
}
plugins {
alias(libs.plugins.kotlin.jvm)
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
dependencies {
implementation(libs.wiremock)
implementation(libs.jackson.databind)
}

View File

@ -0,0 +1,10 @@
[versions]
kotlin = "1.9.23"
wiremock = "3.5.4"
[libraries]
wiremock = { module = "org.wiremock:wiremock", version.ref = "wiremock" }
jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version = "2.17.1" }
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

View File

@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -0,0 +1,249 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View File

@ -0,0 +1,249 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View File

@ -0,0 +1,7 @@
rootProject.name = "kotlin-wiremock"
dependencyResolutionManagement {
repositories {
mavenCentral()
}
}

View File

@ -0,0 +1,525 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* Builder for WireMock stubs of operation addPet.
*/
class AddPetStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for addPet respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: Pet,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for addPet respond with HTTP status code 405.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith405(
body: Pet,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(405)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for addPet respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation deletePet.
*/
class DeletePetStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for deletePet respond with HTTP status code 400.
*
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith400(
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(400)
.configurer()
)
/**
* Let the stub for deletePet respond with HTTP status code [code].
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation findPetsByStatus.
*/
class FindPetsByStatusStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for findPetsByStatus respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.collections.List<Pet>,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for findPetsByStatus respond with HTTP status code 400.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith400(
body: kotlin.collections.List<Pet>,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(400)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for findPetsByStatus respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation findPetsByTags.
*/
class FindPetsByTagsStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for findPetsByTags respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.collections.List<Pet>,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for findPetsByTags respond with HTTP status code 400.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith400(
body: kotlin.collections.List<Pet>,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(400)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for findPetsByTags respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation getPetById.
*/
class GetPetByIdStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for getPetById respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: Pet,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for getPetById respond with HTTP status code 400.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith400(
body: Pet,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(400)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for getPetById respond with HTTP status code 404.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith404(
body: Pet,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for getPetById respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation updatePet.
*/
class UpdatePetStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for updatePet respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: Pet,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for updatePet respond with HTTP status code 400.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith400(
body: Pet,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(400)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for updatePet respond with HTTP status code 404.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith404(
body: Pet,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for updatePet respond with HTTP status code 405.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith405(
body: Pet,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(405)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for updatePet respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation updatePetWithForm.
*/
class UpdatePetWithFormStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for updatePetWithForm respond with HTTP status code 405.
*
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith405(
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(405)
.configurer()
)
/**
* Let the stub for updatePetWithForm respond with HTTP status code [code].
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation uploadFile.
*/
class UploadFileStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for uploadFile respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: ApiResponse,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for uploadFile respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}

View File

@ -0,0 +1,120 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* WireMock stub request builder.
*/
open class PetApiStubs(private val objectMapper: ObjectMapper) {
/**
* Construct a stub for the operation addPet.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [AddPetStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun addPet(configurer: MappingBuilder.() -> MappingBuilder = { this }): AddPetStubBuilder =
AddPetStubBuilder(objectMapper, post(urlPathTemplate("/pet"))
.configurer()
)
/**
* Construct a stub for the operation deletePet.
*
* @param petId path parameter petId pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [DeletePetStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun deletePet(petId: StringValuePattern, configurer: MappingBuilder.() -> MappingBuilder = { this }): DeletePetStubBuilder =
DeletePetStubBuilder(objectMapper, delete(urlPathTemplate("/pet/{petId}"))
.withPathParam("petId", petId)
.configurer()
)
/**
* Construct a stub for the operation findPetsByStatus.
*
* @param status query parameter status pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [FindPetsByStatusStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun findPetsByStatus(status: StringValuePattern? = null, configurer: MappingBuilder.() -> MappingBuilder = { this }): FindPetsByStatusStubBuilder =
FindPetsByStatusStubBuilder(objectMapper, get(urlPathTemplate("/pet/findByStatus"))
.apply { status?.let { withQueryParam("status", it) } }
.configurer()
)
/**
* Construct a stub for the operation findPetsByTags.
*
* @param tags query parameter tags pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [FindPetsByTagsStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun findPetsByTags(tags: StringValuePattern? = null, configurer: MappingBuilder.() -> MappingBuilder = { this }): FindPetsByTagsStubBuilder =
FindPetsByTagsStubBuilder(objectMapper, get(urlPathTemplate("/pet/findByTags"))
.apply { tags?.let { withQueryParam("tags", it) } }
.configurer()
)
/**
* Construct a stub for the operation getPetById.
*
* @param petId path parameter petId pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [GetPetByIdStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun getPetById(petId: StringValuePattern, configurer: MappingBuilder.() -> MappingBuilder = { this }): GetPetByIdStubBuilder =
GetPetByIdStubBuilder(objectMapper, get(urlPathTemplate("/pet/{petId}"))
.withPathParam("petId", petId)
.configurer()
)
/**
* Construct a stub for the operation updatePet.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [UpdatePetStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun updatePet(configurer: MappingBuilder.() -> MappingBuilder = { this }): UpdatePetStubBuilder =
UpdatePetStubBuilder(objectMapper, put(urlPathTemplate("/pet"))
.configurer()
)
/**
* Construct a stub for the operation updatePetWithForm.
*
* @param petId path parameter petId pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [UpdatePetWithFormStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun updatePetWithForm(petId: StringValuePattern, configurer: MappingBuilder.() -> MappingBuilder = { this }): UpdatePetWithFormStubBuilder =
UpdatePetWithFormStubBuilder(objectMapper, post(urlPathTemplate("/pet/{petId}"))
.withPathParam("petId", petId)
.configurer()
)
/**
* Construct a stub for the operation uploadFile.
*
* @param petId path parameter petId pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [UploadFileStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun uploadFile(petId: StringValuePattern, configurer: MappingBuilder.() -> MappingBuilder = { this }): UploadFileStubBuilder =
UploadFileStubBuilder(objectMapper, post(urlPathTemplate("/pet/{petId}/uploadImage"))
.withPathParam("petId", petId)
.configurer()
)
}

View File

@ -0,0 +1,266 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* Builder for WireMock stubs of operation deleteOrder.
*/
class DeleteOrderStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for deleteOrder respond with HTTP status code 400.
*
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith400(
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(400)
.configurer()
)
/**
* Let the stub for deleteOrder respond with HTTP status code 404.
*
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith404(
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(404)
.configurer()
)
/**
* Let the stub for deleteOrder respond with HTTP status code [code].
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation getInventory.
*/
class GetInventoryStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for getInventory respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.collections.Map<kotlin.String, kotlin.Int>,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for getInventory respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation getOrderById.
*/
class GetOrderByIdStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for getOrderById respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: Order,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for getOrderById respond with HTTP status code 400.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith400(
body: Order,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(400)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for getOrderById respond with HTTP status code 404.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith404(
body: Order,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for getOrderById respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation placeOrder.
*/
class PlaceOrderStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for placeOrder respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: Order,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for placeOrder respond with HTTP status code 400.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith400(
body: Order,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(400)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for placeOrder respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}

View File

@ -0,0 +1,68 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* WireMock stub request builder.
*/
open class StoreApiStubs(private val objectMapper: ObjectMapper) {
/**
* Construct a stub for the operation deleteOrder.
*
* @param orderId path parameter orderId pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [DeleteOrderStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun deleteOrder(orderId: StringValuePattern, configurer: MappingBuilder.() -> MappingBuilder = { this }): DeleteOrderStubBuilder =
DeleteOrderStubBuilder(objectMapper, delete(urlPathTemplate("/store/order/{orderId}"))
.withPathParam("orderId", orderId)
.configurer()
)
/**
* Construct a stub for the operation getInventory.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [GetInventoryStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun getInventory(configurer: MappingBuilder.() -> MappingBuilder = { this }): GetInventoryStubBuilder =
GetInventoryStubBuilder(objectMapper, get(urlPathTemplate("/store/inventory"))
.configurer()
)
/**
* Construct a stub for the operation getOrderById.
*
* @param orderId path parameter orderId pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [GetOrderByIdStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun getOrderById(orderId: StringValuePattern, configurer: MappingBuilder.() -> MappingBuilder = { this }): GetOrderByIdStubBuilder =
GetOrderByIdStubBuilder(objectMapper, get(urlPathTemplate("/store/order/{orderId}"))
.withPathParam("orderId", orderId)
.configurer()
)
/**
* Construct a stub for the operation placeOrder.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [PlaceOrderStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun placeOrder(configurer: MappingBuilder.() -> MappingBuilder = { this }): PlaceOrderStubBuilder =
PlaceOrderStubBuilder(objectMapper, post(urlPathTemplate("/store/order"))
.configurer()
)
}

View File

@ -0,0 +1,387 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* Builder for WireMock stubs of operation createUser.
*/
class CreateUserStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for createUser respond with HTTP status code [code].
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation createUsersWithArrayInput.
*/
class CreateUsersWithArrayInputStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for createUsersWithArrayInput respond with HTTP status code [code].
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation createUsersWithListInput.
*/
class CreateUsersWithListInputStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for createUsersWithListInput respond with HTTP status code [code].
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation deleteUser.
*/
class DeleteUserStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for deleteUser respond with HTTP status code 400.
*
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith400(
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(400)
.configurer()
)
/**
* Let the stub for deleteUser respond with HTTP status code 404.
*
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith404(
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(404)
.configurer()
)
/**
* Let the stub for deleteUser respond with HTTP status code [code].
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation getUserByName.
*/
class GetUserByNameStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for getUserByName respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: User,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for getUserByName respond with HTTP status code 400.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith400(
body: User,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(400)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for getUserByName respond with HTTP status code 404.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith404(
body: User,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for getUserByName respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation loginUser.
*/
class LoginUserStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for loginUser respond with HTTP status code 200.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith200(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for loginUser respond with HTTP status code 400.
*
* @param body response body for the [MappingBuilder].
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith400(
body: kotlin.String,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(400)
.withHeader("Content-Type", "application/json")
.withBody(objectMapper.writeValueAsString(body))
.configurer()
)
/**
* Let the stub for loginUser respond with HTTP status code [code].
*
* @param body response body for the [MappingBuilder].
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation logoutUser.
*/
class LogoutUserStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for logoutUser respond with HTTP status code [code].
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}
/**
* Builder for WireMock stubs of operation updateUser.
*/
class UpdateUserStubBuilder internal constructor(private val objectMapper: ObjectMapper, private val stub: MappingBuilder) {
/**
* Let the stub for updateUser respond with HTTP status code 400.
*
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith400(
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(400)
.configurer()
)
/**
* Let the stub for updateUser respond with HTTP status code 404.
*
* @param configurer fonfigurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith404(
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this },
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(404)
.configurer()
)
/**
* Let the stub for updateUser respond with HTTP status code [code].
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return a [MappingBuilder] to be registered with a WireMock instance.
*/
fun respondWith(
code: Int,
body: Any? = null,
configurer: ResponseDefinitionBuilder.() -> ResponseDefinitionBuilder = { this }
): MappingBuilder =
stub.willReturn(aResponse()
.withStatus(code)
.apply {
body?.let {
withHeader("Content-Type", "application/json")
withBody(objectMapper.writeValueAsString(it))
}
}
.configurer()
)
}

View File

@ -0,0 +1,118 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"UnusedImport",
"unused",
)
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.tomakehurst.wiremock.client.MappingBuilder
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.matching.StringValuePattern
import org.openapitools.models.*
/**
* WireMock stub request builder.
*/
open class UserApiStubs(private val objectMapper: ObjectMapper) {
/**
* Construct a stub for the operation createUser.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [CreateUserStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun createUser(configurer: MappingBuilder.() -> MappingBuilder = { this }): CreateUserStubBuilder =
CreateUserStubBuilder(objectMapper, post(urlPathTemplate("/user"))
.configurer()
)
/**
* Construct a stub for the operation createUsersWithArrayInput.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [CreateUsersWithArrayInputStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun createUsersWithArrayInput(configurer: MappingBuilder.() -> MappingBuilder = { this }): CreateUsersWithArrayInputStubBuilder =
CreateUsersWithArrayInputStubBuilder(objectMapper, post(urlPathTemplate("/user/createWithArray"))
.configurer()
)
/**
* Construct a stub for the operation createUsersWithListInput.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [CreateUsersWithListInputStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun createUsersWithListInput(configurer: MappingBuilder.() -> MappingBuilder = { this }): CreateUsersWithListInputStubBuilder =
CreateUsersWithListInputStubBuilder(objectMapper, post(urlPathTemplate("/user/createWithList"))
.configurer()
)
/**
* Construct a stub for the operation deleteUser.
*
* @param username path parameter username pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [DeleteUserStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun deleteUser(username: StringValuePattern, configurer: MappingBuilder.() -> MappingBuilder = { this }): DeleteUserStubBuilder =
DeleteUserStubBuilder(objectMapper, delete(urlPathTemplate("/user/{username}"))
.withPathParam("username", username)
.configurer()
)
/**
* Construct a stub for the operation getUserByName.
*
* @param username path parameter username pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [GetUserByNameStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun getUserByName(username: StringValuePattern, configurer: MappingBuilder.() -> MappingBuilder = { this }): GetUserByNameStubBuilder =
GetUserByNameStubBuilder(objectMapper, get(urlPathTemplate("/user/{username}"))
.withPathParam("username", username)
.configurer()
)
/**
* Construct a stub for the operation loginUser.
*
* @param username query parameter username pattern.
* @param password query parameter password pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [LoginUserStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun loginUser(username: StringValuePattern? = null, password: StringValuePattern? = null, configurer: MappingBuilder.() -> MappingBuilder = { this }): LoginUserStubBuilder =
LoginUserStubBuilder(objectMapper, get(urlPathTemplate("/user/login"))
.apply { username?.let { withQueryParam("username", it) } }
.apply { password?.let { withQueryParam("password", it) } }
.configurer()
)
/**
* Construct a stub for the operation logoutUser.
*
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [LogoutUserStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun logoutUser(configurer: MappingBuilder.() -> MappingBuilder = { this }): LogoutUserStubBuilder =
LogoutUserStubBuilder(objectMapper, get(urlPathTemplate("/user/logout"))
.configurer()
)
/**
* Construct a stub for the operation updateUser.
*
* @param username path parameter username pattern.
* @param configurer configurer for the [MappingBuilder], allowing for arbitrary changes.
* @return A [UpdateUserStubBuilder] to configure the response, and the final [MappingBuilder].
*/
fun updateUser(username: StringValuePattern, configurer: MappingBuilder.() -> MappingBuilder = { this }): UpdateUserStubBuilder =
UpdateUserStubBuilder(objectMapper, put(urlPathTemplate("/user/{username}"))
.withPathParam("username", username)
.configurer()
)
}

View File

@ -0,0 +1,20 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
data class ApiResponse(
@field:JsonProperty("code")
val code: kotlin.Int? = null,
@field:JsonProperty("type")
val type: kotlin.String? = null,
@field:JsonProperty("message")
val message: kotlin.String? = null,
)

View File

@ -0,0 +1,17 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Category(
@field:JsonProperty("id")
val id: kotlin.Long? = null,
@field:JsonProperty("name")
val name: kotlin.String? = null,
)

View File

@ -0,0 +1,29 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Order(
@field:JsonProperty("id")
val id: kotlin.Long? = null,
@field:JsonProperty("petId")
val petId: kotlin.Long? = null,
@field:JsonProperty("quantity")
val quantity: kotlin.Int? = null,
@field:JsonProperty("shipDate")
val shipDate: java.time.OffsetDateTime? = null,
@field:JsonProperty("status")
val status: kotlin.String? = null,
@field:JsonProperty("complete")
val complete: kotlin.Boolean? = false,
)

View File

@ -0,0 +1,29 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Pet(
@field:JsonProperty("name")
val name: kotlin.String,
@field:JsonProperty("photoUrls")
val photoUrls: kotlin.collections.List<kotlin.String>,
@field:JsonProperty("id")
val id: kotlin.Long? = null,
@field:JsonProperty("category")
val category: Category? = null,
@field:JsonProperty("tags")
val tags: kotlin.collections.List<Tag>? = null,
@field:JsonProperty("status")
val status: kotlin.String? = null,
)

View File

@ -0,0 +1,17 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Tag(
@field:JsonProperty("id")
val id: kotlin.Long? = null,
@field:JsonProperty("name")
val name: kotlin.String? = null,
)

View File

@ -0,0 +1,35 @@
@file:Suppress(
"RemoveRedundantQualifierName",
"unused",
)
package org.openapitools.models
import com.fasterxml.jackson.annotation.JsonProperty
data class User(
@field:JsonProperty("id")
val id: kotlin.Long? = null,
@field:JsonProperty("username")
val username: kotlin.String? = null,
@field:JsonProperty("firstName")
val firstName: kotlin.String? = null,
@field:JsonProperty("lastName")
val lastName: kotlin.String? = null,
@field:JsonProperty("email")
val email: kotlin.String? = null,
@field:JsonProperty("password")
val password: kotlin.String? = null,
@field:JsonProperty("phone")
val phone: kotlin.String? = null,
@field:JsonProperty("userStatus")
val userStatus: kotlin.Int? = null,
)

View File

@ -0,0 +1,44 @@
package org.openapitools.apis
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.kotlinModule
import com.github.tomakehurst.wiremock.client.WireMock.equalTo
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo
import com.github.tomakehurst.wiremock.junit5.WireMockTest
import org.openapitools.models.Pet
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
import kotlin.test.Test
import kotlin.test.assertEquals
@WireMockTest
class PetApiStubsTest {
private val objectMapper = ObjectMapper()
.registerModules(JavaTimeModule())
.registerModules(kotlinModule())
private val stubs = PetApiStubs(objectMapper)
private val client = HttpClient.newBuilder().build()
@Test
fun `stub and retrieve`(wiremock: WireMockRuntimeInfo) {
val pet = Pet("Pet", emptyList(), null, null, null, null)
wiremock.wireMock.register(
stubs.getPetById(equalTo("2")).respondWith200(pet)
)
val request = HttpRequest.newBuilder(URI.create(wiremock.httpBaseUrl + "/pet/1"))
.GET()
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
assertEquals(pet, objectMapper.readValue(response.body(), Pet::class.java))
}
}