forked from loafle/openapi-generator-original
feat: add java-wiremock
generator (#17614)
* feat: add `java-wiremock` generator * remove text block usage for samples this will allow more version of jav to be compatible with this * fix extra parenthesis * Add java-wiremock workflow
This commit is contained in:
parent
a0418c2855
commit
092463a513
35
.github/workflows/samples-java-wiremock.yaml
vendored
Normal file
35
.github/workflows/samples-java-wiremock.yaml
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
name: Samples Java Wiremock
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- samples/server/petstore/java-wiremock/**
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/server/petstore/java-wiremock/**
|
||||
jobs:
|
||||
build:
|
||||
name: Build Java Wiremock
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
- samples/server/petstore/java-wiremock
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 11
|
||||
- name: Cache maven dependencies
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: maven-repository
|
||||
with:
|
||||
path: |
|
||||
~/.m2
|
||||
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
|
||||
- name: Build
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: mvn clean package
|
7
bin/configs/java-wiremock.yaml
Normal file
7
bin/configs/java-wiremock.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
generatorName: java-wiremock
|
||||
outputDir: samples/server/petstore/java-wiremock
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/java-wiremock
|
||||
additionalProperties:
|
||||
artifactId: petstore-wiremock
|
||||
hideGenerationTimestamp: "true"
|
@ -107,6 +107,7 @@ The following generators are available:
|
||||
* [java-undertow-server](generators/java-undertow-server.md)
|
||||
* [java-vertx (deprecated)](generators/java-vertx.md)
|
||||
* [java-vertx-web (beta)](generators/java-vertx-web.md)
|
||||
* [java-wiremock (beta)](generators/java-wiremock.md)
|
||||
* [jaxrs-cxf](generators/jaxrs-cxf.md)
|
||||
* [jaxrs-cxf-cdi](generators/jaxrs-cxf-cdi.md)
|
||||
* [jaxrs-cxf-extended](generators/jaxrs-cxf-extended.md)
|
||||
|
329
docs/generators/java-wiremock.md
Normal file
329
docs/generators/java-wiremock.md
Normal file
@ -0,0 +1,329 @@
|
||||
---
|
||||
title: Documentation for the java-wiremock Generator
|
||||
---
|
||||
|
||||
## METADATA
|
||||
|
||||
| Property | Value | Notes |
|
||||
| -------- | ----- | ----- |
|
||||
| generator name | java-wiremock | pass this to the generate command after -g |
|
||||
| generator stability | BETA | |
|
||||
| generator type | SERVER | |
|
||||
| generator language | Java | |
|
||||
| generator default templating engine | mustache | |
|
||||
| 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.
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |null|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|artifactId|artifactId in generated pom.xml. This also becomes part of the generated library's filename| |openapi-java|
|
||||
|artifactUrl|artifact URL in generated pom.xml| |https://github.com/openapitools/openapi-generator|
|
||||
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|
||||
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|
||||
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|
||||
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|
||||
|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|
||||
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.</dd></dl>|false|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |false|
|
||||
|ignoreAnyOfInEnum|Ignore anyOf keyword in enum| |false|
|
||||
|implicitHeaders|Skip header parameters in the generated API methods using @ApiImplicitParams annotation.| |false|
|
||||
|implicitHeadersRegex|Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true| |null|
|
||||
|invokerPackage|root package for generated code| |org.openapitools|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|licenseName|The name of the license| |Unlicense|
|
||||
|licenseUrl|The URL of the license| |http://unlicense.org|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|openApiNullable|Enable OpenAPI Jackson Nullable library| |true|
|
||||
|parentArtifactId|parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
|
||||
|parentGroupId|parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
|
||||
|parentVersion|parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|scmConnection|SCM connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git|
|
||||
|scmDeveloperConnection|SCM developer connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git|
|
||||
|scmUrl|SCM URL in generated pom.xml| |https://github.com/openapitools/openapi-generator|
|
||||
|serializableModel|boolean - toggle "implements Serializable" for generated models| |false|
|
||||
|snapshotVersion|Uses a SNAPSHOT version.|<dl><dt>**true**</dt><dd>Use a SnapShot Version</dd><dt>**false**</dt><dd>Use a Release Version</dd></dl>|null|
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|sourceFolder|source folder for generated code| |src/main/java|
|
||||
|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi|
|
||||
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|
||||
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|
||||
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
||||
|
||||
## SUPPORTED VENDOR EXTENSIONS
|
||||
|
||||
| Extension name | Description | Applicable for | Default value |
|
||||
| -------------- | ----------- | -------------- | ------------- |
|
||||
|x-discriminator-value|Used with model inheritance to specify value for discriminator that identifies current model|MODEL|
|
||||
|x-implements|Ability to specify interfaces that model must implements|MODEL|empty array
|
||||
|x-setter-extra-annotation|Custom annotation that can be specified over java setter for specific field|FIELD|When field is array & uniqueItems, then this extension is used to add `@JsonDeserialize(as = LinkedHashSet.class)` over setter, otherwise no value
|
||||
|x-tags|Specify multiple swagger tags for operation|OPERATION|null
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
| Type/Alias | Imports |
|
||||
| ---------- | ------- |
|
||||
|Array|java.util.List|
|
||||
|ArrayList|java.util.ArrayList|
|
||||
|BigDecimal|java.math.BigDecimal|
|
||||
|Date|java.util.Date|
|
||||
|DateTime|org.joda.time.*|
|
||||
|File|java.io.File|
|
||||
|HashMap|java.util.HashMap|
|
||||
|LinkedHashSet|java.util.LinkedHashSet|
|
||||
|List|java.util.*|
|
||||
|LocalDate|org.joda.time.*|
|
||||
|LocalDateTime|org.joda.time.*|
|
||||
|LocalTime|org.joda.time.*|
|
||||
|Map|java.util.Map|
|
||||
|Set|java.util.*|
|
||||
|Timestamp|java.sql.Timestamp|
|
||||
|URI|java.net.URI|
|
||||
|UUID|java.util.UUID|
|
||||
|
||||
|
||||
## INSTANTIATION TYPES
|
||||
|
||||
| Type/Alias | Instantiated By |
|
||||
| ---------- | --------------- |
|
||||
|array|ArrayList|
|
||||
|map|HashMap|
|
||||
|set|LinkedHashSet|
|
||||
|
||||
|
||||
## LANGUAGE PRIMITIVES
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>Boolean</li>
|
||||
<li>Double</li>
|
||||
<li>Float</li>
|
||||
<li>Integer</li>
|
||||
<li>Long</li>
|
||||
<li>Object</li>
|
||||
<li>String</li>
|
||||
<li>boolean</li>
|
||||
<li>byte[]</li>
|
||||
</ul>
|
||||
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>abstract</li>
|
||||
<li>apiclient</li>
|
||||
<li>apiexception</li>
|
||||
<li>apiresponse</li>
|
||||
<li>assert</li>
|
||||
<li>boolean</li>
|
||||
<li>break</li>
|
||||
<li>byte</li>
|
||||
<li>case</li>
|
||||
<li>catch</li>
|
||||
<li>char</li>
|
||||
<li>class</li>
|
||||
<li>configuration</li>
|
||||
<li>const</li>
|
||||
<li>continue</li>
|
||||
<li>default</li>
|
||||
<li>do</li>
|
||||
<li>double</li>
|
||||
<li>else</li>
|
||||
<li>enum</li>
|
||||
<li>extends</li>
|
||||
<li>file</li>
|
||||
<li>final</li>
|
||||
<li>finally</li>
|
||||
<li>float</li>
|
||||
<li>for</li>
|
||||
<li>goto</li>
|
||||
<li>if</li>
|
||||
<li>implements</li>
|
||||
<li>import</li>
|
||||
<li>instanceof</li>
|
||||
<li>int</li>
|
||||
<li>interface</li>
|
||||
<li>list</li>
|
||||
<li>localdate</li>
|
||||
<li>localreturntype</li>
|
||||
<li>localtime</li>
|
||||
<li>localvaraccept</li>
|
||||
<li>localvaraccepts</li>
|
||||
<li>localvarauthnames</li>
|
||||
<li>localvarcollectionqueryparams</li>
|
||||
<li>localvarcontenttype</li>
|
||||
<li>localvarcontenttypes</li>
|
||||
<li>localvarcookieparams</li>
|
||||
<li>localvarformparams</li>
|
||||
<li>localvarheaderparams</li>
|
||||
<li>localvarpath</li>
|
||||
<li>localvarpostbody</li>
|
||||
<li>localvarqueryparams</li>
|
||||
<li>long</li>
|
||||
<li>native</li>
|
||||
<li>new</li>
|
||||
<li>null</li>
|
||||
<li>object</li>
|
||||
<li>offsetdatetime</li>
|
||||
<li>package</li>
|
||||
<li>private</li>
|
||||
<li>protected</li>
|
||||
<li>public</li>
|
||||
<li>return</li>
|
||||
<li>short</li>
|
||||
<li>static</li>
|
||||
<li>strictfp</li>
|
||||
<li>stringutil</li>
|
||||
<li>super</li>
|
||||
<li>switch</li>
|
||||
<li>synchronized</li>
|
||||
<li>this</li>
|
||||
<li>throw</li>
|
||||
<li>throws</li>
|
||||
<li>transient</li>
|
||||
<li>try</li>
|
||||
<li>void</li>
|
||||
<li>volatile</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
|
@ -0,0 +1,72 @@
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import org.openapitools.codegen.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.templating.mustache.SplitStringLambda;
|
||||
import org.openapitools.codegen.templating.mustache.TrimWhitespaceLambda;
|
||||
|
||||
public class JavaWiremockServerCodegen extends AbstractJavaCodegen implements CodegenConfig {
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "java-wiremock";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates Java Wiremock stubs, requests and responses samples.";
|
||||
}
|
||||
|
||||
public JavaWiremockServerCodegen() {
|
||||
super();
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.BETA)
|
||||
.build();
|
||||
|
||||
outputFolder = "generated-code" + File.separator + "java";
|
||||
embeddedTemplateDir = templateDir = "java-wiremock";
|
||||
invokerPackage = "org.openapitools.mockserver";
|
||||
artifactId = "openapi-java-mockserver";
|
||||
apiPackage = "org.openapitools.mockserver.api";
|
||||
|
||||
apiDocTemplateFiles = new HashMap<>();
|
||||
apiTestTemplateFiles = new HashMap<>();
|
||||
modelDocTemplateFiles = new HashMap<>();
|
||||
modelTemplateFiles = new HashMap<>();
|
||||
|
||||
apiTemplateFiles.clear();
|
||||
apiTemplateFiles.put("wiremock.mustache", "MockServer.java");
|
||||
|
||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")
|
||||
.doNotOverwrite());
|
||||
|
||||
// Ensure the OAS 3.x discriminator mappings include any descendent schemas that allOf
|
||||
// inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values,
|
||||
// and the discriminator mapping schemas in the OAS document.
|
||||
this.setLegacyDiscriminatorBehavior(false);
|
||||
|
||||
// add lambda for mustache templates
|
||||
additionalProperties.put("lambdaRemoveDoubleQuote", (Mustache.Lambda) (fragment, writer) -> writer
|
||||
.write(fragment.execute().replaceAll("\"", Matcher.quoteReplacement(""))));
|
||||
additionalProperties.put("lambdaEscapeDoubleQuote", (Mustache.Lambda) (fragment, writer) -> writer
|
||||
.write(fragment.execute().replaceAll("\"", Matcher.quoteReplacement("\\\""))));
|
||||
additionalProperties.put("lambdaRemoveLineBreak",
|
||||
(Mustache.Lambda) (fragment, writer) -> writer.write(fragment.execute().replaceAll("\\r|\\n", "")));
|
||||
|
||||
additionalProperties.put("lambdaTrimWhitespace", new TrimWhitespaceLambda());
|
||||
|
||||
additionalProperties.put("lambdaSplitString", new SplitStringLambda());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -72,6 +72,7 @@ org.openapitools.codegen.languages.JavascriptClientCodegen
|
||||
org.openapitools.codegen.languages.JavascriptApolloClientCodegen
|
||||
org.openapitools.codegen.languages.JavascriptFlowtypedClientCodegen
|
||||
org.openapitools.codegen.languages.JavascriptClosureAngularClientCodegen
|
||||
org.openapitools.codegen.languages.JavaWiremockServerCodegen
|
||||
org.openapitools.codegen.languages.JetbrainsHttpClientClientCodegen
|
||||
org.openapitools.codegen.languages.JMeterClientCodegen
|
||||
org.openapitools.codegen.languages.JuliaClientCodegen
|
||||
|
1
modules/openapi-generator/src/main/resources/java-wiremock/exampleString.mustache
vendored
Normal file
1
modules/openapi-generator/src/main/resources/java-wiremock/exampleString.mustache
vendored
Normal file
@ -0,0 +1 @@
|
||||
{{#lambdaSplitString}}{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{#lambdaTrimWhitespace}}{{{example}}}{{/lambdaTrimWhitespace}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}{{/lambdaSplitString}}
|
197
modules/openapi-generator/src/main/resources/java-wiremock/pom.mustache
vendored
Normal file
197
modules/openapi-generator/src/main/resources/java-wiremock/pom.mustache
vendored
Normal file
@ -0,0 +1,197 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>{{groupId}}</groupId>
|
||||
<artifactId>{{artifactId}}</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>{{artifactId}}</name>
|
||||
<version>{{artifactVersion}}</version>
|
||||
<url>{{artifactUrl}}</url>
|
||||
<description>{{artifactDescription}}</description>
|
||||
<scm>
|
||||
<connection>{{scmConnection}}</connection>
|
||||
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
|
||||
<url>{{scmUrl}}</url>
|
||||
</scm>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>{{licenseName}}</name>
|
||||
<url>{{licenseUrl}}</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>{{developerName}}</name>
|
||||
<email>{{developerEmail}}</email>
|
||||
<organization>{{developerOrganization}}</organization>
|
||||
<organizationUrl>{{developerOrganizationUrl}}</organizationUrl>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>3.0.0-M1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-maven</id>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireMavenVersion>
|
||||
<version>2.2.0</version>
|
||||
</requireMavenVersion>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- attach test jar -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.10</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add_sources</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>src/main/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>add_test_sources</id>
|
||||
<phase>generate-test-sources</phase>
|
||||
<goals>
|
||||
<goal>add-test-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>src/test/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.3.2</version>
|
||||
<configuration>
|
||||
<doclint>none</doclint>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wiremock</groupId>
|
||||
<artifactId>wiremock-standalone</artifactId>
|
||||
<version>${wiremock.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- @Nullable annotation -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
|
||||
{{#useJakartaEe}}
|
||||
<dependency>
|
||||
<groupId>jakarta.annotation</groupId>
|
||||
<artifactId>jakarta.annotation-api</artifactId>
|
||||
<version>${javax.annotation-api-version}</version>
|
||||
</dependency>
|
||||
{{/useJakartaEe}}
|
||||
{{^useJakartaEe}}
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
<version>${javax.annotation-api-version}</version>
|
||||
</dependency>
|
||||
{{/useJakartaEe}}
|
||||
</dependencies>
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<wiremock.version>3.3.1</wiremock.version>
|
||||
|
||||
{{#useJakartaEe}}
|
||||
<javax.annotation-api-version>2.1.1</javax.annotation-api-version>
|
||||
{{/useJakartaEe}}
|
||||
{{^useJakartaEe}}
|
||||
<javax.annotation-api-version>1.3.2</javax.annotation-api-version>
|
||||
{{/useJakartaEe}}
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
</properties>
|
||||
</project>
|
205
modules/openapi-generator/src/main/resources/java-wiremock/wiremock.mustache
vendored
Normal file
205
modules/openapi-generator/src/main/resources/java-wiremock/wiremock.mustache
vendored
Normal file
@ -0,0 +1,205 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) ({{{generatorVersion}}}).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
package {{package}};
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import com.github.tomakehurst.wiremock.client.MappingBuilder;
|
||||
import com.github.tomakehurst.wiremock.http.Fault;
|
||||
|
||||
{{#operations}}
|
||||
public class {{classname}}MockServer {
|
||||
{{#operation}}
|
||||
{{#responses}}
|
||||
|
||||
{{#isDeprecated}}
|
||||
@Deprecated
|
||||
{{/isDeprecated}}
|
||||
public static MappingBuilder stub{{#lambda.pascalcase}}{{operationId}}{{/lambda.pascalcase}}{{{code}}}({{#allParams}}{{#required}}{{#isNullable}}@{{javaxPackage}}.annotation.Nullable {{/isNullable}}{{^isNullable}}@{{javaxPackage}}.annotation.Nonnull {{/isNullable}}{{/required}}{{^required}}@{{javaxPackage}}.annotation.Nullable {{/required}}{{^isBodyParam}}String {{paramName}}{{/isBodyParam}}{{#isBodyParam}}String body{{/isBodyParam}}{{^-last}}, {{/-last}}{{#-last}}{{#headers.0}}, {{/headers.0}}{{^headers.0}}{{#returnType}}, {{/returnType}}{{/headers.0}}{{/-last}}{{/allParams}}{{#headers}}String response{{#lambda.pascalcase}}{{baseName}}{{/lambda.pascalcase}}{{^-last}}, {{/-last}}{{#-last}}{{#returnType}}, {{/returnType}}{{/-last}}{{/headers}}{{#returnType}}String response{{/returnType}}) {
|
||||
MappingBuilder stub = {{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}({{^pathParams.0}}urlPathEqualTo{{/pathParams.0}}{{#pathParams.0}}urlPathTemplate{{/pathParams.0}}("{{{path}}}")){{#hasProduces}}
|
||||
.withHeader("Accept", havingExactly({{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}})){{/hasProduces}}{{#hasAuthMethods}}{{#hasConsumes}}
|
||||
.withHeader("Content-Type", havingExactly("{{#consumes.0}}{{{mediaType}}}{{/consumes.0}}")){{/hasConsumes}}
|
||||
.withHeader("Authorization", matching(".*")){{/hasAuthMethods}}{{#cookieParams}}
|
||||
.withCookie("{{baseName}}", havingExactly({{paramName}})){{/cookieParams}}{{#hasBodyParam}}
|
||||
.withRequestBody(equalToJson(body)){{/hasBodyParam}}
|
||||
.willReturn(aResponse()
|
||||
.withStatus({{{code}}}){{#hasProduces}}
|
||||
.withHeader("Content-Type", "{{#produces.0}}{{{mediaType}}}{{/produces.0}}"){{/hasProduces}}{{#headers}}
|
||||
.withHeader("{{baseName}}", response{{#lambda.pascalcase}}{{baseName}}{{/lambda.pascalcase}}){{/headers}}{{#returnType}}
|
||||
.withBody(response){{/returnType}}
|
||||
);
|
||||
|
||||
{{#pathParams}}
|
||||
{{#required}}
|
||||
{{#isNullable}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withPathParam("{{paramName}}", equalTo({{paramName}}));
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
stub = stub.withPathParam("{{paramName}}", equalTo({{paramName}}));
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withPathParam("{{paramName}}", equalTo({{paramName}}));
|
||||
}
|
||||
{{/required}}
|
||||
{{/pathParams}}
|
||||
{{#queryParams}}
|
||||
{{#required}}
|
||||
{{#isNullable}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withQueryParam("{{paramName}}", equalTo({{paramName}}));
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
stub = stub.withQueryParam("{{paramName}}", equalTo({{paramName}}));
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withQueryParam("{{paramName}}", equalTo({{paramName}}));
|
||||
}
|
||||
{{/required}}
|
||||
{{/queryParams}}
|
||||
{{#formParams}}
|
||||
{{#required}}
|
||||
{{#isNullable}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withFormParam("{{baseName}}", havingExactly({{paramName}}));
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
stub = stub.withFormParam("{{baseName}}", havingExactly({{paramName}}));
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withFormParam("{{baseName}}", havingExactly({{paramName}}));
|
||||
}
|
||||
{{/required}}
|
||||
{{/formParams}}
|
||||
{{#headerParams}}
|
||||
{{#required}}
|
||||
{{#isNullable}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withHeader("{{baseName}}", havingExactly({{paramName}}));
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
stub = stub.withHeader("{{baseName}}", havingExactly({{paramName}}));
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withHeader("{{baseName}}", havingExactly({{paramName}}));
|
||||
}
|
||||
{{/required}}
|
||||
{{/headerParams}}
|
||||
|
||||
return stub;
|
||||
}
|
||||
{{/responses}}
|
||||
|
||||
public static MappingBuilder stub{{#lambda.pascalcase}}{{operationId}}{{/lambda.pascalcase}}Fault({{#allParams}}{{#required}}{{#isNullable}}@{{javaxPackage}}.annotation.Nullable {{/isNullable}}{{^isNullable}}@{{javaxPackage}}.annotation.Nonnull {{/isNullable}}{{/required}}{{^required}}@{{javaxPackage}}.annotation.Nullable {{/required}}{{^isBodyParam}}String {{paramName}}{{/isBodyParam}}{{#isBodyParam}}String body{{/isBodyParam}}, {{/allParams}}Fault fault) {
|
||||
MappingBuilder stub = {{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}({{^pathParams.0}}urlPathEqualTo{{/pathParams.0}}{{#pathParams.0}}urlPathTemplate{{/pathParams.0}}("{{{path}}}")){{#hasProduces}}
|
||||
.withHeader("Accept", havingExactly({{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}})){{/hasProduces}}{{#hasAuthMethods}}{{#hasConsumes}}
|
||||
.withHeader("Content-Type", havingExactly("{{#consumes.0}}{{{mediaType}}}{{/consumes.0}}")){{/hasConsumes}}
|
||||
.withHeader("Authorization", matching(".*")){{/hasAuthMethods}}{{#cookieParams}}
|
||||
.withCookie("{{baseName}}", havingExactly({{paramName}})){{/cookieParams}}{{#bodyParam}}
|
||||
.withRequestBody(equalToJson(body)){{/bodyParam}}
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
{{#pathParams}}
|
||||
{{#required}}
|
||||
{{#isNullable}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withPathParam("{{paramName}}", equalTo({{paramName}}));
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
stub = stub.withPathParam("{{paramName}}", equalTo({{paramName}}));
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withPathParam("{{paramName}}", equalTo({{paramName}}));
|
||||
}
|
||||
{{/required}}
|
||||
{{/pathParams}}
|
||||
{{#queryParams}}
|
||||
{{#required}}
|
||||
{{#isNullable}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withQueryParam("{{paramName}}", equalTo({{paramName}}));
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
stub = stub.withQueryParam("{{paramName}}", equalTo({{paramName}}));
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withQueryParam("{{paramName}}", equalTo({{paramName}}));
|
||||
}
|
||||
{{/required}}
|
||||
{{/queryParams}}
|
||||
{{#formParams}}
|
||||
{{#required}}
|
||||
{{#isNullable}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withFormParam("{{baseName}}", havingExactly({{paramName}}));
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
stub = stub.withFormParam("{{baseName}}", havingExactly({{paramName}}));
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withFormParam("{{baseName}}", havingExactly({{paramName}}));
|
||||
}
|
||||
{{/required}}
|
||||
{{/formParams}}
|
||||
{{#headerParams}}
|
||||
{{#required}}
|
||||
{{#isNullable}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withHeader("{{baseName}}", havingExactly({{paramName}}));
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
stub = stub.withHeader("{{baseName}}", havingExactly({{paramName}}));
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if({{paramName}} != null) {
|
||||
stub = stub.withHeader("{{baseName}}", havingExactly({{paramName}}));
|
||||
}
|
||||
{{/required}}
|
||||
{{/headerParams}}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
{{#examples}}
|
||||
public static String {{operationId}}{{statusCode}}ResponseSample{{-index}}() {
|
||||
return {{>exampleString}};
|
||||
}
|
||||
{{/examples}}
|
||||
|
||||
{{#requestBodyExamples}}
|
||||
public static String {{operationId}}RequestSample{{-index}}() {
|
||||
return {{>exampleString}};
|
||||
}
|
||||
{{/requestBodyExamples}}
|
||||
|
||||
{{/operation}}
|
||||
|
||||
}
|
||||
{{/operations}}
|
@ -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
|
@ -0,0 +1,8 @@
|
||||
pom.xml
|
||||
src/main/java/org/openapitools/mockserver/api/AnotherFakeApiMockServer.java
|
||||
src/main/java/org/openapitools/mockserver/api/DefaultApiMockServer.java
|
||||
src/main/java/org/openapitools/mockserver/api/FakeApiMockServer.java
|
||||
src/main/java/org/openapitools/mockserver/api/FakeClassnameTags123ApiMockServer.java
|
||||
src/main/java/org/openapitools/mockserver/api/PetApiMockServer.java
|
||||
src/main/java/org/openapitools/mockserver/api/StoreApiMockServer.java
|
||||
src/main/java/org/openapitools/mockserver/api/UserApiMockServer.java
|
@ -0,0 +1 @@
|
||||
7.3.0-SNAPSHOT
|
183
samples/server/petstore/java-wiremock/pom.xml
Normal file
183
samples/server/petstore/java-wiremock/pom.xml
Normal file
@ -0,0 +1,183 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>petstore-wiremock</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>petstore-wiremock</name>
|
||||
<version>1.0.0</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<description>OpenAPI Java</description>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:openapitools/openapi-generator.git</developerConnection>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
</scm>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Unlicense</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.html</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>OpenAPI-Generator Contributors</name>
|
||||
<email>team@openapitools.org</email>
|
||||
<organization>OpenAPITools.org</organization>
|
||||
<organizationUrl>http://openapitools.org</organizationUrl>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>3.0.0-M1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-maven</id>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireMavenVersion>
|
||||
<version>2.2.0</version>
|
||||
</requireMavenVersion>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- attach test jar -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.10</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add_sources</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>src/main/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>add_test_sources</id>
|
||||
<phase>generate-test-sources</phase>
|
||||
<goals>
|
||||
<goal>add-test-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>src/test/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.3.2</version>
|
||||
<configuration>
|
||||
<doclint>none</doclint>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wiremock</groupId>
|
||||
<artifactId>wiremock-standalone</artifactId>
|
||||
<version>${wiremock.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- @Nullable annotation -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
<version>${javax.annotation-api-version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<wiremock.version>3.3.1</wiremock.version>
|
||||
|
||||
<javax.annotation-api-version>1.3.2</javax.annotation-api-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
</properties>
|
||||
</project>
|
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
package org.openapitools.mockserver.api;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import com.github.tomakehurst.wiremock.client.MappingBuilder;
|
||||
import com.github.tomakehurst.wiremock.http.Fault;
|
||||
|
||||
public class AnotherFakeApiMockServer {
|
||||
|
||||
public static MappingBuilder stubCall123testSpecialTags200(@javax.annotation.Nonnull String body, String response) {
|
||||
MappingBuilder stub = patch(urlPathEqualTo("/another-fake/dummy"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/json")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubCall123testSpecialTagsFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = patch(urlPathEqualTo("/another-fake/dummy"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String call123testSpecialTags200ResponseSample1() {
|
||||
return "{ \"client\" : \"client\" }";
|
||||
}
|
||||
|
||||
public static String call123testSpecialTagsRequestSample1() {
|
||||
return "{ \"client\" : \"client\" }";
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
package org.openapitools.mockserver.api;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import com.github.tomakehurst.wiremock.client.MappingBuilder;
|
||||
import com.github.tomakehurst.wiremock.http.Fault;
|
||||
|
||||
public class DefaultApiMockServer {
|
||||
|
||||
public static MappingBuilder stubFooGet0(String response) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/foo"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(0)
|
||||
.withHeader("Content-Type", "application/json")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubFooGetFault(Fault fault) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/foo"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String fooGet200ResponseSample1() {
|
||||
return "{ \"string\" : { \"bar\" : \"bar\" } }";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,892 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
package org.openapitools.mockserver.api;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import com.github.tomakehurst.wiremock.client.MappingBuilder;
|
||||
import com.github.tomakehurst.wiremock.http.Fault;
|
||||
|
||||
public class FakeApiMockServer {
|
||||
|
||||
public static MappingBuilder stubFakeBigDecimalMap200(String response) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/fake/BigDecimalMap"))
|
||||
.withHeader("Accept", havingExactly("*/*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "*/*")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubFakeBigDecimalMapFault(Fault fault) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/fake/BigDecimalMap"))
|
||||
.withHeader("Accept", havingExactly("*/*"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String fakeBigDecimalMap200ResponseSample1() {
|
||||
return "{ \"someId\" : 0.8008281904610115, \"someMap\" : { \"key\" : 6.027456183070403 } }";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubFakeHealthGet200(String response) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/fake/health"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/json")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubFakeHealthGetFault(Fault fault) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/fake/health"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String fakeHealthGet200ResponseSample1() {
|
||||
return "{ \"NullableMessage\" : \"NullableMessage\" }";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubFakeHttpSignatureTest200(@javax.annotation.Nonnull String body, @javax.annotation.Nullable String query1, @javax.annotation.Nullable String header1) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/fake/http-signature-test"))
|
||||
.withHeader("Content-Type", havingExactly("application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
);
|
||||
|
||||
if(query1 != null) {
|
||||
stub = stub.withQueryParam("query1", equalTo(query1));
|
||||
}
|
||||
if(header1 != null) {
|
||||
stub = stub.withHeader("header_1", havingExactly(header1));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubFakeHttpSignatureTestFault(@javax.annotation.Nonnull String body, @javax.annotation.Nullable String query1, @javax.annotation.Nullable String header1, Fault fault) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/fake/http-signature-test"))
|
||||
.withHeader("Content-Type", havingExactly("application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
if(query1 != null) {
|
||||
stub = stub.withQueryParam("query1", equalTo(query1));
|
||||
}
|
||||
if(header1 != null) {
|
||||
stub = stub.withHeader("header_1", havingExactly(header1));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String fakeHttpSignatureTestRequestSample1() {
|
||||
return "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
||||
}
|
||||
public static String fakeHttpSignatureTestRequestSample2() {
|
||||
return "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubFakeOuterBooleanSerialize200(@javax.annotation.Nullable String body, String response) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/outer/boolean"))
|
||||
.withHeader("Accept", havingExactly("*/*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "*/*")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubFakeOuterBooleanSerializeFault(@javax.annotation.Nullable String body, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/outer/boolean"))
|
||||
.withHeader("Accept", havingExactly("*/*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String fakeOuterBooleanSerializeRequestSample1() {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubFakeOuterCompositeSerialize200(@javax.annotation.Nullable String body, String response) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/outer/composite"))
|
||||
.withHeader("Accept", havingExactly("*/*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "*/*")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubFakeOuterCompositeSerializeFault(@javax.annotation.Nullable String body, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/outer/composite"))
|
||||
.withHeader("Accept", havingExactly("*/*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String fakeOuterCompositeSerialize200ResponseSample1() {
|
||||
return "{ \"my_string\" : \"my_string\", \"my_number\" : 0.8008281904610115, \"my_boolean\" : true }";
|
||||
}
|
||||
|
||||
public static String fakeOuterCompositeSerializeRequestSample1() {
|
||||
return "{ \"my_string\" : \"my_string\", \"my_number\" : 0.8008281904610115, \"my_boolean\" : true }";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubFakeOuterNumberSerialize200(@javax.annotation.Nullable String body, String response) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/outer/number"))
|
||||
.withHeader("Accept", havingExactly("*/*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "*/*")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubFakeOuterNumberSerializeFault(@javax.annotation.Nullable String body, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/outer/number"))
|
||||
.withHeader("Accept", havingExactly("*/*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String fakeOuterNumberSerializeRequestSample1() {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubFakeOuterStringSerialize200(@javax.annotation.Nullable String body, String response) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/outer/string"))
|
||||
.withHeader("Accept", havingExactly("*/*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "*/*")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubFakeOuterStringSerializeFault(@javax.annotation.Nullable String body, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/outer/string"))
|
||||
.withHeader("Accept", havingExactly("*/*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String fakeOuterStringSerializeRequestSample1() {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubFakePropertyEnumIntegerSerialize200(@javax.annotation.Nonnull String body, String response) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/property/enum-int"))
|
||||
.withHeader("Accept", havingExactly("*/*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "*/*")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubFakePropertyEnumIntegerSerializeFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/property/enum-int"))
|
||||
.withHeader("Accept", havingExactly("*/*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String fakePropertyEnumIntegerSerialize200ResponseSample1() {
|
||||
return "{ \"value\" : 2 }";
|
||||
}
|
||||
|
||||
public static String fakePropertyEnumIntegerSerializeRequestSample1() {
|
||||
return "{ \"value\" : 2 }";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubTestAdditionalPropertiesReference200(@javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/additionalProperties-reference"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestAdditionalPropertiesReferenceFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/additionalProperties-reference"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String testAdditionalPropertiesReferenceRequestSample1() {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubTestBodyWithBinary200(@javax.annotation.Nullable String body) {
|
||||
MappingBuilder stub = put(urlPathEqualTo("/fake/body-with-binary"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestBodyWithBinaryFault(@javax.annotation.Nullable String body, Fault fault) {
|
||||
MappingBuilder stub = put(urlPathEqualTo("/fake/body-with-binary"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String testBodyWithBinaryRequestSample1() {
|
||||
return "Custom MIME type example not yet supported: image/png";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubTestBodyWithFileSchema200(@javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = put(urlPathEqualTo("/fake/body-with-file-schema"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestBodyWithFileSchemaFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = put(urlPathEqualTo("/fake/body-with-file-schema"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String testBodyWithFileSchemaRequestSample1() {
|
||||
return "{ \"file\" : { \"sourceURI\" : \"sourceURI\" }, \"files\" : [ { \"sourceURI\" : \"sourceURI\" }, { \"sourceURI\" : \"sourceURI\" } ] }";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubTestBodyWithQueryParams200(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = put(urlPathEqualTo("/fake/body-with-query-params"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("query", equalTo(query));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestBodyWithQueryParamsFault(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = put(urlPathEqualTo("/fake/body-with-query-params"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("query", equalTo(query));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String testBodyWithQueryParamsRequestSample1() {
|
||||
return "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\" }";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubTestClientModel200(@javax.annotation.Nonnull String body, String response) {
|
||||
MappingBuilder stub = patch(urlPathEqualTo("/fake"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/json")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestClientModelFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = patch(urlPathEqualTo("/fake"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String testClientModel200ResponseSample1() {
|
||||
return "{ \"client\" : \"client\" }";
|
||||
}
|
||||
|
||||
public static String testClientModelRequestSample1() {
|
||||
return "{ \"client\" : \"client\" }";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubTestEndpointParameters400(@javax.annotation.Nonnull String number, @javax.annotation.Nonnull String _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull String _byte, @javax.annotation.Nullable String integer, @javax.annotation.Nullable String int32, @javax.annotation.Nullable String int64, @javax.annotation.Nullable String _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable String binary, @javax.annotation.Nullable String date, @javax.annotation.Nullable String dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake"))
|
||||
.withHeader("Content-Type", havingExactly("application/x-www-form-urlencoded"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
);
|
||||
|
||||
if(integer != null) {
|
||||
stub = stub.withFormParam("integer", havingExactly(integer));
|
||||
}
|
||||
if(int32 != null) {
|
||||
stub = stub.withFormParam("int32", havingExactly(int32));
|
||||
}
|
||||
if(int64 != null) {
|
||||
stub = stub.withFormParam("int64", havingExactly(int64));
|
||||
}
|
||||
stub = stub.withFormParam("number", havingExactly(number));
|
||||
if(_float != null) {
|
||||
stub = stub.withFormParam("float", havingExactly(_float));
|
||||
}
|
||||
stub = stub.withFormParam("double", havingExactly(_double));
|
||||
if(string != null) {
|
||||
stub = stub.withFormParam("string", havingExactly(string));
|
||||
}
|
||||
stub = stub.withFormParam("pattern_without_delimiter", havingExactly(patternWithoutDelimiter));
|
||||
stub = stub.withFormParam("byte", havingExactly(_byte));
|
||||
if(binary != null) {
|
||||
stub = stub.withFormParam("binary", havingExactly(binary));
|
||||
}
|
||||
if(date != null) {
|
||||
stub = stub.withFormParam("date", havingExactly(date));
|
||||
}
|
||||
if(dateTime != null) {
|
||||
stub = stub.withFormParam("dateTime", havingExactly(dateTime));
|
||||
}
|
||||
if(password != null) {
|
||||
stub = stub.withFormParam("password", havingExactly(password));
|
||||
}
|
||||
if(paramCallback != null) {
|
||||
stub = stub.withFormParam("callback", havingExactly(paramCallback));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestEndpointParameters404(@javax.annotation.Nonnull String number, @javax.annotation.Nonnull String _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull String _byte, @javax.annotation.Nullable String integer, @javax.annotation.Nullable String int32, @javax.annotation.Nullable String int64, @javax.annotation.Nullable String _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable String binary, @javax.annotation.Nullable String date, @javax.annotation.Nullable String dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake"))
|
||||
.withHeader("Content-Type", havingExactly("application/x-www-form-urlencoded"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(404)
|
||||
);
|
||||
|
||||
if(integer != null) {
|
||||
stub = stub.withFormParam("integer", havingExactly(integer));
|
||||
}
|
||||
if(int32 != null) {
|
||||
stub = stub.withFormParam("int32", havingExactly(int32));
|
||||
}
|
||||
if(int64 != null) {
|
||||
stub = stub.withFormParam("int64", havingExactly(int64));
|
||||
}
|
||||
stub = stub.withFormParam("number", havingExactly(number));
|
||||
if(_float != null) {
|
||||
stub = stub.withFormParam("float", havingExactly(_float));
|
||||
}
|
||||
stub = stub.withFormParam("double", havingExactly(_double));
|
||||
if(string != null) {
|
||||
stub = stub.withFormParam("string", havingExactly(string));
|
||||
}
|
||||
stub = stub.withFormParam("pattern_without_delimiter", havingExactly(patternWithoutDelimiter));
|
||||
stub = stub.withFormParam("byte", havingExactly(_byte));
|
||||
if(binary != null) {
|
||||
stub = stub.withFormParam("binary", havingExactly(binary));
|
||||
}
|
||||
if(date != null) {
|
||||
stub = stub.withFormParam("date", havingExactly(date));
|
||||
}
|
||||
if(dateTime != null) {
|
||||
stub = stub.withFormParam("dateTime", havingExactly(dateTime));
|
||||
}
|
||||
if(password != null) {
|
||||
stub = stub.withFormParam("password", havingExactly(password));
|
||||
}
|
||||
if(paramCallback != null) {
|
||||
stub = stub.withFormParam("callback", havingExactly(paramCallback));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestEndpointParametersFault(@javax.annotation.Nonnull String number, @javax.annotation.Nonnull String _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull String _byte, @javax.annotation.Nullable String integer, @javax.annotation.Nullable String int32, @javax.annotation.Nullable String int64, @javax.annotation.Nullable String _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable String binary, @javax.annotation.Nullable String date, @javax.annotation.Nullable String dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake"))
|
||||
.withHeader("Content-Type", havingExactly("application/x-www-form-urlencoded"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
if(integer != null) {
|
||||
stub = stub.withFormParam("integer", havingExactly(integer));
|
||||
}
|
||||
if(int32 != null) {
|
||||
stub = stub.withFormParam("int32", havingExactly(int32));
|
||||
}
|
||||
if(int64 != null) {
|
||||
stub = stub.withFormParam("int64", havingExactly(int64));
|
||||
}
|
||||
stub = stub.withFormParam("number", havingExactly(number));
|
||||
if(_float != null) {
|
||||
stub = stub.withFormParam("float", havingExactly(_float));
|
||||
}
|
||||
stub = stub.withFormParam("double", havingExactly(_double));
|
||||
if(string != null) {
|
||||
stub = stub.withFormParam("string", havingExactly(string));
|
||||
}
|
||||
stub = stub.withFormParam("pattern_without_delimiter", havingExactly(patternWithoutDelimiter));
|
||||
stub = stub.withFormParam("byte", havingExactly(_byte));
|
||||
if(binary != null) {
|
||||
stub = stub.withFormParam("binary", havingExactly(binary));
|
||||
}
|
||||
if(date != null) {
|
||||
stub = stub.withFormParam("date", havingExactly(date));
|
||||
}
|
||||
if(dateTime != null) {
|
||||
stub = stub.withFormParam("dateTime", havingExactly(dateTime));
|
||||
}
|
||||
if(password != null) {
|
||||
stub = stub.withFormParam("password", havingExactly(password));
|
||||
}
|
||||
if(paramCallback != null) {
|
||||
stub = stub.withFormParam("callback", havingExactly(paramCallback));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubTestEnumParameters400(@javax.annotation.Nullable String enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable String enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable String enumQueryInteger, @javax.annotation.Nullable String enumQueryDouble, @javax.annotation.Nullable String enumQueryModelArray, @javax.annotation.Nullable String enumFormStringArray, @javax.annotation.Nullable String enumFormString) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/fake"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
);
|
||||
|
||||
if(enumQueryStringArray != null) {
|
||||
stub = stub.withQueryParam("enumQueryStringArray", equalTo(enumQueryStringArray));
|
||||
}
|
||||
if(enumQueryString != null) {
|
||||
stub = stub.withQueryParam("enumQueryString", equalTo(enumQueryString));
|
||||
}
|
||||
if(enumQueryInteger != null) {
|
||||
stub = stub.withQueryParam("enumQueryInteger", equalTo(enumQueryInteger));
|
||||
}
|
||||
if(enumQueryDouble != null) {
|
||||
stub = stub.withQueryParam("enumQueryDouble", equalTo(enumQueryDouble));
|
||||
}
|
||||
if(enumQueryModelArray != null) {
|
||||
stub = stub.withQueryParam("enumQueryModelArray", equalTo(enumQueryModelArray));
|
||||
}
|
||||
if(enumFormStringArray != null) {
|
||||
stub = stub.withFormParam("enum_form_string_array", havingExactly(enumFormStringArray));
|
||||
}
|
||||
if(enumFormString != null) {
|
||||
stub = stub.withFormParam("enum_form_string", havingExactly(enumFormString));
|
||||
}
|
||||
if(enumHeaderStringArray != null) {
|
||||
stub = stub.withHeader("enum_header_string_array", havingExactly(enumHeaderStringArray));
|
||||
}
|
||||
if(enumHeaderString != null) {
|
||||
stub = stub.withHeader("enum_header_string", havingExactly(enumHeaderString));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestEnumParameters404(@javax.annotation.Nullable String enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable String enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable String enumQueryInteger, @javax.annotation.Nullable String enumQueryDouble, @javax.annotation.Nullable String enumQueryModelArray, @javax.annotation.Nullable String enumFormStringArray, @javax.annotation.Nullable String enumFormString) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/fake"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(404)
|
||||
);
|
||||
|
||||
if(enumQueryStringArray != null) {
|
||||
stub = stub.withQueryParam("enumQueryStringArray", equalTo(enumQueryStringArray));
|
||||
}
|
||||
if(enumQueryString != null) {
|
||||
stub = stub.withQueryParam("enumQueryString", equalTo(enumQueryString));
|
||||
}
|
||||
if(enumQueryInteger != null) {
|
||||
stub = stub.withQueryParam("enumQueryInteger", equalTo(enumQueryInteger));
|
||||
}
|
||||
if(enumQueryDouble != null) {
|
||||
stub = stub.withQueryParam("enumQueryDouble", equalTo(enumQueryDouble));
|
||||
}
|
||||
if(enumQueryModelArray != null) {
|
||||
stub = stub.withQueryParam("enumQueryModelArray", equalTo(enumQueryModelArray));
|
||||
}
|
||||
if(enumFormStringArray != null) {
|
||||
stub = stub.withFormParam("enum_form_string_array", havingExactly(enumFormStringArray));
|
||||
}
|
||||
if(enumFormString != null) {
|
||||
stub = stub.withFormParam("enum_form_string", havingExactly(enumFormString));
|
||||
}
|
||||
if(enumHeaderStringArray != null) {
|
||||
stub = stub.withHeader("enum_header_string_array", havingExactly(enumHeaderStringArray));
|
||||
}
|
||||
if(enumHeaderString != null) {
|
||||
stub = stub.withHeader("enum_header_string", havingExactly(enumHeaderString));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestEnumParametersFault(@javax.annotation.Nullable String enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable String enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable String enumQueryInteger, @javax.annotation.Nullable String enumQueryDouble, @javax.annotation.Nullable String enumQueryModelArray, @javax.annotation.Nullable String enumFormStringArray, @javax.annotation.Nullable String enumFormString, Fault fault) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/fake"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
if(enumQueryStringArray != null) {
|
||||
stub = stub.withQueryParam("enumQueryStringArray", equalTo(enumQueryStringArray));
|
||||
}
|
||||
if(enumQueryString != null) {
|
||||
stub = stub.withQueryParam("enumQueryString", equalTo(enumQueryString));
|
||||
}
|
||||
if(enumQueryInteger != null) {
|
||||
stub = stub.withQueryParam("enumQueryInteger", equalTo(enumQueryInteger));
|
||||
}
|
||||
if(enumQueryDouble != null) {
|
||||
stub = stub.withQueryParam("enumQueryDouble", equalTo(enumQueryDouble));
|
||||
}
|
||||
if(enumQueryModelArray != null) {
|
||||
stub = stub.withQueryParam("enumQueryModelArray", equalTo(enumQueryModelArray));
|
||||
}
|
||||
if(enumFormStringArray != null) {
|
||||
stub = stub.withFormParam("enum_form_string_array", havingExactly(enumFormStringArray));
|
||||
}
|
||||
if(enumFormString != null) {
|
||||
stub = stub.withFormParam("enum_form_string", havingExactly(enumFormString));
|
||||
}
|
||||
if(enumHeaderStringArray != null) {
|
||||
stub = stub.withHeader("enum_header_string_array", havingExactly(enumHeaderStringArray));
|
||||
}
|
||||
if(enumHeaderString != null) {
|
||||
stub = stub.withHeader("enum_header_string", havingExactly(enumHeaderString));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubTestGroupParameters400(@javax.annotation.Nonnull String requiredStringGroup, @javax.annotation.Nonnull String requiredBooleanGroup, @javax.annotation.Nonnull String requiredInt64Group, @javax.annotation.Nullable String stringGroup, @javax.annotation.Nullable String booleanGroup, @javax.annotation.Nullable String int64Group) {
|
||||
MappingBuilder stub = delete(urlPathEqualTo("/fake"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("requiredStringGroup", equalTo(requiredStringGroup));
|
||||
stub = stub.withQueryParam("requiredInt64Group", equalTo(requiredInt64Group));
|
||||
if(stringGroup != null) {
|
||||
stub = stub.withQueryParam("stringGroup", equalTo(stringGroup));
|
||||
}
|
||||
if(int64Group != null) {
|
||||
stub = stub.withQueryParam("int64Group", equalTo(int64Group));
|
||||
}
|
||||
stub = stub.withHeader("required_boolean_group", havingExactly(requiredBooleanGroup));
|
||||
if(booleanGroup != null) {
|
||||
stub = stub.withHeader("boolean_group", havingExactly(booleanGroup));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestGroupParametersFault(@javax.annotation.Nonnull String requiredStringGroup, @javax.annotation.Nonnull String requiredBooleanGroup, @javax.annotation.Nonnull String requiredInt64Group, @javax.annotation.Nullable String stringGroup, @javax.annotation.Nullable String booleanGroup, @javax.annotation.Nullable String int64Group, Fault fault) {
|
||||
MappingBuilder stub = delete(urlPathEqualTo("/fake"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("requiredStringGroup", equalTo(requiredStringGroup));
|
||||
stub = stub.withQueryParam("requiredInt64Group", equalTo(requiredInt64Group));
|
||||
if(stringGroup != null) {
|
||||
stub = stub.withQueryParam("stringGroup", equalTo(stringGroup));
|
||||
}
|
||||
if(int64Group != null) {
|
||||
stub = stub.withQueryParam("int64Group", equalTo(int64Group));
|
||||
}
|
||||
stub = stub.withHeader("required_boolean_group", havingExactly(requiredBooleanGroup));
|
||||
if(booleanGroup != null) {
|
||||
stub = stub.withHeader("boolean_group", havingExactly(booleanGroup));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubTestInlineAdditionalProperties200(@javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/inline-additionalProperties"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestInlineAdditionalPropertiesFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/inline-additionalProperties"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String testInlineAdditionalPropertiesRequestSample1() {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubTestInlineFreeformAdditionalProperties200(@javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/inline-freeform-additionalProperties"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestInlineFreeformAdditionalPropertiesFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/inline-freeform-additionalProperties"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String testInlineFreeformAdditionalPropertiesRequestSample1() {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubTestJsonFormData200(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/fake/jsonFormData"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
);
|
||||
|
||||
stub = stub.withFormParam("param", havingExactly(param));
|
||||
stub = stub.withFormParam("param2", havingExactly(param2));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestJsonFormDataFault(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2, Fault fault) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/fake/jsonFormData"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withFormParam("param", havingExactly(param));
|
||||
stub = stub.withFormParam("param2", havingExactly(param2));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubTestNullable200(@javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/nullable"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestNullableFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/fake/nullable"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String testNullableRequestSample1() {
|
||||
return "{ \"otherProperty\" : \"otherProperty\", \"nullableProperty\" : \"nullableProperty\", \"type\" : \"ChildWithNullable\" }";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubTestQueryParameterCollectionFormat200(@javax.annotation.Nonnull String pipe, @javax.annotation.Nonnull String ioutil, @javax.annotation.Nonnull String http, @javax.annotation.Nonnull String url, @javax.annotation.Nonnull String context, @javax.annotation.Nonnull String allowEmpty, @javax.annotation.Nullable String language) {
|
||||
MappingBuilder stub = put(urlPathEqualTo("/fake/test-query-parameters"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("pipe", equalTo(pipe));
|
||||
stub = stub.withQueryParam("ioutil", equalTo(ioutil));
|
||||
stub = stub.withQueryParam("http", equalTo(http));
|
||||
stub = stub.withQueryParam("url", equalTo(url));
|
||||
stub = stub.withQueryParam("context", equalTo(context));
|
||||
if(language != null) {
|
||||
stub = stub.withQueryParam("language", equalTo(language));
|
||||
}
|
||||
stub = stub.withQueryParam("allowEmpty", equalTo(allowEmpty));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestQueryParameterCollectionFormatFault(@javax.annotation.Nonnull String pipe, @javax.annotation.Nonnull String ioutil, @javax.annotation.Nonnull String http, @javax.annotation.Nonnull String url, @javax.annotation.Nonnull String context, @javax.annotation.Nonnull String allowEmpty, @javax.annotation.Nullable String language, Fault fault) {
|
||||
MappingBuilder stub = put(urlPathEqualTo("/fake/test-query-parameters"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("pipe", equalTo(pipe));
|
||||
stub = stub.withQueryParam("ioutil", equalTo(ioutil));
|
||||
stub = stub.withQueryParam("http", equalTo(http));
|
||||
stub = stub.withQueryParam("url", equalTo(url));
|
||||
stub = stub.withQueryParam("context", equalTo(context));
|
||||
if(language != null) {
|
||||
stub = stub.withQueryParam("language", equalTo(language));
|
||||
}
|
||||
stub = stub.withQueryParam("allowEmpty", equalTo(allowEmpty));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
package org.openapitools.mockserver.api;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import com.github.tomakehurst.wiremock.client.MappingBuilder;
|
||||
import com.github.tomakehurst.wiremock.http.Fault;
|
||||
|
||||
public class FakeClassnameTags123ApiMockServer {
|
||||
|
||||
public static MappingBuilder stubTestClassname200(@javax.annotation.Nonnull String body, String response) {
|
||||
MappingBuilder stub = patch(urlPathEqualTo("/fake_classname_test"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.withHeader("Content-Type", havingExactly("application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/json")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubTestClassnameFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = patch(urlPathEqualTo("/fake_classname_test"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.withHeader("Content-Type", havingExactly("application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String testClassname200ResponseSample1() {
|
||||
return "{ \"client\" : \"client\" }";
|
||||
}
|
||||
|
||||
public static String testClassnameRequestSample1() {
|
||||
return "{ \"client\" : \"client\" }";
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,509 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
package org.openapitools.mockserver.api;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import com.github.tomakehurst.wiremock.client.MappingBuilder;
|
||||
import com.github.tomakehurst.wiremock.http.Fault;
|
||||
|
||||
public class PetApiMockServer {
|
||||
|
||||
public static MappingBuilder stubAddPet200(@javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/pet"))
|
||||
.withHeader("Content-Type", havingExactly("application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubAddPet405(@javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/pet"))
|
||||
.withHeader("Content-Type", havingExactly("application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(405)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubAddPetFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/pet"))
|
||||
.withHeader("Content-Type", havingExactly("application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String addPetRequestSample1() {
|
||||
return "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
||||
}
|
||||
public static String addPetRequestSample2() {
|
||||
return "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubDeletePet200(@javax.annotation.Nonnull String petId, @javax.annotation.Nullable String apiKey) {
|
||||
MappingBuilder stub = delete(urlPathTemplate("/pet/{petId}"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("petId", equalTo(petId));
|
||||
if(apiKey != null) {
|
||||
stub = stub.withHeader("api_key", havingExactly(apiKey));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubDeletePet400(@javax.annotation.Nonnull String petId, @javax.annotation.Nullable String apiKey) {
|
||||
MappingBuilder stub = delete(urlPathTemplate("/pet/{petId}"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("petId", equalTo(petId));
|
||||
if(apiKey != null) {
|
||||
stub = stub.withHeader("api_key", havingExactly(apiKey));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubDeletePetFault(@javax.annotation.Nonnull String petId, @javax.annotation.Nullable String apiKey, Fault fault) {
|
||||
MappingBuilder stub = delete(urlPathTemplate("/pet/{petId}"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("petId", equalTo(petId));
|
||||
if(apiKey != null) {
|
||||
stub = stub.withHeader("api_key", havingExactly(apiKey));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubFindPetsByStatus200(@javax.annotation.Nonnull String status, String response) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/pet/findByStatus"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("status", equalTo(status));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubFindPetsByStatus400(@javax.annotation.Nonnull String status, String response) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/pet/findByStatus"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("status", equalTo(status));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubFindPetsByStatusFault(@javax.annotation.Nonnull String status, Fault fault) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/pet/findByStatus"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("status", equalTo(status));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String findPetsByStatus200ResponseSample1() {
|
||||
return "[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" } ]";
|
||||
}
|
||||
public static String findPetsByStatus200ResponseSample2() {
|
||||
return "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Deprecated
|
||||
public static MappingBuilder stubFindPetsByTags200(@javax.annotation.Nonnull String tags, String response) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/pet/findByTags"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("tags", equalTo(tags));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static MappingBuilder stubFindPetsByTags400(@javax.annotation.Nonnull String tags, String response) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/pet/findByTags"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("tags", equalTo(tags));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubFindPetsByTagsFault(@javax.annotation.Nonnull String tags, Fault fault) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/pet/findByTags"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("tags", equalTo(tags));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String findPetsByTags200ResponseSample1() {
|
||||
return "[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" } ]";
|
||||
}
|
||||
public static String findPetsByTags200ResponseSample2() {
|
||||
return "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubGetPetById200(@javax.annotation.Nonnull String petId, String response) {
|
||||
MappingBuilder stub = get(urlPathTemplate("/pet/{petId}"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("petId", equalTo(petId));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubGetPetById400(@javax.annotation.Nonnull String petId, String response) {
|
||||
MappingBuilder stub = get(urlPathTemplate("/pet/{petId}"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("petId", equalTo(petId));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubGetPetById404(@javax.annotation.Nonnull String petId, String response) {
|
||||
MappingBuilder stub = get(urlPathTemplate("/pet/{petId}"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(404)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("petId", equalTo(petId));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubGetPetByIdFault(@javax.annotation.Nonnull String petId, Fault fault) {
|
||||
MappingBuilder stub = get(urlPathTemplate("/pet/{petId}"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("petId", equalTo(petId));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String getPetById200ResponseSample1() {
|
||||
return "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
||||
}
|
||||
public static String getPetById200ResponseSample2() {
|
||||
return "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubUpdatePet200(@javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = put(urlPathEqualTo("/pet"))
|
||||
.withHeader("Content-Type", havingExactly("application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubUpdatePet400(@javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = put(urlPathEqualTo("/pet"))
|
||||
.withHeader("Content-Type", havingExactly("application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubUpdatePet404(@javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = put(urlPathEqualTo("/pet"))
|
||||
.withHeader("Content-Type", havingExactly("application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(404)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubUpdatePet405(@javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = put(urlPathEqualTo("/pet"))
|
||||
.withHeader("Content-Type", havingExactly("application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(405)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubUpdatePetFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = put(urlPathEqualTo("/pet"))
|
||||
.withHeader("Content-Type", havingExactly("application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String updatePetRequestSample1() {
|
||||
return "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
||||
}
|
||||
public static String updatePetRequestSample2() {
|
||||
return "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubUpdatePetWithForm200(@javax.annotation.Nonnull String petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) {
|
||||
MappingBuilder stub = post(urlPathTemplate("/pet/{petId}"))
|
||||
.withHeader("Content-Type", havingExactly("application/x-www-form-urlencoded"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("petId", equalTo(petId));
|
||||
if(name != null) {
|
||||
stub = stub.withFormParam("name", havingExactly(name));
|
||||
}
|
||||
if(status != null) {
|
||||
stub = stub.withFormParam("status", havingExactly(status));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubUpdatePetWithForm405(@javax.annotation.Nonnull String petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) {
|
||||
MappingBuilder stub = post(urlPathTemplate("/pet/{petId}"))
|
||||
.withHeader("Content-Type", havingExactly("application/x-www-form-urlencoded"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(405)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("petId", equalTo(petId));
|
||||
if(name != null) {
|
||||
stub = stub.withFormParam("name", havingExactly(name));
|
||||
}
|
||||
if(status != null) {
|
||||
stub = stub.withFormParam("status", havingExactly(status));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubUpdatePetWithFormFault(@javax.annotation.Nonnull String petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathTemplate("/pet/{petId}"))
|
||||
.withHeader("Content-Type", havingExactly("application/x-www-form-urlencoded"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("petId", equalTo(petId));
|
||||
if(name != null) {
|
||||
stub = stub.withFormParam("name", havingExactly(name));
|
||||
}
|
||||
if(status != null) {
|
||||
stub = stub.withFormParam("status", havingExactly(status));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubUploadFile200(@javax.annotation.Nonnull String petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable String _file, String response) {
|
||||
MappingBuilder stub = post(urlPathTemplate("/pet/{petId}/uploadImage"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.withHeader("Content-Type", havingExactly("multipart/form-data"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/json")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("petId", equalTo(petId));
|
||||
if(additionalMetadata != null) {
|
||||
stub = stub.withFormParam("additionalMetadata", havingExactly(additionalMetadata));
|
||||
}
|
||||
if(_file != null) {
|
||||
stub = stub.withFormParam("file", havingExactly(_file));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubUploadFileFault(@javax.annotation.Nonnull String petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable String _file, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathTemplate("/pet/{petId}/uploadImage"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.withHeader("Content-Type", havingExactly("multipart/form-data"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("petId", equalTo(petId));
|
||||
if(additionalMetadata != null) {
|
||||
stub = stub.withFormParam("additionalMetadata", havingExactly(additionalMetadata));
|
||||
}
|
||||
if(_file != null) {
|
||||
stub = stub.withFormParam("file", havingExactly(_file));
|
||||
}
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String uploadFile200ResponseSample1() {
|
||||
return "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubUploadFileWithRequiredFile200(@javax.annotation.Nonnull String petId, @javax.annotation.Nonnull String requiredFile, @javax.annotation.Nullable String additionalMetadata, String response) {
|
||||
MappingBuilder stub = post(urlPathTemplate("/fake/{petId}/uploadImageWithRequiredFile"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.withHeader("Content-Type", havingExactly("multipart/form-data"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/json")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("petId", equalTo(petId));
|
||||
if(additionalMetadata != null) {
|
||||
stub = stub.withFormParam("additionalMetadata", havingExactly(additionalMetadata));
|
||||
}
|
||||
stub = stub.withFormParam("requiredFile", havingExactly(requiredFile));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubUploadFileWithRequiredFileFault(@javax.annotation.Nonnull String petId, @javax.annotation.Nonnull String requiredFile, @javax.annotation.Nullable String additionalMetadata, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathTemplate("/fake/{petId}/uploadImageWithRequiredFile"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.withHeader("Content-Type", havingExactly("multipart/form-data"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("petId", equalTo(petId));
|
||||
if(additionalMetadata != null) {
|
||||
stub = stub.withFormParam("additionalMetadata", havingExactly(additionalMetadata));
|
||||
}
|
||||
stub = stub.withFormParam("requiredFile", havingExactly(requiredFile));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String uploadFileWithRequiredFile200ResponseSample1() {
|
||||
return "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,194 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
package org.openapitools.mockserver.api;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import com.github.tomakehurst.wiremock.client.MappingBuilder;
|
||||
import com.github.tomakehurst.wiremock.http.Fault;
|
||||
|
||||
public class StoreApiMockServer {
|
||||
|
||||
public static MappingBuilder stubDeleteOrder400(@javax.annotation.Nonnull String orderId) {
|
||||
MappingBuilder stub = delete(urlPathTemplate("/store/order/{order_id}"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("orderId", equalTo(orderId));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubDeleteOrder404(@javax.annotation.Nonnull String orderId) {
|
||||
MappingBuilder stub = delete(urlPathTemplate("/store/order/{order_id}"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(404)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("orderId", equalTo(orderId));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubDeleteOrderFault(@javax.annotation.Nonnull String orderId, Fault fault) {
|
||||
MappingBuilder stub = delete(urlPathTemplate("/store/order/{order_id}"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("orderId", equalTo(orderId));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubGetInventory200(String response) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/store/inventory"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/json")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubGetInventoryFault(Fault fault) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/store/inventory"))
|
||||
.withHeader("Accept", havingExactly("application/json"))
|
||||
.withHeader("Authorization", matching(".*"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubGetOrderById200(@javax.annotation.Nonnull String orderId, String response) {
|
||||
MappingBuilder stub = get(urlPathTemplate("/store/order/{order_id}"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("orderId", equalTo(orderId));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubGetOrderById400(@javax.annotation.Nonnull String orderId, String response) {
|
||||
MappingBuilder stub = get(urlPathTemplate("/store/order/{order_id}"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("orderId", equalTo(orderId));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubGetOrderById404(@javax.annotation.Nonnull String orderId, String response) {
|
||||
MappingBuilder stub = get(urlPathTemplate("/store/order/{order_id}"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(404)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("orderId", equalTo(orderId));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubGetOrderByIdFault(@javax.annotation.Nonnull String orderId, Fault fault) {
|
||||
MappingBuilder stub = get(urlPathTemplate("/store/order/{order_id}"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("orderId", equalTo(orderId));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String getOrderById200ResponseSample1() {
|
||||
return "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }";
|
||||
}
|
||||
public static String getOrderById200ResponseSample2() {
|
||||
return "<Order> <id>123456789</id> <petId>123456789</petId> <quantity>123</quantity> <shipDate>2000-01-23T04:56:07.000Z</shipDate> <status>aeiou</status> <complete>true</complete> </Order>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubPlaceOrder200(@javax.annotation.Nonnull String body, String response) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/store/order"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubPlaceOrder400(@javax.annotation.Nonnull String body, String response) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/store/order"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubPlaceOrderFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/store/order"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String placeOrder200ResponseSample1() {
|
||||
return "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }";
|
||||
}
|
||||
public static String placeOrder200ResponseSample2() {
|
||||
return "<Order> <id>123456789</id> <petId>123456789</petId> <quantity>123</quantity> <shipDate>2000-01-23T04:56:07.000Z</shipDate> <status>aeiou</status> <complete>true</complete> </Order>";
|
||||
}
|
||||
|
||||
public static String placeOrderRequestSample1() {
|
||||
return "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }";
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,310 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
package org.openapitools.mockserver.api;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import com.github.tomakehurst.wiremock.client.MappingBuilder;
|
||||
import com.github.tomakehurst.wiremock.http.Fault;
|
||||
|
||||
public class UserApiMockServer {
|
||||
|
||||
public static MappingBuilder stubCreateUser0(@javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/user"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(0)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubCreateUserFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/user"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String createUserRequestSample1() {
|
||||
return "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\" }";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubCreateUsersWithArrayInput0(@javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/user/createWithArray"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(0)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubCreateUsersWithArrayInputFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/user/createWithArray"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String createUsersWithArrayInputRequestSample1() {
|
||||
return "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\" }";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubCreateUsersWithListInput0(@javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/user/createWithList"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(0)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubCreateUsersWithListInputFault(@javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = post(urlPathEqualTo("/user/createWithList"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String createUsersWithListInputRequestSample1() {
|
||||
return "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\" }";
|
||||
}
|
||||
|
||||
|
||||
public static MappingBuilder stubDeleteUser400(@javax.annotation.Nonnull String username) {
|
||||
MappingBuilder stub = delete(urlPathTemplate("/user/{username}"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("username", equalTo(username));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubDeleteUser404(@javax.annotation.Nonnull String username) {
|
||||
MappingBuilder stub = delete(urlPathTemplate("/user/{username}"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(404)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("username", equalTo(username));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubDeleteUserFault(@javax.annotation.Nonnull String username, Fault fault) {
|
||||
MappingBuilder stub = delete(urlPathTemplate("/user/{username}"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("username", equalTo(username));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubGetUserByName200(@javax.annotation.Nonnull String username, String response) {
|
||||
MappingBuilder stub = get(urlPathTemplate("/user/{username}"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("username", equalTo(username));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubGetUserByName400(@javax.annotation.Nonnull String username, String response) {
|
||||
MappingBuilder stub = get(urlPathTemplate("/user/{username}"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("username", equalTo(username));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubGetUserByName404(@javax.annotation.Nonnull String username, String response) {
|
||||
MappingBuilder stub = get(urlPathTemplate("/user/{username}"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(404)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("username", equalTo(username));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubGetUserByNameFault(@javax.annotation.Nonnull String username, Fault fault) {
|
||||
MappingBuilder stub = get(urlPathTemplate("/user/{username}"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("username", equalTo(username));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static String getUserByName200ResponseSample1() {
|
||||
return "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\" }";
|
||||
}
|
||||
public static String getUserByName200ResponseSample2() {
|
||||
return "<User> <id>123456789</id> <username>aeiou</username> <firstName>aeiou</firstName> <lastName>aeiou</lastName> <email>aeiou</email> <password>aeiou</password> <phone>aeiou</phone> <userStatus>123</userStatus> </User>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubLoginUser200(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, String responseXRateLimit, String responseXExpiresAfter, String response) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/user/login"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withHeader("X-Rate-Limit", responseXRateLimit)
|
||||
.withHeader("X-Expires-After", responseXExpiresAfter)
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("username", equalTo(username));
|
||||
stub = stub.withQueryParam("password", equalTo(password));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubLoginUser400(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, String response) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/user/login"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
.withHeader("Content-Type", "application/xml")
|
||||
.withBody(response)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("username", equalTo(username));
|
||||
stub = stub.withQueryParam("password", equalTo(password));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubLoginUserFault(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Fault fault) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/user/login"))
|
||||
.withHeader("Accept", havingExactly("application/xml", "application/json"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withQueryParam("username", equalTo(username));
|
||||
stub = stub.withQueryParam("password", equalTo(password));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubLogoutUser0() {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/user/logout"))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(0)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubLogoutUserFault(Fault fault) {
|
||||
MappingBuilder stub = get(urlPathEqualTo("/user/logout"))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static MappingBuilder stubUpdateUser400(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = put(urlPathTemplate("/user/{username}"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(400)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("username", equalTo(username));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubUpdateUser404(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String body) {
|
||||
MappingBuilder stub = put(urlPathTemplate("/user/{username}"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withStatus(404)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("username", equalTo(username));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
public static MappingBuilder stubUpdateUserFault(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String body, Fault fault) {
|
||||
MappingBuilder stub = put(urlPathTemplate("/user/{username}"))
|
||||
.withRequestBody(equalToJson(body))
|
||||
.willReturn(aResponse()
|
||||
.withFault(fault)
|
||||
);
|
||||
|
||||
stub = stub.withPathParam("username", equalTo(username));
|
||||
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
||||
public static String updateUserRequestSample1() {
|
||||
return "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\" }";
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user