diff --git a/bin/html-markdown.sh b/bin/html-markdown.sh new file mode 100755 index 000000000000..089abfc5e8f5 --- /dev/null +++ b/bin/html-markdown.sh @@ -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 diff --git a/bin/java-petstore-all.sh b/bin/java-petstore-all.sh index fbd2ca65cad9..11148e31c9fb 100755 --- a/bin/java-petstore-all.sh +++ b/bin/java-petstore-all.sh @@ -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 diff --git a/bin/java-petstore-jersey2-java6.sh b/bin/java-petstore-jersey2-java6.sh index e3e82f1cdd6b..8ab7c2c7ef48 100755 --- a/bin/java-petstore-jersey2-java6.sh +++ b/bin/java-petstore-jersey2-java6.sh @@ -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 diff --git a/modules/swagger-codegen/pom.xml b/modules/swagger-codegen/pom.xml index 965279524f6e..bb6206a4bee1 100644 --- a/modules/swagger-codegen/pom.xml +++ b/modules/swagger-codegen/pom.xml @@ -283,6 +283,11 @@ ${diffutils-version} test + + com.atlassian.commonmark + commonmark + 0.9.0 + diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java index fc07e0d7174b..c72a844e056f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java @@ -36,6 +36,7 @@ public class CodegenOperation { public Map 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; } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 8e9449bdfde1..e684a94e3752 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -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; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ElixirClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ElixirClientCodegen.java index 1a611e4d5909..21a237dd1b6b 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ElixirClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ElixirClientCodegen.java @@ -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 getPathTemplateNames() { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtmlGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtmlGenerator.java index 1a69811723ec..a22010e51fb4 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtmlGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtmlGenerator.java @@ -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(); } - @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 + * "Text with **bold**" is converted from Markdown to HTML as + * "Text with <strong>bold</strong> text" and then + * the default compiler with HTML escaping on turns this into + * "Text with &lt;strong&gt;bold&lt;/strong&gt; text". + * 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 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); + } + } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/utils/Markdown.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/utils/Markdown.java new file mode 100644 index 000000000000..f57f59e9842d --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/utils/Markdown.java @@ -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. + * This class is threadsafe. + */ +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

...

. + * @param markdown text with Markdown styles. If null, "" 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 + //

... html ...

\n + // This method removes that markup wrapper if there are no other

elements, + // do that Markdown can be used in non-block contexts such as operation summary etc. + private static final String P_END = "

\n"; + private static final String P_START = "

"; + 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; + } +} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/api.mustache index ce2c205ea9d9..df26e39fc55e 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/api.mustache @@ -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 {{operationId}} 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 + *

The following elements may be specified in the query map:

+ *
    + {{#queryParams}} + *
  • {{paramName}} - {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
  • + {{/queryParams}} + *
+ {{#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 queryParams); + + /** + * A convenience class for generating query parameters for the + * {{operationId}} method in a fluent style. + */ + public static class {{operationIdCamelCase}}QueryParams extends HashMap { + {{#queryParams}} + public {{operationIdCamelCase}}QueryParams {{paramName}}(final {{{dataType}}} value) { + put("{{paramName}}", value); + return this; + } + {{/queryParams}} + } + {{/hasQueryParams}} {{/operation}} {{/operations}} } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/api_test.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/api_test.mustache index 303fda344e99..bcc14a987c68 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/api_test.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/api_test.mustache @@ -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}} } diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache index 19a5938c843a..bcaedef14b3a 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache @@ -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}}") diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache index 70f5f4f37ded..ea21a5635c10 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache @@ -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}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/bodyParams.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/bodyParams.mustache index c7d1abfe527e..be56da7535be 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/bodyParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/bodyParams.mustache @@ -1 +1 @@ -{{#isBodyParam}}{{{dataType}}} {{paramName}}{{/isBodyParam}} \ No newline at end of file +{{#isBodyParam}}{{#useBeanValidation}}@Valid {{/useBeanValidation}}{{{dataType}}} {{paramName}}{{/isBodyParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/bodyParamsImpl.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/bodyParamsImpl.mustache new file mode 100644 index 000000000000..c7d1abfe527e --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/bodyParamsImpl.mustache @@ -0,0 +1 @@ +{{#isBodyParam}}{{{dataType}}} {{paramName}}{{/isBodyParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs2/index.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs2/index.mustache index fff1193d70ce..c529d8d58c83 100644 --- a/modules/swagger-codegen/src/main/resources/htmlDocs2/index.mustache +++ b/modules/swagger-codegen/src/main/resources/htmlDocs2/index.mustache @@ -224,7 +224,7 @@
-
curl -X {{httpMethod}}{{#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}}"
+
curl -X {{httpMethod}}{{#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}}"
{{>sample_java}}
diff --git a/modules/swagger-codegen/src/test/resources/2_0/markdown.yaml b/modules/swagger-codegen/src/test/resources/2_0/markdown.yaml new file mode 100644 index 000000000000..efb852f40367 --- /dev/null +++ b/modules/swagger-codegen/src/test/resources/2_0/markdown.yaml @@ -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 diff --git a/pom.xml b/pom.xml index c856dbfd57bc..f0f11feb2ec5 100644 --- a/pom.xml +++ b/pom.xml @@ -772,7 +772,6 @@ samples/client/petstore/jaxrs-cxf-client samples/client/petstore/javascript samples/client/petstore/python - samples/client/petstore/spring-cloud samples/client/petstore/scala samples/client/petstore/typescript-fetch/builds/default samples/client/petstore/typescript-fetch/builds/es6-target @@ -785,19 +784,20 @@ samples/server/petstore/java-inflector - samples/server/petstore/java-play-framework + samples/server/petstore/undertow samples/server/petstore/jaxrs/jersey1 samples/server/petstore/jaxrs/jersey2 samples/server/petstore/jaxrs-resteasy/default samples/server/petstore/jaxrs-resteasy/joda + samples/server/petstore/scalatra + samples/server/petstore/spring-mvc + samples/client/petstore/spring-cloud + samples/server/petstore/springboot samples/server/petstore/jaxrs-cxf samples/server/petstore/jaxrs-cxf-annotated-base-path samples/server/petstore/jaxrs-cxf-cdi samples/server/petstore/jaxrs-cxf-non-spring-app - samples/server/petstore/scalatra - samples/server/petstore/spring-mvc - samples/server/petstore/springboot - samples/server/petstore/undertow + diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java index fdace62d9b0e..391de4d710aa 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java @@ -76,4 +76,54 @@ public interface FakeApi extends ApiClient.Api { "enum_header_string: {enumHeaderString}" }) void testEnumParameters(@Param("enumFormStringArray") List enumFormStringArray, @Param("enumFormString") String enumFormString, @Param("enumHeaderStringArray") List enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryStringArray") List 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 testEnumParameters 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 + *

The following elements may be specified in the query map:

+ *
    + *
  • enumQueryStringArray - Query parameter enum test (string array) (optional)
  • + *
  • enumQueryString - Query parameter enum test (string) (optional, default to -efg)
  • + *
  • enumQueryInteger - Query parameter enum test (double) (optional)
  • + *
+ */ + @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 enumFormStringArray, @Param("enumFormString") String enumFormString, @Param("enumHeaderStringArray") List enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryDouble") Double enumQueryDouble, @QueryMap Map queryParams); + + /** + * A convenience class for generating query parameters for the + * testEnumParameters method in a fluent style. + */ + public static class TestEnumParametersQueryParams extends HashMap { + public TestEnumParametersQueryParams enumQueryStringArray(final List 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; + } + } } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java index 05133620f821..48987c67f380 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java @@ -55,6 +55,39 @@ public interface PetApi extends ApiClient.Api { }) List findPetsByStatus(@Param("status") List status); + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * Note, this is equivalent to the other findPetsByStatus 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 + *

The following elements may be specified in the query map:

+ *
    + *
  • status - Status values that need to be considered for filter (required)
  • + *
+ * @return List<Pet> + */ + @RequestLine("GET /pet/findByStatus?status={status}") + @Headers({ + "Content-Type: application/json", + "Accept: application/json", + }) + List findPetsByStatus(@QueryMap Map queryParams); + + /** + * A convenience class for generating query parameters for the + * findPetsByStatus method in a fluent style. + */ + public static class FindPetsByStatusQueryParams extends HashMap { + public FindPetsByStatusQueryParams status(final List 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 findPetsByTags(@Param("tags") List 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 findPetsByTags 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 + *

The following elements may be specified in the query map:

+ *
    + *
  • tags - Tags to filter by (required)
  • + *
+ * @return List<Pet> + */ + @RequestLine("GET /pet/findByTags?tags={tags}") + @Headers({ + "Content-Type: application/json", + "Accept: application/json", + }) + List findPetsByTags(@QueryMap Map queryParams); + + /** + * A convenience class for generating query parameters for the + * findPetsByTags method in a fluent style. + */ + public static class FindPetsByTagsQueryParams extends HashMap { + public FindPetsByTagsQueryParams tags(final List value) { + put("tags", value); + return this; + } + } + /** * Find pet by ID * Returns a single pet diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java index ae2ea06f9b60..c271b9deda80 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java @@ -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 loginUser 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 + *

The following elements may be specified in the query map:

+ *
    + *
  • username - The user name for login (required)
  • + *
  • password - The password for login in clear text (required)
  • + *
+ * @return String + */ + @RequestLine("GET /user/login?username={username}&password={password}") + @Headers({ + "Content-Type: application/json", + "Accept: application/json", + }) + String loginUser(@QueryMap Map queryParams); + + /** + * A convenience class for generating query parameters for the + * loginUser method in a fluent style. + */ + public static class LoginUserQueryParams extends HashMap { + 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 * diff --git a/samples/client/petstore/java/feign/src/test/java/io/swagger/client/api/PetApiTest.java b/samples/client/petstore/java/feign/src/test/java/io/swagger/client/api/PetApiTest.java index 643ad874d94e..261fffcbe0c8 100644 --- a/samples/client/petstore/java/feign/src/test/java/io/swagger/client/api/PetApiTest.java +++ b/samples/client/petstore/java/feign/src/test/java/io/swagger/client/api/PetApiTest.java @@ -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 diff --git a/samples/client/petstore/java/feign/src/test/java/io/swagger/client/api/UserApiTest.java b/samples/client/petstore/java/feign/src/test/java/io/swagger/client/api/UserApiTest.java index 3e58a20f98cf..d1c9b67f7222 100644 --- a/samples/client/petstore/java/feign/src/test/java/io/swagger/client/api/UserApiTest.java +++ b/samples/client/petstore/java/feign/src/test/java/io/swagger/client/api/UserApiTest.java @@ -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 diff --git a/samples/client/petstore/java/jersey2-java6/build.gradle b/samples/client/petstore/java/jersey2-java6/build.gradle index d0acf976a5a5..d7ca30e79b84 100644 --- a/samples/client/petstore/java/jersey2-java6/build.gradle +++ b/samples/client/petstore/java/jersey2-java6/build.gradle @@ -82,7 +82,7 @@ if(hasProperty('target') && target == 'android') { install { repositories.mavenInstaller { - pom.artifactId = 'swagger-petstore-jersey2' + pom.artifactId = 'swagger-petstore-jersey2-java6' } } diff --git a/samples/client/petstore/java/jersey2-java6/build.sbt b/samples/client/petstore/java/jersey2-java6/build.sbt index 48cf18c0d8c7..4a68e390aa16 100644 --- a/samples/client/petstore/java/jersey2-java6/build.sbt +++ b/samples/client/petstore/java/jersey2-java6/build.sbt @@ -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"), diff --git a/samples/client/petstore/java/jersey2-java6/docs/FormatTest.md b/samples/client/petstore/java/jersey2-java6/docs/FormatTest.md index c7a3acb3cb7e..06bed417232a 100644 --- a/samples/client/petstore/java/jersey2-java6/docs/FormatTest.md +++ b/samples/client/petstore/java/jersey2-java6/docs/FormatTest.md @@ -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** | | diff --git a/samples/client/petstore/java/jersey2-java6/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/java/jersey2-java6/docs/MixedPropertiesAndAdditionalPropertiesClass.md index b12e2cd70e69..349afef35a98 100644 --- a/samples/client/petstore/java/jersey2-java6/docs/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/client/petstore/java/jersey2-java6/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -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<String, Animal>**](Animal.md) | | [optional] diff --git a/samples/client/petstore/java/jersey2-java6/settings.gradle b/samples/client/petstore/java/jersey2-java6/settings.gradle index 498d426abeeb..4449df586597 100644 --- a/samples/client/petstore/java/jersey2-java6/settings.gradle +++ b/samples/client/petstore/java/jersey2-java6/settings.gradle @@ -1 +1 @@ -rootProject.name = "swagger-petstore-jersey2" \ No newline at end of file +rootProject.name = "swagger-petstore-jersey2-java6" \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/FakeApi.java index 208886d5bedb..a8c2ebfa2b72 100644 --- a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/FakeApi.java @@ -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 diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/FormatTest.java index 4737f683aa02..e530b8360c8a 100644 --- a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/FormatTest.java @@ -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; } diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java index 3c21d7c6db81..f7458c793a83 100644 --- a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -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 map = new HashMap(); @@ -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; } diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/Order.java index 2e9a960e5ca0..30648dbb7ffd 100644 --- a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/Order.java @@ -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; } diff --git a/samples/html.md/.swagger-codegen-ignore b/samples/html.md/.swagger-codegen-ignore new file mode 100644 index 000000000000..c5fa491b4c55 --- /dev/null +++ b/samples/html.md/.swagger-codegen-ignore @@ -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 diff --git a/samples/html.md/index.html b/samples/html.md/index.html new file mode 100644 index 000000000000..28cbed90cc3b --- /dev/null +++ b/samples/html.md/index.html @@ -0,0 +1,278 @@ + + + + An <em>API</em> with more <strong>Markdown</strong> in summary, description, and other text + + + +

An API with more Markdown in summary, description, and other text

+

Not really a pseudo-randum number generator API. This API uses Markdown in text:

+
    +
  1. in this API description
  2. +
  3. in operation summaries
  4. +
  5. in operation descriptions
  6. +
  7. in schema (model) titles and descriptions
  8. +
  9. in schema (model) member descriptions
  10. +
+
+
More information: https://helloreverb.com
+
Contact Info: hello@helloreverb.com
+
Version: 0.1.0
+
BasePath:/v1
+
All rights reserved
+
http://apache.org/licenses/LICENSE-2.0.html
+

Access

+
    +
  1. APIKey KeyParamName:api_key KeyInQuery:false KeyInHeader:true
  2. +
+ +

Methods

+ [ Jump to Models ] + +

Table of Contents

+
+

Tag1

+ + +

Tag1

+
+
+ Up +
get /random
+
A single random result (getRandomNumber)
+
Return a single random result from a given seed
+ + + + + +

Query parameters

+
+
seed (required)
+ +
Query Parameter — A random number seed.
+
+ + +

Return type

+
+ RandomNumber + +
+ + + +

Example data

+
Content-Type: application/json
+
{
+  "sequence" : 1,
+  "seed" : 6.027456183070403,
+  "value" : 0.8008281904610115
+}
+ + +

Responses

+

200

+ Operation succeded + RandomNumber +

404

+ Invalid or omitted seed. Seeds must be valid numbers. + +
+
+ +

Models

+ [ Jump to Methods ] + +

Table of Contents

+
    +
  1. RandomNumber - Pseudo-random number
  2. +
+ +
+

RandomNumber - Pseudo-random number Up

+
A pseudo-random number generated from a seed.
+
+
value (optional)
Double The pseudo-random number format: double
+
seed (optional)
Double The seed used to generate this number format: double
+
sequence (optional)
Long The sequence number of this random number. format: int64
+
+
+ + diff --git a/samples/html/index.html b/samples/html/index.html index df37d5bf5b16..8638d803c182 100644 --- a/samples/html/index.html +++ b/samples/html/index.html @@ -180,8 +180,8 @@ font-style: italic;

Swagger Petstore

-
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.
- +
This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key special-key to test the authorization filters.
+
More information:
Contact Info: apiteam@swagger.io
Version: 1.0.0
BasePath:/v2
@@ -783,7 +783,7 @@ font-style: italic; Up
get /store/order/{orderId}
Find purchase order by ID (getOrderById)
-
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
+
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions

Path parameters

@@ -1078,7 +1078,7 @@ font-style: italic;
username (required)
-
Path Parameter — The name that needs to be fetched. Use user1 for testing.
+
Path Parameter — The name that needs to be fetched. Use user1 for testing.
diff --git a/samples/html2/index.html b/samples/html2/index.html index fdf3c580196a..fb509613ef95 100644 --- a/samples/html2/index.html +++ b/samples/html2/index.html @@ -7293,7 +7293,7 @@ except ApiException as e:
- Generated 2017-03-21T22:07:17.642+08:00 + Generated 2017-03-23T14:23:30.922+08:00
diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeApi.java index c0caf421aeb9..cc48320d8cf8 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeApi.java @@ -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") diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java index 68701e28cc29..93a82ed4f6c8 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java @@ -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}") diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java index f6f1b34c2436..8ddeb8f3deab 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java @@ -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); } diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java index 172b6938f1d2..4b12da15c8ec 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java @@ -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 body); + public void createUsersWithArrayInput(@Valid List 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 body); + public void createUsersWithListInput(@Valid List 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); } diff --git a/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/PetApiTest.java b/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/PetApiTest.java index 188fdb7b5cf7..444c595b78e0 100644 --- a/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/PetApiTest.java +++ b/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/PetApiTest.java @@ -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 diff --git a/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/StoreApiTest.java b/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/StoreApiTest.java index aa476b0cf0ff..c0cd10dca719 100644 --- a/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/StoreApiTest.java +++ b/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/StoreApiTest.java @@ -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 diff --git a/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/UserApiTest.java b/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/UserApiTest.java index 76bb7fa55782..2d1481bde34f 100644 --- a/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/UserApiTest.java +++ b/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/UserApiTest.java @@ -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 body = null; - //api.createUsersWithArrayInput(body); + //api.createUsersWithArrayInput(body); // TODO: test validations @@ -115,7 +115,7 @@ public class UserApiTest { @Test public void createUsersWithListInputTest() { List 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