Merge remote-tracking branch 'origin/master' into 2.3.0

This commit is contained in:
wing328 2017-03-23 16:54:49 +08:00
commit aa3a5c6347
43 changed files with 878 additions and 71 deletions

31
bin/html-markdown.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
SCRIPT="$0"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/markdown.yaml -l html -o samples/html.md"
java $JAVA_OPTS -jar $executable $ags

View File

@ -10,3 +10,4 @@
./bin/java-petstore-retrofit2rx.sh
./bin/java8-petstore-jersey2.sh
./bin/java-petstore-retrofit2-play24.sh
./bin/java-petstore-jersey2-java6.sh

View File

@ -26,7 +26,7 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2-java6 -DhideGenerationTimestamp=true,supportJava6=true"
ags="$@ generate --artifact-id swagger-petstore-jersey2-java6 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2-java6 -DhideGenerationTimestamp=true,supportJava6=true"
echo "Removing files and folders under samples/client/petstore/java/jersey2/src/main"
rm -rf samples/client/petstore/java/jersey2-java6/src/main

View File

@ -283,6 +283,11 @@
<version>${diffutils-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.atlassian.commonmark</groupId>
<artifactId>commonmark</artifactId>
<version>0.9.0</version>
</dependency>
</dependencies>
<repositories>

View File

@ -36,6 +36,7 @@ public class CodegenOperation {
public Map<String, Object> vendorExtensions;
public String nickname; // legacy support
public String operationIdLowerCase; // for mardown documentation
public String operationIdCamelCase; // for class names
/**
* Check if there's at least one parameter
@ -279,7 +280,9 @@ public class CodegenOperation {
return false;
if ( prioritizedContentTypes != null ? !prioritizedContentTypes.equals(that.prioritizedContentTypes) : that.prioritizedContentTypes != null )
return false;
return operationIdLowerCase != null ? operationIdLowerCase.equals(that.operationIdLowerCase) : that.operationIdLowerCase == null;
if ( operationIdLowerCase != null ? !operationIdLowerCase.equals(that.operationIdLowerCase) : that.operationIdLowerCase != null )
return false;
return operationIdCamelCase != null ? operationIdCamelCase.equals(that.operationIdCamelCase) : that.operationIdCamelCase == null;
}
@ -332,6 +335,7 @@ public class CodegenOperation {
result = 31 * result + (nickname != null ? nickname.hashCode() : 0);
result = 31 * result + (prioritizedContentTypes != null ? prioritizedContentTypes.hashCode() : 0);
result = 31 * result + (operationIdLowerCase != null ? operationIdLowerCase.hashCode() : 0);
result = 31 * result + (operationIdCamelCase != null ? operationIdCamelCase.hashCode() : 0);
return result;
}
}

View File

@ -2827,6 +2827,7 @@ public class DefaultCodegen {
}
co.operationId = uniqueName;
co.operationIdLowerCase = uniqueName.toLowerCase();
co.operationIdCamelCase = DefaultCodegen.camelize(uniqueName);
opList.add(co);
co.baseName = tag;
}

View File

@ -356,6 +356,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
this.vendorExtensions = o.vendorExtensions;
this.nickname = o.nickname;
this.operationIdLowerCase = o.operationIdLowerCase;
this.operationIdCamelCase = o.operationIdCamelCase;
}
public List<String> getPathTemplateNames() {

View File

@ -3,22 +3,31 @@ package io.swagger.codegen.languages;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenOperation;
import io.swagger.codegen.CodegenParameter;
import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.CodegenResponse;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile;
import io.swagger.models.Operation;
import io.swagger.models.Info;
import io.swagger.models.Model;
import io.swagger.models.Swagger;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.Property;
import java.util.ArrayList;
import io.swagger.codegen.utils.Markdown;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import com.samskivert.mustache.Escapers;
import com.samskivert.mustache.Mustache.Compiler;
import io.swagger.codegen.utils.Markdown;
public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "io.swagger.client";
protected String groupId = "io.swagger";
@ -61,13 +70,19 @@ public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig
importMapping = new HashMap<String, String>();
}
@Override
/**
* Convert Markdown (CommonMark) to HTML. This class also disables normal HTML
* escaping in the Mustache engine (see {@link #processCompiler(Compiler)} above.)
*/
@Override
public String escapeText(String input) {
// newline escaping disabled for HTML documentation for markdown to work correctly
return input;
return toHtml(input);
}
@Override
@Override
public CodegenType getTag() {
return CodegenType.DOCUMENTATION;
}
@ -124,4 +139,61 @@ public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig
// just return the original string
return input;
}
/**
* Markdown conversion emits HTML and by default, the Mustache
* {@link Compiler} will escape HTML. For example a summary
* <code>"Text with **bold**"</code> is converted from Markdown to HTML as
* <code>"Text with &lt;strong&gt;bold&lt;/strong&gt; text"</code> and then
* the default compiler with HTML escaping on turns this into
* <code>"Text with &amp;lt;strong&amp;gt;bold&amp;lt;/strong&amp;gt; text"</code>.
* Here, we disable escaping by setting the compiler to {@link Escapers#NONE
* Escapers.NONE}
*/
@Override
public Compiler processCompiler(Compiler compiler) {
return compiler.withEscaper(Escapers.NONE);
}
private Markdown markdownConverter = new Markdown();
private static final boolean CONVERT_TO_MARKDOWN_VIA_ESCAPE_TEXT = false;
/**
* Convert Markdown text to HTML
* @param input text in Markdown; may be null.
* @return the text, converted to Markdown. For null input, "" is returned.
*/
public String toHtml(String input) {
if (input == null)
return "";
return markdownConverter.toHtml(input);
}
public void preprocessSwagger(Swagger swagger) {
Info info = swagger.getInfo();
info.setDescription(toHtml(info.getDescription()));
info.setTitle(toHtml(info.getTitle()));
Map<String, Model> models = swagger.getDefinitions();
for (Model model : models.values()) {
model.setDescription(toHtml(model.getDescription()));
model.setTitle(toHtml(model.getTitle()));
}
}
// override to post-process any parameters
public void postProcessParameter(CodegenParameter parameter) {
parameter.description = toHtml(parameter.description);
parameter.unescapedDescription = toHtml(
parameter.unescapedDescription);
}
// override to post-process any model properties
public void postProcessModelProperty(CodegenModel model,
CodegenProperty property) {
property.description = toHtml(property.description);
property.unescapedDescription = toHtml(
property.unescapedDescription);
}
}

View File

@ -0,0 +1,47 @@
package io.swagger.codegen.utils;
import org.commonmark.node.Node;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;
/**
* Utility class to convert Markdown (CommonMark) to HTML.
* <a href='https://github.com/atlassian/commonmark-java/issues/83'>This class is threadsafe.</a>
*/
public class Markdown {
// see https://github.com/atlassian/commonmark-java
private final Parser parser = Parser.builder().build();
private final HtmlRenderer renderer = HtmlRenderer.builder().build();
/**
* Convert input markdown text to HTML.
* Simple text is not wrapped in <p>...</p>.
* @param markdown text with Markdown styles. If <code>null<code>, </code>""</code> is returned.
* @return HTML rendering from the Markdown
*/
public String toHtml(String markdown) {
if (markdown == null)
return "";
Node document = parser.parse(markdown);
String html = renderer.render(document);
html = unwrapped(html);
return html;
}
// The CommonMark library wraps the HTML with
// <p> ... html ... </p>\n
// This method removes that markup wrapper if there are no other <p> elements,
// do that Markdown can be used in non-block contexts such as operation summary etc.
private static final String P_END = "</p>\n";
private static final String P_START = "<p>";
private String unwrapped(String html) {
if (html.startsWith(P_START) && html.endsWith(P_END)
&& html.lastIndexOf(P_START) == 0)
return html.substring(P_START.length(),
html.length() - P_END.length());
else
return html;
}
}

View File

@ -38,6 +38,54 @@ public interface {{classname}} extends ApiClient.Api {
{{/hasMore}}{{/headerParams}}
})
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{^isBodyParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isBodyParam}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{#hasQueryParams}}
/**
* {{summary}}
* {{notes}}
* Note, this is equivalent to the other <code>{{operationId}}</code> method,
* but with the query parameters collected into a single Map parameter. This
* is convenient for services with optional query parameters, especially when
* used with the {@link {{operationIdCamelCase}}QueryParams} class that allows for
* building up this map in a fluent style.
{{#allParams}}
{{^isQueryParam}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/isQueryParam}}
{{/allParams}}
* @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:</p>
* <ul>
{{#queryParams}}
* <li>{{paramName}} - {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}</li>
{{/queryParams}}
* </ul>
{{#returnType}}
* @return {{returnType}}
{{/returnType}}
*/
@RequestLine("{{httpMethod}} {{{path}}}?{{#queryParams}}{{baseName}}={{=<% %>=}}{<%paramName%>}<%={{ }}=%>{{#hasMore}}&{{/hasMore}}{{/queryParams}}")
@Headers({
"Content-Type: {{vendorExtensions.x-contentType}}",
"Accept: {{vendorExtensions.x-accepts}}",{{#headerParams}}
"{{baseName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{#hasMore}},
{{/hasMore}}{{/headerParams}}
})
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{^isQueryParam}}{{^isBodyParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isBodyParam}}{{{dataType}}} {{paramName}}, {{/isQueryParam}}{{/allParams}}@QueryMap Map<String, Object> queryParams);
/**
* A convenience class for generating query parameters for the
* <code>{{operationId}}</code> method in a fluent style.
*/
public static class {{operationIdCamelCase}}QueryParams extends HashMap<String, Object> {
{{#queryParams}}
public {{operationIdCamelCase}}QueryParams {{paramName}}(final {{{dataType}}} value) {
put("{{paramName}}", value);
return this;
}
{{/queryParams}}
}
{{/hasQueryParams}}
{{/operation}}
{{/operations}}
}

View File

@ -40,5 +40,31 @@ public class {{classname}}Test {
// TODO: test validations
}
{{#hasQueryParams}}
/**
* {{summary}}
*
* {{notes}}
*
* This tests the overload of the method that uses a Map for query parameters instead of
* listing them out individually.
*/
@Test
public void {{operationId}}TestQueryMap() {
{{#allParams}}
{{^isQueryParam}}
{{{dataType}}} {{paramName}} = null;
{{/isQueryParam}}
{{/allParams}}
{{classname}}.{{operationIdCamelCase}}QueryParams queryParams = new {{classname}}.{{operationIdCamelCase}}QueryParams()
{{#queryParams}}
.{{paramName}}(null){{^hasMore}};{{/hasMore}}
{{/queryParams}}
// {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{^isQueryParam}}{{paramName}}, {{/isQueryParam}}{{/allParams}}queryParams);
// TODO: test validations
}
{{/hasQueryParams}}
{{/operation}}{{/operations}}
}

View File

@ -19,6 +19,7 @@ import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH;
{{#useBeanValidation}}
import javax.validation.constraints.*;
import javax.validation.Valid;
{{/useBeanValidation}}
@Path("{{^useAnnotatedBasePath}}/{{/useAnnotatedBasePath}}{{#useAnnotatedBasePath}}{{contextPath}}{{/useAnnotatedBasePath}}")

View File

@ -28,7 +28,7 @@ import org.springframework.stereotype.Service;
public class {{classname}}ServiceImpl implements {{classname}} {
{{#operations}}
{{#operation}}
public {{>returnTypes}} {{nickname}}({{#allParams}}{{>queryParamsImpl}}{{>pathParamsImpl}}{{>headerParamsImpl}}{{>bodyParams}}{{>formParamsImpl}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
public {{>returnTypes}} {{nickname}}({{#allParams}}{{>queryParamsImpl}}{{>pathParamsImpl}}{{>headerParamsImpl}}{{>bodyParamsImpl}}{{>formParamsImpl}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
// TODO: Implement...
{{^vendorExtensions.x-java-is-response-void}}return null;{{/vendorExtensions.x-java-is-response-void}}

View File

@ -1 +1 @@
{{#isBodyParam}}{{{dataType}}} {{paramName}}{{/isBodyParam}}
{{#isBodyParam}}{{#useBeanValidation}}@Valid {{/useBeanValidation}}{{{dataType}}} {{paramName}}{{/isBodyParam}}

View File

@ -0,0 +1 @@
{{#isBodyParam}}{{{dataType}}} {{paramName}}{{/isBodyParam}}

View File

@ -224,7 +224,7 @@
<div class="tab-content">
<div class="tab-pane active" id="examples-{{baseName}}-{{nickname}}-0-curl">
<pre class="prettyprint"><code class="language-bsh">curl -X <span style="text-transform: uppercase;">{{httpMethod}}</span>{{#authMethods}}{{#isApiKey}}{{#isKeyInHeader}} -H "{{keyParamName}}: [[apiKey]]"{{/isKeyInHeader}}{{/isApiKey}}{{#isBasic}}{{#hasProduces}} -H "Accept: {{#produces}}{{{mediaType}}}{{#hasMore}},{{/hasMore}}{{/produces}}"{{/hasProduces}}{{#hasConsumes}} -H "Content-Type: {{#consumes}}{{{mediaType}}}{{#hasMore}},{{/hasMore}}{{/consumes}}"{{/hasConsumes}} -H "Authorization: Basic [[basicHash]]"{{/isBasic}}{{/authMethods}} "{{basePath}}{{path}}{{#hasQueryParams}}?{{#queryParams}}{{^-first}}&{{/-first}}{{paramName}}={{vendorExtensions.x-eg}}{{/queryParams}}{{/hasQueryParams}}"</code></pre>
<pre class="prettyprint"><code class="language-bsh">curl -X <span style="text-transform: uppercase;">{{httpMethod}}</span>{{#authMethods}}{{#isApiKey}}{{#isKeyInHeader}} -H "{{keyParamName}}: [[apiKey]]"{{/isKeyInHeader}}{{/isApiKey}}{{#isBasic}}{{#hasProduces}} -H "Accept: {{#produces}}{{{mediaType}}}{{#hasMore}},{{/hasMore}}{{/produces}}"{{/hasProduces}}{{#hasConsumes}} -H "Content-Type: {{#consumes}}{{{mediaType}}}{{#hasMore}},{{/hasMore}}{{/consumes}}"{{/hasConsumes}} -H "Authorization: Basic [[basicHash]]"{{/isBasic}}{{/authMethods}} "{{basePath}}{{path}}{{#hasQueryParams}}?{{#queryParams}}{{^-first}}&{{/-first}}{{baseName}}={{vendorExtensions.x-eg}}{{/queryParams}}{{/hasQueryParams}}"</code></pre>
</div>
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-java">
<pre class="prettyprint"><code class="language-java">{{>sample_java}}</code></pre>

View File

@ -0,0 +1,75 @@
swagger: '2.0'
info:
version: '0.1.0'
title: An *API* with more **Markdown** in summary, description, and other text
description: >
Not really a *pseudo-randum* number generator API.
This API uses [Markdown](http://daringfireball.net/projects/markdown/syntax)
in text:
1. in this API description
1. in operation summaries
1. in operation descriptions
1. in schema (model) titles and descriptions
1. in schema (model) member descriptions
schemes:
- http
host: api.example.com
basePath: /v1
tags:
- name: tag1
description: A simple API **tag**
securityDefinitions:
apiKey:
type: apiKey
in: header
name: api_key
security:
- apiKey: []
paths:
/random:
get:
tags:
- tag1
summary: A single *random* result
description: Return a single *random* result from a given seed
operationId: getRandomNumber
parameters:
- name: seed
in: query
description: A random number *seed*.
required: true
type: string
responses:
'200':
description: Operation *succeded*
schema:
$ref: '#/definitions/RandomNumber'
'404':
description: Invalid or omitted *seed*. Seeds must be **valid** numbers.
definitions:
RandomNumber:
title: '*Pseudo-random* number'
description: A *pseudo-random* number generated from a seed.
properties:
value:
description: The *pseudo-random* number
type: number
format: double
seed:
description: The `seed` used to generate this number
type: number
format: double
sequence:
description: The sequence number of this random number.
type: integer
format: int64

12
pom.xml
View File

@ -772,7 +772,6 @@
<module>samples/client/petstore/jaxrs-cxf-client</module>
<module>samples/client/petstore/javascript</module>
<module>samples/client/petstore/python</module>
<module>samples/client/petstore/spring-cloud</module>
<module>samples/client/petstore/scala</module>
<module>samples/client/petstore/typescript-fetch/builds/default</module>
<module>samples/client/petstore/typescript-fetch/builds/es6-target</module>
@ -785,19 +784,20 @@
<!--module>samples/client/petstore/swift/SwaggerClientTests</module-->
<!-- servers -->
<module>samples/server/petstore/java-inflector</module>
<module>samples/server/petstore/java-play-framework</module>
<module>samples/server/petstore/undertow</module>
<module>samples/server/petstore/jaxrs/jersey1</module>
<module>samples/server/petstore/jaxrs/jersey2</module>
<module>samples/server/petstore/jaxrs-resteasy/default</module>
<module>samples/server/petstore/jaxrs-resteasy/joda</module>
<module>samples/server/petstore/scalatra</module>
<module>samples/server/petstore/spring-mvc</module>
<module>samples/client/petstore/spring-cloud</module>
<module>samples/server/petstore/springboot</module>
<module>samples/server/petstore/jaxrs-cxf</module>
<module>samples/server/petstore/jaxrs-cxf-annotated-base-path</module>
<module>samples/server/petstore/jaxrs-cxf-cdi</module>
<module>samples/server/petstore/jaxrs-cxf-non-spring-app</module>
<module>samples/server/petstore/scalatra</module>
<module>samples/server/petstore/spring-mvc</module>
<module>samples/server/petstore/springboot</module>
<module>samples/server/petstore/undertow</module>
<!--<module>samples/server/petstore/java-msf4j</module> note: JDK8 only -->
</modules>
</profile>

View File

@ -76,4 +76,54 @@ public interface FakeApi extends ApiClient.Api {
"enum_header_string: {enumHeaderString}"
})
void testEnumParameters(@Param("enumFormStringArray") List<String> enumFormStringArray, @Param("enumFormString") String enumFormString, @Param("enumHeaderStringArray") List<String> enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryStringArray") List<String> enumQueryStringArray, @Param("enumQueryString") String enumQueryString, @Param("enumQueryInteger") Integer enumQueryInteger, @Param("enumQueryDouble") Double enumQueryDouble);
/**
* To test enum parameters
* To test enum parameters
* Note, this is equivalent to the other <code>testEnumParameters</code> method,
* but with the query parameters collected into a single Map parameter. This
* is convenient for services with optional query parameters, especially when
* used with the {@link TestEnumParametersQueryParams} class that allows for
* building up this map in a fluent style.
* @param enumFormStringArray Form parameter enum test (string array) (optional)
* @param enumFormString Form parameter enum test (string) (optional, default to -efg)
* @param enumHeaderStringArray Header parameter enum test (string array) (optional)
* @param enumHeaderString Header parameter enum test (string) (optional, default to -efg)
* @param enumQueryDouble Query parameter enum test (double) (optional)
* @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:</p>
* <ul>
* <li>enumQueryStringArray - Query parameter enum test (string array) (optional)</li>
* <li>enumQueryString - Query parameter enum test (string) (optional, default to -efg)</li>
* <li>enumQueryInteger - Query parameter enum test (double) (optional)</li>
* </ul>
*/
@RequestLine("GET /fake?enum_query_string_array={enumQueryStringArray}&enum_query_string={enumQueryString}&enum_query_integer={enumQueryInteger}")
@Headers({
"Content-Type: */*",
"Accept: */*",
"enum_header_string_array: {enumHeaderStringArray}",
"enum_header_string: {enumHeaderString}"
})
void testEnumParameters(@Param("enumFormStringArray") List<String> enumFormStringArray, @Param("enumFormString") String enumFormString, @Param("enumHeaderStringArray") List<String> enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryDouble") Double enumQueryDouble, @QueryMap Map<String, Object> queryParams);
/**
* A convenience class for generating query parameters for the
* <code>testEnumParameters</code> method in a fluent style.
*/
public static class TestEnumParametersQueryParams extends HashMap<String, Object> {
public TestEnumParametersQueryParams enumQueryStringArray(final List<String> value) {
put("enumQueryStringArray", value);
return this;
}
public TestEnumParametersQueryParams enumQueryString(final String value) {
put("enumQueryString", value);
return this;
}
public TestEnumParametersQueryParams enumQueryInteger(final Integer value) {
put("enumQueryInteger", value);
return this;
}
}
}

View File

@ -55,6 +55,39 @@ public interface PetApi extends ApiClient.Api {
})
List<Pet> findPetsByStatus(@Param("status") List<String> status);
/**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
* Note, this is equivalent to the other <code>findPetsByStatus</code> method,
* but with the query parameters collected into a single Map parameter. This
* is convenient for services with optional query parameters, especially when
* used with the {@link FindPetsByStatusQueryParams} class that allows for
* building up this map in a fluent style.
* @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:</p>
* <ul>
* <li>status - Status values that need to be considered for filter (required)</li>
* </ul>
* @return List&lt;Pet&gt;
*/
@RequestLine("GET /pet/findByStatus?status={status}")
@Headers({
"Content-Type: application/json",
"Accept: application/json",
})
List<Pet> findPetsByStatus(@QueryMap Map<String, Object> queryParams);
/**
* A convenience class for generating query parameters for the
* <code>findPetsByStatus</code> method in a fluent style.
*/
public static class FindPetsByStatusQueryParams extends HashMap<String, Object> {
public FindPetsByStatusQueryParams status(final List<String> value) {
put("status", value);
return this;
}
}
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
@ -68,6 +101,39 @@ public interface PetApi extends ApiClient.Api {
})
List<Pet> findPetsByTags(@Param("tags") List<String> tags);
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* Note, this is equivalent to the other <code>findPetsByTags</code> method,
* but with the query parameters collected into a single Map parameter. This
* is convenient for services with optional query parameters, especially when
* used with the {@link FindPetsByTagsQueryParams} class that allows for
* building up this map in a fluent style.
* @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:</p>
* <ul>
* <li>tags - Tags to filter by (required)</li>
* </ul>
* @return List&lt;Pet&gt;
*/
@RequestLine("GET /pet/findByTags?tags={tags}")
@Headers({
"Content-Type: application/json",
"Accept: application/json",
})
List<Pet> findPetsByTags(@QueryMap Map<String, Object> queryParams);
/**
* A convenience class for generating query parameters for the
* <code>findPetsByTags</code> method in a fluent style.
*/
public static class FindPetsByTagsQueryParams extends HashMap<String, Object> {
public FindPetsByTagsQueryParams tags(final List<String> value) {
put("tags", value);
return this;
}
}
/**
* Find pet by ID
* Returns a single pet

View File

@ -89,6 +89,44 @@ public interface UserApi extends ApiClient.Api {
})
String loginUser(@Param("username") String username, @Param("password") String password);
/**
* Logs user into the system
*
* Note, this is equivalent to the other <code>loginUser</code> method,
* but with the query parameters collected into a single Map parameter. This
* is convenient for services with optional query parameters, especially when
* used with the {@link LoginUserQueryParams} class that allows for
* building up this map in a fluent style.
* @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:</p>
* <ul>
* <li>username - The user name for login (required)</li>
* <li>password - The password for login in clear text (required)</li>
* </ul>
* @return String
*/
@RequestLine("GET /user/login?username={username}&password={password}")
@Headers({
"Content-Type: application/json",
"Accept: application/json",
})
String loginUser(@QueryMap Map<String, Object> queryParams);
/**
* A convenience class for generating query parameters for the
* <code>loginUser</code> method in a fluent style.
*/
public static class LoginUserQueryParams extends HashMap<String, Object> {
public LoginUserQueryParams username(final String value) {
put("username", value);
return this;
}
public LoginUserQueryParams password(final String value) {
put("password", value);
return this;
}
}
/**
* Logs out current logged in user session
*

View File

@ -83,6 +83,21 @@ public class PetApiTest {
}
assertTrue(found);
PetApi.FindPetsByStatusQueryParams queryParams = new PetApi.FindPetsByStatusQueryParams()
.status(Arrays.asList(new String[]{"available"}));
pets = api.findPetsByStatus(queryParams);
assertNotNull(pets);
found = false;
for (Pet fetched : pets) {
if (fetched.getId().equals(pet.getId())) {
found = true;
break;
}
}
assertTrue(found);
}
@Test
@ -110,6 +125,20 @@ public class PetApiTest {
}
}
assertTrue(found);
PetApi.FindPetsByTagsQueryParams queryParams = new PetApi.FindPetsByTagsQueryParams()
.tags(Arrays.asList(new String[]{"friendly"}));
pets = api.findPetsByTags(queryParams);
assertNotNull(pets);
found = false;
for (Pet fetched : pets) {
if (fetched.getId().equals(pet.getId())) {
found = true;
break;
}
}
assertTrue(found);
}
@Test

View File

@ -64,6 +64,12 @@ public class UserApiTest {
String token = api.loginUser(user.getUsername(), user.getPassword());
assertTrue(token.startsWith("logged in user session:"));
UserApi.LoginUserQueryParams queryParams = new UserApi.LoginUserQueryParams()
.username(user.getUsername())
.password(user.getPassword());
token = api.loginUser(queryParams);
assertTrue(token.startsWith("logged in user session:"));
}
@Test

View File

@ -82,7 +82,7 @@ if(hasProperty('target') && target == 'android') {
install {
repositories.mavenInstaller {
pom.artifactId = 'swagger-petstore-jersey2'
pom.artifactId = 'swagger-petstore-jersey2-java6'
}
}

View File

@ -1,7 +1,7 @@
lazy val root = (project in file(".")).
settings(
organization := "io.swagger",
name := "swagger-petstore-jersey2",
name := "swagger-petstore-jersey2-java6",
version := "1.0.0",
scalaVersion := "2.11.4",
scalacOptions ++= Seq("-feature"),

View File

@ -14,7 +14,7 @@ Name | Type | Description | Notes
**_byte** | **byte[]** | |
**binary** | **byte[]** | | [optional]
**date** | [**LocalDate**](LocalDate.md) | |
**dateTime** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional]
**dateTime** | [**DateTime**](DateTime.md) | | [optional]
**uuid** | [**UUID**](UUID.md) | | [optional]
**password** | **String** | |

View File

@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**uuid** | [**UUID**](UUID.md) | | [optional]
**dateTime** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional]
**dateTime** | [**DateTime**](DateTime.md) | | [optional]
**map** | [**Map&lt;String, Animal&gt;**](Animal.md) | | [optional]

View File

@ -1 +1 @@
rootProject.name = "swagger-petstore-jersey2"
rootProject.name = "swagger-petstore-jersey2-java6"

View File

@ -9,8 +9,8 @@ import javax.ws.rs.core.GenericType;
import java.math.BigDecimal;
import io.swagger.client.model.Client;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
@ -97,7 +97,7 @@ public class FakeApi {
* @param paramCallback None (optional)
* @throws ApiException if fails to make API call
*/
public void testEndpointParameters(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws ApiException {
public void testEndpointParameters(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, DateTime dateTime, String password, String paramCallback) throws ApiException {
Object localVarPostBody = null;
// verify the required parameter 'number' is set

View File

@ -20,8 +20,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.util.UUID;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
/**
* FormatTest
@ -59,7 +59,7 @@ public class FormatTest {
private LocalDate date = null;
@JsonProperty("dateTime")
private OffsetDateTime dateTime = null;
private DateTime dateTime = null;
@JsonProperty("uuid")
private UUID uuid = null;
@ -257,7 +257,7 @@ public class FormatTest {
this.date = date;
}
public FormatTest dateTime(OffsetDateTime dateTime) {
public FormatTest dateTime(DateTime dateTime) {
this.dateTime = dateTime;
return this;
}
@ -267,11 +267,11 @@ public class FormatTest {
* @return dateTime
**/
@ApiModelProperty(value = "")
public OffsetDateTime getDateTime() {
public DateTime getDateTime() {
return dateTime;
}
public void setDateTime(OffsetDateTime dateTime) {
public void setDateTime(DateTime dateTime) {
this.dateTime = dateTime;
}

View File

@ -23,7 +23,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.threeten.bp.OffsetDateTime;
import org.joda.time.DateTime;
/**
* MixedPropertiesAndAdditionalPropertiesClass
@ -34,7 +34,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
private UUID uuid = null;
@JsonProperty("dateTime")
private OffsetDateTime dateTime = null;
private DateTime dateTime = null;
@JsonProperty("map")
private Map<String, Animal> map = new HashMap<String, Animal>();
@ -57,7 +57,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
this.uuid = uuid;
}
public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) {
public MixedPropertiesAndAdditionalPropertiesClass dateTime(DateTime dateTime) {
this.dateTime = dateTime;
return this;
}
@ -67,11 +67,11 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
* @return dateTime
**/
@ApiModelProperty(value = "")
public OffsetDateTime getDateTime() {
public DateTime getDateTime() {
return dateTime;
}
public void setDateTime(OffsetDateTime dateTime) {
public void setDateTime(DateTime dateTime) {
this.dateTime = dateTime;
}

View File

@ -18,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.threeten.bp.OffsetDateTime;
import org.joda.time.DateTime;
/**
* Order
@ -35,7 +35,7 @@ public class Order {
private Integer quantity = null;
@JsonProperty("shipDate")
private OffsetDateTime shipDate = null;
private DateTime shipDate = null;
/**
* Order Status
@ -129,7 +129,7 @@ public class Order {
this.quantity = quantity;
}
public Order shipDate(OffsetDateTime shipDate) {
public Order shipDate(DateTime shipDate) {
this.shipDate = shipDate;
return this;
}
@ -139,11 +139,11 @@ public class Order {
* @return shipDate
**/
@ApiModelProperty(value = "")
public OffsetDateTime getShipDate() {
public DateTime getShipDate() {
return shipDate;
}
public void setShipDate(OffsetDateTime shipDate) {
public void setShipDate(DateTime shipDate) {
this.shipDate = shipDate;
}

View File

@ -0,0 +1,23 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# 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 Swagger Codgen 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

278
samples/html.md/index.html Normal file
View File

@ -0,0 +1,278 @@
<!doctype html>
<html>
<head>
<title>An <em>API</em> with more <strong>Markdown</strong> in summary, description, and other text</title>
<style type="text/css">
body {
font-family: Trebuchet MS, sans-serif;
font-size: 15px;
color: #444;
margin-right: 24px;
}
h1 {
font-size: 25px;
}
h2 {
font-size: 20px;
}
h3 {
font-size: 16px;
font-weight: bold;
}
hr {
height: 1px;
border: 0;
color: #ddd;
background-color: #ddd;
}
.app-desc {
clear: both;
margin-left: 20px;
}
.param-name {
width: 100%;
}
.license-info {
margin-left: 20px;
}
.license-url {
margin-left: 20px;
}
.model {
margin: 0 0 0px 20px;
}
.method {
margin-left: 20px;
}
.method-notes {
margin: 10px 0 20px 0;
font-size: 90%;
color: #555;
}
pre {
padding: 10px;
margin-bottom: 2px;
}
.http-method {
text-transform: uppercase;
}
pre.get {
background-color: #0f6ab4;
}
pre.post {
background-color: #10a54a;
}
pre.put {
background-color: #c5862b;
}
pre.delete {
background-color: #a41e22;
}
.huge {
color: #fff;
}
pre.example {
background-color: #f3f3f3;
padding: 10px;
border: 1px solid #ddd;
}
code {
white-space: pre;
}
.nickname {
font-weight: bold;
}
.method-path {
font-size: 1.5em;
background-color: #0f6ab4;
}
.up {
float:right;
}
.parameter {
width: 500px;
}
.param {
width: 500px;
padding: 10px 0 0 20px;
font-weight: bold;
}
.param-desc {
width: 700px;
padding: 0 0 0 20px;
color: #777;
}
.param-type {
font-style: italic;
}
.param-enum-header {
width: 700px;
padding: 0 0 0 60px;
color: #777;
font-weight: bold;
}
.param-enum {
width: 700px;
padding: 0 0 0 80px;
color: #777;
font-style: italic;
}
.field-label {
padding: 0;
margin: 0;
clear: both;
}
.field-items {
padding: 0 0 15px 0;
margin-bottom: 15px;
}
.return-type {
clear: both;
padding-bottom: 10px;
}
.param-header {
font-weight: bold;
}
.method-tags {
text-align: right;
}
.method-tag {
background: none repeat scroll 0% 0% #24A600;
border-radius: 3px;
padding: 2px 10px;
margin: 2px;
color: #FFF;
display: inline-block;
text-decoration: none;
}
</style>
</head>
<body>
<h1>An <em>API</em> with more <strong>Markdown</strong> in summary, description, and other text</h1>
<div class="app-desc"><p>Not really a <em>pseudo-randum</em> number generator API. This API uses <a href="http://daringfireball.net/projects/markdown/syntax">Markdown</a> in text:</p>
<ol>
<li>in this API description</li>
<li>in operation summaries</li>
<li>in operation descriptions</li>
<li>in schema (model) titles and descriptions</li>
<li>in schema (model) member descriptions</li>
</ol>
</div>
<div class="app-desc">More information: <a href="https://helloreverb.com">https://helloreverb.com</a></div>
<div class="app-desc">Contact Info: <a href="hello@helloreverb.com">hello@helloreverb.com</a></div>
<div class="app-desc">Version: 0.1.0</div>
<div class="app-desc">BasePath:/v1</div>
<div class="license-info">All rights reserved</div>
<div class="license-url">http://apache.org/licenses/LICENSE-2.0.html</div>
<h2>Access</h2>
<ol>
<li>APIKey KeyParamName:api_key KeyInQuery:false KeyInHeader:true</li>
</ol>
<h2><a name="__Methods">Methods</a></h2>
[ Jump to <a href="#__Models">Models</a> ]
<h3>Table of Contents </h3>
<div class="method-summary"></div>
<h4><a href="#Tag1">Tag1</a></h4>
<ul>
<li><a href="#getRandomNumber"><code><span class="http-method">get</span> /random</code></a></li>
</ul>
<h1><a name="Tag1">Tag1</a></h1>
<div class="method"><a name="getRandomNumber"/>
<div class="method-path">
<a class="up" href="#__Methods">Up</a>
<pre class="get"><code class="huge"><span class="http-method">get</span> /random</code></pre></div>
<div class="method-summary">A single <em>random</em> result (<span class="nickname">getRandomNumber</span>)</div>
<div class="method-notes">Return a single <em>random</em> result from a given seed</div>
<h3 class="field-label">Query parameters</h3>
<div class="field-items">
<div class="param">seed (required)</div>
<div class="param-desc"><span class="param-type">Query Parameter</span> &mdash; A random number <em>seed</em>. </div>
</div> <!-- field-items -->
<h3 class="field-label">Return type</h3>
<div class="return-type">
<a href="#RandomNumber">RandomNumber</a>
</div>
<!--Todo: process Response Object and its headers, schema, examples -->
<h3 class="field-label">Example data</h3>
<div class="example-data-content-type">Content-Type: application/json</div>
<pre class="example"><code>{
"sequence" : 1,
"seed" : 6.027456183070403,
"value" : 0.8008281904610115
}</code></pre>
<h3 class="field-label">Responses</h3>
<h4 class="field-label">200</h4>
Operation <em>succeded</em>
<a href="#RandomNumber">RandomNumber</a>
<h4 class="field-label">404</h4>
Invalid or omitted <em>seed</em>. Seeds must be <strong>valid</strong> numbers.
<a href="#"></a>
</div> <!-- method -->
<hr/>
<h2><a name="__Models">Models</a></h2>
[ Jump to <a href="#__Methods">Methods</a> ]
<h3>Table of Contents</h3>
<ol>
<li><a href="#RandomNumber"><code>RandomNumber</code> - <em>Pseudo-random</em> number</a></li>
</ol>
<div class="model">
<h3><a name="RandomNumber"><code>RandomNumber</code> - <em>Pseudo-random</em> number</a> <a class="up" href="#__Models">Up</a></h3>
<div class='model-description'>A <em>pseudo-random</em> number generated from a seed.</div>
<div class="field-items">
<div class="param">value (optional)</div><div class="param-desc"><span class="param-type"><a href="#double">Double</a></span> The <em>pseudo-random</em> number format: double</div>
<div class="param">seed (optional)</div><div class="param-desc"><span class="param-type"><a href="#double">Double</a></span> The <code>seed</code> used to generate this number format: double</div>
<div class="param">sequence (optional)</div><div class="param-desc"><span class="param-type"><a href="#long">Long</a></span> The sequence number of this random number. format: int64</div>
</div> <!-- field-items -->
</div>
</body>
</html>

View File

@ -180,8 +180,8 @@ font-style: italic;
</head>
<body>
<h1>Swagger Petstore</h1>
<div class="app-desc">This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.</div>
<div class="app-desc">This is a sample server Petstore server. You can find out more about Swagger at <a href="http://swagger.io">http://swagger.io</a> or on <a href="http://swagger.io/irc/">irc.freenode.net, #swagger</a>. For this sample, you can use the api key <code>special-key</code> to test the authorization filters.</div>
<div class="app-desc">More information: <a href=""></a></div>
<div class="app-desc">Contact Info: <a href="apiteam@swagger.io">apiteam@swagger.io</a></div>
<div class="app-desc">Version: 1.0.0</div>
<div class="app-desc">BasePath:/v2</div>
@ -783,7 +783,7 @@ font-style: italic;
<a class="up" href="#__Methods">Up</a>
<pre class="get"><code class="huge"><span class="http-method">get</span> /store/order/{orderId}</code></pre></div>
<div class="method-summary">Find purchase order by ID (<span class="nickname">getOrderById</span>)</div>
<div class="method-notes">For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions</div>
<div class="method-notes">For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions</div>
<h3 class="field-label">Path parameters</h3>
<div class="field-items">
@ -1078,7 +1078,7 @@ font-style: italic;
<div class="field-items">
<div class="param">username (required)</div>
<div class="param-desc"><span class="param-type">Path Parameter</span> &mdash; The name that needs to be fetched. Use user1 for testing. </div>
<div class="param-desc"><span class="param-type">Path Parameter</span> &mdash; The name that needs to be fetched. Use user1 for testing. </div>
</div> <!-- field-items -->

View File

@ -7293,7 +7293,7 @@ except ApiException as e:
</div>
<div id="generator">
<div class="content">
Generated 2017-03-21T22:07:17.642+08:00
Generated 2017-03-23T14:23:30.922+08:00
</div>
</div>
</div>

View File

@ -20,6 +20,7 @@ import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH;
import javax.validation.constraints.*;
import javax.validation.Valid;
@Path("/")
@Api(value = "/", description = "")
@ -32,7 +33,7 @@ public interface FakeApi {
@ApiOperation(value = "To test \"client\" model", tags={ "fake", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Client.class) })
public Client testClientModel(Client body);
public Client testClientModel(@Valid Client body);
@POST
@Path("/fake")

View File

@ -19,6 +19,7 @@ import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH;
import javax.validation.constraints.*;
import javax.validation.Valid;
@Path("/")
@Api(value = "/", description = "")
@ -31,7 +32,7 @@ public interface PetApi {
@ApiOperation(value = "Add a new pet to the store", tags={ "pet", })
@ApiResponses(value = {
@ApiResponse(code = 405, message = "Invalid input") })
public void addPet(Pet body);
public void addPet(@Valid Pet body);
@DELETE
@Path("/pet/{petId}")
@ -78,7 +79,7 @@ public interface PetApi {
@ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "Pet not found"),
@ApiResponse(code = 405, message = "Validation exception") })
public void updatePet(Pet body);
public void updatePet(@Valid Pet body);
@POST
@Path("/pet/{petId}")

View File

@ -18,6 +18,7 @@ import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH;
import javax.validation.constraints.*;
import javax.validation.Valid;
@Path("/")
@Api(value = "/", description = "")
@ -57,6 +58,6 @@ public interface StoreApi {
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Order.class),
@ApiResponse(code = 400, message = "Invalid Order") })
public Order placeOrder(Order body);
public Order placeOrder(@Valid Order body);
}

View File

@ -18,6 +18,7 @@ import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH;
import javax.validation.constraints.*;
import javax.validation.Valid;
@Path("/")
@Api(value = "/", description = "")
@ -29,7 +30,7 @@ public interface UserApi {
@ApiOperation(value = "Create user", tags={ "user", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") })
public void createUser(User body);
public void createUser(@Valid User body);
@POST
@Path("/user/createWithArray")
@ -37,7 +38,7 @@ public interface UserApi {
@ApiOperation(value = "Creates list of users with given input array", tags={ "user", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") })
public void createUsersWithArrayInput(List<User> body);
public void createUsersWithArrayInput(@Valid List<User> body);
@POST
@Path("/user/createWithList")
@ -45,7 +46,7 @@ public interface UserApi {
@ApiOperation(value = "Creates list of users with given input array", tags={ "user", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") })
public void createUsersWithListInput(List<User> body);
public void createUsersWithListInput(@Valid List<User> body);
@DELETE
@Path("/user/{username}")
@ -90,6 +91,6 @@ public interface UserApi {
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid user supplied"),
@ApiResponse(code = 404, message = "User not found") })
public void updateUser(@PathParam("username") String username, User body);
public void updateUser(@Valid @PathParam("username") String username, User body);
}

View File

@ -80,7 +80,7 @@ public class PetApiTest {
@Test
public void addPetTest() {
Pet body = null;
//api.addPet(body);
//api.addPet(body);
// TODO: test validations
@ -99,7 +99,7 @@ public class PetApiTest {
public void deletePetTest() {
Long petId = null;
String apiKey = null;
//api.deletePet(petId, apiKey);
//api.deletePet(petId, apiKey);
// TODO: test validations
@ -153,7 +153,7 @@ public class PetApiTest {
@Test
public void getPetByIdTest() {
Long petId = null;
//Pet response = api.getPetById(petId);
//Pet response = api.getPetById(petId);
//assertNotNull(response);
// TODO: test validations
@ -171,7 +171,7 @@ public class PetApiTest {
@Test
public void updatePetTest() {
Pet body = null;
//api.updatePet(body);
//api.updatePet(body);
// TODO: test validations
@ -191,7 +191,7 @@ public class PetApiTest {
Long petId = null;
String name = null;
String status = null;
//api.updatePetWithForm(petId, name, status);
//api.updatePetWithForm(petId, name, status);
// TODO: test validations
@ -211,7 +211,7 @@ public class PetApiTest {
Long petId = null;
String additionalMetadata = null;
org.apache.cxf.jaxrs.ext.multipart.Attachment file = null;
//ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
//ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
//assertNotNull(response);
// TODO: test validations

View File

@ -79,7 +79,7 @@ public class StoreApiTest {
@Test
public void deleteOrderTest() {
String orderId = null;
//api.deleteOrder(orderId);
//api.deleteOrder(orderId);
// TODO: test validations
@ -114,7 +114,7 @@ public class StoreApiTest {
@Test
public void getOrderByIdTest() {
Long orderId = null;
//Order response = api.getOrderById(orderId);
//Order response = api.getOrderById(orderId);
//assertNotNull(response);
// TODO: test validations
@ -132,7 +132,7 @@ public class StoreApiTest {
@Test
public void placeOrderTest() {
Order body = null;
//Order response = api.placeOrder(body);
//Order response = api.placeOrder(body);
//assertNotNull(response);
// TODO: test validations

View File

@ -79,7 +79,7 @@ public class UserApiTest {
@Test
public void createUserTest() {
User body = null;
//api.createUser(body);
//api.createUser(body);
// TODO: test validations
@ -97,7 +97,7 @@ public class UserApiTest {
@Test
public void createUsersWithArrayInputTest() {
List<User> body = null;
//api.createUsersWithArrayInput(body);
//api.createUsersWithArrayInput(body);
// TODO: test validations
@ -115,7 +115,7 @@ public class UserApiTest {
@Test
public void createUsersWithListInputTest() {
List<User> body = null;
//api.createUsersWithListInput(body);
//api.createUsersWithListInput(body);
// TODO: test validations
@ -133,7 +133,7 @@ public class UserApiTest {
@Test
public void deleteUserTest() {
String username = null;
//api.deleteUser(username);
//api.deleteUser(username);
// TODO: test validations
@ -151,7 +151,7 @@ public class UserApiTest {
@Test
public void getUserByNameTest() {
String username = null;
//User response = api.getUserByName(username);
//User response = api.getUserByName(username);
//assertNotNull(response);
// TODO: test validations
@ -170,7 +170,7 @@ public class UserApiTest {
public void loginUserTest() {
String username = null;
String password = null;
//String response = api.loginUser(username, password);
//String response = api.loginUser(username, password);
//assertNotNull(response);
// TODO: test validations
@ -187,7 +187,7 @@ public class UserApiTest {
*/
@Test
public void logoutUserTest() {
//api.logoutUser();
//api.logoutUser();
// TODO: test validations
@ -206,7 +206,7 @@ public class UserApiTest {
public void updateUserTest() {
String username = null;
User body = null;
//api.updateUser(username, body);
//api.updateUser(username, body);
// TODO: test validations