diff --git a/bin/csharp-petstore-net-40.json b/bin/csharp-petstore-net-40.json new file mode 100644 index 00000000000..884f7ea9bc9 --- /dev/null +++ b/bin/csharp-petstore-net-40.json @@ -0,0 +1,3 @@ +{ + "targetFramework": "v4.0" +} diff --git a/bin/csharp-petstore-net-40.sh b/bin/csharp-petstore-net-40.sh new file mode 100755 index 00000000000..fd5d0876d04 --- /dev/null +++ b/bin/csharp-petstore-net-40.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/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples/client/petstore/csharp/SwaggerClientNet40 --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C} -c ./bin/csharp-petstore-net-40.json" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/csharp-petstore.sh b/bin/csharp-petstore.sh index 232f706b7fd..fd5d0876d04 100755 --- a/bin/csharp-petstore.sh +++ b/bin/csharp-petstore.sh @@ -26,6 +26,6 @@ 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 csharp -o samples/client/petstore/csharp/SwaggerClient --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C}" +ags="generate $@ -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples/client/petstore/csharp/SwaggerClientNet40 --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C} -c ./bin/csharp-petstore-net-40.json" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/typescript-angular-petstore-all.sh b/bin/typescript-angular-petstore-all.sh old mode 100644 new mode 100755 diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java index 69bee7bd9c9..5f739840a2f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java @@ -15,6 +15,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { @SuppressWarnings({"hiding"}) private static final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class); private static final String NET45 = "v4.5"; + private static final String NET40 = "v4.0"; private static final String NET35 = "v3.5"; private static final String NETSTANDARD = "v5.0"; private static final String UWP = "uwp"; @@ -75,6 +76,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { ); frameworks = new ImmutableMap.Builder() .put(NET35, ".NET Framework 3.5 compatible") + .put(NET40, ".NET Framework 4.0 compatible") .put(NET45, ".NET Framework 4.5+ compatible") .put(NETSTANDARD, ".NET Standard 1.3 compatible") .put(UWP, "Universal Windows Platform (IMPORTANT: this will be decommissioned and replaced by v5.0)") @@ -227,7 +229,13 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { setSupportsUWP(Boolean.TRUE); additionalProperties.put("supportsAsync", this.supportsAsync); additionalProperties.put("supportsUWP", this.supportsUWP); - + } else if (NET40.equals(this.targetFramework)) { + setTargetFrameworkNuget("net40"); + setSupportsAsync(Boolean.FALSE); + if (additionalProperties.containsKey("supportsAsync")) { + additionalProperties.remove("supportsAsync"); + } + additionalProperties.put("isNet40", true); } else { setTargetFrameworkNuget("net45"); setSupportsAsync(Boolean.TRUE); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/HaskellHttpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/HaskellHttpClientCodegen.java index 23476ddf803..370e54bbb5f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/HaskellHttpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/HaskellHttpClientCodegen.java @@ -2,7 +2,6 @@ package io.swagger.codegen.languages; import io.swagger.codegen.*; import io.swagger.models.Model; -import io.swagger.models.ModelImpl; import io.swagger.models.Operation; import io.swagger.models.Swagger; import io.swagger.models.properties.*; @@ -10,8 +9,6 @@ import io.swagger.models.properties.*; import java.util.*; import java.util.regex.Pattern; -import org.apache.commons.io.FileUtils; - import io.swagger.models.auth.SecuritySchemeDefinition; import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConstants; @@ -24,6 +21,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.tuple.Pair; import java.util.regex.Matcher; @@ -38,12 +36,14 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC protected String defaultDateFormat = "%Y-%m-%d"; protected Boolean useMonadLogger = false; + protected Boolean genEnums = true; // CLI PROPS public static final String PROP_ALLOW_FROMJSON_NULLS = "allowFromJsonNulls"; public static final String PROP_ALLOW_TOJSON_NULLS = "allowToJsonNulls"; public static final String PROP_DATETIME_FORMAT = "dateTimeFormat"; public static final String PROP_DATE_FORMAT = "dateFormat"; + public static final String PROP_GENERATE_ENUMS = "generateEnums"; public static final String PROP_GENERATE_FORM_URLENCODED_INSTANCES = "generateFormUrlEncodedInstances"; public static final String PROP_GENERATE_LENSES = "generateLenses"; public static final String PROP_GENERATE_MODEL_CONSTRUCTORS = "generateModelConstructors"; @@ -62,9 +62,9 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC // vendor extensions static final String X_ALL_UNIQUE_PARAMS = "x-allUniqueParams"; static final String X_COLLECTION_FORMAT = "x-collectionFormat"; - static final String X_DUPLICATE = "x-duplicate"; static final String X_HADDOCK_PATH = "x-haddockPath"; static final String X_HAS_BODY_OR_FORM_PARAM = "x-hasBodyOrFormParam"; + static final String X_HAS_ENUM_SECTION = "x-hasEnumSection"; static final String X_HAS_MIME_FORM_URL_ENCODED = "x-hasMimeFormUrlEncoded"; static final String X_HAS_NEW_TAG = "x-hasNewTag"; static final String X_HAS_OPTIONAL_PARAMS = "x-hasOptionalParams"; @@ -72,7 +72,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC static final String X_HAS_UNKNOWN_RETURN = "x-hasUnknownReturn"; static final String X_INLINE_CONTENT_TYPE = "x-inlineContentType"; static final String X_IS_BODY_OR_FORM_PARAM = "x-isBodyOrFormParam"; + static final String X_IS_BODY_PARAM = "x-isBodyParam"; static final String X_MEDIA_DATA_TYPE = "x-mediaDataType"; + static final String X_DATA_TYPE = "x-dataType"; + static final String X_ENUM_VALUES = "x-enumValues"; static final String X_MEDIA_IS_JSON = "x-mediaIsJson"; static final String X_MIME_TYPES = "x-mimeTypes"; static final String X_OPERATION_TYPE = "x-operationType"; @@ -82,14 +85,15 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC static final String X_STRICT_FIELDS = "x-strictFields"; static final String X_UNKNOWN_MIME_TYPES = "x-unknownMimeTypes"; static final String X_USE_MONAD_LOGGER = "x-useMonadLogger"; + static final String X_NEWTYPE = "x-newtype"; + static final String X_ENUM = "x-enum"; - protected Map uniqueParamsByName = new HashMap(); + protected ArrayList> unknownMimeTypes = new ArrayList<>(); + protected Map> uniqueParamNameTypes = new HashMap<>(); + protected Map> modelMimeTypes = new HashMap<>(); + protected Map knownMimeDataTypes = new HashMap<>(); protected Set typeNames = new HashSet(); - protected Map knownMimeDataTypes = new HashMap(); - protected Map> modelMimeTypes = new HashMap>(); - protected String lastTag = ""; - protected ArrayList> unknownMimeTypes = new ArrayList>(); public CodegenType getTag() { return CodegenType.CLIENT; @@ -212,6 +216,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC cliOptions.add(CliOption.newBoolean(PROP_ALLOW_TOJSON_NULLS, "allow emitting JSON Null during model encoding to JSON").defaultValue(Boolean.FALSE.toString())); cliOptions.add(CliOption.newBoolean(PROP_GENERATE_LENSES, "Generate Lens optics for Models").defaultValue(Boolean.TRUE.toString())); cliOptions.add(CliOption.newBoolean(PROP_GENERATE_MODEL_CONSTRUCTORS, "Generate smart constructors (only supply required fields) for models").defaultValue(Boolean.TRUE.toString())); + cliOptions.add(CliOption.newBoolean(PROP_GENERATE_ENUMS, "Generate specific datatypes for swagger enums").defaultValue(Boolean.TRUE.toString())); cliOptions.add(CliOption.newBoolean(PROP_GENERATE_FORM_URLENCODED_INSTANCES, "Generate FromForm/ToForm instances for models that are used by operations that produce or consume application/x-www-form-urlencoded").defaultValue(Boolean.TRUE.toString())); cliOptions.add(CliOption.newBoolean(PROP_INLINE_CONSUMES_CONTENT_TYPES, "Inline (hardcode) the content-type on operations that do not have multiple content-types (Consumes)").defaultValue(Boolean.FALSE.toString())); @@ -237,7 +242,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC public void setGenerateModelConstructors(Boolean value) { additionalProperties.put(PROP_GENERATE_MODEL_CONSTRUCTORS, value); } - + public void setGenerateEnums(Boolean value) { + additionalProperties.put(PROP_GENERATE_ENUMS, value); + genEnums = value; + } public void setGenerateFormUrlEncodedInstances(Boolean value) { additionalProperties.put(PROP_GENERATE_FORM_URLENCODED_INSTANCES, value); } @@ -311,6 +319,12 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC setGenerateModelConstructors(true); } + if (additionalProperties.containsKey(PROP_GENERATE_ENUMS)) { + setGenerateEnums(convertPropertyToBoolean(PROP_GENERATE_ENUMS)); + } else { + setGenerateEnums(true); + } + if (additionalProperties.containsKey(PROP_GENERATE_FORM_URLENCODED_INSTANCES)) { setGenerateFormUrlEncodedInstances(convertPropertyToBoolean(PROP_GENERATE_FORM_URLENCODED_INSTANCES)); } else { @@ -515,7 +529,19 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC op.vendorExtensions.put(X_HAS_OPTIONAL_PARAMS, true); } - deduplicateParameter(param); + if (typeMapping.containsKey(param.dataType) + || param.isMapContainer || param.isListContainer + || param.isPrimitiveType || param.isFile || param.isEnum) { + + String dataType = genEnums && param.isEnum ? param.datatypeWithEnum : param.dataType; + + String paramNameType = toDedupedName(toTypeName("Param", param.paramName), dataType, !param.isEnum); + param.vendorExtensions.put(X_PARAM_NAME_TYPE, paramNameType); + + HashMap props = new HashMap<>(); + props.put(X_IS_BODY_PARAM, param.isBodyParam); + addToUniques(X_NEWTYPE, paramNameType, dataType, props); + } } processPathExpr(op); @@ -560,14 +586,14 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC }); additionalProperties.put(X_UNKNOWN_MIME_TYPES, unknownMimeTypes); - ArrayList params = new ArrayList<>(uniqueParamsByName.values()); - Collections.sort(params, new Comparator() { + ArrayList> params = new ArrayList<>(uniqueParamNameTypes.values()); + Collections.sort(params, new Comparator>() { @Override - public int compare(CodegenParameter o1, CodegenParameter o2) { + public int compare(Map o1, Map o2) { return - ((String) o1.vendorExtensions.get(X_PARAM_NAME_TYPE)) + ((String) o1.get(X_PARAM_NAME_TYPE)) .compareTo( - (String) o2.vendorExtensions.get(X_PARAM_NAME_TYPE)); + (String) o2.get(X_PARAM_NAME_TYPE)); } }); additionalProperties.put(X_ALL_UNIQUE_PARAMS, params); @@ -615,12 +641,6 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC prop.name = toVarName(prefix, prop.name); } - //String dataOrNewtype = "data"; - // check if it's a ModelImpl before casting - if (!(mod instanceof ModelImpl)) { - return model; - } - return model; } @@ -699,51 +719,67 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC } } - private void deduplicateParameter(CodegenParameter param) { - if (typeMapping.containsKey(param.dataType) || param.isPrimitiveType || param.isListContainer || param.isMapContainer || param.isFile) { - - String paramNameType = toTypeName("Param", param.paramName); - - if (uniqueParamsByName.containsKey(paramNameType)) { - if(!checkParamForDuplicates(paramNameType, param)) { - paramNameType = paramNameType + param.dataType; - if(!checkParamForDuplicates(paramNameType, param)) { - while (typeNames.contains(paramNameType)) { - paramNameType = generateNextName(paramNameType); - if(checkParamForDuplicates(paramNameType, param)) { - break; - } - } - } - - uniqueParamsByName.put(paramNameType, param); - } - } else { - - while (typeNames.contains(paramNameType)) { - paramNameType = generateNextName(paramNameType); - if(checkParamForDuplicates(paramNameType, param)) { - break; - } - } - - uniqueParamsByName.put(paramNameType, param); - } - - param.vendorExtensions.put(X_PARAM_NAME_TYPE, paramNameType); - typeNames.add(paramNameType); + private String toDedupedName(String paramNameType, String dataType, Boolean appendDataType) { + if (appendDataType + && uniqueParamNameTypes.containsKey(paramNameType) + && !isDuplicate(paramNameType, dataType)) { + paramNameType = paramNameType + dataType; } + + while (typeNames.contains(paramNameType)) { + if (isDuplicate(paramNameType, dataType)) { + break; + } + paramNameType = generateNextName(paramNameType); + } + + typeNames.add(paramNameType); + return paramNameType; } - public Boolean checkParamForDuplicates(String paramNameType, CodegenParameter param) { - CodegenParameter lastParam = this.uniqueParamsByName.get(paramNameType); - if (lastParam != null && lastParam.dataType != null && lastParam.dataType.equals(param.dataType)) { - param.vendorExtensions.put(X_DUPLICATE, true); - return true; + public Boolean isDuplicate(String paramNameType, String dataType) { + Map lastParam = this.uniqueParamNameTypes.get(paramNameType); + if (lastParam != null) { + String comparisonKey = lastParam.containsKey(X_ENUM) ? X_ENUM_VALUES : X_DATA_TYPE; + String lastParamDataType = (String) lastParam.get(comparisonKey); + if (lastParamDataType != null && lastParamDataType.equals(dataType)) { + return true; + } } return false; } + private Pair isDuplicateEnumValues(String enumValues) { + for (Map vs : uniqueParamNameTypes.values()) { + if (enumValues.equals(vs.get(X_ENUM_VALUES))) { + return Pair.of(true, (String) vs.get(X_PARAM_NAME_TYPE)); + } + } + return Pair.of(false, null); + } + + + private void addToUniques(String xGroup, String paramNameType, String dataType, Map props) { + HashMap m = new HashMap<>(); + m.put(X_PARAM_NAME_TYPE, paramNameType); + m.put(X_DATA_TYPE, dataType); + m.put(xGroup, true); + m.putAll(props); + uniqueParamNameTypes.put(paramNameType, m); + } + + private void addEnumToUniques(String paramNameType, String datatype, String enumValues, Map allowableValues, String description) { + HashMap props = new HashMap<>(); + props.put("allowableValues", allowableValues); + if(StringUtils.isNotBlank(description)) { + props.put("description", description); + } + props.put(X_ENUM_VALUES, enumValues); + addToUniques(X_ENUM, paramNameType, datatype, props); + additionalProperties.put(X_HAS_ENUM_SECTION, true); + } + + // build the parameterized path segments, according to pathParams private void processPathExpr(CodegenOperation op) { String xPath = "[\"" + escapeText(op.path) + "\"]"; @@ -962,20 +998,121 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC } @Override - public String toEnumName(CodegenProperty property) { - return "Enum'" + toTypeName("", property.name); + public Map postProcessModels(Map objs) { + List models = (List) objs.get("models"); + for (Object _mo : models) { + Map mo = (Map) _mo; + CodegenModel cm = (CodegenModel) mo.get("model"); + cm.isEnum = genEnums && cm.isEnum; + if(cm.isAlias) { + cm.vendorExtensions.put(X_DATA_TYPE, cm.dataType); + } + for (CodegenProperty var : cm.vars) { + String datatype = genEnums && !StringUtils.isBlank(var.datatypeWithEnum) + ? var.datatypeWithEnum + : var.datatype; + var.vendorExtensions.put(X_DATA_TYPE, datatype); + } + } + return postProcessModelsEnum(objs); + } + + @Override + public Map postProcessModelsEnum(Map objs) { + Map objsEnum = super.postProcessModelsEnum(objs); + if (genEnums) { + List models = (List) objsEnum.get("models"); + for (Object _mo : models) { + Map mo = (Map) _mo; + CodegenModel cm = (CodegenModel) mo.get("model"); + if (cm.isEnum && cm.allowableValues != null) { + updateAllowableValuesNames(cm.classname, cm.allowableValues); + addEnumToUniques(cm.classname, cm.dataType, cm.allowableValues.values().toString(), cm.allowableValues, cm.description); + } + } + } + return objsEnum; + } + + @Override + protected void updateDataTypeWithEnumForMap(CodegenProperty property) { + CodegenProperty baseItem = property.items; + while (baseItem != null && (Boolean.TRUE.equals(baseItem.isMapContainer) || Boolean.TRUE.equals(baseItem.isListContainer))) { + baseItem = baseItem.items; + } + if (baseItem != null) { + + // this replacement is/needs to be language-specific + property.datatypeWithEnum = property.datatypeWithEnum.replace(baseItem.baseType + ")", toEnumName(baseItem) + ")"); + + property.enumName = toEnumName(property); + if (property.defaultValue != null) { + property.defaultValue = property.defaultValue.replace(", " + property.items.baseType, ", " + toEnumName(property.items)); + } + } + } + + @Override + public String toEnumName(CodegenProperty var) { + if (!genEnums) return super.toEnumName(var); + + if (var.items != null && var.items.isEnum) { + return toEnumName(var.items); + } + String paramNameType = "E'" + toTypeName("", var.name); + String enumValues = var._enum.toString(); + + Pair duplicateEnum = isDuplicateEnumValues(enumValues); + if (duplicateEnum.getLeft()) { + paramNameType = duplicateEnum.getRight(); + } else { + paramNameType = toDedupedName(paramNameType, enumValues, false); + var.datatypeWithEnum = paramNameType; + updateCodegenPropertyEnum(var); + addEnumToUniques(paramNameType, var.datatype, enumValues, var.allowableValues, var.description); + } + + return paramNameType; + } + + @Override + public void updateCodegenPropertyEnum(CodegenProperty var) { + super.updateCodegenPropertyEnum(var); + if (!genEnums) return; + updateCodegenPropertyEnumValues(var, var.datatypeWithEnum); + } + + public void updateCodegenPropertyEnumValues(CodegenProperty var, String paramNameType) { + if (var.items != null && var.items.allowableValues != null) { + updateCodegenPropertyEnumValues(var.items, var.items.datatypeWithEnum); + return; + } + if(var.isEnum && var.allowableValues != null) { + updateAllowableValuesNames(paramNameType, var.allowableValues); + } + } + + private void updateAllowableValuesNames(String paramNameType, Map allowableValues) { + if (allowableValues == null) { + return; + } + for (Map enumVar : (List>) allowableValues.get("enumVars")) { + enumVar.put("name", paramNameType + enumVar.get("name")); + } } @Override public String toEnumVarName(String value, String datatype) { + if (!genEnums) return super.toEnumVarName(value, datatype); + List num = new ArrayList<>(Arrays.asList("integer","int","double","long","float")); if (value.length() == 0) { - return "E'Empty"; + return "'Empty"; } // for symbol, e.g. $, # if (getSymbolName(value) != null) { - return "E'" + sanitizeName(getSymbolName(value)); + return "'" + StringUtils.capitalize(sanitizeName(getSymbolName(value))); } // number @@ -984,10 +1121,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC varName = varName.replaceAll("-", "Minus_"); varName = varName.replaceAll("\\+", "Plus_"); varName = varName.replaceAll("\\.", "_Dot_"); - return "E'" + sanitizeName(varName); + return "'" + StringUtils.capitalize(sanitizeName(varName)); } - return "E'" + sanitizeName(value); + return "'" + StringUtils.capitalize(sanitizeName(value)); } @Override diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 33066ebeb92..51b79ef9a47 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -1,10 +1,13 @@ package io.swagger.codegen.languages; +import static java.util.Collections.sort; + import com.google.common.collect.LinkedListMultimap; import io.swagger.codegen.*; import io.swagger.codegen.languages.features.BeanValidationFeatures; import io.swagger.codegen.languages.features.GzipFeatures; import io.swagger.codegen.languages.features.PerformBeanValidationFeatures; + import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -49,6 +52,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen protected boolean useGzipFeature = false; protected boolean useRuntimeException = false; + public JavaClientCodegen() { super(); outputFolder = "generated-code" + File.separator + "java"; @@ -316,10 +320,34 @@ public class JavaClientCodegen extends AbstractJavaCodegen if (operation.returnType == null) { operation.returnType = "Void"; } - if (usesRetrofit2Library() && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")) + if (usesRetrofit2Library() && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")){ operation.path = operation.path.substring(1); + } + + // sorting operation parameters to make sure path params are parsed before query params + if (operation.allParams != null) { + sort(operation.allParams, new Comparator() { + @Override + public int compare(CodegenParameter one, CodegenParameter another) { + if (one.isPathParam && another.isQueryParam) { + return -1; + } + if (one.isQueryParam && another.isPathParam){ + return 1; + } + + return 0; + } + }); + Iterator iterator = operation.allParams.iterator(); + while (iterator.hasNext()){ + CodegenParameter param = iterator.next(); + param.hasMore = iterator.hasNext(); + } + } } } + } // camelize path variables for Feign client diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java index 918b681d6ed..703555f1153 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java @@ -246,8 +246,6 @@ public class SpringCodegen extends AbstractJavaCodegen additionalProperties.put(SINGLE_CONTENT_TYPES, "true"); this.setSingleContentTypes(true); } - additionalProperties.put("useSpringCloudClient", true); - } else { apiTemplateFiles.put("apiController.mustache", "Controller.java"); supportingFiles.add(new SupportingFile("apiException.mustache", diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/queryParams.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/queryParams.mustache index 5a9a4398a03..292fbb4600f 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/queryParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/queryParams.mustache @@ -1 +1 @@ -{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}} \ No newline at end of file +{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/application.mustache b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/application.mustache index c8a2d02d746..139e83e56cc 100644 --- a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/application.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/application.mustache @@ -17,6 +17,17 @@ play.filters.headers.contentSecurityPolicy=null +{{#useBeanValidation}} +# When using bean validation with the swagger api, the validator will check that every constraint is respected +# This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have +# shown that the time it takes to validate is exponential. +# If this is a concern in your application, or if you don't want to validate the output coming from your API for +# respecting its contract, set the "output" property below to "false". Since there is not a lot of data as input for +# an endpoint, I highly suggest you let the "input" property set to true. +useInputBeanValidation=true +useOutputBeanValidation=true +{{/useBeanValidation}} + {{#handleExceptions}} play.http.errorHandler="swagger.ErrorHandler" {{/handleExceptions}} diff --git a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/conversionBegin.mustache b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/conversionBegin.mustache index ef61e4943bc..69001e01d84 100644 --- a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/conversionBegin.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/conversionBegin.mustache @@ -1 +1 @@ -{{#isBoolean}}Boolean.valueOf({{/isBoolean}}{{#isInteger}}Integer.parseInt({{/isInteger}}{{#isDouble}}Double.parseDouble({{/isDouble}}{{#isLong}}Long.parseLong({{/isLong}}{{#isFloat}}Float.parseFloat({{/isFloat}}{{#isUuid}}UUID.fromString({{/isUuid}}{{#isDateTime}}OffsetDateTime.parse({{/isDateTime}} \ No newline at end of file +{{#isBoolean}}Boolean.valueOf({{/isBoolean}}{{#isInteger}}Integer.parseInt({{/isInteger}}{{#isDouble}}Double.parseDouble({{/isDouble}}{{#isLong}}Long.parseLong({{/isLong}}{{#isFloat}}Float.parseFloat({{/isFloat}}{{#isUuid}}UUID.fromString({{/isUuid}}{{#isDateTime}}OffsetDateTime.parse({{/isDateTime}}{{#isDate}}LocalDate.parse({{/isDate}}{{#isByteArray}}{{/isByteArray}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/conversionEnd.mustache b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/conversionEnd.mustache index ece85da5a28..fc7e52c40e8 100644 --- a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/conversionEnd.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/conversionEnd.mustache @@ -1 +1 @@ -{{#isBoolean}}){{/isBoolean}}{{#isInteger}}){{/isInteger}}{{#isDouble}}){{/isDouble}}{{#isLong}}){{/isLong}}{{#isFloat}}){{/isFloat}}{{#isUuid}}){{/isUuid}}{{#isDateTime}}){{/isDateTime}} \ No newline at end of file +{{#isBoolean}}){{/isBoolean}}{{#isInteger}}){{/isInteger}}{{#isDouble}}){{/isDouble}}{{#isLong}}){{/isLong}}{{#isFloat}}){{/isFloat}}{{#isUuid}}){{/isUuid}}{{#isDateTime}}){{/isDateTime}}{{#isDate}}){{/isDate}}{{#isByteArray}}.getBytes(){{/isByteArray}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/itemConversionBegin.mustache b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/itemConversionBegin.mustache index 42bcc99d36a..962109d36db 100644 --- a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/itemConversionBegin.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/itemConversionBegin.mustache @@ -1 +1 @@ -{{#items.isBoolean}}Boolean.valueOf({{/items.isBoolean}}{{#items.isInteger}}Integer.parseInt({{/items.isInteger}}{{#items.isDouble}}Double.parseDouble({{/items.isDouble}}{{#items.isLong}}Long.parseLong({{/items.isLong}}{{#items.isFloat}}Float.parseFloat({{/items.isFloat}}{{#items.isUuid}}UUID.fromString({{/items.isUuid}}{{#items.isDateTime}}OffsetDateTime.parse({{/items.isDateTime}} \ No newline at end of file +{{#items.isBoolean}}Boolean.valueOf({{/items.isBoolean}}{{#items.isInteger}}Integer.parseInt({{/items.isInteger}}{{#items.isDouble}}Double.parseDouble({{/items.isDouble}}{{#items.isLong}}Long.parseLong({{/items.isLong}}{{#items.isFloat}}Float.parseFloat({{/items.isFloat}}{{#items.isUuid}}UUID.fromString({{/items.isUuid}}{{#items.isDateTime}}OffsetDateTime.parse({{/items.isDateTime}}{{#items.isDate}}LocalDate.parse({{/items.isDate}}{{#isByteArray}}{{/isByteArray}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/itemConversionEnd.mustache b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/itemConversionEnd.mustache index cb202e4325e..771cf4f349d 100644 --- a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/itemConversionEnd.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/itemConversionEnd.mustache @@ -1 +1 @@ -{{#items.isBoolean}}){{/items.isBoolean}}{{#items.isInteger}}){{/items.isInteger}}{{#items.isDouble}}){{/items.isDouble}}{{#items.isLong}}){{/items.isLong}}{{#items.isFloat}}){{/items.isFloat}}{{#items.isUuid}}){{/items.isUuid}}{{#items.isDateTime}}){{/items.isDateTime}} \ No newline at end of file +{{#items.isBoolean}}){{/items.isBoolean}}{{#items.isInteger}}){{/items.isInteger}}{{#items.isDouble}}){{/items.isDouble}}{{#items.isLong}}){{/items.isLong}}{{#items.isFloat}}){{/items.isFloat}}{{#items.isUuid}}){{/items.isUuid}}{{#items.isDateTime}}){{/items.isDateTime}}{{#items.isDate}}){{/items.isDate}}{{#isByteArray}}.getBytes(){{/isByteArray}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/newApiController.mustache b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/newApiController.mustache index 0d7345a93b9..9f20541d056 100644 --- a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/newApiController.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/newApiController.mustache @@ -21,6 +21,7 @@ import com.fasterxml.jackson.core.type.TypeReference; {{#useBeanValidation}} import javax.validation.constraints.*; +import play.Configuration; {{/useBeanValidation}} {{#wrapCalls}} @@ -35,13 +36,19 @@ public class {{classname}}Controller extends Controller { private final {{classname}}ControllerImp{{#useInterfaces}}Interface{{/useInterfaces}} imp; {{/controllerOnly}} private final ObjectMapper mapper; + {{#useBeanValidation}} + private final Configuration configuration; + {{/useBeanValidation}} @Inject - private {{classname}}Controller({{^controllerOnly}}{{classname}}ControllerImp{{#useInterfaces}}Interface{{/useInterfaces}} imp{{/controllerOnly}}) { + private {{classname}}Controller({{#useBeanValidation}}Configuration configuration{{^controllerOnly}}, {{/controllerOnly}}{{/useBeanValidation}}{{^controllerOnly}}{{classname}}ControllerImp{{#useInterfaces}}Interface{{/useInterfaces}} imp{{/controllerOnly}}) { {{^controllerOnly}} this.imp = imp; {{/controllerOnly}} mapper = new ObjectMapper(); + {{#useBeanValidation}} + this.configuration = configuration; + {{/useBeanValidation}} } {{#operation}} @@ -55,12 +62,21 @@ public class {{classname}}Controller extends Controller { if (node{{paramName}} != null) { {{paramName}} = mapper.readValue(node{{paramName}}.toString(), {{#isContainer}}new TypeReference<{{{dataType}}}>(){}{{/isContainer}}{{^isContainer}}{{{dataType}}}.class{{/isContainer}}); {{#useBeanValidation}} - {{#isListContainer}}for ({{{baseType}}} curItem : {{paramName}}) { - curItem.validate(); - }{{/isListContainer}}{{#isMapContainer}}for (Map.Entry entry : {{paramName}}.entrySet()) { - entry.getValue().validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + {{#isListContainer}} + for ({{{baseType}}} curItem : {{paramName}}) { + SwaggerUtils.validate(curItem); + } + {{/isListContainer}} + {{#isMapContainer}} + for (Map.Entry entry : {{paramName}}.entrySet()) { + SwaggerUtils.validate(entry.getValue()); + } + {{/isMapContainer}} + {{^isContainer}} + SwaggerUtils.validate({{paramName}}); + {{/isContainer}} } - {{/isMapContainer}}{{^isContainer}}{{paramName}}.validate();{{/isContainer}} {{/useBeanValidation}} } else { {{#required}} @@ -173,13 +189,30 @@ public class {{classname}}Controller extends Controller { {{/collectionFormat}} {{/headerParams}} {{^controllerOnly}} - {{#returnType}}{{>returnTypesNoVoid}} obj = {{/returnType}}imp.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}{{^isResponseFile}}{{^returnTypeIsPrimitive}}{{#useBeanValidation}} - {{#isListContainer}}for ({{{returnType}}} curItem : obj) { - curItem.validate(); - }{{/isListContainer}}{{#isMapContainer}}for (Map.Entry entry : obj.entrySet()) { - entry.getValue().validate(); + {{#returnType}}{{>returnTypesNoVoid}} obj = {{/returnType}}imp.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + {{#returnType}} + {{^isResponseFile}} + {{^returnTypeIsPrimitive}} + {{#useBeanValidation}} + if (configuration.getBoolean("useOutputBeanValidation")) { + {{#isListContainer}} + for ({{{returnType}}} curItem : obj) { + SwaggerUtils.validate(curItem); + } + {{/isListContainer}} + {{#isMapContainer}} + for (Map.Entry entry : obj.entrySet()) { + SwaggerUtils.validate(entry.getValue()); + } + {{/isMapContainer}} + {{^returnContainer}} + SwaggerUtils.validate(obj); + {{/returnContainer}} } - {{/isMapContainer}}{{^returnContainer}}obj.validate();{{/returnContainer}}{{/useBeanValidation}}{{/returnTypeIsPrimitive}}{{/isResponseFile}}{{/returnType}} + {{/useBeanValidation}} + {{/returnTypeIsPrimitive}} + {{/isResponseFile}} + {{/returnType}} {{#returnType}} {{^isResponseFile}}JsonNode result = mapper.valueToTree(obj); return ok(result); diff --git a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/pojo.mustache b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/pojo.mustache index 25bb4e49c4a..c7ce1c4dadb 100644 --- a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/pojo.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/pojo.mustache @@ -134,22 +134,4 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali } return o.toString().replace("\n", "\n "); } - - {{#useBeanValidation}} - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation<{{classname}}> contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } - {{/useBeanValidation}} } diff --git a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/swaggerUtils.mustache b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/swaggerUtils.mustache index c03add93e1a..8b472f131d0 100644 --- a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/swaggerUtils.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/swaggerUtils.mustache @@ -9,6 +9,13 @@ import java.lang.annotation.Target; import java.text.SimpleDateFormat; import java.util.*; +{{#useBeanValidation}} +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; +{{/useBeanValidation}} + public class SwaggerUtils { {{#wrapCalls}} @@ -19,6 +26,24 @@ public class SwaggerUtils { } {{/wrapCalls}} +{{#useBeanValidation}} + public static void validate(T obj) { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + Validator validator = factory.getValidator(); + Set> constraintViolations = validator.validate(obj); + if (constraintViolations.size() > 0) { + StringBuilder errors = new StringBuilder(); + for (ConstraintViolation contraintes : constraintViolations) { + errors.append(String.format("%s.%s %s\n", + contraintes.getRootBeanClass().getSimpleName(), + contraintes.getPropertyPath(), + contraintes.getMessage())); + } + throw new RuntimeException("Bean validation : " + errors); + } + } +{{/useBeanValidation}} + public static List parametersToList(String collectionFormat, String[] values){ List params = new ArrayList<>(); diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache index be425a1e760..58bfee5f8ba 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache @@ -7,12 +7,19 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} - +{{#jdk8-no-delegate}} +import com.fasterxml.jackson.databind.ObjectMapper; +{{/jdk8-no-delegate}} import io.swagger.annotations.*; -{{#jdk8}} +{{#jdk8-no-delegate}} +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; -{{/jdk8}} +{{/jdk8-no-delegate}} import org.springframework.http.ResponseEntity; +{{#useBeanValidation}} +import org.springframework.validation.annotation.Validated; +{{/useBeanValidation}} import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -21,26 +28,54 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -{{^useSpringCloudClient}} -import java.io.IOException; -{{/useSpringCloudClient}} +{{#jdk8-no-delegate}} +import javax.servlet.http.HttpServletRequest; +{{/jdk8-no-delegate}} +{{#useBeanValidation}} +import javax.validation.Valid; +import javax.validation.constraints.*; +{{/useBeanValidation}} +{{#jdk8-no-delegate}} +import java.io.IOException; +{{/jdk8-no-delegate}} import java.util.List; -{{#useOptional}} +{{#jdk8-no-delegate}} import java.util.Optional; -{{/useOptional}} +{{/jdk8-no-delegate}} +{{^jdk8-no-delegate}} + {{#useOptional}} +import java.util.Optional; + {{/useOptional}} +{{/jdk8-no-delegate}} {{#async}} import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}}; {{/async}} -{{#useBeanValidation}} -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; -import javax.validation.Valid; -{{/useBeanValidation}} {{>generatedAnnotation}} @Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API") {{#operations}} public interface {{classname}} { +{{#jdk8}} + + {{^isDelegate}} + Logger log = LoggerFactory.getLogger({{classname}}.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + {{/isDelegate}} + {{#isDelegate}} + {{classname}}Delegate getDelegate(); + {{/isDelegate}} +{{/jdk8}} {{#operation}} @ApiOperation(value = "{{{summary}}}", nickname = "{{{operationId}}}", notes = "{{{notes}}}"{{#returnBaseType}}, response = {{{returnBaseType}}}.class{{/returnBaseType}}{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { @@ -65,20 +100,29 @@ public interface {{classname}} { produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} method = RequestMethod.{{httpMethod}}) -{{#useSpringCloudClient}} {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} { - // do some magic! - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; + {{^isDelegate}} + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + {{#examples}} + if (getAcceptHeader().get().contains("{{{contentType}}}")) { + try { + return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(getObjectMapper().get().readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; + } catch (IOException e) { + log.error("Couldn't serialize response for content type {{{contentType}}}", e); + return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR){{#async}}){{/async}}; + } + } + {{/examples}} + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default {{classname}} interface so no example is generated"); + } + return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; + {{/isDelegate}} + {{#isDelegate}} + return getDelegate().{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + {{/isDelegate}} }{{/jdk8}} -{{/useSpringCloudClient}} -{{^useSpringCloudClient}} - {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}} @RequestHeader(value = "Accept", required = false) String accept) throws Exception{{^jdk8}};{{/jdk8}}{{#jdk8}} { - // do some magic! - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}}; - }{{/jdk8}} - -{{/useSpringCloudClient}} {{/operation}} } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache index 019c7618e06..4d56cdab40a 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache @@ -1,16 +1,21 @@ package {{package}}; -{{^jdk8-no-delegate}} +{{^jdk8}} {{#imports}}import {{import}}; {{/imports}} - +{{/jdk8}} +{{^isDelegate}} +import com.fasterxml.jackson.databind.ObjectMapper; +{{/isDelegate}} +{{^jdk8}} import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -{{/jdk8-no-delegate}} +{{/jdk8}} import org.springframework.stereotype.Controller; -{{^jdk8-no-delegate}} +{{^jdk8}} import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,31 +23,35 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -{{#useOptional}} -import java.util.Optional; -{{/useOptional}} -{{#async}} -import java.util.concurrent.Callable; -{{/async}} -{{/jdk8-no-delegate}} -{{^useSpringCloudClient}} -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -{{/useSpringCloudClient}} -{{#useBeanValidation}} + {{#useBeanValidation}} import javax.validation.constraints.*; import javax.validation.Valid; -{{/useBeanValidation}} + {{/useBeanValidation}} +{{/jdk8}} +{{^isDelegate}} +import javax.servlet.http.HttpServletRequest; + {{#jdk8}} +import java.util.Optional; + {{/jdk8}} +{{/isDelegate}} +{{^jdk8-no-delegate}} + {{#useOptional}} +import java.util.Optional; + {{/useOptional}} +{{/jdk8-no-delegate}} +{{^jdk8}} + {{^isDelegate}} +import java.io.IOException; + {{/isDelegate}} +import java.util.List; + {{#async}} +import java.util.concurrent.Callable; + {{/async}} +{{/jdk8}} {{>generatedAnnotation}} @Controller {{#operations}} public class {{classname}}Controller implements {{classname}} { - private final ObjectMapper objectMapper; - - public {{classname}}Controller(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } {{#isDelegate}} private final {{classname}}Delegate delegate; @@ -51,48 +60,78 @@ public class {{classname}}Controller implements {{classname}} { public {{classname}}Controller({{classname}}Delegate delegate) { this.delegate = delegate; } + {{#jdk8}} + + @Override + public {{classname}}Delegate getDelegate() { + return delegate; + } + {{/jdk8}} +{{/isDelegate}} +{{^isDelegate}} + {{^jdk8}} + private static final Logger log = LoggerFactory.getLogger({{classname}}Controller.class); + + {{/jdk8}} + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public {{classname}}Controller(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + {{#jdk8}} + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + {{/jdk8}} {{/isDelegate}} -{{^jdk8-no-delegate}} +{{^jdk8}} {{#operation}} - public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}, - {{/allParams}}@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! -{{#useSpringCloudClient}} - {{^isDelegate}} - {{^async}} - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); - {{/async}} - {{#async}} - return new CallablereturnTypes}}>>() { - @Override - public ResponseEntity<{{>returnTypes}}> call() throws Exception { - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); - } - }; - {{/async}} - {{/isDelegate}} - {{#isDelegate}} - return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); - {{/isDelegate}} -{{/useSpringCloudClient}} -{{^useSpringCloudClient}} + public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}) { {{^isDelegate}} {{^async}} + String accept = request.getHeader("Accept"); {{#examples}} - if (accept != null && accept.contains("{{{contentType}}}")) { - return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.OK); + try { + return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type {{{contentType}}}", e); + return new ResponseEntity<{{>returnTypes}}>(HttpStatus.INTERNAL_SERVER_ERROR); + } } {{/examples}} - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); + return new ResponseEntity<{{>returnTypes}}>(HttpStatus.NOT_IMPLEMENTED); {{/async}} {{#async}} return new CallablereturnTypes}}>>() { @Override - public ResponseEntity<{{>returnTypes}}> call() throws Exception { - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); + public ResponseEntity<{{>returnTypes}}> call() { + String accept = request.getHeader("Accept"); + {{#examples}} + if (accept != null && accept.contains("{{{contentType}}}")) { + try { + return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type {{{contentType}}}", e); + return new ResponseEntity<{{>returnTypes}}>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + {{/examples}} + return new ResponseEntity<{{>returnTypes}}>(HttpStatus.NOT_IMPLEMENTED); } }; {{/async}} @@ -100,10 +139,9 @@ public class {{classname}}Controller implements {{classname}} { {{#isDelegate}} return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); {{/isDelegate}} -{{/useSpringCloudClient}} } {{/operation}} -{{/jdk8-no-delegate}} +{{/jdk8}} } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/apiDelegate.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/apiDelegate.mustache index eed583ea916..482cdb1b2fb 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/apiDelegate.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/apiDelegate.mustache @@ -2,13 +2,33 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} - -import io.swagger.annotations.*;{{#jdk8}} -import org.springframework.http.HttpStatus;{{/jdk8}} +{{#jdk8}} +import com.fasterxml.jackson.databind.ObjectMapper; +{{/jdk8}} +import io.swagger.annotations.*; +{{#jdk8}} +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +{{/jdk8}} import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; +{{#jdk8}} +import java.io.IOException; +{{/jdk8}} +{{#jdk8}} +import javax.servlet.http.HttpServletRequest; +{{/jdk8}} import java.util.List; +{{#jdk8}} +import java.util.Optional; +{{/jdk8}} +{{^jdk8}} + {{#useOptional}} +import java.util.Optional; + {{/useOptional}} +{{/jdk8}} {{#async}} import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}}; {{/async}} @@ -16,11 +36,26 @@ import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture {{#operations}} /** * A delegate to be called by the {@link {{classname}}Controller}}. - * Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation. - * Instead, use spring to autowire this class into the {@link {{classname}}Controller}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. */ {{>generatedAnnotation}} public interface {{classname}}Delegate { +{{#jdk8}} + + Logger log = LoggerFactory.getLogger({{classname}}.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } +{{/jdk8}} {{#operation}} /** @@ -28,8 +63,21 @@ public interface {{classname}}Delegate { */ {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{{dataType}}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} { - // do some magic! - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}}; + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + {{#examples}} + if (getAcceptHeader().get().contains("{{{contentType}}}")) { + try { + return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(getObjectMapper().get().readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; + } catch (IOException e) { + log.error("Couldn't serialize response for content type {{{contentType}}}", e); + return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR){{#async}}){{/async}}; + } + } + {{/examples}} + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default {{classname}} interface so no example is generated"); + } + return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; }{{/jdk8}} {{/operation}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/beanValidationCore.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/beanValidationCore.mustache index 84a26690f9b..3e7954e4a87 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/beanValidationCore.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/beanValidationCore.mustache @@ -1,20 +1,20 @@ -{{#pattern}} @Pattern(regexp="{{{pattern}}}"){{/pattern}}{{! +{{#pattern}}@Pattern(regexp="{{{pattern}}}") {{/pattern}}{{! minLength && maxLength set -}}{{#minLength}}{{#maxLength}} @Size(min={{minLength}},max={{maxLength}}){{/maxLength}}{{/minLength}}{{! +}}{{#minLength}}{{#maxLength}}@Size(min={{minLength}},max={{maxLength}}) {{/maxLength}}{{/minLength}}{{! minLength set, maxLength not -}}{{#minLength}}{{^maxLength}} @Size(min={{minLength}}){{/maxLength}}{{/minLength}}{{! +}}{{#minLength}}{{^maxLength}}@Size(min={{minLength}}) {{/maxLength}}{{/minLength}}{{! minLength not set, maxLength set -}}{{^minLength}}{{#maxLength}} @Size(max={{maxLength}}){{/maxLength}}{{/minLength}}{{! +}}{{^minLength}}{{#maxLength}}@Size(max={{maxLength}}) {{/maxLength}}{{/minLength}}{{! @Size: minItems && maxItems set -}}{{#minItems}}{{#maxItems}} @Size(min={{minItems}},max={{maxItems}}){{/maxItems}}{{/minItems}}{{! +}}{{#minItems}}{{#maxItems}}@Size(min={{minItems}},max={{maxItems}}) {{/maxItems}}{{/minItems}}{{! @Size: minItems set, maxItems not -}}{{#minItems}}{{^maxItems}} @Size(min={{minItems}}){{/maxItems}}{{/minItems}}{{! +}}{{#minItems}}{{^maxItems}}@Size(min={{minItems}}) {{/maxItems}}{{/minItems}}{{! @Size: minItems not set && maxItems set -}}{{^minItems}}{{#maxItems}} @Size(max={{maxItems}}){{/maxItems}}{{/minItems}}{{! +}}{{^minItems}}{{#maxItems}}@Size(max={{maxItems}}) {{/maxItems}}{{/minItems}}{{! check for integer or long / all others=decimal type with @Decimal* isInteger set -}}{{#isInteger}}{{#minimum}} @Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}){{/maximum}}{{/isInteger}}{{! +}}{{#isInteger}}{{#minimum}}@Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}) {{/maximum}}{{/isInteger}}{{! isLong set -}}{{#isLong}}{{#minimum}} @Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}){{/maximum}}{{/isLong}}{{! +}}{{#isLong}}{{#minimum}}@Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}) {{/maximum}}{{/isLong}}{{! Not Integer, not Long => we have a decimal value! -}}{{^isInteger}}{{^isLong}}{{#minimum}} @DecimalMin("{{minimum}}"){{/minimum}}{{#maximum}} @DecimalMax("{{maximum}}"){{/maximum}}{{/isLong}}{{/isInteger}} \ No newline at end of file +}}{{^isInteger}}{{^isLong}}{{#minimum}}@DecimalMin("{{minimum}}"){{/minimum}}{{#maximum}} @DecimalMax("{{maximum}}") {{/maximum}}{{/isLong}}{{/isInteger}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/beanValidationQueryParams.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/beanValidationQueryParams.mustache index c4ff01d7e55..9cca8cb8874 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/beanValidationQueryParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/beanValidationQueryParams.mustache @@ -1 +1 @@ -{{#required}} @NotNull{{/required}}{{>beanValidationCore}} \ No newline at end of file +{{#required}}@NotNull {{/required}}{{>beanValidationCore}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache b/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache index bc5905954eb..91fe1d8b323 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache @@ -15,8 +15,8 @@ mono nuget.exe install src/{{packageName}}/packages.config -o packages; echo "[INFO] Copy DLLs to the 'bin' folder" mkdir -p bin; -cp packages/Newtonsoft.Json.10.0.3/lib/{{targetFrameworkNuget}}/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll; -cp packages/RestSharp.105.1.0/lib/{{targetFrameworkNuget}}/RestSharp.dll bin/RestSharp.dll; +cp packages/Newtonsoft.Json.{{#isNet40}}4.5.11{{/isNet40}}{{^isNet40}}10.0.3{{/isNet40}}/lib/{{targetFrameworkNuget}}/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll; +cp packages/RestSharp.105.1.0/lib/{{#isNet40}}net4{{/isNet40}}{{^isNet40}}{{targetFrameworkNuget}}{{/isNet40}}/RestSharp.dll bin/RestSharp.dll; {{#generatePropertyChanged}} cp packages/Fody.1.29.4/Fody.dll bin/Fody.dll cp packages/PropertyChanged.Fody.1.51.3/PropertyChanged.Fody.dll bin/PropertyChanged.Fody.dll diff --git a/modules/swagger-codegen/src/main/resources/csharp/compile.mustache b/modules/swagger-codegen/src/main/resources/csharp/compile.mustache index 2ef0e06e902..dab5acb5869 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/compile.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/compile.mustache @@ -15,8 +15,8 @@ if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient if not exist ".\bin" mkdir bin -copy packages\Newtonsoft.Json.10.0.3\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll -copy packages\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll bin\RestSharp.dll +copy packages\Newtonsoft.Json.{{#isNet40}}4.5.11{{/isNet40}}{{^isNet40}}10.0.3{{/isNet40}}\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll +copy packages\RestSharp.105.1.0\lib\{{#isNet40}}net4{{/isNet40}}{{^isNet40}}{{targetFrameworkNuget}}{{/isNet40}}\RestSharp.dll bin\RestSharp.dll {{#generatePropertyChanged}} copy packages\Fody.1.29.4\Fody.dll bin\Fody.dll copy packages\PropertyChanged.Fody.1.51.3\PropertyChanged.Fody.dll bin\PropertyChanged.Fody.dll diff --git a/modules/swagger-codegen/src/main/resources/csharp/packages.config.mustache b/modules/swagger-codegen/src/main/resources/csharp/packages.config.mustache index 10218bf15c5..feb72290656 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/packages.config.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/packages.config.mustache @@ -1,7 +1,7 @@ - + {{#generatePropertyChanged}} diff --git a/modules/swagger-codegen/src/main/resources/csharp/packages_test.config.mustache b/modules/swagger-codegen/src/main/resources/csharp/packages_test.config.mustache index 1403975d651..8e102af48aa 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/packages_test.config.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/packages_test.config.mustache @@ -2,5 +2,5 @@ - + diff --git a/modules/swagger-codegen/src/main/resources/elixir/request_builder.ex.mustache b/modules/swagger-codegen/src/main/resources/elixir/request_builder.ex.mustache index 8b0480496c8..191832e9bdb 100644 --- a/modules/swagger-codegen/src/main/resources/elixir/request_builder.ex.mustache +++ b/modules/swagger-codegen/src/main/resources/elixir/request_builder.ex.mustache @@ -10,13 +10,13 @@ defmodule {{moduleName}}.RequestBuilder do ## Parameters - request (Map) - Collected request options - - m (String) - Request method + - m (atom) - Request method ## Returns Map """ - @spec method(map(), String.t) :: map() + @spec method(map(), atom) :: map() def method(request, m) do Map.put_new(request, :method, m) end @@ -51,7 +51,7 @@ defmodule {{moduleName}}.RequestBuilder do Map """ - @spec add_optional_params(map(), %{optional(:atom) => :atom}, keyword()) :: map() + @spec add_optional_params(map(), %{optional(atom) => atom}, keyword()) :: map() def add_optional_params(request, _, []), do: request def add_optional_params(request, definitions, [{key, value} | tail]) do case definitions do @@ -78,7 +78,7 @@ defmodule {{moduleName}}.RequestBuilder do Map """ - @spec add_param(map(), :atom, :atom, any()) :: map() + @spec add_param(map(), atom, atom, any()) :: map() def add_param(request, :body, :body, value), do: Map.put(request, :body, value) def add_param(request, :body, key, value) do request @@ -103,25 +103,20 @@ defmodule {{moduleName}}.RequestBuilder do ## Parameters - - env (Tesla.Env) - The response object - - struct - The shape of the struct to deserialize into + - arg1 (Tesla.Env.t | term) - The response object + - arg2 (:false | struct | [struct]) - The shape of the struct to deserialize into ## Returns {:ok, struct} on success - {:error, info} on failure + {:error, term} on failure """ - @spec decode(Tesla.Env.t) :: {:ok, struct()} | {:error, Tesla.Env.t} + @spec decode(Tesla.Env.t | term()) :: {:ok, struct()} | {:error, Tesla.Env.t} | {:error, term()} def decode(%Tesla.Env{status: 200, body: body}), do: Poison.decode(body) - def decode(response) do - {:error, response} - end - @spec decode(Tesla.Env.t, struct()) :: {:ok, struct()} | {:error, Tesla.Env.t} + def decode(response), do: {:error, response} + + @spec decode(Tesla.Env.t | term(), :false | struct() | [struct()]) :: {:ok, struct()} | {:error, Tesla.Env.t} | {:error, term()} def decode(%Tesla.Env{status: 200} = env, false), do: {:ok, env} - def decode(%Tesla.Env{status: 200, body: body}, struct) do - Poison.decode(body, as: struct) - end - def decode(response, _struct) do - {:error, response} - end + def decode(%Tesla.Env{status: 200, body: body}, struct), do: Poison.decode(body, as: struct) + def decode(response, _struct), do: {:error, response} end diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/API.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/API.mustache index 0ed4d1093a2..ebfdc970ab7 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/API.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/API.mustache @@ -75,7 +75,7 @@ import qualified Prelude as P {{operationId}} :: {{#vendorExtensions.x-hasBodyOrFormParam}}(Consumes {{{vendorExtensions.x-operationType}}} {{>_contentType}}{{#allParams}}{{#isBodyParam}}{{#required}}, MimeRender {{>_contentType}} {{#vendorExtensions.x-paramNameType}}{{{.}}}{{/vendorExtensions.x-paramNameType}}{{^vendorExtensions.x-paramNameType}}{{{dataType}}}{{/vendorExtensions.x-paramNameType}}{{/required}}{{/isBodyParam}}{{/allParams}}) => {{^vendorExtensions.x-inlineContentType}}contentType -- ^ request content-type ('MimeType') - -> {{/vendorExtensions.x-inlineContentType}}{{/vendorExtensions.x-hasBodyOrFormParam}}{{#allParams}}{{#required}}{{#vendorExtensions.x-paramNameType}}{{{.}}}{{/vendorExtensions.x-paramNameType}}{{^vendorExtensions.x-paramNameType}}{{{dataType}}}{{/vendorExtensions.x-paramNameType}} -- ^ "{{{paramName}}}"{{#description}} - {{/description}} {{{description}}} + -> {{/vendorExtensions.x-inlineContentType}}{{/vendorExtensions.x-hasBodyOrFormParam}}{{#allParams}}{{#required}}{{#vendorExtensions.x-paramNameType}}{{{.}}}{{/vendorExtensions.x-paramNameType}}{{^vendorExtensions.x-paramNameType}}{{{dataType}}}{{/vendorExtensions.x-paramNameType}} -- ^ "{{{paramName}}}"{{#description}} - {{{.}}}{{/description}}{{^required}}{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}{{/required}} -> {{/required}}{{/allParams}}{{requestType}} {{{vendorExtensions.x-operationType}}} {{#vendorExtensions.x-hasBodyOrFormParam}}{{>_contentType}}{{/vendorExtensions.x-hasBodyOrFormParam}}{{^vendorExtensions.x-hasBodyOrFormParam}}MimeNoContent{{/vendorExtensions.x-hasBodyOrFormParam}} {{vendorExtensions.x-returnType}} {{operationId}} {{#vendorExtensions.x-hasBodyOrFormParam}}{{^vendorExtensions.x-inlineContentType}}_ {{/vendorExtensions.x-inlineContentType}}{{/vendorExtensions.x-hasBodyOrFormParam}}{{#allParams}}{{#required}}{{#isBodyParam}}{{{paramName}}}{{/isBodyParam}}{{^isBodyParam}}({{{vendorExtensions.x-paramNameType}}} {{{paramName}}}){{/isBodyParam}} {{/required}}{{/allParams}}= _mkRequest "{{httpMethod}}" {{{vendorExtensions.x-path}}}{{#authMethods}} @@ -108,14 +108,12 @@ instance Produces {{{vendorExtensions.x-operationType}}} {{{x-mediaDataType}}} -- * Parameter newtypes +{{#x-allUniqueParams}}{{#x-newtype}} +newtype {{{x-paramNameType}}} = {{{x-paramNameType}}} { un{{{x-paramNameType}}} :: {{{x-dataType}}} } deriving (P.Eq, P.Show{{#x-isBodyParam}}, A.ToJSON{{/x-isBodyParam}}){{/x-newtype}}{{/x-allUniqueParams}} -{{#x-allUniqueParams}} -newtype {{{vendorExtensions.x-paramNameType}}} = {{{vendorExtensions.x-paramNameType}}} { un{{{vendorExtensions.x-paramNameType}}} :: {{{dataType}}} } deriving (P.Eq, P.Show{{#isBodyParam}}, A.ToJSON{{/isBodyParam}}) -{{/x-allUniqueParams}} +{{#authMethods}}{{#-first}}-- * Auth Methods --- * Auth Methods - -{{#authMethods}}{{#isBasic}}-- ** {{name}} +{{/-first}}{{#isBasic}}-- ** {{name}} data {{name}} = {{name}} B.ByteString B.ByteString -- ^ username password deriving (P.Eq, P.Show, P.Typeable) diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/Model.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/Model.mustache index ca63b567309..3613d9588d1 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/Model.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/Model.mustache @@ -8,6 +8,8 @@ Module : {{title}}.Model {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} @@ -18,9 +20,11 @@ Module : {{title}}.Model module {{title}}.Model where import {{title}}.Core +import {{title}}.MimeTypes import Data.Aeson ((.:),(.:!),(.:?),(.=)) +import qualified Control.Arrow as P (left) import qualified Data.Aeson as A import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL @@ -39,7 +43,7 @@ import qualified Web.HttpApiData as WH import Control.Applicative ((<|>)) import Control.Applicative (Alternative) import Data.Text (Text) -import Prelude (($), (.),(<$>),(<*>),(>>=),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor) +import Prelude (($), (.),(<$>),(<*>),(>>=),(=<<),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor) import qualified Prelude as P @@ -50,18 +54,17 @@ import qualified Prelude as P -- * Models {{#models}} -{{#model}} - +{{#model}}{{^isEnum}} -- ** {{classname}} -- | {{classname}}{{#title}} -- {{{.}}} -- {{/title}}{{#description}} -- {{{.}}}{{/description}}{{#isAlias}} newtype {{classname}} = {{classname}} - { un{{classname}} :: {{{dataType}}} + { un{{classname}} :: {{{vendorExtensions.x-dataType}}} } deriving (P.Eq, P.Show, P.Typeable, A.ToJSON, A.FromJSON, WH.ToHttpApiData, WH.FromHttpApiData{{#modelDeriving}}, {{modelDeriving}}{{/modelDeriving}}){{/isAlias}}{{^isAlias}} data {{classname}} = {{classname}} - { {{#vars}}{{name}} :: {{#x-strictFields}}!({{/x-strictFields}}{{^required}}Maybe {{/required}}{{datatype}}{{#x-strictFields}}){{/x-strictFields}} -- ^ {{#required}}/Required/ {{/required}}{{#readOnly}}/ReadOnly/ {{/readOnly}}"{{baseName}}"{{#description}} - {{description}}{{/description}}{{#hasMore}} + { {{#vars}}{{name}} :: {{#x-strictFields}}!({{/x-strictFields}}{{^required}}Maybe {{/required}}{{{vendorExtensions.x-dataType}}}{{#x-strictFields}}){{/x-strictFields}} -- ^ {{#required}}/Required/ {{/required}}{{#readOnly}}/ReadOnly/ {{/readOnly}}"{{baseName}}"{{#description}} - {{description}}{{/description}}{{#hasMore}} , {{/hasMore}}{{/vars}} } deriving (P.Show, P.Eq, P.Typeable{{#modelDeriving}}, {{modelDeriving}}{{/modelDeriving}}){{/isAlias}} @@ -100,17 +103,40 @@ instance WH.ToForm {{classname}} where {{#generateModelConstructors}} -- | Construct a value of type '{{classname}}' (by applying it's required fields, if any) mk{{classname}} - :: {{#requiredVars}}{{{datatype}}} -- ^ '{{name}}'{{#description}}:{{/description}} {{{description}}} + :: {{#requiredVars}}{{{vendorExtensions.x-dataType}}} -- ^ '{{name}}'{{#description}}:{{/description}} {{{description}}} -> {{/requiredVars}}{{classname}} mk{{classname}} {{#requiredVars}}{{name}} {{/requiredVars}}= {{classname}} { {{#vars}}{{#required}}{{name}}{{/required}}{{^required}}{{name}} = {{#isListContainer}}Nothing{{/isListContainer}}{{#isMapContainer}}Nothing{{/isMapContainer}}{{^isContainer}}Nothing{{/isContainer}}{{/required}}{{#hasMore}} , {{/hasMore}}{{/vars}} } -{{/generateModelConstructors}} -{{/isAlias}} +{{/generateModelConstructors}}{{/isAlias}}{{/isEnum}}{{/model}}{{/models}} -{{/model}} -{{/models}} +{{#x-hasEnumSection}}-- * Enums +{{#x-allUniqueParams}}{{#x-enum}} +-- ** {{{x-paramNameType}}} +-- | Enum of '{{{x-dataType}}}'{{#description}} . +-- {{{.}}}{{/description}} +data {{{x-paramNameType}}} + = {{#allowableValues}}{{#enumVars}}{{{name}}} -- ^ @{{{value}}}@ + {{^-last}}| {{/-last}}{{#-last}}deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum){{/-last}}{{/enumVars}}{{/allowableValues}} + +instance A.ToJSON {{{x-paramNameType}}} where toJSON = A.toJSON . from{{{x-paramNameType}}} +instance A.FromJSON {{{x-paramNameType}}} where parseJSON o = P.either P.fail (pure . P.id) . to{{{x-paramNameType}}} =<< A.parseJSON o +instance WH.ToHttpApiData {{{x-paramNameType}}} where toQueryParam = WH.toQueryParam . from{{{x-paramNameType}}} +instance WH.FromHttpApiData {{{x-paramNameType}}} where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . to{{{x-paramNameType}}} +instance MimeRender MimeMultipartFormData {{{x-paramNameType}}} where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap '{{{x-paramNameType}}}' enum +from{{{x-paramNameType}}} :: {{{x-paramNameType}}} -> {{{x-dataType}}} +from{{{x-paramNameType}}} = \case{{#allowableValues}}{{#enumVars}} + {{{name}}} -> {{{value}}}{{/enumVars}}{{/allowableValues}} + +-- | parse '{{{x-paramNameType}}}' enum +to{{{x-paramNameType}}} :: {{{x-dataType}}} -> P.Either String {{{x-paramNameType}}} +to{{{x-paramNameType}}} = \case{{#allowableValues}}{{#enumVars}} + {{{value}}} -> P.Right {{{name}}}{{/enumVars}}{{/allowableValues}} + s -> P.Left $ "to{{{x-paramNameType}}}: enum parse failure: " P.++ P.show s +{{/x-enum}}{{/x-allUniqueParams}}{{/x-hasEnumSection}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/ModelLens.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/ModelLens.mustache index 9e509aeebb5..d15a4ba8336 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/ModelLens.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/ModelLens.mustache @@ -33,7 +33,7 @@ import {{title}}.Core {{#vars}} -- | '{{name}}' Lens -{{name}}L :: Lens_' {{classname}} ({{^required}}Maybe {{/required}}{{datatype}}) +{{name}}L :: Lens_' {{classname}} ({{^required}}Maybe {{/required}}{{{vendorExtensions.x-dataType}}}) {{name}}L f {{classname}}{..} = (\{{name}} -> {{classname}} { {{name}}, ..} ) <$> f {{name}} {-# INLINE {{name}}L #-} diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/README.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/README.mustache index ba1195d798a..9c89f0f5115 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/README.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/README.mustache @@ -48,11 +48,6 @@ haskell-http-client * Model Inheritance -* Default Parameter Values - -* Enum Parameters - - This is beta software; other cases may not be supported. ### Codegen "additional properties" parameters @@ -67,6 +62,7 @@ These options allow some customization of the code generation process. | allowToJsonNulls | allow emitting JSON Null during model encoding to JSON | false | {{{allowToJsonNulls}}} | | dateFormat | format string used to parse/render a date | %Y-%m-%d | {{{dateFormat}}} | | dateTimeFormat | format string used to parse/render a datetime. (Defaults to [formatISO8601Millis][1] when not provided) | | {{{dateTimeFormat}}} | +| generateEnums | Generate specific datatypes for swagger enums | true | {{{generateEnums}}} | | generateFormUrlEncodedInstances | Generate FromForm/ToForm instances for models used by x-www-form-urlencoded operations (model fields must be primitive types) | true | {{{generateFormUrlEncodedInstances}}} | | generateLenses | Generate Lens optics for Models | true | {{{generateLenses}}} | | generateModelConstructors | Generate smart constructors (only supply required fields) for models | true | {{{generateModelConstructors}}} | diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/haskell-http-client.cabal.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/haskell-http-client.cabal.mustache index fb8d17763d5..2b0b517b845 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/haskell-http-client.cabal.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/haskell-http-client.cabal.mustache @@ -44,7 +44,7 @@ library , bytestring >=0.10.0 && <0.11 , base64-bytestring >1.0 && <2.0 , containers >=0.5.0.0 && <0.6 - , http-types >=0.8 && <0.10 + , http-types >=0.8 && <0.11 , http-client >=0.5 && <0.6 , http-client-tls , http-api-data >= 0.3.4 && <0.4 diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/stack.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/stack.mustache index 174a76815bc..aa4a059faa5 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/stack.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/stack.mustache @@ -1,4 +1,4 @@ -resolver: lts-9.0 +resolver: lts-9.10 build: haddock-arguments: haddock-args: diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/Instances.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/Instances.mustache index f8d6a3c406f..afaaf140c98 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/Instances.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/Instances.mustache @@ -91,13 +91,19 @@ instance ApproxEq TI.Day where {{#models}} {{#model}} +{{^isEnum}} instance Arbitrary {{classname}} where arbitrary = {{#isAlias}}{{classname}} <$> arbitrary{{/isAlias}}{{^isAlias}}{{^hasVars}} pure {{/hasVars}}{{classname}} {{#hasVars}} <$>{{/hasVars}} {{#vars}}arbitrary -- {{name}} :: {{^required}}Maybe {{/required}}{{datatype}} {{#hasMore}} <*> {{/hasMore}}{{/vars}}{{/isAlias}} - +{{/isEnum}} {{/model}} {{/models}} + +{{#x-allUniqueParams}}{{#x-enum}} +instance Arbitrary {{{x-paramNameType}}} where + arbitrary = arbitraryBoundedEnum +{{/x-enum}}{{/x-allUniqueParams}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/haskellhttpclient/HaskellHttpClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/haskellhttpclient/HaskellHttpClientOptionsTest.java index b79dbe398e0..ef70ceb7d3e 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/haskellhttpclient/HaskellHttpClientOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/haskellhttpclient/HaskellHttpClientOptionsTest.java @@ -36,6 +36,8 @@ public class HaskellHttpClientOptionsTest extends AbstractOptionsTest { times = 1; clientCodegen.setGenerateModelConstructors(Boolean.valueOf(HaskellHttpClientOptionsProvider.GENERATE_MODEL_CONSTRUCTORS)); times = 1; + clientCodegen.setGenerateEnums(Boolean.valueOf(HaskellHttpClientOptionsProvider.GENERATE_ENUMS)); + times = 1; clientCodegen.setGenerateFormUrlEncodedInstances(Boolean.valueOf(HaskellHttpClientOptionsProvider.GENERATE_FORM_URLENCODED_INSTANCES)); times = 1; clientCodegen.setGenerateLenses(Boolean.valueOf(HaskellHttpClientOptionsProvider.GENERATE_LENSES)); diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/JavaClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/JavaClientCodegenTest.java index e761f2ec088..99cccc1a070 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/JavaClientCodegenTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/JavaClientCodegenTest.java @@ -1,5 +1,8 @@ package io.swagger.codegen.languages; +import static io.swagger.codegen.languages.JavaClientCodegen.RETROFIT_2; + +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -9,6 +12,11 @@ import java.util.Map; import org.testng.Assert; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableMap; + +import io.swagger.codegen.CodegenOperation; +import io.swagger.codegen.CodegenParameter; + public class JavaClientCodegenTest { private static final String VENDOR_MIME_TYPE = "application/vnd.company.v1+json"; @@ -51,15 +59,15 @@ public class JavaClientCodegenTest { Assert.assertEquals(JavaClientCodegen.prioritizeContentTypes(Arrays.asList(jsonMimeType)), Arrays.asList(jsonMimeType)); Assert.assertEquals(JavaClientCodegen.prioritizeContentTypes(Arrays.asList(vendorMimeType)), Arrays.asList(vendorMimeType)); - Assert.assertEquals(JavaClientCodegen.prioritizeContentTypes(Arrays.asList(xmlMimeType, jsonMimeType)), + Assert.assertEquals(JavaClientCodegen.prioritizeContentTypes(Arrays.asList(xmlMimeType, jsonMimeType)), Arrays.asList(jsonMimeType, xmlMimeType)); - Assert.assertEquals(JavaClientCodegen.prioritizeContentTypes(Arrays.asList(jsonMimeType, xmlMimeType)), + Assert.assertEquals(JavaClientCodegen.prioritizeContentTypes(Arrays.asList(jsonMimeType, xmlMimeType)), Arrays.asList(jsonMimeType, xmlMimeType)); - Assert.assertEquals(JavaClientCodegen.prioritizeContentTypes(Arrays.asList(jsonMimeType, vendorMimeType)), + Assert.assertEquals(JavaClientCodegen.prioritizeContentTypes(Arrays.asList(jsonMimeType, vendorMimeType)), Arrays.asList(vendorMimeType, jsonMimeType)); - Assert.assertEquals(JavaClientCodegen.prioritizeContentTypes(Arrays.asList(textMimeType, xmlMimeType)), + Assert.assertEquals(JavaClientCodegen.prioritizeContentTypes(Arrays.asList(textMimeType, xmlMimeType)), Arrays.asList(textMimeType, xmlMimeType)); - Assert.assertEquals(JavaClientCodegen.prioritizeContentTypes(Arrays.asList(xmlMimeType, textMimeType)), + Assert.assertEquals(JavaClientCodegen.prioritizeContentTypes(Arrays.asList(xmlMimeType, textMimeType)), Arrays.asList(xmlMimeType, textMimeType)); System.out.println(JavaClientCodegen.prioritizeContentTypes(Arrays.asList( @@ -74,4 +82,53 @@ public class JavaClientCodegenTest { Assert.assertNull(priContentTypes.get(3).get("hasMore")); } + + @Test + public void testParametersAreCorrectlyOrderedWhenUsingRetrofit(){ + JavaClientCodegen javaClientCodegen = new JavaClientCodegen(); + javaClientCodegen.setLibrary(RETROFIT_2); + + CodegenOperation codegenOperation = new CodegenOperation(); + CodegenParameter queryParamRequired = createQueryParam("queryParam1", true); + CodegenParameter queryParamOptional = createQueryParam("queryParam2", false); + CodegenParameter pathParam1 = createPathParam("pathParam1"); + CodegenParameter pathParam2 = createPathParam("pathParam2"); + + codegenOperation.allParams = Arrays.asList(queryParamRequired, pathParam1, pathParam2, queryParamOptional); + Map operations = ImmutableMap.of("operation", Arrays.asList(codegenOperation)); + + Map objs = ImmutableMap.of("operations", operations, "imports", new ArrayList>()); + + javaClientCodegen.postProcessOperations(objs); + + Assert.assertEquals(Arrays.asList(pathParam1, pathParam2, queryParamRequired, queryParamOptional), codegenOperation.allParams); + Assert.assertTrue(pathParam1.hasMore); + Assert.assertTrue(pathParam2.hasMore); + Assert.assertTrue(queryParamRequired.hasMore); + Assert.assertFalse(queryParamOptional.hasMore); + + } + + private CodegenParameter createPathParam(String name) { + CodegenParameter codegenParameter = createStringParam(name); + codegenParameter.isPathParam = true; + return codegenParameter; + } + + private CodegenParameter createQueryParam(String name, boolean required) { + CodegenParameter codegenParameter = createStringParam(name); + codegenParameter.isQueryParam = true; + codegenParameter.required = required; + return codegenParameter; + } + + private CodegenParameter createStringParam(String name){ + CodegenParameter codegenParameter = new CodegenParameter(); + codegenParameter.paramName = name; + codegenParameter.baseName = name; + codegenParameter.dataType = "String"; + return codegenParameter; + } + + } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/HaskellHttpClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/HaskellHttpClientOptionsProvider.java index 1b776f43e13..bc2a5ccbeaf 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/HaskellHttpClientOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/HaskellHttpClientOptionsProvider.java @@ -20,6 +20,7 @@ public class HaskellHttpClientOptionsProvider implements OptionsProvider { public static final String DATE_FORMAT = "%Y-%m-%d"; public static final String MODEL_DERIVING = ""; public static final String STRICT_FIELDS = "false"; + public static final String GENERATE_ENUMS = "true"; public static final String GENERATE_FORM_URLENCODED_INSTANCES = "true"; public static final String GENERATE_LENSES = "true"; public static final String GENERATE_MODEL_CONSTRUCTORS = "true"; @@ -46,6 +47,7 @@ public class HaskellHttpClientOptionsProvider implements OptionsProvider { .put(HaskellHttpClientCodegen.PROP_DATETIME_FORMAT, DATETIME_FORMAT) .put(HaskellHttpClientCodegen.PROP_DATE_FORMAT, DATE_FORMAT) .put(HaskellHttpClientCodegen.PROP_MODEL_DERIVING, MODEL_DERIVING) + .put(HaskellHttpClientCodegen.PROP_GENERATE_ENUMS, GENERATE_ENUMS) .put(HaskellHttpClientCodegen.PROP_GENERATE_FORM_URLENCODED_INSTANCES, GENERATE_FORM_URLENCODED_INSTANCES) .put(HaskellHttpClientCodegen.PROP_GENERATE_LENSES, GENERATE_LENSES) .put(HaskellHttpClientCodegen.PROP_GENERATE_MODEL_CONSTRUCTORS, GENERATE_MODEL_CONSTRUCTORS) diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/.gitignore b/samples/client/petstore/csharp/SwaggerClientNet40/.gitignore new file mode 100644 index 00000000000..d3f4f7b6f55 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/.gitignore @@ -0,0 +1,185 @@ +# Ref: https://gist.github.com/kmorcinek/2710267 +# Download this file using PowerShell v3 under Windows with the following comand +# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +[Bb]in/ +[Oo]bj/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# OS generated files # +.DS_Store* +ehthumbs.db +Icon? +Thumbs.db + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings +modulesbin/ +tempbin/ + +# EPiServer Site file (VPP) +AppData/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# vim +*.txt~ +*.swp +*.swo + +# svn +.svn + +# SQL Server files +**/App_Data/*.mdf +**/App_Data/*.ldf +**/App_Data/*.sdf + + +#LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +# SASS Compiler cache +.sass-cache + +# Visual Studio 2014 CTP +**/*.sln.ide diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/.swagger-codegen-ignore b/samples/client/petstore/csharp/SwaggerClientNet40/.swagger-codegen-ignore new file mode 100644 index 00000000000..c5fa491b4c5 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/.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/client/petstore/csharp/SwaggerClientNet40/.swagger-codegen/VERSION b/samples/client/petstore/csharp/SwaggerClientNet40/.swagger-codegen/VERSION new file mode 100644 index 00000000000..f9f7450d135 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/.swagger-codegen/VERSION @@ -0,0 +1 @@ +2.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/.travis.yml b/samples/client/petstore/csharp/SwaggerClientNet40/.travis.yml new file mode 100644 index 00000000000..805caf43c2c --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/.travis.yml @@ -0,0 +1,9 @@ +# +# Generated by: https://github.com/swagger-api/swagger-codegen.git +# +language: csharp +mono: + - latest +solution: IO.Swagger.sln +script: + - /bin/sh ./mono_nunit_test.sh diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/IO.Swagger.sln b/samples/client/petstore/csharp/SwaggerClientNet40/IO.Swagger.sln new file mode 100644 index 00000000000..05f9d7c8586 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/IO.Swagger.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +VisualStudioVersion = 12.0.0.0 +MinimumVisualStudioVersion = 10.0.0.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{321C8C3F-0156-40C1-AE42-D59761FB9B6C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger.Test", "src\IO.Swagger.Test\IO.Swagger.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.Build.0 = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/README.md b/samples/client/petstore/csharp/SwaggerClientNet40/README.md new file mode 100644 index 00000000000..8257b6b39dc --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/README.md @@ -0,0 +1,202 @@ +# IO.Swagger - the C# library for the Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +This C# SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: 1.0.0 +- SDK version: 1.0.0 +- Build package: io.swagger.codegen.languages.CSharpClientCodegen + + +## Frameworks supported +- .NET 4.0 or later +- Windows Phone 7.1 (Mango) + + +## Dependencies +- [RestSharp](https://www.nuget.org/packages/RestSharp) - 105.1.0 or later +- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 7.0.0 or later + +The DLLs included in the package may not be the latest version. We recommend using [NuGet] (https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages: +``` +Install-Package RestSharp +Install-Package Newtonsoft.Json +``` + +NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742) + + +## Installation +Run the following command to generate the DLL +- [Mac/Linux] `/bin/sh build.sh` +- [Windows] `build.bat` + +Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces: +```csharp +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; +``` + +## Packaging + +A `.nuspec` is included with the project. You can follow the Nuget quickstart to [create](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#create-the-package) and [publish](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#publish-the-package) packages. + +This `.nuspec` uses placeholders from the `.csproj`, so build the `.csproj` directly: + +``` +nuget pack -Build -OutputDirectory out IO.Swagger.csproj +``` + +Then, publish to a [local feed](https://docs.microsoft.com/en-us/nuget/hosting-packages/local-feeds) or [other host](https://docs.microsoft.com/en-us/nuget/hosting-packages/overview) and consume the new package via Nuget as usual. + + +## Getting Started + +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class Example + { + public void main() + { + + var apiInstance = new AnotherFakeApi(); + var body = new ModelClient(); // ModelClient | client model + + try + { + // To test special tags + ModelClient result = apiInstance.TestSpecialTags(body); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling AnotherFakeApi.TestSpecialTags: " + e.Message ); + } + + } + } +} +``` + + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*AnotherFakeApi* | [**TestSpecialTags**](docs/AnotherFakeApi.md#testspecialtags) | **PATCH** /another-fake/dummy | To test special tags +*FakeApi* | [**FakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | +*FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | +*FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | +*FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | +*FakeApi* | [**TestClientModel**](docs/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model +*FakeApi* | [**TestEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +*FakeApi* | [**TestEnumParameters**](docs/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters +*FakeApi* | [**TestInlineAdditionalProperties**](docs/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +*FakeApi* | [**TestJsonFormData**](docs/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeClassnameTags123Api* | [**TestClassname**](docs/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case +*PetApi* | [**AddPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**DeletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**FindPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**FindPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**GetPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**UpdatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet +*PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**UploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**DeleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +*StoreApi* | [**GetInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**GetOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID +*StoreApi* | [**PlaceOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet +*UserApi* | [**CreateUser**](docs/UserApi.md#createuser) | **POST** /user | Create user +*UserApi* | [**CreateUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**CreateUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**DeleteUser**](docs/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**GetUserByName**](docs/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +*UserApi* | [**LoginUser**](docs/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system +*UserApi* | [**LogoutUser**](docs/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**UpdateUser**](docs/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + + +## Documentation for Models + + - [Model.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) + - [Model.Animal](docs/Animal.md) + - [Model.AnimalFarm](docs/AnimalFarm.md) + - [Model.ApiResponse](docs/ApiResponse.md) + - [Model.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) + - [Model.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) + - [Model.ArrayTest](docs/ArrayTest.md) + - [Model.Capitalization](docs/Capitalization.md) + - [Model.Category](docs/Category.md) + - [Model.ClassModel](docs/ClassModel.md) + - [Model.EnumArrays](docs/EnumArrays.md) + - [Model.EnumClass](docs/EnumClass.md) + - [Model.EnumTest](docs/EnumTest.md) + - [Model.FormatTest](docs/FormatTest.md) + - [Model.HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [Model.List](docs/List.md) + - [Model.MapTest](docs/MapTest.md) + - [Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) + - [Model.Model200Response](docs/Model200Response.md) + - [Model.ModelClient](docs/ModelClient.md) + - [Model.ModelReturn](docs/ModelReturn.md) + - [Model.Name](docs/Name.md) + - [Model.NumberOnly](docs/NumberOnly.md) + - [Model.Order](docs/Order.md) + - [Model.OuterBoolean](docs/OuterBoolean.md) + - [Model.OuterComposite](docs/OuterComposite.md) + - [Model.OuterEnum](docs/OuterEnum.md) + - [Model.OuterNumber](docs/OuterNumber.md) + - [Model.OuterString](docs/OuterString.md) + - [Model.Pet](docs/Pet.md) + - [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md) + - [Model.SpecialModelName](docs/SpecialModelName.md) + - [Model.Tag](docs/Tag.md) + - [Model.User](docs/User.md) + - [Model.Cat](docs/Cat.md) + - [Model.Dog](docs/Dog.md) + + + +## Documentation for Authorization + + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +### api_key_query + +- **Type**: API key +- **API key parameter name**: api_key_query +- **Location**: URL query string + + +### http_basic_test + +- **Type**: HTTP basic authentication + + +### petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - write:pets: modify pets in your account + - read:pets: read your pets + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/build.bat b/samples/client/petstore/csharp/SwaggerClientNet40/build.bat new file mode 100644 index 00000000000..3944ce79ec2 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/build.bat @@ -0,0 +1,16 @@ +:: Generated by: https://github.com/swagger-api/swagger-codegen.git +:: + +@echo off + +SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v3.5 + +if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '.\nuget.exe')" +.\nuget.exe install src\IO.Swagger\packages.config -o packages + +if not exist ".\bin" mkdir bin + +copy packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll +copy packages\RestSharp.105.1.0\lib\net4\RestSharp.dll bin\RestSharp.dll +%CSCPATH%\csc /reference:bin\Newtonsoft.Json.dll;bin\RestSharp.dll;System.ComponentModel.DataAnnotations.dll /target:library /out:bin\IO.Swagger.dll /recurse:src\IO.Swagger\*.cs /doc:bin\IO.Swagger.xml + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/build.sh b/samples/client/petstore/csharp/SwaggerClientNet40/build.sh new file mode 100644 index 00000000000..838fd258d52 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/build.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# +# Generated by: https://github.com/swagger-api/swagger-codegen.git +# + +frameworkVersion=net40 +netfx=${frameworkVersion#net} + +echo "[INFO] Target framework: ${frameworkVersion}" + +echo "[INFO] Download nuget and packages" +wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe; +mozroots --import --sync +mono nuget.exe install src/IO.Swagger/packages.config -o packages; + +echo "[INFO] Copy DLLs to the 'bin' folder" +mkdir -p bin; +cp packages/Newtonsoft.Json.4.5.11/lib/net40/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll; +cp packages/RestSharp.105.1.0/lib/net4/RestSharp.dll bin/RestSharp.dll; + +echo "[INFO] Run 'mcs' to build bin/IO.Swagger.dll" +mcs -sdk:${netfx} -r:bin/Newtonsoft.Json.dll,\ +bin/RestSharp.dll,\ +System.ComponentModel.DataAnnotations.dll,\ +System.Runtime.Serialization.dll \ +-target:library \ +-out:bin/IO.Swagger.dll \ +-recurse:'src/IO.Swagger/*.cs' \ +-doc:bin/IO.Swagger.xml \ +-platform:anycpu + +if [ $? -ne 0 ] +then + echo "[ERROR] Compilation failed with exit code $?" + exit 1 +else + echo "[INFO] bin/IO.Swagger.dll was created successfully" +fi diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/AdditionalPropertiesClass.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/AdditionalPropertiesClass.md new file mode 100644 index 00000000000..ac4f9d10798 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/AdditionalPropertiesClass.md @@ -0,0 +1,10 @@ +# IO.Swagger.Model.AdditionalPropertiesClass +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**MapProperty** | **Dictionary<string, string>** | | [optional] +**MapOfMapProperty** | **Dictionary<string, Dictionary<string, string>>** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/Animal.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Animal.md new file mode 100644 index 00000000000..f461176159c --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Animal.md @@ -0,0 +1,10 @@ +# IO.Swagger.Model.Animal +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | +**Color** | **string** | | [optional] [default to "red"] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/AnimalFarm.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/AnimalFarm.md new file mode 100644 index 00000000000..4d1cccb0cef --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/AnimalFarm.md @@ -0,0 +1,8 @@ +# IO.Swagger.Model.AnimalFarm +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/AnotherFakeApi.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/AnotherFakeApi.md new file mode 100644 index 00000000000..89bc406754a --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/AnotherFakeApi.md @@ -0,0 +1,70 @@ +# IO.Swagger.Api.AnotherFakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**TestSpecialTags**](AnotherFakeApi.md#testspecialtags) | **PATCH** /another-fake/dummy | To test special tags + + + +# **TestSpecialTags** +> ModelClient TestSpecialTags (ModelClient body) + +To test special tags + +To test special tags + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class TestSpecialTagsExample + { + public void main() + { + var apiInstance = new AnotherFakeApi(); + var body = new ModelClient(); // ModelClient | client model + + try + { + // To test special tags + ModelClient result = apiInstance.TestSpecialTags(body); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling AnotherFakeApi.TestSpecialTags: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**ModelClient**](ModelClient.md)| client model | + +### Return type + +[**ModelClient**](ModelClient.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/ApiResponse.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ApiResponse.md new file mode 100644 index 00000000000..3e4b4c5e9cb --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ApiResponse.md @@ -0,0 +1,11 @@ +# IO.Swagger.Model.ApiResponse +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **int?** | | [optional] +**Type** | **string** | | [optional] +**Message** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/ArrayOfArrayOfNumberOnly.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ArrayOfArrayOfNumberOnly.md new file mode 100644 index 00000000000..3431d89edd0 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ArrayOfArrayOfNumberOnly.md @@ -0,0 +1,9 @@ +# IO.Swagger.Model.ArrayOfArrayOfNumberOnly +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ArrayArrayNumber** | **List<List<decimal?>>** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/ArrayOfNumberOnly.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ArrayOfNumberOnly.md new file mode 100644 index 00000000000..9dc573663d6 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ArrayOfNumberOnly.md @@ -0,0 +1,9 @@ +# IO.Swagger.Model.ArrayOfNumberOnly +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ArrayNumber** | **List<decimal?>** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/ArrayTest.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ArrayTest.md new file mode 100644 index 00000000000..37fb2788b77 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ArrayTest.md @@ -0,0 +1,11 @@ +# IO.Swagger.Model.ArrayTest +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ArrayOfString** | **List<string>** | | [optional] +**ArrayArrayOfInteger** | **List<List<long?>>** | | [optional] +**ArrayArrayOfModel** | **List<List<ReadOnlyFirst>>** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/Capitalization.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Capitalization.md new file mode 100644 index 00000000000..87d14f03e0d --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Capitalization.md @@ -0,0 +1,14 @@ +# IO.Swagger.Model.Capitalization +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**SmallCamel** | **string** | | [optional] +**CapitalCamel** | **string** | | [optional] +**SmallSnake** | **string** | | [optional] +**CapitalSnake** | **string** | | [optional] +**SCAETHFlowPoints** | **string** | | [optional] +**ATT_NAME** | **string** | Name of the pet | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/Cat.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Cat.md new file mode 100644 index 00000000000..a88425f4307 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Cat.md @@ -0,0 +1,11 @@ +# IO.Swagger.Model.Cat +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | +**Color** | **string** | | [optional] [default to "red"] +**Declawed** | **bool?** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/Category.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Category.md new file mode 100644 index 00000000000..20b56b1728c --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Category.md @@ -0,0 +1,10 @@ +# IO.Swagger.Model.Category +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **long?** | | [optional] +**Name** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/ClassModel.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ClassModel.md new file mode 100644 index 00000000000..760130f053c --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ClassModel.md @@ -0,0 +1,9 @@ +# IO.Swagger.Model.ClassModel +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_Class** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/Dog.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Dog.md new file mode 100644 index 00000000000..c3ee6d927b4 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Dog.md @@ -0,0 +1,11 @@ +# IO.Swagger.Model.Dog +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | +**Color** | **string** | | [optional] [default to "red"] +**Breed** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/EnumArrays.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/EnumArrays.md new file mode 100644 index 00000000000..86fd208f8f8 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/EnumArrays.md @@ -0,0 +1,10 @@ +# IO.Swagger.Model.EnumArrays +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**JustSymbol** | **string** | | [optional] +**ArrayEnum** | **List<string>** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/EnumClass.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/EnumClass.md new file mode 100644 index 00000000000..d936aad6f0b --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/EnumClass.md @@ -0,0 +1,8 @@ +# IO.Swagger.Model.EnumClass +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/EnumTest.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/EnumTest.md new file mode 100644 index 00000000000..a4371a96695 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/EnumTest.md @@ -0,0 +1,12 @@ +# IO.Swagger.Model.EnumTest +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**EnumString** | **string** | | [optional] +**EnumInteger** | **int?** | | [optional] +**EnumNumber** | **double?** | | [optional] +**OuterEnum** | [**OuterEnum**](OuterEnum.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/FakeApi.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/FakeApi.md new file mode 100644 index 00000000000..166fc077b26 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/FakeApi.md @@ -0,0 +1,604 @@ +# IO.Swagger.Api.FakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**FakeOuterBooleanSerialize**](FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | +[**FakeOuterCompositeSerialize**](FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | +[**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | +[**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | +[**TestClientModel**](FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model +[**TestEndpointParameters**](FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +[**TestEnumParameters**](FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters +[**TestInlineAdditionalProperties**](FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +[**TestJsonFormData**](FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data + + + +# **FakeOuterBooleanSerialize** +> OuterBoolean FakeOuterBooleanSerialize (OuterBoolean body = null) + + + +Test serialization of outer boolean types + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class FakeOuterBooleanSerializeExample + { + public void main() + { + var apiInstance = new FakeApi(); + var body = new OuterBoolean(); // OuterBoolean | Input boolean as post body (optional) + + try + { + OuterBoolean result = apiInstance.FakeOuterBooleanSerialize(body); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterBooleanSerialize: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**OuterBoolean**](OuterBoolean.md)| Input boolean as post body | [optional] + +### Return type + +[**OuterBoolean**](OuterBoolean.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **FakeOuterCompositeSerialize** +> OuterComposite FakeOuterCompositeSerialize (OuterComposite body = null) + + + +Test serialization of object with outer number type + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class FakeOuterCompositeSerializeExample + { + public void main() + { + var apiInstance = new FakeApi(); + var body = new OuterComposite(); // OuterComposite | Input composite as post body (optional) + + try + { + OuterComposite result = apiInstance.FakeOuterCompositeSerialize(body); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterCompositeSerialize: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional] + +### Return type + +[**OuterComposite**](OuterComposite.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **FakeOuterNumberSerialize** +> OuterNumber FakeOuterNumberSerialize (OuterNumber body = null) + + + +Test serialization of outer number types + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class FakeOuterNumberSerializeExample + { + public void main() + { + var apiInstance = new FakeApi(); + var body = new OuterNumber(); // OuterNumber | Input number as post body (optional) + + try + { + OuterNumber result = apiInstance.FakeOuterNumberSerialize(body); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterNumberSerialize: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**OuterNumber**](OuterNumber.md)| Input number as post body | [optional] + +### Return type + +[**OuterNumber**](OuterNumber.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **FakeOuterStringSerialize** +> OuterString FakeOuterStringSerialize (OuterString body = null) + + + +Test serialization of outer string types + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class FakeOuterStringSerializeExample + { + public void main() + { + var apiInstance = new FakeApi(); + var body = new OuterString(); // OuterString | Input string as post body (optional) + + try + { + OuterString result = apiInstance.FakeOuterStringSerialize(body); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterStringSerialize: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**OuterString**](OuterString.md)| Input string as post body | [optional] + +### Return type + +[**OuterString**](OuterString.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **TestClientModel** +> ModelClient TestClientModel (ModelClient body) + +To test \"client\" model + +To test \"client\" model + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class TestClientModelExample + { + public void main() + { + var apiInstance = new FakeApi(); + var body = new ModelClient(); // ModelClient | client model + + try + { + // To test \"client\" model + ModelClient result = apiInstance.TestClientModel(body); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeApi.TestClientModel: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**ModelClient**](ModelClient.md)| client model | + +### Return type + +[**ModelClient**](ModelClient.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **TestEndpointParameters** +> void TestEndpointParameters (decimal? number, double? _double, string patternWithoutDelimiter, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, string _string = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null, string callback = null) + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class TestEndpointParametersExample + { + public void main() + { + // Configure HTTP basic authorization: http_basic_test + Configuration.Default.Username = "YOUR_USERNAME"; + Configuration.Default.Password = "YOUR_PASSWORD"; + + var apiInstance = new FakeApi(); + var number = 3.4; // decimal? | None + var _double = 1.2; // double? | None + var patternWithoutDelimiter = patternWithoutDelimiter_example; // string | None + var _byte = _byte_example; // byte[] | None + var integer = 56; // int? | None (optional) + var int32 = 56; // int? | None (optional) + var int64 = 789; // long? | None (optional) + var _float = 3.4; // float? | None (optional) + var _string = _string_example; // string | None (optional) + var binary = B; // byte[] | None (optional) + var date = 2013-10-20; // DateTime? | None (optional) + var dateTime = 2013-10-20T19:20:30+01:00; // DateTime? | None (optional) + var password = password_example; // string | None (optional) + var callback = callback_example; // string | None (optional) + + try + { + // Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + apiInstance.TestEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, _string, binary, date, dateTime, password, callback); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeApi.TestEndpointParameters: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **number** | **decimal?**| None | + **_double** | **double?**| None | + **patternWithoutDelimiter** | **string**| None | + **_byte** | **byte[]**| None | + **integer** | **int?**| None | [optional] + **int32** | **int?**| None | [optional] + **int64** | **long?**| None | [optional] + **_float** | **float?**| None | [optional] + **_string** | **string**| None | [optional] + **binary** | **byte[]**| None | [optional] + **date** | **DateTime?**| None | [optional] + **dateTime** | **DateTime?**| None | [optional] + **password** | **string**| None | [optional] + **callback** | **string**| None | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[http_basic_test](../README.md#http_basic_test) + +### HTTP request headers + + - **Content-Type**: application/xml; charset=utf-8, application/json; charset=utf-8 + - **Accept**: application/xml; charset=utf-8, application/json; charset=utf-8 + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **TestEnumParameters** +> void TestEnumParameters (List enumFormStringArray = null, string enumFormString = null, List enumHeaderStringArray = null, string enumHeaderString = null, List enumQueryStringArray = null, string enumQueryString = null, int? enumQueryInteger = null, double? enumQueryDouble = null) + +To test enum parameters + +To test enum parameters + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class TestEnumParametersExample + { + public void main() + { + var apiInstance = new FakeApi(); + var enumFormStringArray = new List(); // List | Form parameter enum test (string array) (optional) + var enumFormString = enumFormString_example; // string | Form parameter enum test (string) (optional) (default to -efg) + var enumHeaderStringArray = new List(); // List | Header parameter enum test (string array) (optional) + var enumHeaderString = enumHeaderString_example; // string | Header parameter enum test (string) (optional) (default to -efg) + var enumQueryStringArray = new List(); // List | Query parameter enum test (string array) (optional) + var enumQueryString = enumQueryString_example; // string | Query parameter enum test (string) (optional) (default to -efg) + var enumQueryInteger = 56; // int? | Query parameter enum test (double) (optional) + var enumQueryDouble = 1.2; // double? | Query parameter enum test (double) (optional) + + try + { + // To test enum parameters + apiInstance.TestEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeApi.TestEnumParameters: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **enumFormStringArray** | [**List<string>**](string.md)| Form parameter enum test (string array) | [optional] + **enumFormString** | **string**| Form parameter enum test (string) | [optional] [default to -efg] + **enumHeaderStringArray** | [**List<string>**](string.md)| Header parameter enum test (string array) | [optional] + **enumHeaderString** | **string**| Header parameter enum test (string) | [optional] [default to -efg] + **enumQueryStringArray** | [**List<string>**](string.md)| Query parameter enum test (string array) | [optional] + **enumQueryString** | **string**| Query parameter enum test (string) | [optional] [default to -efg] + **enumQueryInteger** | **int?**| Query parameter enum test (double) | [optional] + **enumQueryDouble** | **double?**| Query parameter enum test (double) | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: */* + - **Accept**: */* + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **TestInlineAdditionalProperties** +> void TestInlineAdditionalProperties (Object param) + +test inline additionalProperties + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class TestInlineAdditionalPropertiesExample + { + public void main() + { + var apiInstance = new FakeApi(); + var param = ; // Object | request body + + try + { + // test inline additionalProperties + apiInstance.TestInlineAdditionalProperties(param); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeApi.TestInlineAdditionalProperties: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **TestJsonFormData** +> void TestJsonFormData (string param, string param2) + +test json serialization of form data + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class TestJsonFormDataExample + { + public void main() + { + var apiInstance = new FakeApi(); + var param = param_example; // string | field1 + var param2 = param2_example; // string | field2 + + try + { + // test json serialization of form data + apiInstance.TestJsonFormData(param, param2); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeApi.TestJsonFormData: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **string**| field1 | + **param2** | **string**| field2 | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/FakeClassnameTags123Api.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/FakeClassnameTags123Api.md new file mode 100644 index 00000000000..5f1d0ca776b --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/FakeClassnameTags123Api.md @@ -0,0 +1,73 @@ +# IO.Swagger.Api.FakeClassnameTags123Api + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**TestClassname**](FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case + + + +# **TestClassname** +> ModelClient TestClassname (ModelClient body) + +To test class name in snake case + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class TestClassnameExample + { + public void main() + { + // Configure API key authorization: api_key_query + Configuration.Default.AddApiKey("api_key_query", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // Configuration.Default.AddApiKeyPrefix("api_key_query", "Bearer"); + + var apiInstance = new FakeClassnameTags123Api(); + var body = new ModelClient(); // ModelClient | client model + + try + { + // To test class name in snake case + ModelClient result = apiInstance.TestClassname(body); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeClassnameTags123Api.TestClassname: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**ModelClient**](ModelClient.md)| client model | + +### Return type + +[**ModelClient**](ModelClient.md) + +### Authorization + +[api_key_query](../README.md#api_key_query) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/FormatTest.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/FormatTest.md new file mode 100644 index 00000000000..1d366bd7cab --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/FormatTest.md @@ -0,0 +1,21 @@ +# IO.Swagger.Model.FormatTest +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Integer** | **int?** | | [optional] +**Int32** | **int?** | | [optional] +**Int64** | **long?** | | [optional] +**Number** | **decimal?** | | +**_Float** | **float?** | | [optional] +**_Double** | **double?** | | [optional] +**_String** | **string** | | [optional] +**_Byte** | **byte[]** | | +**Binary** | **byte[]** | | [optional] +**Date** | **DateTime?** | | +**DateTime** | **DateTime?** | | [optional] +**Uuid** | **Guid?** | | [optional] +**Password** | **string** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/HasOnlyReadOnly.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/HasOnlyReadOnly.md new file mode 100644 index 00000000000..cf0190498b9 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/HasOnlyReadOnly.md @@ -0,0 +1,10 @@ +# IO.Swagger.Model.HasOnlyReadOnly +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Bar** | **string** | | [optional] +**Foo** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/List.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/List.md new file mode 100644 index 00000000000..d7555b7e7ac --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/List.md @@ -0,0 +1,9 @@ +# IO.Swagger.Model.List +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123List** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/MapTest.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/MapTest.md new file mode 100644 index 00000000000..5c202aa336a --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/MapTest.md @@ -0,0 +1,10 @@ +# IO.Swagger.Model.MapTest +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**MapMapOfString** | **Dictionary<string, Dictionary<string, string>>** | | [optional] +**MapOfEnumString** | **Dictionary<string, string>** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/MixedPropertiesAndAdditionalPropertiesClass.md new file mode 100644 index 00000000000..e2c978f9ab1 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -0,0 +1,11 @@ +# IO.Swagger.Model.MixedPropertiesAndAdditionalPropertiesClass +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Uuid** | **Guid?** | | [optional] +**DateTime** | **DateTime?** | | [optional] +**Map** | [**Dictionary<string, Animal>**](Animal.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/Model200Response.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Model200Response.md new file mode 100644 index 00000000000..cfaddb67027 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Model200Response.md @@ -0,0 +1,10 @@ +# IO.Swagger.Model.Model200Response +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Name** | **int?** | | [optional] +**_Class** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/ModelClient.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ModelClient.md new file mode 100644 index 00000000000..9ecdc0e1141 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ModelClient.md @@ -0,0 +1,9 @@ +# IO.Swagger.Model.ModelClient +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_Client** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/ModelReturn.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ModelReturn.md new file mode 100644 index 00000000000..9895ccde2b0 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ModelReturn.md @@ -0,0 +1,9 @@ +# IO.Swagger.Model.ModelReturn +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_Return** | **int?** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/Name.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Name.md new file mode 100644 index 00000000000..678132c8e4e --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Name.md @@ -0,0 +1,12 @@ +# IO.Swagger.Model.Name +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_Name** | **int?** | | +**SnakeCase** | **int?** | | [optional] +**Property** | **string** | | [optional] +**_123Number** | **int?** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/NumberOnly.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/NumberOnly.md new file mode 100644 index 00000000000..a156dc4e2fc --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/NumberOnly.md @@ -0,0 +1,9 @@ +# IO.Swagger.Model.NumberOnly +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**JustNumber** | **decimal?** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/Order.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Order.md new file mode 100644 index 00000000000..32aeab388e5 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Order.md @@ -0,0 +1,14 @@ +# IO.Swagger.Model.Order +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **long?** | | [optional] +**PetId** | **long?** | | [optional] +**Quantity** | **int?** | | [optional] +**ShipDate** | **DateTime?** | | [optional] +**Status** | **string** | Order Status | [optional] +**Complete** | **bool?** | | [optional] [default to false] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterBoolean.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterBoolean.md new file mode 100644 index 00000000000..84845b35e54 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterBoolean.md @@ -0,0 +1,8 @@ +# IO.Swagger.Model.OuterBoolean +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterComposite.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterComposite.md new file mode 100644 index 00000000000..41fae66f136 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterComposite.md @@ -0,0 +1,11 @@ +# IO.Swagger.Model.OuterComposite +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**MyNumber** | [**OuterNumber**](OuterNumber.md) | | [optional] +**MyString** | [**OuterString**](OuterString.md) | | [optional] +**MyBoolean** | [**OuterBoolean**](OuterBoolean.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterEnum.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterEnum.md new file mode 100644 index 00000000000..55eb118a349 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterEnum.md @@ -0,0 +1,8 @@ +# IO.Swagger.Model.OuterEnum +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterNumber.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterNumber.md new file mode 100644 index 00000000000..7c88274d6ee --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterNumber.md @@ -0,0 +1,8 @@ +# IO.Swagger.Model.OuterNumber +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterString.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterString.md new file mode 100644 index 00000000000..524423a5dab --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/OuterString.md @@ -0,0 +1,8 @@ +# IO.Swagger.Model.OuterString +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/Pet.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Pet.md new file mode 100644 index 00000000000..e83933d1c60 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Pet.md @@ -0,0 +1,14 @@ +# IO.Swagger.Model.Pet +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **long?** | | [optional] +**Category** | [**Category**](Category.md) | | [optional] +**Name** | **string** | | +**PhotoUrls** | **List<string>** | | +**Tags** | [**List<Tag>**](Tag.md) | | [optional] +**Status** | **string** | pet status in the store | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/PetApi.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/PetApi.md new file mode 100644 index 00000000000..6b6450a12ab --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/PetApi.md @@ -0,0 +1,536 @@ +# IO.Swagger.Api.PetApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**AddPet**](PetApi.md#addpet) | **POST** /pet | Add a new pet to the store +[**DeletePet**](PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +[**FindPetsByStatus**](PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +[**FindPetsByTags**](PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +[**GetPetById**](PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +[**UpdatePet**](PetApi.md#updatepet) | **PUT** /pet | Update an existing pet +[**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image + + + +# **AddPet** +> void AddPet (Pet body) + +Add a new pet to the store + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class AddPetExample + { + public void main() + { + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var body = new Pet(); // Pet | Pet object that needs to be added to the store + + try + { + // Add a new pet to the store + apiInstance.AddPet(body); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.AddPet: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **DeletePet** +> void DeletePet (long? petId, string apiKey = null) + +Deletes a pet + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class DeletePetExample + { + public void main() + { + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var petId = 789; // long? | Pet id to delete + var apiKey = apiKey_example; // string | (optional) + + try + { + // Deletes a pet + apiInstance.DeletePet(petId, apiKey); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.DeletePet: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **long?**| Pet id to delete | + **apiKey** | **string**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **FindPetsByStatus** +> List FindPetsByStatus (List status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class FindPetsByStatusExample + { + public void main() + { + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var status = new List(); // List | Status values that need to be considered for filter + + try + { + // Finds Pets by status + List<Pet> result = apiInstance.FindPetsByStatus(status); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.FindPetsByStatus: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**List<string>**](string.md)| Status values that need to be considered for filter | + +### Return type + +[**List**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **FindPetsByTags** +> List FindPetsByTags (List tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class FindPetsByTagsExample + { + public void main() + { + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var tags = new List(); // List | Tags to filter by + + try + { + // Finds Pets by tags + List<Pet> result = apiInstance.FindPetsByTags(tags); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.FindPetsByTags: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**List<string>**](string.md)| Tags to filter by | + +### Return type + +[**List**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **GetPetById** +> Pet GetPetById (long? petId) + +Find pet by ID + +Returns a single pet + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class GetPetByIdExample + { + public void main() + { + // Configure API key authorization: api_key + Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); + + var apiInstance = new PetApi(); + var petId = 789; // long? | ID of pet to return + + try + { + // Find pet by ID + Pet result = apiInstance.GetPetById(petId); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.GetPetById: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **long?**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **UpdatePet** +> void UpdatePet (Pet body) + +Update an existing pet + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class UpdatePetExample + { + public void main() + { + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var body = new Pet(); // Pet | Pet object that needs to be added to the store + + try + { + // Update an existing pet + apiInstance.UpdatePet(body); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.UpdatePet: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **UpdatePetWithForm** +> void UpdatePetWithForm (long? petId, string name = null, string status = null) + +Updates a pet in the store with form data + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class UpdatePetWithFormExample + { + public void main() + { + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var petId = 789; // long? | ID of pet that needs to be updated + var name = name_example; // string | Updated name of the pet (optional) + var status = status_example; // string | Updated status of the pet (optional) + + try + { + // Updates a pet in the store with form data + apiInstance.UpdatePetWithForm(petId, name, status); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.UpdatePetWithForm: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **long?**| ID of pet that needs to be updated | + **name** | **string**| Updated name of the pet | [optional] + **status** | **string**| Updated status of the pet | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **UploadFile** +> ApiResponse UploadFile (long? petId, string additionalMetadata = null, System.IO.Stream file = null) + +uploads an image + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class UploadFileExample + { + public void main() + { + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var petId = 789; // long? | ID of pet to update + var additionalMetadata = additionalMetadata_example; // string | Additional data to pass to server (optional) + var file = new System.IO.Stream(); // System.IO.Stream | file to upload (optional) + + try + { + // uploads an image + ApiResponse result = apiInstance.UploadFile(petId, additionalMetadata, file); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.UploadFile: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **long?**| ID of pet to update | + **additionalMetadata** | **string**| Additional data to pass to server | [optional] + **file** | **System.IO.Stream**| file to upload | [optional] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/ReadOnlyFirst.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ReadOnlyFirst.md new file mode 100644 index 00000000000..b5f8d484869 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/ReadOnlyFirst.md @@ -0,0 +1,10 @@ +# IO.Swagger.Model.ReadOnlyFirst +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Bar** | **string** | | [optional] +**Baz** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/SpecialModelName.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/SpecialModelName.md new file mode 100644 index 00000000000..ee1bc316835 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/SpecialModelName.md @@ -0,0 +1,9 @@ +# IO.Swagger.Model.SpecialModelName +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**SpecialPropertyName** | **long?** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/StoreApi.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/StoreApi.md new file mode 100644 index 00000000000..113032c257b --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/StoreApi.md @@ -0,0 +1,256 @@ +# IO.Swagger.Api.StoreApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**DeleteOrder**](StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +[**GetInventory**](StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +[**GetOrderById**](StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID +[**PlaceOrder**](StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet + + + +# **DeleteOrder** +> void DeleteOrder (string orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class DeleteOrderExample + { + public void main() + { + var apiInstance = new StoreApi(); + var orderId = orderId_example; // string | ID of the order that needs to be deleted + + try + { + // Delete purchase order by ID + apiInstance.DeleteOrder(orderId); + } + catch (Exception e) + { + Debug.Print("Exception when calling StoreApi.DeleteOrder: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **string**| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **GetInventory** +> Dictionary GetInventory () + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class GetInventoryExample + { + public void main() + { + // Configure API key authorization: api_key + Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); + + var apiInstance = new StoreApi(); + + try + { + // Returns pet inventories by status + Dictionary<string, int?> result = apiInstance.GetInventory(); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling StoreApi.GetInventory: " + e.Message ); + } + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**Dictionary** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **GetOrderById** +> Order GetOrderById (long? orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class GetOrderByIdExample + { + public void main() + { + var apiInstance = new StoreApi(); + var orderId = 789; // long? | ID of pet that needs to be fetched + + try + { + // Find purchase order by ID + Order result = apiInstance.GetOrderById(orderId); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling StoreApi.GetOrderById: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **long?**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **PlaceOrder** +> Order PlaceOrder (Order body) + +Place an order for a pet + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class PlaceOrderExample + { + public void main() + { + var apiInstance = new StoreApi(); + var body = new Order(); // Order | order placed for purchasing the pet + + try + { + // Place an order for a pet + Order result = apiInstance.PlaceOrder(body); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling StoreApi.PlaceOrder: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/Tag.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Tag.md new file mode 100644 index 00000000000..64c5e6bdc72 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/Tag.md @@ -0,0 +1,10 @@ +# IO.Swagger.Model.Tag +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **long?** | | [optional] +**Name** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/User.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/User.md new file mode 100644 index 00000000000..fbea33c48b9 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/User.md @@ -0,0 +1,16 @@ +# IO.Swagger.Model.User +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **long?** | | [optional] +**Username** | **string** | | [optional] +**FirstName** | **string** | | [optional] +**LastName** | **string** | | [optional] +**Email** | **string** | | [optional] +**Password** | **string** | | [optional] +**Phone** | **string** | | [optional] +**UserStatus** | **int?** | User Status | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/docs/UserApi.md b/samples/client/petstore/csharp/SwaggerClientNet40/docs/UserApi.md new file mode 100644 index 00000000000..0ddde3f669c --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/docs/UserApi.md @@ -0,0 +1,498 @@ +# IO.Swagger.Api.UserApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**CreateUser**](UserApi.md#createuser) | **POST** /user | Create user +[**CreateUsersWithArrayInput**](UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +[**CreateUsersWithListInput**](UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +[**DeleteUser**](UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +[**GetUserByName**](UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +[**LoginUser**](UserApi.md#loginuser) | **GET** /user/login | Logs user into the system +[**LogoutUser**](UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +[**UpdateUser**](UserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + + +# **CreateUser** +> void CreateUser (User body) + +Create user + +This can only be done by the logged in user. + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class CreateUserExample + { + public void main() + { + var apiInstance = new UserApi(); + var body = new User(); // User | Created user object + + try + { + // Create user + apiInstance.CreateUser(body); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.CreateUser: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **CreateUsersWithArrayInput** +> void CreateUsersWithArrayInput (List body) + +Creates list of users with given input array + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class CreateUsersWithArrayInputExample + { + public void main() + { + var apiInstance = new UserApi(); + var body = new List(); // List | List of user object + + try + { + // Creates list of users with given input array + apiInstance.CreateUsersWithArrayInput(body); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.CreateUsersWithArrayInput: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **CreateUsersWithListInput** +> void CreateUsersWithListInput (List body) + +Creates list of users with given input array + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class CreateUsersWithListInputExample + { + public void main() + { + var apiInstance = new UserApi(); + var body = new List(); // List | List of user object + + try + { + // Creates list of users with given input array + apiInstance.CreateUsersWithListInput(body); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.CreateUsersWithListInput: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **DeleteUser** +> void DeleteUser (string username) + +Delete user + +This can only be done by the logged in user. + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class DeleteUserExample + { + public void main() + { + var apiInstance = new UserApi(); + var username = username_example; // string | The name that needs to be deleted + + try + { + // Delete user + apiInstance.DeleteUser(username); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.DeleteUser: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **GetUserByName** +> User GetUserByName (string username) + +Get user by user name + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class GetUserByNameExample + { + public void main() + { + var apiInstance = new UserApi(); + var username = username_example; // string | The name that needs to be fetched. Use user1 for testing. + + try + { + // Get user by user name + User result = apiInstance.GetUserByName(username); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.GetUserByName: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **LoginUser** +> string LoginUser (string username, string password) + +Logs user into the system + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class LoginUserExample + { + public void main() + { + var apiInstance = new UserApi(); + var username = username_example; // string | The user name for login + var password = password_example; // string | The password for login in clear text + + try + { + // Logs user into the system + string result = apiInstance.LoginUser(username, password); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.LoginUser: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The user name for login | + **password** | **string**| The password for login in clear text | + +### Return type + +**string** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **LogoutUser** +> void LogoutUser () + +Logs out current logged in user session + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class LogoutUserExample + { + public void main() + { + var apiInstance = new UserApi(); + + try + { + // Logs out current logged in user session + apiInstance.LogoutUser(); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.LogoutUser: " + e.Message ); + } + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **UpdateUser** +> void UpdateUser (string username, User body) + +Updated user + +This can only be done by the logged in user. + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class UpdateUserExample + { + public void main() + { + var apiInstance = new UserApi(); + var username = username_example; // string | name that need to be deleted + var body = new User(); // User | Updated user object + + try + { + // Updated user + apiInstance.UpdateUser(username, body); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.UpdateUser: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/git_push.sh b/samples/client/petstore/csharp/SwaggerClientNet40/git_push.sh new file mode 100644 index 00000000000..792320114fb --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/mono_nunit_test.sh b/samples/client/petstore/csharp/SwaggerClientNet40/mono_nunit_test.sh new file mode 100644 index 00000000000..1276032d81b --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/mono_nunit_test.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# +# Generated by: https://github.com/swagger-api/swagger-codegen.git +# + +wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe +mozroots --import --sync + +echo "[INFO] remove bin/Debug/SwaggerClientTest.dll" +rm src/IO.Swagger.Test/bin/Debug/IO.Swagger.Test.dll 2> /dev/null + +echo "[INFO] install NUnit runners via NuGet" +wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe +mozroots --import --sync +mono nuget.exe install src/IO.Swagger.Test/packages.config -o packages + +echo "[INFO] Install NUnit runners via NuGet" +mono nuget.exe install NUnit.Runners -Version 2.6.4 -OutputDirectory packages + +echo "[INFO] Build the solution and run the unit test" +xbuild IO.Swagger.sln && \ + mono ./packages/NUnit.Runners.2.6.4/tools/nunit-console.exe src/IO.Swagger.Test/bin/Debug/IO.Swagger.Test.dll diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/nuget.exe b/samples/client/petstore/csharp/SwaggerClientNet40/nuget.exe new file mode 100644 index 00000000000..ec1309c7aa6 Binary files /dev/null and b/samples/client/petstore/csharp/SwaggerClientNet40/nuget.exe differ diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/AnotherFakeApiTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/AnotherFakeApiTests.cs new file mode 100644 index 00000000000..070e217a0f5 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/AnotherFakeApiTests.cs @@ -0,0 +1,81 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.IO; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection; +using RestSharp; +using NUnit.Framework; + +using IO.Swagger.Client; +using IO.Swagger.Api; +using IO.Swagger.Model; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing AnotherFakeApi + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the API endpoint. + /// + [TestFixture] + public class AnotherFakeApiTests + { + private AnotherFakeApi instance; + + /// + /// Setup before each unit test + /// + [SetUp] + public void Init() + { + instance = new AnotherFakeApi(); + } + + /// + /// Clean up after each unit test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of AnotherFakeApi + /// + [Test] + public void InstanceTest() + { + // TODO uncomment below to test 'IsInstanceOfType' AnotherFakeApi + //Assert.IsInstanceOfType(typeof(AnotherFakeApi), instance, "instance is a AnotherFakeApi"); + } + + + /// + /// Test TestSpecialTags + /// + [Test] + public void TestSpecialTagsTest() + { + // TODO uncomment below to test the method and replace null with proper value + //ModelClient body = null; + //var response = instance.TestSpecialTags(body); + //Assert.IsInstanceOf (response, "response is ModelClient"); + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/FakeApiTests.cs new file mode 100644 index 00000000000..fc21272e659 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/FakeApiTests.cs @@ -0,0 +1,198 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.IO; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection; +using RestSharp; +using NUnit.Framework; + +using IO.Swagger.Client; +using IO.Swagger.Api; +using IO.Swagger.Model; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing FakeApi + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the API endpoint. + /// + [TestFixture] + public class FakeApiTests + { + private FakeApi instance; + + /// + /// Setup before each unit test + /// + [SetUp] + public void Init() + { + instance = new FakeApi(); + } + + /// + /// Clean up after each unit test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of FakeApi + /// + [Test] + public void InstanceTest() + { + // TODO uncomment below to test 'IsInstanceOfType' FakeApi + //Assert.IsInstanceOfType(typeof(FakeApi), instance, "instance is a FakeApi"); + } + + + /// + /// Test FakeOuterBooleanSerialize + /// + [Test] + public void FakeOuterBooleanSerializeTest() + { + // TODO uncomment below to test the method and replace null with proper value + //OuterBoolean body = null; + //var response = instance.FakeOuterBooleanSerialize(body); + //Assert.IsInstanceOf (response, "response is OuterBoolean"); + } + + /// + /// Test FakeOuterCompositeSerialize + /// + [Test] + public void FakeOuterCompositeSerializeTest() + { + // TODO uncomment below to test the method and replace null with proper value + //OuterComposite body = null; + //var response = instance.FakeOuterCompositeSerialize(body); + //Assert.IsInstanceOf (response, "response is OuterComposite"); + } + + /// + /// Test FakeOuterNumberSerialize + /// + [Test] + public void FakeOuterNumberSerializeTest() + { + // TODO uncomment below to test the method and replace null with proper value + //OuterNumber body = null; + //var response = instance.FakeOuterNumberSerialize(body); + //Assert.IsInstanceOf (response, "response is OuterNumber"); + } + + /// + /// Test FakeOuterStringSerialize + /// + [Test] + public void FakeOuterStringSerializeTest() + { + // TODO uncomment below to test the method and replace null with proper value + //OuterString body = null; + //var response = instance.FakeOuterStringSerialize(body); + //Assert.IsInstanceOf (response, "response is OuterString"); + } + + /// + /// Test TestClientModel + /// + [Test] + public void TestClientModelTest() + { + // TODO uncomment below to test the method and replace null with proper value + //ModelClient body = null; + //var response = instance.TestClientModel(body); + //Assert.IsInstanceOf (response, "response is ModelClient"); + } + + /// + /// Test TestEndpointParameters + /// + [Test] + public void TestEndpointParametersTest() + { + // TODO uncomment below to test the method and replace null with proper value + //decimal? number = null; + //double? _double = null; + //string patternWithoutDelimiter = null; + //byte[] _byte = null; + //int? integer = null; + //int? int32 = null; + //long? int64 = null; + //float? _float = null; + //string _string = null; + //byte[] binary = null; + //DateTime? date = null; + //DateTime? dateTime = null; + //string password = null; + //string callback = null; + //instance.TestEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, _string, binary, date, dateTime, password, callback); + + } + + /// + /// Test TestEnumParameters + /// + [Test] + public void TestEnumParametersTest() + { + // TODO uncomment below to test the method and replace null with proper value + //List enumFormStringArray = null; + //string enumFormString = null; + //List enumHeaderStringArray = null; + //string enumHeaderString = null; + //List enumQueryStringArray = null; + //string enumQueryString = null; + //int? enumQueryInteger = null; + //double? enumQueryDouble = null; + //instance.TestEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble); + + } + + /// + /// Test TestInlineAdditionalProperties + /// + [Test] + public void TestInlineAdditionalPropertiesTest() + { + // TODO uncomment below to test the method and replace null with proper value + //Object param = null; + //instance.TestInlineAdditionalProperties(param); + + } + + /// + /// Test TestJsonFormData + /// + [Test] + public void TestJsonFormDataTest() + { + // TODO uncomment below to test the method and replace null with proper value + //string param = null; + //string param2 = null; + //instance.TestJsonFormData(param, param2); + + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/FakeClassnameTags123ApiTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/FakeClassnameTags123ApiTests.cs new file mode 100644 index 00000000000..36a5acb38a9 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/FakeClassnameTags123ApiTests.cs @@ -0,0 +1,81 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.IO; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection; +using RestSharp; +using NUnit.Framework; + +using IO.Swagger.Client; +using IO.Swagger.Api; +using IO.Swagger.Model; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing FakeClassnameTags123Api + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the API endpoint. + /// + [TestFixture] + public class FakeClassnameTags123ApiTests + { + private FakeClassnameTags123Api instance; + + /// + /// Setup before each unit test + /// + [SetUp] + public void Init() + { + instance = new FakeClassnameTags123Api(); + } + + /// + /// Clean up after each unit test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of FakeClassnameTags123Api + /// + [Test] + public void InstanceTest() + { + // TODO uncomment below to test 'IsInstanceOfType' FakeClassnameTags123Api + //Assert.IsInstanceOfType(typeof(FakeClassnameTags123Api), instance, "instance is a FakeClassnameTags123Api"); + } + + + /// + /// Test TestClassname + /// + [Test] + public void TestClassnameTest() + { + // TODO uncomment below to test the method and replace null with proper value + //ModelClient body = null; + //var response = instance.TestClassname(body); + //Assert.IsInstanceOf (response, "response is ModelClient"); + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/PetApiTests.cs new file mode 100644 index 00000000000..34c1fb71f44 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/PetApiTests.cs @@ -0,0 +1,170 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.IO; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection; +using RestSharp; +using NUnit.Framework; + +using IO.Swagger.Client; +using IO.Swagger.Api; +using IO.Swagger.Model; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing PetApi + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the API endpoint. + /// + [TestFixture] + public class PetApiTests + { + private PetApi instance; + + /// + /// Setup before each unit test + /// + [SetUp] + public void Init() + { + instance = new PetApi(); + } + + /// + /// Clean up after each unit test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of PetApi + /// + [Test] + public void InstanceTest() + { + // TODO uncomment below to test 'IsInstanceOfType' PetApi + //Assert.IsInstanceOfType(typeof(PetApi), instance, "instance is a PetApi"); + } + + + /// + /// Test AddPet + /// + [Test] + public void AddPetTest() + { + // TODO uncomment below to test the method and replace null with proper value + //Pet body = null; + //instance.AddPet(body); + + } + + /// + /// Test DeletePet + /// + [Test] + public void DeletePetTest() + { + // TODO uncomment below to test the method and replace null with proper value + //long? petId = null; + //string apiKey = null; + //instance.DeletePet(petId, apiKey); + + } + + /// + /// Test FindPetsByStatus + /// + [Test] + public void FindPetsByStatusTest() + { + // TODO uncomment below to test the method and replace null with proper value + //List status = null; + //var response = instance.FindPetsByStatus(status); + //Assert.IsInstanceOf> (response, "response is List"); + } + + /// + /// Test FindPetsByTags + /// + [Test] + public void FindPetsByTagsTest() + { + // TODO uncomment below to test the method and replace null with proper value + //List tags = null; + //var response = instance.FindPetsByTags(tags); + //Assert.IsInstanceOf> (response, "response is List"); + } + + /// + /// Test GetPetById + /// + [Test] + public void GetPetByIdTest() + { + // TODO uncomment below to test the method and replace null with proper value + //long? petId = null; + //var response = instance.GetPetById(petId); + //Assert.IsInstanceOf (response, "response is Pet"); + } + + /// + /// Test UpdatePet + /// + [Test] + public void UpdatePetTest() + { + // TODO uncomment below to test the method and replace null with proper value + //Pet body = null; + //instance.UpdatePet(body); + + } + + /// + /// Test UpdatePetWithForm + /// + [Test] + public void UpdatePetWithFormTest() + { + // TODO uncomment below to test the method and replace null with proper value + //long? petId = null; + //string name = null; + //string status = null; + //instance.UpdatePetWithForm(petId, name, status); + + } + + /// + /// Test UploadFile + /// + [Test] + public void UploadFileTest() + { + // TODO uncomment below to test the method and replace null with proper value + //long? petId = null; + //string additionalMetadata = null; + //System.IO.Stream file = null; + //var response = instance.UploadFile(petId, additionalMetadata, file); + //Assert.IsInstanceOf (response, "response is ApiResponse"); + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/StoreApiTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/StoreApiTests.cs new file mode 100644 index 00000000000..005bf9f0315 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/StoreApiTests.cs @@ -0,0 +1,116 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.IO; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection; +using RestSharp; +using NUnit.Framework; + +using IO.Swagger.Client; +using IO.Swagger.Api; +using IO.Swagger.Model; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing StoreApi + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the API endpoint. + /// + [TestFixture] + public class StoreApiTests + { + private StoreApi instance; + + /// + /// Setup before each unit test + /// + [SetUp] + public void Init() + { + instance = new StoreApi(); + } + + /// + /// Clean up after each unit test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of StoreApi + /// + [Test] + public void InstanceTest() + { + // TODO uncomment below to test 'IsInstanceOfType' StoreApi + //Assert.IsInstanceOfType(typeof(StoreApi), instance, "instance is a StoreApi"); + } + + + /// + /// Test DeleteOrder + /// + [Test] + public void DeleteOrderTest() + { + // TODO uncomment below to test the method and replace null with proper value + //string orderId = null; + //instance.DeleteOrder(orderId); + + } + + /// + /// Test GetInventory + /// + [Test] + public void GetInventoryTest() + { + // TODO uncomment below to test the method and replace null with proper value + //var response = instance.GetInventory(); + //Assert.IsInstanceOf> (response, "response is Dictionary"); + } + + /// + /// Test GetOrderById + /// + [Test] + public void GetOrderByIdTest() + { + // TODO uncomment below to test the method and replace null with proper value + //long? orderId = null; + //var response = instance.GetOrderById(orderId); + //Assert.IsInstanceOf (response, "response is Order"); + } + + /// + /// Test PlaceOrder + /// + [Test] + public void PlaceOrderTest() + { + // TODO uncomment below to test the method and replace null with proper value + //Order body = null; + //var response = instance.PlaceOrder(body); + //Assert.IsInstanceOf (response, "response is Order"); + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/UserApiTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/UserApiTests.cs new file mode 100644 index 00000000000..e119bb85c22 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Api/UserApiTests.cs @@ -0,0 +1,166 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.IO; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection; +using RestSharp; +using NUnit.Framework; + +using IO.Swagger.Client; +using IO.Swagger.Api; +using IO.Swagger.Model; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing UserApi + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the API endpoint. + /// + [TestFixture] + public class UserApiTests + { + private UserApi instance; + + /// + /// Setup before each unit test + /// + [SetUp] + public void Init() + { + instance = new UserApi(); + } + + /// + /// Clean up after each unit test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of UserApi + /// + [Test] + public void InstanceTest() + { + // TODO uncomment below to test 'IsInstanceOfType' UserApi + //Assert.IsInstanceOfType(typeof(UserApi), instance, "instance is a UserApi"); + } + + + /// + /// Test CreateUser + /// + [Test] + public void CreateUserTest() + { + // TODO uncomment below to test the method and replace null with proper value + //User body = null; + //instance.CreateUser(body); + + } + + /// + /// Test CreateUsersWithArrayInput + /// + [Test] + public void CreateUsersWithArrayInputTest() + { + // TODO uncomment below to test the method and replace null with proper value + //List body = null; + //instance.CreateUsersWithArrayInput(body); + + } + + /// + /// Test CreateUsersWithListInput + /// + [Test] + public void CreateUsersWithListInputTest() + { + // TODO uncomment below to test the method and replace null with proper value + //List body = null; + //instance.CreateUsersWithListInput(body); + + } + + /// + /// Test DeleteUser + /// + [Test] + public void DeleteUserTest() + { + // TODO uncomment below to test the method and replace null with proper value + //string username = null; + //instance.DeleteUser(username); + + } + + /// + /// Test GetUserByName + /// + [Test] + public void GetUserByNameTest() + { + // TODO uncomment below to test the method and replace null with proper value + //string username = null; + //var response = instance.GetUserByName(username); + //Assert.IsInstanceOf (response, "response is User"); + } + + /// + /// Test LoginUser + /// + [Test] + public void LoginUserTest() + { + // TODO uncomment below to test the method and replace null with proper value + //string username = null; + //string password = null; + //var response = instance.LoginUser(username, password); + //Assert.IsInstanceOf (response, "response is string"); + } + + /// + /// Test LogoutUser + /// + [Test] + public void LogoutUserTest() + { + // TODO uncomment below to test the method and replace null with proper value + //instance.LogoutUser(); + + } + + /// + /// Test UpdateUser + /// + [Test] + public void UpdateUserTest() + { + // TODO uncomment below to test the method and replace null with proper value + //string username = null; + //User body = null; + //instance.UpdateUser(username, body); + + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/IO.Swagger.Test.csproj b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/IO.Swagger.Test.csproj new file mode 100644 index 00000000000..b1aded9e1a9 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/IO.Swagger.Test.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {19F1DEBC-DE5E-4517-8062-F000CD499087} + Library + Properties + IO.Swagger.Test + IO.Swagger.Test + v4.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + $(SolutionDir)\packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll + ..\..\vendor\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll + + + $(SolutionDir)\packages\RestSharp.105.1.0\lib\net40\RestSharp.dll + ..\packages\RestSharp.105.1.0\lib\net40\RestSharp.dll + ..\..\packages\RestSharp.105.1.0\lib\net40\RestSharp.dll + ..\..\vendor\RestSharp.105.1.0\lib\net40\RestSharp.dll + + + $(SolutionDir)\packages\NUnit.2.6.4\lib\nunit.framework.dll + ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + ..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll + ..\..\vendor\NUnit.2.6.4\lib\nunit.framework.dll + + + + + + + + + + + + {321C8C3F-0156-40C1-AE42-D59761FB9B6C} + IO.Swagger + + + + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/AdditionalPropertiesClassTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/AdditionalPropertiesClassTests.cs new file mode 100644 index 00000000000..60b6cee9f53 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/AdditionalPropertiesClassTests.cs @@ -0,0 +1,88 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing AdditionalPropertiesClass + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class AdditionalPropertiesClassTests + { + // TODO uncomment below to declare an instance variable for AdditionalPropertiesClass + //private AdditionalPropertiesClass instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of AdditionalPropertiesClass + //instance = new AdditionalPropertiesClass(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of AdditionalPropertiesClass + /// + [Test] + public void AdditionalPropertiesClassInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" AdditionalPropertiesClass + //Assert.IsInstanceOfType (instance, "variable 'instance' is a AdditionalPropertiesClass"); + } + + + /// + /// Test the property 'MapProperty' + /// + [Test] + public void MapPropertyTest() + { + // TODO unit test for the property 'MapProperty' + } + /// + /// Test the property 'MapOfMapProperty' + /// + [Test] + public void MapOfMapPropertyTest() + { + // TODO unit test for the property 'MapOfMapProperty' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/AnimalFarmTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/AnimalFarmTests.cs new file mode 100644 index 00000000000..6fa7b87485a --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/AnimalFarmTests.cs @@ -0,0 +1,72 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing AnimalFarm + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class AnimalFarmTests + { + // TODO uncomment below to declare an instance variable for AnimalFarm + //private AnimalFarm instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of AnimalFarm + //instance = new AnimalFarm(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of AnimalFarm + /// + [Test] + public void AnimalFarmInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" AnimalFarm + //Assert.IsInstanceOfType (instance, "variable 'instance' is a AnimalFarm"); + } + + + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/AnimalTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/AnimalTests.cs new file mode 100644 index 00000000000..ba3786457af --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/AnimalTests.cs @@ -0,0 +1,106 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing Animal + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class AnimalTests + { + // TODO uncomment below to declare an instance variable for Animal + //private Animal instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of Animal + //instance = new Animal(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of Animal + /// + [Test] + public void AnimalInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" Animal + //Assert.IsInstanceOfType (instance, "variable 'instance' is a Animal"); + } + + /// + /// Test deserialize a Dog from type Animal + /// + [Test] + public void DogDeserializeFromAnimalTest() + { + // TODO uncomment below to test deserialize a Dog from type Animal + //Assert.IsInstanceOf(JsonConvert.DeserializeObject(new Dog().ToJson())); + } + /// + /// Test deserialize a Cat from type Animal + /// + [Test] + public void CatDeserializeFromAnimalTest() + { + // TODO uncomment below to test deserialize a Cat from type Animal + //Assert.IsInstanceOf(JsonConvert.DeserializeObject(new Cat().ToJson())); + } + + /// + /// Test the property 'ClassName' + /// + [Test] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + /// + /// Test the property 'Color' + /// + [Test] + public void ColorTest() + { + // TODO unit test for the property 'Color' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ApiResponseTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ApiResponseTests.cs new file mode 100644 index 00000000000..8a5649b4676 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ApiResponseTests.cs @@ -0,0 +1,96 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing ApiResponse + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class ApiResponseTests + { + // TODO uncomment below to declare an instance variable for ApiResponse + //private ApiResponse instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of ApiResponse + //instance = new ApiResponse(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of ApiResponse + /// + [Test] + public void ApiResponseInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" ApiResponse + //Assert.IsInstanceOfType (instance, "variable 'instance' is a ApiResponse"); + } + + + /// + /// Test the property 'Code' + /// + [Test] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + /// + /// Test the property 'Type' + /// + [Test] + public void TypeTest() + { + // TODO unit test for the property 'Type' + } + /// + /// Test the property 'Message' + /// + [Test] + public void MessageTest() + { + // TODO unit test for the property 'Message' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ArrayOfArrayOfNumberOnlyTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ArrayOfArrayOfNumberOnlyTests.cs new file mode 100644 index 00000000000..3f8f100a7f5 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ArrayOfArrayOfNumberOnlyTests.cs @@ -0,0 +1,80 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing ArrayOfArrayOfNumberOnly + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class ArrayOfArrayOfNumberOnlyTests + { + // TODO uncomment below to declare an instance variable for ArrayOfArrayOfNumberOnly + //private ArrayOfArrayOfNumberOnly instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of ArrayOfArrayOfNumberOnly + //instance = new ArrayOfArrayOfNumberOnly(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of ArrayOfArrayOfNumberOnly + /// + [Test] + public void ArrayOfArrayOfNumberOnlyInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" ArrayOfArrayOfNumberOnly + //Assert.IsInstanceOfType (instance, "variable 'instance' is a ArrayOfArrayOfNumberOnly"); + } + + + /// + /// Test the property 'ArrayArrayNumber' + /// + [Test] + public void ArrayArrayNumberTest() + { + // TODO unit test for the property 'ArrayArrayNumber' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ArrayOfNumberOnlyTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ArrayOfNumberOnlyTests.cs new file mode 100644 index 00000000000..28a540e676b --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ArrayOfNumberOnlyTests.cs @@ -0,0 +1,80 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing ArrayOfNumberOnly + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class ArrayOfNumberOnlyTests + { + // TODO uncomment below to declare an instance variable for ArrayOfNumberOnly + //private ArrayOfNumberOnly instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of ArrayOfNumberOnly + //instance = new ArrayOfNumberOnly(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of ArrayOfNumberOnly + /// + [Test] + public void ArrayOfNumberOnlyInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" ArrayOfNumberOnly + //Assert.IsInstanceOfType (instance, "variable 'instance' is a ArrayOfNumberOnly"); + } + + + /// + /// Test the property 'ArrayNumber' + /// + [Test] + public void ArrayNumberTest() + { + // TODO unit test for the property 'ArrayNumber' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ArrayTestTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ArrayTestTests.cs new file mode 100644 index 00000000000..09864b81ac2 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ArrayTestTests.cs @@ -0,0 +1,96 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing ArrayTest + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class ArrayTestTests + { + // TODO uncomment below to declare an instance variable for ArrayTest + //private ArrayTest instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of ArrayTest + //instance = new ArrayTest(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of ArrayTest + /// + [Test] + public void ArrayTestInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" ArrayTest + //Assert.IsInstanceOfType (instance, "variable 'instance' is a ArrayTest"); + } + + + /// + /// Test the property 'ArrayOfString' + /// + [Test] + public void ArrayOfStringTest() + { + // TODO unit test for the property 'ArrayOfString' + } + /// + /// Test the property 'ArrayArrayOfInteger' + /// + [Test] + public void ArrayArrayOfIntegerTest() + { + // TODO unit test for the property 'ArrayArrayOfInteger' + } + /// + /// Test the property 'ArrayArrayOfModel' + /// + [Test] + public void ArrayArrayOfModelTest() + { + // TODO unit test for the property 'ArrayArrayOfModel' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/CapitalizationTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/CapitalizationTests.cs new file mode 100644 index 00000000000..fe7637ded78 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/CapitalizationTests.cs @@ -0,0 +1,120 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing Capitalization + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class CapitalizationTests + { + // TODO uncomment below to declare an instance variable for Capitalization + //private Capitalization instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of Capitalization + //instance = new Capitalization(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of Capitalization + /// + [Test] + public void CapitalizationInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" Capitalization + //Assert.IsInstanceOfType (instance, "variable 'instance' is a Capitalization"); + } + + + /// + /// Test the property 'SmallCamel' + /// + [Test] + public void SmallCamelTest() + { + // TODO unit test for the property 'SmallCamel' + } + /// + /// Test the property 'CapitalCamel' + /// + [Test] + public void CapitalCamelTest() + { + // TODO unit test for the property 'CapitalCamel' + } + /// + /// Test the property 'SmallSnake' + /// + [Test] + public void SmallSnakeTest() + { + // TODO unit test for the property 'SmallSnake' + } + /// + /// Test the property 'CapitalSnake' + /// + [Test] + public void CapitalSnakeTest() + { + // TODO unit test for the property 'CapitalSnake' + } + /// + /// Test the property 'SCAETHFlowPoints' + /// + [Test] + public void SCAETHFlowPointsTest() + { + // TODO unit test for the property 'SCAETHFlowPoints' + } + /// + /// Test the property 'ATT_NAME' + /// + [Test] + public void ATT_NAMETest() + { + // TODO unit test for the property 'ATT_NAME' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/CatTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/CatTests.cs new file mode 100644 index 00000000000..d79719efdbc --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/CatTests.cs @@ -0,0 +1,80 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing Cat + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class CatTests + { + // TODO uncomment below to declare an instance variable for Cat + //private Cat instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of Cat + //instance = new Cat(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of Cat + /// + [Test] + public void CatInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" Cat + //Assert.IsInstanceOfType (instance, "variable 'instance' is a Cat"); + } + + + /// + /// Test the property 'Declawed' + /// + [Test] + public void DeclawedTest() + { + // TODO unit test for the property 'Declawed' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/CategoryTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/CategoryTests.cs new file mode 100644 index 00000000000..13497ed1fd6 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/CategoryTests.cs @@ -0,0 +1,88 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing Category + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class CategoryTests + { + // TODO uncomment below to declare an instance variable for Category + //private Category instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of Category + //instance = new Category(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of Category + /// + [Test] + public void CategoryInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" Category + //Assert.IsInstanceOfType (instance, "variable 'instance' is a Category"); + } + + + /// + /// Test the property 'Id' + /// + [Test] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + /// + /// Test the property 'Name' + /// + [Test] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ClassModelTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ClassModelTests.cs new file mode 100644 index 00000000000..2589ea4ecea --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ClassModelTests.cs @@ -0,0 +1,80 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing ClassModel + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class ClassModelTests + { + // TODO uncomment below to declare an instance variable for ClassModel + //private ClassModel instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of ClassModel + //instance = new ClassModel(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of ClassModel + /// + [Test] + public void ClassModelInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" ClassModel + //Assert.IsInstanceOfType (instance, "variable 'instance' is a ClassModel"); + } + + + /// + /// Test the property '_Class' + /// + [Test] + public void _ClassTest() + { + // TODO unit test for the property '_Class' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/DogTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/DogTests.cs new file mode 100644 index 00000000000..3f47e42e8c2 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/DogTests.cs @@ -0,0 +1,80 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing Dog + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class DogTests + { + // TODO uncomment below to declare an instance variable for Dog + //private Dog instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of Dog + //instance = new Dog(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of Dog + /// + [Test] + public void DogInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" Dog + //Assert.IsInstanceOfType (instance, "variable 'instance' is a Dog"); + } + + + /// + /// Test the property 'Breed' + /// + [Test] + public void BreedTest() + { + // TODO unit test for the property 'Breed' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/EnumArraysTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/EnumArraysTests.cs new file mode 100644 index 00000000000..f84821d33eb --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/EnumArraysTests.cs @@ -0,0 +1,88 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing EnumArrays + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class EnumArraysTests + { + // TODO uncomment below to declare an instance variable for EnumArrays + //private EnumArrays instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of EnumArrays + //instance = new EnumArrays(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of EnumArrays + /// + [Test] + public void EnumArraysInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" EnumArrays + //Assert.IsInstanceOfType (instance, "variable 'instance' is a EnumArrays"); + } + + + /// + /// Test the property 'JustSymbol' + /// + [Test] + public void JustSymbolTest() + { + // TODO unit test for the property 'JustSymbol' + } + /// + /// Test the property 'ArrayEnum' + /// + [Test] + public void ArrayEnumTest() + { + // TODO unit test for the property 'ArrayEnum' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/EnumClassTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/EnumClassTests.cs new file mode 100644 index 00000000000..b37648d2200 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/EnumClassTests.cs @@ -0,0 +1,72 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing EnumClass + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class EnumClassTests + { + // TODO uncomment below to declare an instance variable for EnumClass + //private EnumClass instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of EnumClass + //instance = new EnumClass(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of EnumClass + /// + [Test] + public void EnumClassInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" EnumClass + //Assert.IsInstanceOfType (instance, "variable 'instance' is a EnumClass"); + } + + + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/EnumTestTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/EnumTestTests.cs new file mode 100644 index 00000000000..66664cbd9af --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/EnumTestTests.cs @@ -0,0 +1,104 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing EnumTest + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class EnumTestTests + { + // TODO uncomment below to declare an instance variable for EnumTest + //private EnumTest instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of EnumTest + //instance = new EnumTest(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of EnumTest + /// + [Test] + public void EnumTestInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" EnumTest + //Assert.IsInstanceOfType (instance, "variable 'instance' is a EnumTest"); + } + + + /// + /// Test the property 'EnumString' + /// + [Test] + public void EnumStringTest() + { + // TODO unit test for the property 'EnumString' + } + /// + /// Test the property 'EnumInteger' + /// + [Test] + public void EnumIntegerTest() + { + // TODO unit test for the property 'EnumInteger' + } + /// + /// Test the property 'EnumNumber' + /// + [Test] + public void EnumNumberTest() + { + // TODO unit test for the property 'EnumNumber' + } + /// + /// Test the property 'OuterEnum' + /// + [Test] + public void OuterEnumTest() + { + // TODO unit test for the property 'OuterEnum' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/FormatTestTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/FormatTestTests.cs new file mode 100644 index 00000000000..3ae16b2fc6b --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/FormatTestTests.cs @@ -0,0 +1,176 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing FormatTest + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class FormatTestTests + { + // TODO uncomment below to declare an instance variable for FormatTest + //private FormatTest instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of FormatTest + //instance = new FormatTest(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of FormatTest + /// + [Test] + public void FormatTestInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" FormatTest + //Assert.IsInstanceOfType (instance, "variable 'instance' is a FormatTest"); + } + + + /// + /// Test the property 'Integer' + /// + [Test] + public void IntegerTest() + { + // TODO unit test for the property 'Integer' + } + /// + /// Test the property 'Int32' + /// + [Test] + public void Int32Test() + { + // TODO unit test for the property 'Int32' + } + /// + /// Test the property 'Int64' + /// + [Test] + public void Int64Test() + { + // TODO unit test for the property 'Int64' + } + /// + /// Test the property 'Number' + /// + [Test] + public void NumberTest() + { + // TODO unit test for the property 'Number' + } + /// + /// Test the property '_Float' + /// + [Test] + public void _FloatTest() + { + // TODO unit test for the property '_Float' + } + /// + /// Test the property '_Double' + /// + [Test] + public void _DoubleTest() + { + // TODO unit test for the property '_Double' + } + /// + /// Test the property '_String' + /// + [Test] + public void _StringTest() + { + // TODO unit test for the property '_String' + } + /// + /// Test the property '_Byte' + /// + [Test] + public void _ByteTest() + { + // TODO unit test for the property '_Byte' + } + /// + /// Test the property 'Binary' + /// + [Test] + public void BinaryTest() + { + // TODO unit test for the property 'Binary' + } + /// + /// Test the property 'Date' + /// + [Test] + public void DateTest() + { + // TODO unit test for the property 'Date' + } + /// + /// Test the property 'DateTime' + /// + [Test] + public void DateTimeTest() + { + // TODO unit test for the property 'DateTime' + } + /// + /// Test the property 'Uuid' + /// + [Test] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + /// + /// Test the property 'Password' + /// + [Test] + public void PasswordTest() + { + // TODO unit test for the property 'Password' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/HasOnlyReadOnlyTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/HasOnlyReadOnlyTests.cs new file mode 100644 index 00000000000..cafd23d90b2 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/HasOnlyReadOnlyTests.cs @@ -0,0 +1,88 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing HasOnlyReadOnly + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class HasOnlyReadOnlyTests + { + // TODO uncomment below to declare an instance variable for HasOnlyReadOnly + //private HasOnlyReadOnly instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of HasOnlyReadOnly + //instance = new HasOnlyReadOnly(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of HasOnlyReadOnly + /// + [Test] + public void HasOnlyReadOnlyInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" HasOnlyReadOnly + //Assert.IsInstanceOfType (instance, "variable 'instance' is a HasOnlyReadOnly"); + } + + + /// + /// Test the property 'Bar' + /// + [Test] + public void BarTest() + { + // TODO unit test for the property 'Bar' + } + /// + /// Test the property 'Foo' + /// + [Test] + public void FooTest() + { + // TODO unit test for the property 'Foo' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ListTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ListTests.cs new file mode 100644 index 00000000000..6ca026a83e0 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ListTests.cs @@ -0,0 +1,80 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing List + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class ListTests + { + // TODO uncomment below to declare an instance variable for List + //private List instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of List + //instance = new List(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of List + /// + [Test] + public void ListInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" List + //Assert.IsInstanceOfType (instance, "variable 'instance' is a List"); + } + + + /// + /// Test the property '_123List' + /// + [Test] + public void _123ListTest() + { + // TODO unit test for the property '_123List' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/MapTestTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/MapTestTests.cs new file mode 100644 index 00000000000..d61693c3322 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/MapTestTests.cs @@ -0,0 +1,88 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing MapTest + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class MapTestTests + { + // TODO uncomment below to declare an instance variable for MapTest + //private MapTest instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of MapTest + //instance = new MapTest(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of MapTest + /// + [Test] + public void MapTestInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" MapTest + //Assert.IsInstanceOfType (instance, "variable 'instance' is a MapTest"); + } + + + /// + /// Test the property 'MapMapOfString' + /// + [Test] + public void MapMapOfStringTest() + { + // TODO unit test for the property 'MapMapOfString' + } + /// + /// Test the property 'MapOfEnumString' + /// + [Test] + public void MapOfEnumStringTest() + { + // TODO unit test for the property 'MapOfEnumString' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/MixedPropertiesAndAdditionalPropertiesClassTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/MixedPropertiesAndAdditionalPropertiesClassTests.cs new file mode 100644 index 00000000000..55302d27c40 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/MixedPropertiesAndAdditionalPropertiesClassTests.cs @@ -0,0 +1,96 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing MixedPropertiesAndAdditionalPropertiesClass + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class MixedPropertiesAndAdditionalPropertiesClassTests + { + // TODO uncomment below to declare an instance variable for MixedPropertiesAndAdditionalPropertiesClass + //private MixedPropertiesAndAdditionalPropertiesClass instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of MixedPropertiesAndAdditionalPropertiesClass + //instance = new MixedPropertiesAndAdditionalPropertiesClass(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of MixedPropertiesAndAdditionalPropertiesClass + /// + [Test] + public void MixedPropertiesAndAdditionalPropertiesClassInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" MixedPropertiesAndAdditionalPropertiesClass + //Assert.IsInstanceOfType (instance, "variable 'instance' is a MixedPropertiesAndAdditionalPropertiesClass"); + } + + + /// + /// Test the property 'Uuid' + /// + [Test] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + /// + /// Test the property 'DateTime' + /// + [Test] + public void DateTimeTest() + { + // TODO unit test for the property 'DateTime' + } + /// + /// Test the property 'Map' + /// + [Test] + public void MapTest() + { + // TODO unit test for the property 'Map' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/Model200ResponseTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/Model200ResponseTests.cs new file mode 100644 index 00000000000..cdb0c1960c2 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/Model200ResponseTests.cs @@ -0,0 +1,88 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing Model200Response + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class Model200ResponseTests + { + // TODO uncomment below to declare an instance variable for Model200Response + //private Model200Response instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of Model200Response + //instance = new Model200Response(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of Model200Response + /// + [Test] + public void Model200ResponseInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" Model200Response + //Assert.IsInstanceOfType (instance, "variable 'instance' is a Model200Response"); + } + + + /// + /// Test the property 'Name' + /// + [Test] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + /// + /// Test the property '_Class' + /// + [Test] + public void _ClassTest() + { + // TODO unit test for the property '_Class' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ModelClientTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ModelClientTests.cs new file mode 100644 index 00000000000..f552ab92959 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ModelClientTests.cs @@ -0,0 +1,80 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing ModelClient + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class ModelClientTests + { + // TODO uncomment below to declare an instance variable for ModelClient + //private ModelClient instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of ModelClient + //instance = new ModelClient(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of ModelClient + /// + [Test] + public void ModelClientInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" ModelClient + //Assert.IsInstanceOfType (instance, "variable 'instance' is a ModelClient"); + } + + + /// + /// Test the property '_Client' + /// + [Test] + public void _ClientTest() + { + // TODO unit test for the property '_Client' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ModelReturnTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ModelReturnTests.cs new file mode 100644 index 00000000000..7c9ca513a7d --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ModelReturnTests.cs @@ -0,0 +1,80 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing ModelReturn + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class ModelReturnTests + { + // TODO uncomment below to declare an instance variable for ModelReturn + //private ModelReturn instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of ModelReturn + //instance = new ModelReturn(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of ModelReturn + /// + [Test] + public void ModelReturnInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" ModelReturn + //Assert.IsInstanceOfType (instance, "variable 'instance' is a ModelReturn"); + } + + + /// + /// Test the property '_Return' + /// + [Test] + public void _ReturnTest() + { + // TODO unit test for the property '_Return' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/NameTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/NameTests.cs new file mode 100644 index 00000000000..3802292269a --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/NameTests.cs @@ -0,0 +1,104 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing Name + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class NameTests + { + // TODO uncomment below to declare an instance variable for Name + //private Name instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of Name + //instance = new Name(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of Name + /// + [Test] + public void NameInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" Name + //Assert.IsInstanceOfType (instance, "variable 'instance' is a Name"); + } + + + /// + /// Test the property '_Name' + /// + [Test] + public void _NameTest() + { + // TODO unit test for the property '_Name' + } + /// + /// Test the property 'SnakeCase' + /// + [Test] + public void SnakeCaseTest() + { + // TODO unit test for the property 'SnakeCase' + } + /// + /// Test the property 'Property' + /// + [Test] + public void PropertyTest() + { + // TODO unit test for the property 'Property' + } + /// + /// Test the property '_123Number' + /// + [Test] + public void _123NumberTest() + { + // TODO unit test for the property '_123Number' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/NumberOnlyTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/NumberOnlyTests.cs new file mode 100644 index 00000000000..afa72bf45e4 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/NumberOnlyTests.cs @@ -0,0 +1,80 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing NumberOnly + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class NumberOnlyTests + { + // TODO uncomment below to declare an instance variable for NumberOnly + //private NumberOnly instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of NumberOnly + //instance = new NumberOnly(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of NumberOnly + /// + [Test] + public void NumberOnlyInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" NumberOnly + //Assert.IsInstanceOfType (instance, "variable 'instance' is a NumberOnly"); + } + + + /// + /// Test the property 'JustNumber' + /// + [Test] + public void JustNumberTest() + { + // TODO unit test for the property 'JustNumber' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OrderTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OrderTests.cs new file mode 100644 index 00000000000..40757e5c01c --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OrderTests.cs @@ -0,0 +1,120 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing Order + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class OrderTests + { + // TODO uncomment below to declare an instance variable for Order + //private Order instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of Order + //instance = new Order(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of Order + /// + [Test] + public void OrderInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" Order + //Assert.IsInstanceOfType (instance, "variable 'instance' is a Order"); + } + + + /// + /// Test the property 'Id' + /// + [Test] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + /// + /// Test the property 'PetId' + /// + [Test] + public void PetIdTest() + { + // TODO unit test for the property 'PetId' + } + /// + /// Test the property 'Quantity' + /// + [Test] + public void QuantityTest() + { + // TODO unit test for the property 'Quantity' + } + /// + /// Test the property 'ShipDate' + /// + [Test] + public void ShipDateTest() + { + // TODO unit test for the property 'ShipDate' + } + /// + /// Test the property 'Status' + /// + [Test] + public void StatusTest() + { + // TODO unit test for the property 'Status' + } + /// + /// Test the property 'Complete' + /// + [Test] + public void CompleteTest() + { + // TODO unit test for the property 'Complete' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterBooleanTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterBooleanTests.cs new file mode 100644 index 00000000000..81a6cdf5323 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterBooleanTests.cs @@ -0,0 +1,72 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing OuterBoolean + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class OuterBooleanTests + { + // TODO uncomment below to declare an instance variable for OuterBoolean + //private OuterBoolean instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of OuterBoolean + //instance = new OuterBoolean(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of OuterBoolean + /// + [Test] + public void OuterBooleanInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" OuterBoolean + //Assert.IsInstanceOfType (instance, "variable 'instance' is a OuterBoolean"); + } + + + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterCompositeTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterCompositeTests.cs new file mode 100644 index 00000000000..8cae88a554a --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterCompositeTests.cs @@ -0,0 +1,96 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing OuterComposite + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class OuterCompositeTests + { + // TODO uncomment below to declare an instance variable for OuterComposite + //private OuterComposite instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of OuterComposite + //instance = new OuterComposite(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of OuterComposite + /// + [Test] + public void OuterCompositeInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" OuterComposite + //Assert.IsInstanceOfType (instance, "variable 'instance' is a OuterComposite"); + } + + + /// + /// Test the property 'MyNumber' + /// + [Test] + public void MyNumberTest() + { + // TODO unit test for the property 'MyNumber' + } + /// + /// Test the property 'MyString' + /// + [Test] + public void MyStringTest() + { + // TODO unit test for the property 'MyString' + } + /// + /// Test the property 'MyBoolean' + /// + [Test] + public void MyBooleanTest() + { + // TODO unit test for the property 'MyBoolean' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterEnumTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterEnumTests.cs new file mode 100644 index 00000000000..b65bc240b0d --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterEnumTests.cs @@ -0,0 +1,72 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing OuterEnum + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class OuterEnumTests + { + // TODO uncomment below to declare an instance variable for OuterEnum + //private OuterEnum instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of OuterEnum + //instance = new OuterEnum(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of OuterEnum + /// + [Test] + public void OuterEnumInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" OuterEnum + //Assert.IsInstanceOfType (instance, "variable 'instance' is a OuterEnum"); + } + + + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterNumberTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterNumberTests.cs new file mode 100644 index 00000000000..55ebb7da9fd --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterNumberTests.cs @@ -0,0 +1,72 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing OuterNumber + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class OuterNumberTests + { + // TODO uncomment below to declare an instance variable for OuterNumber + //private OuterNumber instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of OuterNumber + //instance = new OuterNumber(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of OuterNumber + /// + [Test] + public void OuterNumberInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" OuterNumber + //Assert.IsInstanceOfType (instance, "variable 'instance' is a OuterNumber"); + } + + + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterStringTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterStringTests.cs new file mode 100644 index 00000000000..76a2c2253dc --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/OuterStringTests.cs @@ -0,0 +1,72 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing OuterString + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class OuterStringTests + { + // TODO uncomment below to declare an instance variable for OuterString + //private OuterString instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of OuterString + //instance = new OuterString(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of OuterString + /// + [Test] + public void OuterStringInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" OuterString + //Assert.IsInstanceOfType (instance, "variable 'instance' is a OuterString"); + } + + + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/PetTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/PetTests.cs new file mode 100644 index 00000000000..89b221bde94 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/PetTests.cs @@ -0,0 +1,120 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing Pet + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class PetTests + { + // TODO uncomment below to declare an instance variable for Pet + //private Pet instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of Pet + //instance = new Pet(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of Pet + /// + [Test] + public void PetInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" Pet + //Assert.IsInstanceOfType (instance, "variable 'instance' is a Pet"); + } + + + /// + /// Test the property 'Id' + /// + [Test] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + /// + /// Test the property 'Category' + /// + [Test] + public void CategoryTest() + { + // TODO unit test for the property 'Category' + } + /// + /// Test the property 'Name' + /// + [Test] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + /// + /// Test the property 'PhotoUrls' + /// + [Test] + public void PhotoUrlsTest() + { + // TODO unit test for the property 'PhotoUrls' + } + /// + /// Test the property 'Tags' + /// + [Test] + public void TagsTest() + { + // TODO unit test for the property 'Tags' + } + /// + /// Test the property 'Status' + /// + [Test] + public void StatusTest() + { + // TODO unit test for the property 'Status' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ReadOnlyFirstTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ReadOnlyFirstTests.cs new file mode 100644 index 00000000000..f3836f4cabd --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/ReadOnlyFirstTests.cs @@ -0,0 +1,88 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing ReadOnlyFirst + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class ReadOnlyFirstTests + { + // TODO uncomment below to declare an instance variable for ReadOnlyFirst + //private ReadOnlyFirst instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of ReadOnlyFirst + //instance = new ReadOnlyFirst(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of ReadOnlyFirst + /// + [Test] + public void ReadOnlyFirstInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" ReadOnlyFirst + //Assert.IsInstanceOfType (instance, "variable 'instance' is a ReadOnlyFirst"); + } + + + /// + /// Test the property 'Bar' + /// + [Test] + public void BarTest() + { + // TODO unit test for the property 'Bar' + } + /// + /// Test the property 'Baz' + /// + [Test] + public void BazTest() + { + // TODO unit test for the property 'Baz' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/SpecialModelNameTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/SpecialModelNameTests.cs new file mode 100644 index 00000000000..547c62fd482 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/SpecialModelNameTests.cs @@ -0,0 +1,80 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing SpecialModelName + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class SpecialModelNameTests + { + // TODO uncomment below to declare an instance variable for SpecialModelName + //private SpecialModelName instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of SpecialModelName + //instance = new SpecialModelName(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of SpecialModelName + /// + [Test] + public void SpecialModelNameInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" SpecialModelName + //Assert.IsInstanceOfType (instance, "variable 'instance' is a SpecialModelName"); + } + + + /// + /// Test the property 'SpecialPropertyName' + /// + [Test] + public void SpecialPropertyNameTest() + { + // TODO unit test for the property 'SpecialPropertyName' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/TagTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/TagTests.cs new file mode 100644 index 00000000000..adb4bf7c8be --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/TagTests.cs @@ -0,0 +1,88 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing Tag + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class TagTests + { + // TODO uncomment below to declare an instance variable for Tag + //private Tag instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of Tag + //instance = new Tag(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of Tag + /// + [Test] + public void TagInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" Tag + //Assert.IsInstanceOfType (instance, "variable 'instance' is a Tag"); + } + + + /// + /// Test the property 'Id' + /// + [Test] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + /// + /// Test the property 'Name' + /// + [Test] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/UserTests.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/UserTests.cs new file mode 100644 index 00000000000..1f64a7aa433 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/Model/UserTests.cs @@ -0,0 +1,136 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing User + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class UserTests + { + // TODO uncomment below to declare an instance variable for User + //private User instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + // TODO uncomment below to create an instance of User + //instance = new User(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of User + /// + [Test] + public void UserInstanceTest() + { + // TODO uncomment below to test "IsInstanceOfType" User + //Assert.IsInstanceOfType (instance, "variable 'instance' is a User"); + } + + + /// + /// Test the property 'Id' + /// + [Test] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + /// + /// Test the property 'Username' + /// + [Test] + public void UsernameTest() + { + // TODO unit test for the property 'Username' + } + /// + /// Test the property 'FirstName' + /// + [Test] + public void FirstNameTest() + { + // TODO unit test for the property 'FirstName' + } + /// + /// Test the property 'LastName' + /// + [Test] + public void LastNameTest() + { + // TODO unit test for the property 'LastName' + } + /// + /// Test the property 'Email' + /// + [Test] + public void EmailTest() + { + // TODO unit test for the property 'Email' + } + /// + /// Test the property 'Password' + /// + [Test] + public void PasswordTest() + { + // TODO unit test for the property 'Password' + } + /// + /// Test the property 'Phone' + /// + [Test] + public void PhoneTest() + { + // TODO unit test for the property 'Phone' + } + /// + /// Test the property 'UserStatus' + /// + [Test] + public void UserStatusTest() + { + // TODO unit test for the property 'UserStatus' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/packages.config b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/packages.config new file mode 100644 index 00000000000..5d9b19287bc --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger.Test/packages.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/AnotherFakeApi.cs new file mode 100644 index 00000000000..5c2dd82f5bd --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/AnotherFakeApi.cs @@ -0,0 +1,223 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using RestSharp; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace IO.Swagger.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public interface IAnotherFakeApi : IApiAccessor + { + #region Synchronous Operations + /// + /// To test special tags + /// + /// + /// To test special tags + /// + /// Thrown when fails to make API call + /// client model + /// ModelClient + ModelClient TestSpecialTags (ModelClient body); + + /// + /// To test special tags + /// + /// + /// To test special tags + /// + /// Thrown when fails to make API call + /// client model + /// ApiResponse of ModelClient + ApiResponse TestSpecialTagsWithHttpInfo (ModelClient body); + #endregion Synchronous Operations + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public partial class AnotherFakeApi : IAnotherFakeApi + { + private IO.Swagger.Client.ExceptionFactory _exceptionFactory = (name, response) => null; + + /// + /// Initializes a new instance of the class. + /// + /// + public AnotherFakeApi(String basePath) + { + this.Configuration = new Configuration { BasePath = basePath }; + + ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class + /// using Configuration object + /// + /// An instance of Configuration + /// + public AnotherFakeApi(Configuration configuration = null) + { + if (configuration == null) // use the default one in Configuration + this.Configuration = Configuration.Default; + else + this.Configuration = configuration; + + ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Gets the base path of the API client. + /// + /// The base path + public String GetBasePath() + { + return this.Configuration.ApiClient.RestClient.BaseUrl.ToString(); + } + + /// + /// Sets the base path of the API client. + /// + /// The base path + [Obsolete("SetBasePath is deprecated, please do 'Configuration.ApiClient = new ApiClient(\"http://new-path\")' instead.")] + public void SetBasePath(String basePath) + { + // do nothing + } + + /// + /// Gets or sets the configuration object + /// + /// An instance of the Configuration + public Configuration Configuration {get; set;} + + /// + /// Provides a factory method hook for the creation of exceptions. + /// + public IO.Swagger.Client.ExceptionFactory ExceptionFactory + { + get + { + if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) + { + throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); + } + return _exceptionFactory; + } + set { _exceptionFactory = value; } + } + + /// + /// Gets the default header. + /// + /// Dictionary of HTTP header + [Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] + public IDictionary DefaultHeader() + { + return new ReadOnlyDictionary(this.Configuration.DefaultHeader); + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + [Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")] + public void AddDefaultHeader(string key, string value) + { + this.Configuration.AddDefaultHeader(key, value); + } + + /// + /// To test special tags To test special tags + /// + /// Thrown when fails to make API call + /// client model + /// ModelClient + public ModelClient TestSpecialTags (ModelClient body) + { + ApiResponse localVarResponse = TestSpecialTagsWithHttpInfo(body); + return localVarResponse.Data; + } + + /// + /// To test special tags To test special tags + /// + /// Thrown when fails to make API call + /// client model + /// ApiResponse of ModelClient + public ApiResponse< ModelClient > TestSpecialTagsWithHttpInfo (ModelClient body) + { + // verify the required parameter 'body' is set + if (body == null) + throw new ApiException(400, "Missing required parameter 'body' when calling AnotherFakeApi->TestSpecialTags"); + + var localVarPath = "/another-fake/dummy"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "application/json" + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.PATCH, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("TestSpecialTags", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (ModelClient) Configuration.ApiClient.Deserialize(localVarResponse, typeof(ModelClient))); + } + + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/FakeApi.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/FakeApi.cs new file mode 100644 index 00000000000..36f85798534 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/FakeApi.cs @@ -0,0 +1,1058 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using RestSharp; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace IO.Swagger.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public interface IFakeApi : IApiAccessor + { + #region Synchronous Operations + /// + /// + /// + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// OuterBoolean + OuterBoolean FakeOuterBooleanSerialize (OuterBoolean body = null); + + /// + /// + /// + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// ApiResponse of OuterBoolean + ApiResponse FakeOuterBooleanSerializeWithHttpInfo (OuterBoolean body = null); + /// + /// + /// + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// OuterComposite + OuterComposite FakeOuterCompositeSerialize (OuterComposite body = null); + + /// + /// + /// + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// ApiResponse of OuterComposite + ApiResponse FakeOuterCompositeSerializeWithHttpInfo (OuterComposite body = null); + /// + /// + /// + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// OuterNumber + OuterNumber FakeOuterNumberSerialize (OuterNumber body = null); + + /// + /// + /// + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// ApiResponse of OuterNumber + ApiResponse FakeOuterNumberSerializeWithHttpInfo (OuterNumber body = null); + /// + /// + /// + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Input string as post body (optional) + /// OuterString + OuterString FakeOuterStringSerialize (OuterString body = null); + + /// + /// + /// + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Input string as post body (optional) + /// ApiResponse of OuterString + ApiResponse FakeOuterStringSerializeWithHttpInfo (OuterString body = null); + /// + /// To test \"client\" model + /// + /// + /// To test \"client\" model + /// + /// Thrown when fails to make API call + /// client model + /// ModelClient + ModelClient TestClientModel (ModelClient body); + + /// + /// To test \"client\" model + /// + /// + /// To test \"client\" model + /// + /// Thrown when fails to make API call + /// client model + /// ApiResponse of ModelClient + ApiResponse TestClientModelWithHttpInfo (ModelClient body); + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// + void TestEndpointParameters (decimal? number, double? _double, string patternWithoutDelimiter, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, string _string = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null, string callback = null); + + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// ApiResponse of Object(void) + ApiResponse TestEndpointParametersWithHttpInfo (decimal? number, double? _double, string patternWithoutDelimiter, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, string _string = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null, string callback = null); + /// + /// To test enum parameters + /// + /// + /// To test enum parameters + /// + /// Thrown when fails to make API call + /// Form parameter enum test (string array) (optional) + /// Form parameter enum test (string) (optional, default to -efg) + /// Header parameter enum test (string array) (optional) + /// Header parameter enum test (string) (optional, default to -efg) + /// Query parameter enum test (string array) (optional) + /// Query parameter enum test (string) (optional, default to -efg) + /// Query parameter enum test (double) (optional) + /// Query parameter enum test (double) (optional) + /// + void TestEnumParameters (List enumFormStringArray = null, string enumFormString = null, List enumHeaderStringArray = null, string enumHeaderString = null, List enumQueryStringArray = null, string enumQueryString = null, int? enumQueryInteger = null, double? enumQueryDouble = null); + + /// + /// To test enum parameters + /// + /// + /// To test enum parameters + /// + /// Thrown when fails to make API call + /// Form parameter enum test (string array) (optional) + /// Form parameter enum test (string) (optional, default to -efg) + /// Header parameter enum test (string array) (optional) + /// Header parameter enum test (string) (optional, default to -efg) + /// Query parameter enum test (string array) (optional) + /// Query parameter enum test (string) (optional, default to -efg) + /// Query parameter enum test (double) (optional) + /// Query parameter enum test (double) (optional) + /// ApiResponse of Object(void) + ApiResponse TestEnumParametersWithHttpInfo (List enumFormStringArray = null, string enumFormString = null, List enumHeaderStringArray = null, string enumHeaderString = null, List enumQueryStringArray = null, string enumQueryString = null, int? enumQueryInteger = null, double? enumQueryDouble = null); + /// + /// test inline additionalProperties + /// + /// + /// + /// + /// Thrown when fails to make API call + /// request body + /// + void TestInlineAdditionalProperties (Object param); + + /// + /// test inline additionalProperties + /// + /// + /// + /// + /// Thrown when fails to make API call + /// request body + /// ApiResponse of Object(void) + ApiResponse TestInlineAdditionalPropertiesWithHttpInfo (Object param); + /// + /// test json serialization of form data + /// + /// + /// + /// + /// Thrown when fails to make API call + /// field1 + /// field2 + /// + void TestJsonFormData (string param, string param2); + + /// + /// test json serialization of form data + /// + /// + /// + /// + /// Thrown when fails to make API call + /// field1 + /// field2 + /// ApiResponse of Object(void) + ApiResponse TestJsonFormDataWithHttpInfo (string param, string param2); + #endregion Synchronous Operations + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public partial class FakeApi : IFakeApi + { + private IO.Swagger.Client.ExceptionFactory _exceptionFactory = (name, response) => null; + + /// + /// Initializes a new instance of the class. + /// + /// + public FakeApi(String basePath) + { + this.Configuration = new Configuration { BasePath = basePath }; + + ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class + /// using Configuration object + /// + /// An instance of Configuration + /// + public FakeApi(Configuration configuration = null) + { + if (configuration == null) // use the default one in Configuration + this.Configuration = Configuration.Default; + else + this.Configuration = configuration; + + ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Gets the base path of the API client. + /// + /// The base path + public String GetBasePath() + { + return this.Configuration.ApiClient.RestClient.BaseUrl.ToString(); + } + + /// + /// Sets the base path of the API client. + /// + /// The base path + [Obsolete("SetBasePath is deprecated, please do 'Configuration.ApiClient = new ApiClient(\"http://new-path\")' instead.")] + public void SetBasePath(String basePath) + { + // do nothing + } + + /// + /// Gets or sets the configuration object + /// + /// An instance of the Configuration + public Configuration Configuration {get; set;} + + /// + /// Provides a factory method hook for the creation of exceptions. + /// + public IO.Swagger.Client.ExceptionFactory ExceptionFactory + { + get + { + if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) + { + throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); + } + return _exceptionFactory; + } + set { _exceptionFactory = value; } + } + + /// + /// Gets the default header. + /// + /// Dictionary of HTTP header + [Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] + public IDictionary DefaultHeader() + { + return new ReadOnlyDictionary(this.Configuration.DefaultHeader); + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + [Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")] + public void AddDefaultHeader(string key, string value) + { + this.Configuration.AddDefaultHeader(key, value); + } + + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// OuterBoolean + public OuterBoolean FakeOuterBooleanSerialize (OuterBoolean body = null) + { + ApiResponse localVarResponse = FakeOuterBooleanSerializeWithHttpInfo(body); + return localVarResponse.Data; + } + + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// ApiResponse of OuterBoolean + public ApiResponse< OuterBoolean > FakeOuterBooleanSerializeWithHttpInfo (OuterBoolean body = null) + { + + var localVarPath = "/fake/outer/boolean"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("FakeOuterBooleanSerialize", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (OuterBoolean) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterBoolean))); + } + + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// OuterComposite + public OuterComposite FakeOuterCompositeSerialize (OuterComposite body = null) + { + ApiResponse localVarResponse = FakeOuterCompositeSerializeWithHttpInfo(body); + return localVarResponse.Data; + } + + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// ApiResponse of OuterComposite + public ApiResponse< OuterComposite > FakeOuterCompositeSerializeWithHttpInfo (OuterComposite body = null) + { + + var localVarPath = "/fake/outer/composite"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("FakeOuterCompositeSerialize", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (OuterComposite) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterComposite))); + } + + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// OuterNumber + public OuterNumber FakeOuterNumberSerialize (OuterNumber body = null) + { + ApiResponse localVarResponse = FakeOuterNumberSerializeWithHttpInfo(body); + return localVarResponse.Data; + } + + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// ApiResponse of OuterNumber + public ApiResponse< OuterNumber > FakeOuterNumberSerializeWithHttpInfo (OuterNumber body = null) + { + + var localVarPath = "/fake/outer/number"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("FakeOuterNumberSerialize", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (OuterNumber) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterNumber))); + } + + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Input string as post body (optional) + /// OuterString + public OuterString FakeOuterStringSerialize (OuterString body = null) + { + ApiResponse localVarResponse = FakeOuterStringSerializeWithHttpInfo(body); + return localVarResponse.Data; + } + + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Input string as post body (optional) + /// ApiResponse of OuterString + public ApiResponse< OuterString > FakeOuterStringSerializeWithHttpInfo (OuterString body = null) + { + + var localVarPath = "/fake/outer/string"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("FakeOuterStringSerialize", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (OuterString) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterString))); + } + + /// + /// To test \"client\" model To test \"client\" model + /// + /// Thrown when fails to make API call + /// client model + /// ModelClient + public ModelClient TestClientModel (ModelClient body) + { + ApiResponse localVarResponse = TestClientModelWithHttpInfo(body); + return localVarResponse.Data; + } + + /// + /// To test \"client\" model To test \"client\" model + /// + /// Thrown when fails to make API call + /// client model + /// ApiResponse of ModelClient + public ApiResponse< ModelClient > TestClientModelWithHttpInfo (ModelClient body) + { + // verify the required parameter 'body' is set + if (body == null) + throw new ApiException(400, "Missing required parameter 'body' when calling FakeApi->TestClientModel"); + + var localVarPath = "/fake"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "application/json" + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.PATCH, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("TestClientModel", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (ModelClient) Configuration.ApiClient.Deserialize(localVarResponse, typeof(ModelClient))); + } + + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// + public void TestEndpointParameters (decimal? number, double? _double, string patternWithoutDelimiter, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, string _string = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null, string callback = null) + { + TestEndpointParametersWithHttpInfo(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, _string, binary, date, dateTime, password, callback); + } + + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// ApiResponse of Object(void) + public ApiResponse TestEndpointParametersWithHttpInfo (decimal? number, double? _double, string patternWithoutDelimiter, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, string _string = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null, string callback = null) + { + // verify the required parameter 'number' is set + if (number == null) + throw new ApiException(400, "Missing required parameter 'number' when calling FakeApi->TestEndpointParameters"); + // verify the required parameter '_double' is set + if (_double == null) + throw new ApiException(400, "Missing required parameter '_double' when calling FakeApi->TestEndpointParameters"); + // verify the required parameter 'patternWithoutDelimiter' is set + if (patternWithoutDelimiter == null) + throw new ApiException(400, "Missing required parameter 'patternWithoutDelimiter' when calling FakeApi->TestEndpointParameters"); + // verify the required parameter '_byte' is set + if (_byte == null) + throw new ApiException(400, "Missing required parameter '_byte' when calling FakeApi->TestEndpointParameters"); + + var localVarPath = "/fake"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "application/xml; charset=utf-8", + "application/json; charset=utf-8" + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml; charset=utf-8", + "application/json; charset=utf-8" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (integer != null) localVarFormParams.Add("integer", Configuration.ApiClient.ParameterToString(integer)); // form parameter + if (int32 != null) localVarFormParams.Add("int32", Configuration.ApiClient.ParameterToString(int32)); // form parameter + if (int64 != null) localVarFormParams.Add("int64", Configuration.ApiClient.ParameterToString(int64)); // form parameter + if (number != null) localVarFormParams.Add("number", Configuration.ApiClient.ParameterToString(number)); // form parameter + if (_float != null) localVarFormParams.Add("float", Configuration.ApiClient.ParameterToString(_float)); // form parameter + if (_double != null) localVarFormParams.Add("double", Configuration.ApiClient.ParameterToString(_double)); // form parameter + if (_string != null) localVarFormParams.Add("string", Configuration.ApiClient.ParameterToString(_string)); // form parameter + if (patternWithoutDelimiter != null) localVarFormParams.Add("pattern_without_delimiter", Configuration.ApiClient.ParameterToString(patternWithoutDelimiter)); // form parameter + if (_byte != null) localVarFormParams.Add("byte", Configuration.ApiClient.ParameterToString(_byte)); // form parameter + if (binary != null) localVarFormParams.Add("binary", Configuration.ApiClient.ParameterToString(binary)); // form parameter + if (date != null) localVarFormParams.Add("date", Configuration.ApiClient.ParameterToString(date)); // form parameter + if (dateTime != null) localVarFormParams.Add("dateTime", Configuration.ApiClient.ParameterToString(dateTime)); // form parameter + if (password != null) localVarFormParams.Add("password", Configuration.ApiClient.ParameterToString(password)); // form parameter + if (callback != null) localVarFormParams.Add("callback", Configuration.ApiClient.ParameterToString(callback)); // form parameter + + // authentication (http_basic_test) required + // http basic authentication required + if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password)) + { + localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password); + } + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("TestEndpointParameters", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// To test enum parameters To test enum parameters + /// + /// Thrown when fails to make API call + /// Form parameter enum test (string array) (optional) + /// Form parameter enum test (string) (optional, default to -efg) + /// Header parameter enum test (string array) (optional) + /// Header parameter enum test (string) (optional, default to -efg) + /// Query parameter enum test (string array) (optional) + /// Query parameter enum test (string) (optional, default to -efg) + /// Query parameter enum test (double) (optional) + /// Query parameter enum test (double) (optional) + /// + public void TestEnumParameters (List enumFormStringArray = null, string enumFormString = null, List enumHeaderStringArray = null, string enumHeaderString = null, List enumQueryStringArray = null, string enumQueryString = null, int? enumQueryInteger = null, double? enumQueryDouble = null) + { + TestEnumParametersWithHttpInfo(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble); + } + + /// + /// To test enum parameters To test enum parameters + /// + /// Thrown when fails to make API call + /// Form parameter enum test (string array) (optional) + /// Form parameter enum test (string) (optional, default to -efg) + /// Header parameter enum test (string array) (optional) + /// Header parameter enum test (string) (optional, default to -efg) + /// Query parameter enum test (string array) (optional) + /// Query parameter enum test (string) (optional, default to -efg) + /// Query parameter enum test (double) (optional) + /// Query parameter enum test (double) (optional) + /// ApiResponse of Object(void) + public ApiResponse TestEnumParametersWithHttpInfo (List enumFormStringArray = null, string enumFormString = null, List enumHeaderStringArray = null, string enumHeaderString = null, List enumQueryStringArray = null, string enumQueryString = null, int? enumQueryInteger = null, double? enumQueryDouble = null) + { + + var localVarPath = "/fake"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "*/*" + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "*/*" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (enumQueryStringArray != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("csv", "enum_query_string_array", enumQueryStringArray)); // query parameter + if (enumQueryString != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "enum_query_string", enumQueryString)); // query parameter + if (enumQueryInteger != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "enum_query_integer", enumQueryInteger)); // query parameter + if (enumHeaderStringArray != null) localVarHeaderParams.Add("enum_header_string_array", Configuration.ApiClient.ParameterToString(enumHeaderStringArray)); // header parameter + if (enumHeaderString != null) localVarHeaderParams.Add("enum_header_string", Configuration.ApiClient.ParameterToString(enumHeaderString)); // header parameter + if (enumFormStringArray != null) localVarFormParams.Add("enum_form_string_array", Configuration.ApiClient.ParameterToString(enumFormStringArray)); // form parameter + if (enumFormString != null) localVarFormParams.Add("enum_form_string", Configuration.ApiClient.ParameterToString(enumFormString)); // form parameter + if (enumQueryDouble != null) localVarFormParams.Add("enum_query_double", Configuration.ApiClient.ParameterToString(enumQueryDouble)); // form parameter + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("TestEnumParameters", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// test inline additionalProperties + /// + /// Thrown when fails to make API call + /// request body + /// + public void TestInlineAdditionalProperties (Object param) + { + TestInlineAdditionalPropertiesWithHttpInfo(param); + } + + /// + /// test inline additionalProperties + /// + /// Thrown when fails to make API call + /// request body + /// ApiResponse of Object(void) + public ApiResponse TestInlineAdditionalPropertiesWithHttpInfo (Object param) + { + // verify the required parameter 'param' is set + if (param == null) + throw new ApiException(400, "Missing required parameter 'param' when calling FakeApi->TestInlineAdditionalProperties"); + + var localVarPath = "/fake/inline-additionalProperties"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "application/json" + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (param != null && param.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(param); // http body (model) parameter + } + else + { + localVarPostBody = param; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("TestInlineAdditionalProperties", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// test json serialization of form data + /// + /// Thrown when fails to make API call + /// field1 + /// field2 + /// + public void TestJsonFormData (string param, string param2) + { + TestJsonFormDataWithHttpInfo(param, param2); + } + + /// + /// test json serialization of form data + /// + /// Thrown when fails to make API call + /// field1 + /// field2 + /// ApiResponse of Object(void) + public ApiResponse TestJsonFormDataWithHttpInfo (string param, string param2) + { + // verify the required parameter 'param' is set + if (param == null) + throw new ApiException(400, "Missing required parameter 'param' when calling FakeApi->TestJsonFormData"); + // verify the required parameter 'param2' is set + if (param2 == null) + throw new ApiException(400, "Missing required parameter 'param2' when calling FakeApi->TestJsonFormData"); + + var localVarPath = "/fake/jsonFormData"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "application/json" + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (param != null) localVarFormParams.Add("param", Configuration.ApiClient.ParameterToString(param)); // form parameter + if (param2 != null) localVarFormParams.Add("param2", Configuration.ApiClient.ParameterToString(param2)); // form parameter + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("TestJsonFormData", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/FakeClassnameTags123Api.cs new file mode 100644 index 00000000000..9ca1ed03b7b --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/FakeClassnameTags123Api.cs @@ -0,0 +1,228 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using RestSharp; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace IO.Swagger.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public interface IFakeClassnameTags123Api : IApiAccessor + { + #region Synchronous Operations + /// + /// To test class name in snake case + /// + /// + /// + /// + /// Thrown when fails to make API call + /// client model + /// ModelClient + ModelClient TestClassname (ModelClient body); + + /// + /// To test class name in snake case + /// + /// + /// + /// + /// Thrown when fails to make API call + /// client model + /// ApiResponse of ModelClient + ApiResponse TestClassnameWithHttpInfo (ModelClient body); + #endregion Synchronous Operations + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public partial class FakeClassnameTags123Api : IFakeClassnameTags123Api + { + private IO.Swagger.Client.ExceptionFactory _exceptionFactory = (name, response) => null; + + /// + /// Initializes a new instance of the class. + /// + /// + public FakeClassnameTags123Api(String basePath) + { + this.Configuration = new Configuration { BasePath = basePath }; + + ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class + /// using Configuration object + /// + /// An instance of Configuration + /// + public FakeClassnameTags123Api(Configuration configuration = null) + { + if (configuration == null) // use the default one in Configuration + this.Configuration = Configuration.Default; + else + this.Configuration = configuration; + + ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Gets the base path of the API client. + /// + /// The base path + public String GetBasePath() + { + return this.Configuration.ApiClient.RestClient.BaseUrl.ToString(); + } + + /// + /// Sets the base path of the API client. + /// + /// The base path + [Obsolete("SetBasePath is deprecated, please do 'Configuration.ApiClient = new ApiClient(\"http://new-path\")' instead.")] + public void SetBasePath(String basePath) + { + // do nothing + } + + /// + /// Gets or sets the configuration object + /// + /// An instance of the Configuration + public Configuration Configuration {get; set;} + + /// + /// Provides a factory method hook for the creation of exceptions. + /// + public IO.Swagger.Client.ExceptionFactory ExceptionFactory + { + get + { + if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) + { + throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); + } + return _exceptionFactory; + } + set { _exceptionFactory = value; } + } + + /// + /// Gets the default header. + /// + /// Dictionary of HTTP header + [Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] + public IDictionary DefaultHeader() + { + return new ReadOnlyDictionary(this.Configuration.DefaultHeader); + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + [Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")] + public void AddDefaultHeader(string key, string value) + { + this.Configuration.AddDefaultHeader(key, value); + } + + /// + /// To test class name in snake case + /// + /// Thrown when fails to make API call + /// client model + /// ModelClient + public ModelClient TestClassname (ModelClient body) + { + ApiResponse localVarResponse = TestClassnameWithHttpInfo(body); + return localVarResponse.Data; + } + + /// + /// To test class name in snake case + /// + /// Thrown when fails to make API call + /// client model + /// ApiResponse of ModelClient + public ApiResponse< ModelClient > TestClassnameWithHttpInfo (ModelClient body) + { + // verify the required parameter 'body' is set + if (body == null) + throw new ApiException(400, "Missing required parameter 'body' when calling FakeClassnameTags123Api->TestClassname"); + + var localVarPath = "/fake_classname_test"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "application/json" + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + // authentication (api_key_query) required + if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key_query"))) + { + localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "api_key_query", Configuration.GetApiKeyWithPrefix("api_key_query"))); + } + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.PATCH, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("TestClassname", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (ModelClient) Configuration.ApiClient.Deserialize(localVarResponse, typeof(ModelClient))); + } + + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/PetApi.cs new file mode 100644 index 00000000000..40e495d110d --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/PetApi.cs @@ -0,0 +1,919 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using RestSharp; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace IO.Swagger.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public interface IPetApi : IApiAccessor + { + #region Synchronous Operations + /// + /// Add a new pet to the store + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// + void AddPet (Pet body); + + /// + /// Add a new pet to the store + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// ApiResponse of Object(void) + ApiResponse AddPetWithHttpInfo (Pet body); + /// + /// Deletes a pet + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Pet id to delete + /// (optional) + /// + void DeletePet (long? petId, string apiKey = null); + + /// + /// Deletes a pet + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Pet id to delete + /// (optional) + /// ApiResponse of Object(void) + ApiResponse DeletePetWithHttpInfo (long? petId, string apiKey = null); + /// + /// Finds Pets by status + /// + /// + /// Multiple status values can be provided with comma separated strings + /// + /// Thrown when fails to make API call + /// Status values that need to be considered for filter + /// List<Pet> + List FindPetsByStatus (List status); + + /// + /// Finds Pets by status + /// + /// + /// Multiple status values can be provided with comma separated strings + /// + /// Thrown when fails to make API call + /// Status values that need to be considered for filter + /// ApiResponse of List<Pet> + ApiResponse> FindPetsByStatusWithHttpInfo (List status); + /// + /// Finds Pets by tags + /// + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Thrown when fails to make API call + /// Tags to filter by + /// List<Pet> + List FindPetsByTags (List tags); + + /// + /// Finds Pets by tags + /// + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Thrown when fails to make API call + /// Tags to filter by + /// ApiResponse of List<Pet> + ApiResponse> FindPetsByTagsWithHttpInfo (List tags); + /// + /// Find pet by ID + /// + /// + /// Returns a single pet + /// + /// Thrown when fails to make API call + /// ID of pet to return + /// Pet + Pet GetPetById (long? petId); + + /// + /// Find pet by ID + /// + /// + /// Returns a single pet + /// + /// Thrown when fails to make API call + /// ID of pet to return + /// ApiResponse of Pet + ApiResponse GetPetByIdWithHttpInfo (long? petId); + /// + /// Update an existing pet + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// + void UpdatePet (Pet body); + + /// + /// Update an existing pet + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// ApiResponse of Object(void) + ApiResponse UpdatePetWithHttpInfo (Pet body); + /// + /// Updates a pet in the store with form data + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be updated + /// Updated name of the pet (optional) + /// Updated status of the pet (optional) + /// + void UpdatePetWithForm (long? petId, string name = null, string status = null); + + /// + /// Updates a pet in the store with form data + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be updated + /// Updated name of the pet (optional) + /// Updated status of the pet (optional) + /// ApiResponse of Object(void) + ApiResponse UpdatePetWithFormWithHttpInfo (long? petId, string name = null, string status = null); + /// + /// uploads an image + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// Additional data to pass to server (optional) + /// file to upload (optional) + /// ApiResponse + ApiResponse UploadFile (long? petId, string additionalMetadata = null, System.IO.Stream file = null); + + /// + /// uploads an image + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// Additional data to pass to server (optional) + /// file to upload (optional) + /// ApiResponse of ApiResponse + ApiResponse UploadFileWithHttpInfo (long? petId, string additionalMetadata = null, System.IO.Stream file = null); + #endregion Synchronous Operations + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public partial class PetApi : IPetApi + { + private IO.Swagger.Client.ExceptionFactory _exceptionFactory = (name, response) => null; + + /// + /// Initializes a new instance of the class. + /// + /// + public PetApi(String basePath) + { + this.Configuration = new Configuration { BasePath = basePath }; + + ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class + /// using Configuration object + /// + /// An instance of Configuration + /// + public PetApi(Configuration configuration = null) + { + if (configuration == null) // use the default one in Configuration + this.Configuration = Configuration.Default; + else + this.Configuration = configuration; + + ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Gets the base path of the API client. + /// + /// The base path + public String GetBasePath() + { + return this.Configuration.ApiClient.RestClient.BaseUrl.ToString(); + } + + /// + /// Sets the base path of the API client. + /// + /// The base path + [Obsolete("SetBasePath is deprecated, please do 'Configuration.ApiClient = new ApiClient(\"http://new-path\")' instead.")] + public void SetBasePath(String basePath) + { + // do nothing + } + + /// + /// Gets or sets the configuration object + /// + /// An instance of the Configuration + public Configuration Configuration {get; set;} + + /// + /// Provides a factory method hook for the creation of exceptions. + /// + public IO.Swagger.Client.ExceptionFactory ExceptionFactory + { + get + { + if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) + { + throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); + } + return _exceptionFactory; + } + set { _exceptionFactory = value; } + } + + /// + /// Gets the default header. + /// + /// Dictionary of HTTP header + [Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] + public IDictionary DefaultHeader() + { + return new ReadOnlyDictionary(this.Configuration.DefaultHeader); + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + [Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")] + public void AddDefaultHeader(string key, string value) + { + this.Configuration.AddDefaultHeader(key, value); + } + + /// + /// Add a new pet to the store + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// + public void AddPet (Pet body) + { + AddPetWithHttpInfo(body); + } + + /// + /// Add a new pet to the store + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// ApiResponse of Object(void) + public ApiResponse AddPetWithHttpInfo (Pet body) + { + // verify the required parameter 'body' is set + if (body == null) + throw new ApiException(400, "Missing required parameter 'body' when calling PetApi->AddPet"); + + var localVarPath = "/pet"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "application/json", + "application/xml" + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + // authentication (petstore_auth) required + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("AddPet", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// Deletes a pet + /// + /// Thrown when fails to make API call + /// Pet id to delete + /// (optional) + /// + public void DeletePet (long? petId, string apiKey = null) + { + DeletePetWithHttpInfo(petId, apiKey); + } + + /// + /// Deletes a pet + /// + /// Thrown when fails to make API call + /// Pet id to delete + /// (optional) + /// ApiResponse of Object(void) + public ApiResponse DeletePetWithHttpInfo (long? petId, string apiKey = null) + { + // verify the required parameter 'petId' is set + if (petId == null) + throw new ApiException(400, "Missing required parameter 'petId' when calling PetApi->DeletePet"); + + var localVarPath = "/pet/{petId}"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (petId != null) localVarPathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter + if (apiKey != null) localVarHeaderParams.Add("api_key", Configuration.ApiClient.ParameterToString(apiKey)); // header parameter + + // authentication (petstore_auth) required + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.DELETE, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("DeletePet", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// Finds Pets by status Multiple status values can be provided with comma separated strings + /// + /// Thrown when fails to make API call + /// Status values that need to be considered for filter + /// List<Pet> + public List FindPetsByStatus (List status) + { + ApiResponse> localVarResponse = FindPetsByStatusWithHttpInfo(status); + return localVarResponse.Data; + } + + /// + /// Finds Pets by status Multiple status values can be provided with comma separated strings + /// + /// Thrown when fails to make API call + /// Status values that need to be considered for filter + /// ApiResponse of List<Pet> + public ApiResponse< List > FindPetsByStatusWithHttpInfo (List status) + { + // verify the required parameter 'status' is set + if (status == null) + throw new ApiException(400, "Missing required parameter 'status' when calling PetApi->FindPetsByStatus"); + + var localVarPath = "/pet/findByStatus"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (status != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("csv", "status", status)); // query parameter + + // authentication (petstore_auth) required + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("FindPetsByStatus", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse>(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (List) Configuration.ApiClient.Deserialize(localVarResponse, typeof(List))); + } + + /// + /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Thrown when fails to make API call + /// Tags to filter by + /// List<Pet> + public List FindPetsByTags (List tags) + { + ApiResponse> localVarResponse = FindPetsByTagsWithHttpInfo(tags); + return localVarResponse.Data; + } + + /// + /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Thrown when fails to make API call + /// Tags to filter by + /// ApiResponse of List<Pet> + public ApiResponse< List > FindPetsByTagsWithHttpInfo (List tags) + { + // verify the required parameter 'tags' is set + if (tags == null) + throw new ApiException(400, "Missing required parameter 'tags' when calling PetApi->FindPetsByTags"); + + var localVarPath = "/pet/findByTags"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (tags != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("csv", "tags", tags)); // query parameter + + // authentication (petstore_auth) required + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("FindPetsByTags", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse>(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (List) Configuration.ApiClient.Deserialize(localVarResponse, typeof(List))); + } + + /// + /// Find pet by ID Returns a single pet + /// + /// Thrown when fails to make API call + /// ID of pet to return + /// Pet + public Pet GetPetById (long? petId) + { + ApiResponse localVarResponse = GetPetByIdWithHttpInfo(petId); + return localVarResponse.Data; + } + + /// + /// Find pet by ID Returns a single pet + /// + /// Thrown when fails to make API call + /// ID of pet to return + /// ApiResponse of Pet + public ApiResponse< Pet > GetPetByIdWithHttpInfo (long? petId) + { + // verify the required parameter 'petId' is set + if (petId == null) + throw new ApiException(400, "Missing required parameter 'petId' when calling PetApi->GetPetById"); + + var localVarPath = "/pet/{petId}"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (petId != null) localVarPathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter + + // authentication (api_key) required + if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key"))) + { + localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key"); + } + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("GetPetById", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (Pet) Configuration.ApiClient.Deserialize(localVarResponse, typeof(Pet))); + } + + /// + /// Update an existing pet + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// + public void UpdatePet (Pet body) + { + UpdatePetWithHttpInfo(body); + } + + /// + /// Update an existing pet + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// ApiResponse of Object(void) + public ApiResponse UpdatePetWithHttpInfo (Pet body) + { + // verify the required parameter 'body' is set + if (body == null) + throw new ApiException(400, "Missing required parameter 'body' when calling PetApi->UpdatePet"); + + var localVarPath = "/pet"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "application/json", + "application/xml" + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + // authentication (petstore_auth) required + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("UpdatePet", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// Updates a pet in the store with form data + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be updated + /// Updated name of the pet (optional) + /// Updated status of the pet (optional) + /// + public void UpdatePetWithForm (long? petId, string name = null, string status = null) + { + UpdatePetWithFormWithHttpInfo(petId, name, status); + } + + /// + /// Updates a pet in the store with form data + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be updated + /// Updated name of the pet (optional) + /// Updated status of the pet (optional) + /// ApiResponse of Object(void) + public ApiResponse UpdatePetWithFormWithHttpInfo (long? petId, string name = null, string status = null) + { + // verify the required parameter 'petId' is set + if (petId == null) + throw new ApiException(400, "Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm"); + + var localVarPath = "/pet/{petId}"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "application/x-www-form-urlencoded" + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (petId != null) localVarPathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter + if (name != null) localVarFormParams.Add("name", Configuration.ApiClient.ParameterToString(name)); // form parameter + if (status != null) localVarFormParams.Add("status", Configuration.ApiClient.ParameterToString(status)); // form parameter + + // authentication (petstore_auth) required + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("UpdatePetWithForm", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// uploads an image + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// Additional data to pass to server (optional) + /// file to upload (optional) + /// ApiResponse + public ApiResponse UploadFile (long? petId, string additionalMetadata = null, System.IO.Stream file = null) + { + ApiResponse localVarResponse = UploadFileWithHttpInfo(petId, additionalMetadata, file); + return localVarResponse.Data; + } + + /// + /// uploads an image + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// Additional data to pass to server (optional) + /// file to upload (optional) + /// ApiResponse of ApiResponse + public ApiResponse< ApiResponse > UploadFileWithHttpInfo (long? petId, string additionalMetadata = null, System.IO.Stream file = null) + { + // verify the required parameter 'petId' is set + if (petId == null) + throw new ApiException(400, "Missing required parameter 'petId' when calling PetApi->UploadFile"); + + var localVarPath = "/pet/{petId}/uploadImage"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "multipart/form-data" + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (petId != null) localVarPathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter + if (additionalMetadata != null) localVarFormParams.Add("additionalMetadata", Configuration.ApiClient.ParameterToString(additionalMetadata)); // form parameter + if (file != null) localVarFileParams.Add("file", Configuration.ApiClient.ParameterToFile("file", file)); + + // authentication (petstore_auth) required + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("UploadFile", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (ApiResponse) Configuration.ApiClient.Deserialize(localVarResponse, typeof(ApiResponse))); + } + + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/StoreApi.cs new file mode 100644 index 00000000000..8829f14e96c --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/StoreApi.cs @@ -0,0 +1,482 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using RestSharp; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace IO.Swagger.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public interface IStoreApi : IApiAccessor + { + #region Synchronous Operations + /// + /// Delete purchase order by ID + /// + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// Thrown when fails to make API call + /// ID of the order that needs to be deleted + /// + void DeleteOrder (string orderId); + + /// + /// Delete purchase order by ID + /// + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// Thrown when fails to make API call + /// ID of the order that needs to be deleted + /// ApiResponse of Object(void) + ApiResponse DeleteOrderWithHttpInfo (string orderId); + /// + /// Returns pet inventories by status + /// + /// + /// Returns a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// Dictionary<string, int?> + Dictionary GetInventory (); + + /// + /// Returns pet inventories by status + /// + /// + /// Returns a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// ApiResponse of Dictionary<string, int?> + ApiResponse> GetInventoryWithHttpInfo (); + /// + /// Find purchase order by ID + /// + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// Order + Order GetOrderById (long? orderId); + + /// + /// Find purchase order by ID + /// + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// ApiResponse of Order + ApiResponse GetOrderByIdWithHttpInfo (long? orderId); + /// + /// Place an order for a pet + /// + /// + /// + /// + /// Thrown when fails to make API call + /// order placed for purchasing the pet + /// Order + Order PlaceOrder (Order body); + + /// + /// Place an order for a pet + /// + /// + /// + /// + /// Thrown when fails to make API call + /// order placed for purchasing the pet + /// ApiResponse of Order + ApiResponse PlaceOrderWithHttpInfo (Order body); + #endregion Synchronous Operations + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public partial class StoreApi : IStoreApi + { + private IO.Swagger.Client.ExceptionFactory _exceptionFactory = (name, response) => null; + + /// + /// Initializes a new instance of the class. + /// + /// + public StoreApi(String basePath) + { + this.Configuration = new Configuration { BasePath = basePath }; + + ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class + /// using Configuration object + /// + /// An instance of Configuration + /// + public StoreApi(Configuration configuration = null) + { + if (configuration == null) // use the default one in Configuration + this.Configuration = Configuration.Default; + else + this.Configuration = configuration; + + ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Gets the base path of the API client. + /// + /// The base path + public String GetBasePath() + { + return this.Configuration.ApiClient.RestClient.BaseUrl.ToString(); + } + + /// + /// Sets the base path of the API client. + /// + /// The base path + [Obsolete("SetBasePath is deprecated, please do 'Configuration.ApiClient = new ApiClient(\"http://new-path\")' instead.")] + public void SetBasePath(String basePath) + { + // do nothing + } + + /// + /// Gets or sets the configuration object + /// + /// An instance of the Configuration + public Configuration Configuration {get; set;} + + /// + /// Provides a factory method hook for the creation of exceptions. + /// + public IO.Swagger.Client.ExceptionFactory ExceptionFactory + { + get + { + if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) + { + throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); + } + return _exceptionFactory; + } + set { _exceptionFactory = value; } + } + + /// + /// Gets the default header. + /// + /// Dictionary of HTTP header + [Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] + public IDictionary DefaultHeader() + { + return new ReadOnlyDictionary(this.Configuration.DefaultHeader); + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + [Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")] + public void AddDefaultHeader(string key, string value) + { + this.Configuration.AddDefaultHeader(key, value); + } + + /// + /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// Thrown when fails to make API call + /// ID of the order that needs to be deleted + /// + public void DeleteOrder (string orderId) + { + DeleteOrderWithHttpInfo(orderId); + } + + /// + /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// Thrown when fails to make API call + /// ID of the order that needs to be deleted + /// ApiResponse of Object(void) + public ApiResponse DeleteOrderWithHttpInfo (string orderId) + { + // verify the required parameter 'orderId' is set + if (orderId == null) + throw new ApiException(400, "Missing required parameter 'orderId' when calling StoreApi->DeleteOrder"); + + var localVarPath = "/store/order/{order_id}"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (orderId != null) localVarPathParams.Add("order_id", Configuration.ApiClient.ParameterToString(orderId)); // path parameter + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.DELETE, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("DeleteOrder", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// Dictionary<string, int?> + public Dictionary GetInventory () + { + ApiResponse> localVarResponse = GetInventoryWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// ApiResponse of Dictionary<string, int?> + public ApiResponse< Dictionary > GetInventoryWithHttpInfo () + { + + var localVarPath = "/store/inventory"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + + // authentication (api_key) required + if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key"))) + { + localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key"); + } + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("GetInventory", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse>(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (Dictionary) Configuration.ApiClient.Deserialize(localVarResponse, typeof(Dictionary))); + } + + /// + /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// Order + public Order GetOrderById (long? orderId) + { + ApiResponse localVarResponse = GetOrderByIdWithHttpInfo(orderId); + return localVarResponse.Data; + } + + /// + /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// ApiResponse of Order + public ApiResponse< Order > GetOrderByIdWithHttpInfo (long? orderId) + { + // verify the required parameter 'orderId' is set + if (orderId == null) + throw new ApiException(400, "Missing required parameter 'orderId' when calling StoreApi->GetOrderById"); + + var localVarPath = "/store/order/{order_id}"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (orderId != null) localVarPathParams.Add("order_id", Configuration.ApiClient.ParameterToString(orderId)); // path parameter + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("GetOrderById", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (Order) Configuration.ApiClient.Deserialize(localVarResponse, typeof(Order))); + } + + /// + /// Place an order for a pet + /// + /// Thrown when fails to make API call + /// order placed for purchasing the pet + /// Order + public Order PlaceOrder (Order body) + { + ApiResponse localVarResponse = PlaceOrderWithHttpInfo(body); + return localVarResponse.Data; + } + + /// + /// Place an order for a pet + /// + /// Thrown when fails to make API call + /// order placed for purchasing the pet + /// ApiResponse of Order + public ApiResponse< Order > PlaceOrderWithHttpInfo (Order body) + { + // verify the required parameter 'body' is set + if (body == null) + throw new ApiException(400, "Missing required parameter 'body' when calling StoreApi->PlaceOrder"); + + var localVarPath = "/store/order"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("PlaceOrder", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (Order) Configuration.ApiClient.Deserialize(localVarResponse, typeof(Order))); + } + + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/UserApi.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/UserApi.cs new file mode 100644 index 00000000000..5d8c4507bb6 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Api/UserApi.cs @@ -0,0 +1,862 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using RestSharp; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace IO.Swagger.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public interface IUserApi : IApiAccessor + { + #region Synchronous Operations + /// + /// Create user + /// + /// + /// This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// Created user object + /// + void CreateUser (User body); + + /// + /// Create user + /// + /// + /// This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// Created user object + /// ApiResponse of Object(void) + ApiResponse CreateUserWithHttpInfo (User body); + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// Thrown when fails to make API call + /// List of user object + /// + void CreateUsersWithArrayInput (List body); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// Thrown when fails to make API call + /// List of user object + /// ApiResponse of Object(void) + ApiResponse CreateUsersWithArrayInputWithHttpInfo (List body); + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// Thrown when fails to make API call + /// List of user object + /// + void CreateUsersWithListInput (List body); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// Thrown when fails to make API call + /// List of user object + /// ApiResponse of Object(void) + ApiResponse CreateUsersWithListInputWithHttpInfo (List body); + /// + /// Delete user + /// + /// + /// This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// The name that needs to be deleted + /// + void DeleteUser (string username); + + /// + /// Delete user + /// + /// + /// This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// The name that needs to be deleted + /// ApiResponse of Object(void) + ApiResponse DeleteUserWithHttpInfo (string username); + /// + /// Get user by user name + /// + /// + /// + /// + /// Thrown when fails to make API call + /// The name that needs to be fetched. Use user1 for testing. + /// User + User GetUserByName (string username); + + /// + /// Get user by user name + /// + /// + /// + /// + /// Thrown when fails to make API call + /// The name that needs to be fetched. Use user1 for testing. + /// ApiResponse of User + ApiResponse GetUserByNameWithHttpInfo (string username); + /// + /// Logs user into the system + /// + /// + /// + /// + /// Thrown when fails to make API call + /// The user name for login + /// The password for login in clear text + /// string + string LoginUser (string username, string password); + + /// + /// Logs user into the system + /// + /// + /// + /// + /// Thrown when fails to make API call + /// The user name for login + /// The password for login in clear text + /// ApiResponse of string + ApiResponse LoginUserWithHttpInfo (string username, string password); + /// + /// Logs out current logged in user session + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + void LogoutUser (); + + /// + /// Logs out current logged in user session + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ApiResponse of Object(void) + ApiResponse LogoutUserWithHttpInfo (); + /// + /// Updated user + /// + /// + /// This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// name that need to be deleted + /// Updated user object + /// + void UpdateUser (string username, User body); + + /// + /// Updated user + /// + /// + /// This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// name that need to be deleted + /// Updated user object + /// ApiResponse of Object(void) + ApiResponse UpdateUserWithHttpInfo (string username, User body); + #endregion Synchronous Operations + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public partial class UserApi : IUserApi + { + private IO.Swagger.Client.ExceptionFactory _exceptionFactory = (name, response) => null; + + /// + /// Initializes a new instance of the class. + /// + /// + public UserApi(String basePath) + { + this.Configuration = new Configuration { BasePath = basePath }; + + ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class + /// using Configuration object + /// + /// An instance of Configuration + /// + public UserApi(Configuration configuration = null) + { + if (configuration == null) // use the default one in Configuration + this.Configuration = Configuration.Default; + else + this.Configuration = configuration; + + ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Gets the base path of the API client. + /// + /// The base path + public String GetBasePath() + { + return this.Configuration.ApiClient.RestClient.BaseUrl.ToString(); + } + + /// + /// Sets the base path of the API client. + /// + /// The base path + [Obsolete("SetBasePath is deprecated, please do 'Configuration.ApiClient = new ApiClient(\"http://new-path\")' instead.")] + public void SetBasePath(String basePath) + { + // do nothing + } + + /// + /// Gets or sets the configuration object + /// + /// An instance of the Configuration + public Configuration Configuration {get; set;} + + /// + /// Provides a factory method hook for the creation of exceptions. + /// + public IO.Swagger.Client.ExceptionFactory ExceptionFactory + { + get + { + if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) + { + throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); + } + return _exceptionFactory; + } + set { _exceptionFactory = value; } + } + + /// + /// Gets the default header. + /// + /// Dictionary of HTTP header + [Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] + public IDictionary DefaultHeader() + { + return new ReadOnlyDictionary(this.Configuration.DefaultHeader); + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + [Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")] + public void AddDefaultHeader(string key, string value) + { + this.Configuration.AddDefaultHeader(key, value); + } + + /// + /// Create user This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// Created user object + /// + public void CreateUser (User body) + { + CreateUserWithHttpInfo(body); + } + + /// + /// Create user This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// Created user object + /// ApiResponse of Object(void) + public ApiResponse CreateUserWithHttpInfo (User body) + { + // verify the required parameter 'body' is set + if (body == null) + throw new ApiException(400, "Missing required parameter 'body' when calling UserApi->CreateUser"); + + var localVarPath = "/user"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("CreateUser", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// Creates list of users with given input array + /// + /// Thrown when fails to make API call + /// List of user object + /// + public void CreateUsersWithArrayInput (List body) + { + CreateUsersWithArrayInputWithHttpInfo(body); + } + + /// + /// Creates list of users with given input array + /// + /// Thrown when fails to make API call + /// List of user object + /// ApiResponse of Object(void) + public ApiResponse CreateUsersWithArrayInputWithHttpInfo (List body) + { + // verify the required parameter 'body' is set + if (body == null) + throw new ApiException(400, "Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput"); + + var localVarPath = "/user/createWithArray"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("CreateUsersWithArrayInput", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// Creates list of users with given input array + /// + /// Thrown when fails to make API call + /// List of user object + /// + public void CreateUsersWithListInput (List body) + { + CreateUsersWithListInputWithHttpInfo(body); + } + + /// + /// Creates list of users with given input array + /// + /// Thrown when fails to make API call + /// List of user object + /// ApiResponse of Object(void) + public ApiResponse CreateUsersWithListInputWithHttpInfo (List body) + { + // verify the required parameter 'body' is set + if (body == null) + throw new ApiException(400, "Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput"); + + var localVarPath = "/user/createWithList"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("CreateUsersWithListInput", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// Delete user This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// The name that needs to be deleted + /// + public void DeleteUser (string username) + { + DeleteUserWithHttpInfo(username); + } + + /// + /// Delete user This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// The name that needs to be deleted + /// ApiResponse of Object(void) + public ApiResponse DeleteUserWithHttpInfo (string username) + { + // verify the required parameter 'username' is set + if (username == null) + throw new ApiException(400, "Missing required parameter 'username' when calling UserApi->DeleteUser"); + + var localVarPath = "/user/{username}"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (username != null) localVarPathParams.Add("username", Configuration.ApiClient.ParameterToString(username)); // path parameter + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.DELETE, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("DeleteUser", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// Get user by user name + /// + /// Thrown when fails to make API call + /// The name that needs to be fetched. Use user1 for testing. + /// User + public User GetUserByName (string username) + { + ApiResponse localVarResponse = GetUserByNameWithHttpInfo(username); + return localVarResponse.Data; + } + + /// + /// Get user by user name + /// + /// Thrown when fails to make API call + /// The name that needs to be fetched. Use user1 for testing. + /// ApiResponse of User + public ApiResponse< User > GetUserByNameWithHttpInfo (string username) + { + // verify the required parameter 'username' is set + if (username == null) + throw new ApiException(400, "Missing required parameter 'username' when calling UserApi->GetUserByName"); + + var localVarPath = "/user/{username}"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (username != null) localVarPathParams.Add("username", Configuration.ApiClient.ParameterToString(username)); // path parameter + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("GetUserByName", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (User) Configuration.ApiClient.Deserialize(localVarResponse, typeof(User))); + } + + /// + /// Logs user into the system + /// + /// Thrown when fails to make API call + /// The user name for login + /// The password for login in clear text + /// string + public string LoginUser (string username, string password) + { + ApiResponse localVarResponse = LoginUserWithHttpInfo(username, password); + return localVarResponse.Data; + } + + /// + /// Logs user into the system + /// + /// Thrown when fails to make API call + /// The user name for login + /// The password for login in clear text + /// ApiResponse of string + public ApiResponse< string > LoginUserWithHttpInfo (string username, string password) + { + // verify the required parameter 'username' is set + if (username == null) + throw new ApiException(400, "Missing required parameter 'username' when calling UserApi->LoginUser"); + // verify the required parameter 'password' is set + if (password == null) + throw new ApiException(400, "Missing required parameter 'password' when calling UserApi->LoginUser"); + + var localVarPath = "/user/login"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (username != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "username", username)); // query parameter + if (password != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "password", password)); // query parameter + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("LoginUser", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (string) Configuration.ApiClient.Deserialize(localVarResponse, typeof(string))); + } + + /// + /// Logs out current logged in user session + /// + /// Thrown when fails to make API call + /// + public void LogoutUser () + { + LogoutUserWithHttpInfo(); + } + + /// + /// Logs out current logged in user session + /// + /// Thrown when fails to make API call + /// ApiResponse of Object(void) + public ApiResponse LogoutUserWithHttpInfo () + { + + var localVarPath = "/user/logout"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("LogoutUser", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// Updated user This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// name that need to be deleted + /// Updated user object + /// + public void UpdateUser (string username, User body) + { + UpdateUserWithHttpInfo(username, body); + } + + /// + /// Updated user This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// name that need to be deleted + /// Updated user object + /// ApiResponse of Object(void) + public ApiResponse UpdateUserWithHttpInfo (string username, User body) + { + // verify the required parameter 'username' is set + if (username == null) + throw new ApiException(400, "Missing required parameter 'username' when calling UserApi->UpdateUser"); + // verify the required parameter 'body' is set + if (body == null) + throw new ApiException(400, "Missing required parameter 'body' when calling UserApi->UpdateUser"); + + var localVarPath = "/user/{username}"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/xml", + "application/json" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (username != null) localVarPathParams.Add("username", Configuration.ApiClient.ParameterToString(username)); // path parameter + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("UpdateUser", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/ApiClient.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/ApiClient.cs new file mode 100644 index 00000000000..db66a078c13 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/ApiClient.cs @@ -0,0 +1,504 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Text.RegularExpressions; +using System.IO; +using System.Web; +using System.Linq; +using System.Net; +using System.Text; +using Newtonsoft.Json; +using RestSharp; + +namespace IO.Swagger.Client +{ + /// + /// API client is mainly responsible for making the HTTP call to the API backend. + /// + public partial class ApiClient + { + private JsonSerializerSettings serializerSettings = new JsonSerializerSettings + { + ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor + }; + + /// + /// Allows for extending request processing for generated code. + /// + /// The RestSharp request object + partial void InterceptRequest(IRestRequest request); + + /// + /// Allows for extending response processing for generated code. + /// + /// The RestSharp request object + /// The RestSharp response object + partial void InterceptResponse(IRestRequest request, IRestResponse response); + + /// + /// Initializes a new instance of the class + /// with default configuration. + /// + public ApiClient() + { + Configuration = IO.Swagger.Client.Configuration.Default; + RestClient = new RestClient("http://petstore.swagger.io:80/v2"); + } + + /// + /// Initializes a new instance of the class + /// with default base path (http://petstore.swagger.io:80/v2). + /// + /// An instance of Configuration. + public ApiClient(Configuration config) + { + Configuration = config ?? IO.Swagger.Client.Configuration.Default; + + RestClient = new RestClient(Configuration.BasePath); + } + + /// + /// Initializes a new instance of the class + /// with default configuration. + /// + /// The base path. + public ApiClient(String basePath = "http://petstore.swagger.io:80/v2") + { + if (String.IsNullOrEmpty(basePath)) + throw new ArgumentException("basePath cannot be empty"); + + RestClient = new RestClient(basePath); + Configuration = Client.Configuration.Default; + } + + /// + /// Gets or sets the default API client for making HTTP calls. + /// + /// The default API client. + [Obsolete("ApiClient.Default is deprecated, please use 'Configuration.Default.ApiClient' instead.")] + public static ApiClient Default; + + /// + /// Gets or sets an instance of the IReadableConfiguration. + /// + /// An instance of the IReadableConfiguration. + /// + /// helps us to avoid modifying possibly global + /// configuration values from within a given client. It does not gaurantee thread-safety + /// of the instance in any way. + /// + public IReadableConfiguration Configuration { get; set; } + + /// + /// Gets or sets the RestClient. + /// + /// An instance of the RestClient + public RestClient RestClient { get; set; } + + // Creates and sets up a RestRequest prior to a call. + private RestRequest PrepareRequest( + String path, RestSharp.Method method, List> queryParams, Object postBody, + Dictionary headerParams, Dictionary formParams, + Dictionary fileParams, Dictionary pathParams, + String contentType) + { + var request = new RestRequest(path, method); + + // add path parameter, if any + foreach(var param in pathParams) + request.AddParameter(param.Key, param.Value, ParameterType.UrlSegment); + + // add header parameter, if any + foreach(var param in headerParams) + request.AddHeader(param.Key, param.Value); + + // add query parameter, if any + foreach(var param in queryParams) + request.AddQueryParameter(param.Key, param.Value); + + // add form parameter, if any + foreach(var param in formParams) + request.AddParameter(param.Key, param.Value); + + // add file parameter, if any + foreach(var param in fileParams) + { + request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType); + } + + if (postBody != null) // http body (model or byte[]) parameter + { + request.AddParameter(contentType, postBody, ParameterType.RequestBody); + } + + return request; + } + + /// + /// Makes the HTTP request (Sync). + /// + /// URL path. + /// HTTP method. + /// Query parameters. + /// HTTP body (POST request). + /// Header parameters. + /// Form parameters. + /// File parameters. + /// Path parameters. + /// Content Type of the request + /// Object + public Object CallApi( + String path, RestSharp.Method method, List> queryParams, Object postBody, + Dictionary headerParams, Dictionary formParams, + Dictionary fileParams, Dictionary pathParams, + String contentType) + { + var request = PrepareRequest( + path, method, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, contentType); + + // set timeout + + RestClient.Timeout = Configuration.Timeout; + // set user agent + RestClient.UserAgent = Configuration.UserAgent; + + InterceptRequest(request); + var response = RestClient.Execute(request); + InterceptResponse(request, response); + + return (Object) response; + } + + + /// + /// Escape string (url-encoded). + /// + /// String to be escaped. + /// Escaped string. + public string EscapeString(string str) + { + return UrlEncode(str); + } + + /// + /// Create FileParameter based on Stream. + /// + /// Parameter name. + /// Input stream. + /// FileParameter. + public FileParameter ParameterToFile(string name, Stream stream) + { + if (stream is FileStream) + return FileParameter.Create(name, ReadAsBytes(stream), Path.GetFileName(((FileStream)stream).Name)); + else + return FileParameter.Create(name, ReadAsBytes(stream), "no_file_name_provided"); + } + + /// + /// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. + /// If parameter is a list, join the list with ",". + /// Otherwise just return the string. + /// + /// The parameter (header, path, query, form). + /// Formatted string. + public string ParameterToString(object obj) + { + if (obj is DateTime) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return ((DateTime)obj).ToString (Configuration.DateTimeFormat); + else if (obj is DateTimeOffset) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return ((DateTimeOffset)obj).ToString (Configuration.DateTimeFormat); + else if (obj is IList) + { + var flattenedString = new StringBuilder(); + foreach (var param in (IList)obj) + { + if (flattenedString.Length > 0) + flattenedString.Append(","); + flattenedString.Append(param); + } + return flattenedString.ToString(); + } + else + return Convert.ToString (obj); + } + + /// + /// Deserialize the JSON string into a proper object. + /// + /// The HTTP response. + /// Object type. + /// Object representation of the JSON string. + public object Deserialize(IRestResponse response, Type type) + { + IList headers = response.Headers; + if (type == typeof(byte[])) // return byte array + { + return response.RawBytes; + } + + // TODO: ? if (type.IsAssignableFrom(typeof(Stream))) + if (type == typeof(Stream)) + { + if (headers != null) + { + var filePath = String.IsNullOrEmpty(Configuration.TempFolderPath) + ? Path.GetTempPath() + : Configuration.TempFolderPath; + var regex = new Regex(@"Content-Disposition=.*filename=['""]?([^'""\s]+)['""]?$"); + foreach (var header in headers) + { + var match = regex.Match(header.ToString()); + if (match.Success) + { + string fileName = filePath + SanitizeFilename(match.Groups[1].Value.Replace("\"", "").Replace("'", "")); + File.WriteAllBytes(fileName, response.RawBytes); + return new FileStream(fileName, FileMode.Open); + } + } + } + var stream = new MemoryStream(response.RawBytes); + return stream; + } + + if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object + { + return DateTime.Parse(response.Content, null, System.Globalization.DateTimeStyles.RoundtripKind); + } + + if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type + { + return ConvertType(response.Content, type); + } + + // at this point, it must be a model (json) + try + { + return JsonConvert.DeserializeObject(response.Content, type, serializerSettings); + } + catch (Exception e) + { + throw new ApiException(500, e.Message); + } + } + + /// + /// Serialize an input (model) into JSON string + /// + /// Object. + /// JSON string. + public String Serialize(object obj) + { + try + { + return obj != null ? JsonConvert.SerializeObject(obj) : null; + } + catch (Exception e) + { + throw new ApiException(500, e.Message); + } + } + + /// + ///Check if the given MIME is a JSON MIME. + ///JSON MIME examples: + /// application/json + /// application/json; charset=UTF8 + /// APPLICATION/JSON + /// application/vnd.company+json + /// + /// MIME + /// Returns True if MIME type is json. + public bool IsJsonMime(String mime) + { + var jsonRegex = new Regex("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"); + return mime != null && (jsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json")); + } + + /// + /// Select the Content-Type header's value from the given content-type array: + /// if JSON type exists in the given array, use it; + /// otherwise use the first one defined in 'consumes' + /// + /// The Content-Type array to select from. + /// The Content-Type header to use. + public String SelectHeaderContentType(String[] contentTypes) + { + if (contentTypes.Length == 0) + return "application/json"; + + foreach (var contentType in contentTypes) + { + if (IsJsonMime(contentType.ToLower())) + return contentType; + } + + return contentTypes[0]; // use the first content type specified in 'consumes' + } + + /// + /// Select the Accept header's value from the given accepts array: + /// if JSON exists in the given array, use it; + /// otherwise use all of them (joining into a string) + /// + /// The accepts array to select from. + /// The Accept header to use. + public String SelectHeaderAccept(String[] accepts) + { + if (accepts.Length == 0) + return null; + + if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase)) + return "application/json"; + + return String.Join(",", accepts); + } + + /// + /// Encode string in base64 format. + /// + /// String to be encoded. + /// Encoded string. + public static string Base64Encode(string text) + { + return System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text)); + } + + /// + /// Dynamically cast the object into target type. + /// + /// Object to be casted + /// Target type + /// Casted object + public static object ConvertType(T fromObject, Type toObject) where T : class + { + return Convert.ChangeType(fromObject, toObject); + } + + /// + /// Convert stream to byte array + /// + /// Input stream to be converted + /// Byte array + public static byte[] ReadAsBytes(Stream inputStream) + { + byte[] buf = new byte[16*1024]; + using (MemoryStream ms = new MemoryStream()) + { + int count; + while ((count = inputStream.Read(buf, 0, buf.Length)) > 0) + { + ms.Write(buf, 0, count); + } + return ms.ToArray(); + } + } + + /// + /// URL encode a string + /// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50 + /// + /// String to be URL encoded + /// Byte array + public static string UrlEncode(string input) + { + const int maxLength = 32766; + + if (input == null) + { + throw new ArgumentNullException("input"); + } + + if (input.Length <= maxLength) + { + return Uri.EscapeDataString(input); + } + + StringBuilder sb = new StringBuilder(input.Length * 2); + int index = 0; + + while (index < input.Length) + { + int length = Math.Min(input.Length - index, maxLength); + string subString = input.Substring(index, length); + + sb.Append(Uri.EscapeDataString(subString)); + index += subString.Length; + } + + return sb.ToString(); + } + + /// + /// Sanitize filename by removing the path + /// + /// Filename + /// Filename + public static string SanitizeFilename(string filename) + { + Match match = Regex.Match(filename, @".*[/\\](.*)$"); + + if (match.Success) + { + return match.Groups[1].Value; + } + else + { + return filename; + } + } + + /// + /// Convert params to key/value pairs. + /// Use collectionFormat to properly format lists and collections. + /// + /// Key name. + /// Value object. + /// A list of KeyValuePairs + public IEnumerable> ParameterToKeyValuePairs(string collectionFormat, string name, object value) + { + var parameters = new List>(); + + if (IsCollection(value) && collectionFormat == "multi") + { + var valueCollection = value as IEnumerable; + parameters.AddRange(from object item in valueCollection select new KeyValuePair(name, ParameterToString(item))); + } + else + { + parameters.Add(new KeyValuePair(name, ParameterToString(value))); + } + + return parameters; + } + + /// + /// Check if generic object is a collection. + /// + /// + /// True if object is a collection type + private static bool IsCollection(object value) + { + return value is IList || value is ICollection; + } + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/ApiException.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/ApiException.cs new file mode 100644 index 00000000000..8f0fc5a05d5 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/ApiException.cs @@ -0,0 +1,60 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; + +namespace IO.Swagger.Client +{ + /// + /// API Exception + /// + public class ApiException : Exception + { + /// + /// Gets or sets the error code (HTTP status code) + /// + /// The error code (HTTP status code). + public int ErrorCode { get; set; } + + /// + /// Gets or sets the error content (body json object) + /// + /// The error content (Http response body). + public object ErrorContent { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + public ApiException() {} + + /// + /// Initializes a new instance of the class. + /// + /// HTTP status code. + /// Error message. + public ApiException(int errorCode, string message) : base(message) + { + this.ErrorCode = errorCode; + } + + /// + /// Initializes a new instance of the class. + /// + /// HTTP status code. + /// Error message. + /// Error content. + public ApiException(int errorCode, string message, object errorContent = null) : base(message) + { + this.ErrorCode = errorCode; + this.ErrorContent = errorContent; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/ApiResponse.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/ApiResponse.cs new file mode 100644 index 00000000000..b21347aa408 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/ApiResponse.cs @@ -0,0 +1,54 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Collections.Generic; + +namespace IO.Swagger.Client +{ + /// + /// API Response + /// + public class ApiResponse + { + /// + /// Gets or sets the status code (HTTP status code) + /// + /// The status code. + public int StatusCode { get; private set; } + + /// + /// Gets or sets the HTTP headers + /// + /// HTTP headers + public IDictionary Headers { get; private set; } + + /// + /// Gets or sets the data (parsed HTTP body) + /// + /// The data. + public T Data { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + /// HTTP status code. + /// HTTP headers. + /// Data (parsed HTTP body) + public ApiResponse(int statusCode, IDictionary headers, T data) + { + this.StatusCode= statusCode; + this.Headers = headers; + this.Data = data; + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/Configuration.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/Configuration.cs new file mode 100644 index 00000000000..531d240482a --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/Configuration.cs @@ -0,0 +1,453 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Reflection; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace IO.Swagger.Client +{ + /// + /// Represents a set of configuration settings + /// + public class Configuration : IReadableConfiguration + { + #region Constants + + /// + /// Version of the package. + /// + /// Version of the package. + public const string Version = "1.0.0"; + + /// + /// Identifier for ISO 8601 DateTime Format + /// + /// See https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 for more information. + // ReSharper disable once InconsistentNaming + public const string ISO8601_DATETIME_FORMAT = "o"; + + #endregion Constants + + #region Static Members + + private static readonly object GlobalConfigSync = new { }; + private static Configuration _globalConfiguration; + + /// + /// Default creation of exceptions for a given method name and response object + /// + public static readonly ExceptionFactory DefaultExceptionFactory = (methodName, response) => + { + var status = (int)response.StatusCode; + if (status >= 400) + { + return new ApiException(status, + string.Format("Error calling {0}: {1}", methodName, response.Content), + response.Content); + } + if (status == 0) + { + return new ApiException(status, + string.Format("Error calling {0}: {1}", methodName, response.ErrorMessage), response.ErrorMessage); + } + return null; + }; + + /// + /// Gets or sets the default Configuration. + /// + /// Configuration. + public static Configuration Default + { + get { return _globalConfiguration; } + set + { + lock (GlobalConfigSync) + { + _globalConfiguration = value; + } + } + } + + #endregion Static Members + + #region Private Members + + /// + /// Gets or sets the API key based on the authentication name. + /// + /// The API key. + private IDictionary _apiKey = null; + + /// + /// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name. + /// + /// The prefix of the API key. + private IDictionary _apiKeyPrefix = null; + + private string _dateTimeFormat = ISO8601_DATETIME_FORMAT; + private string _tempFolderPath = Path.GetTempPath(); + + #endregion Private Members + + #region Constructors + + static Configuration() + { + _globalConfiguration = new GlobalConfiguration(); + } + + /// + /// Initializes a new instance of the class + /// + public Configuration() + { + UserAgent = "Swagger-Codegen/1.0.0/csharp"; + BasePath = "http://petstore.swagger.io:80/v2"; + DefaultHeader = new ConcurrentDictionary(); + ApiKey = new ConcurrentDictionary(); + ApiKeyPrefix = new ConcurrentDictionary(); + + // Setting Timeout has side effects (forces ApiClient creation). + Timeout = 100000; + } + + /// + /// Initializes a new instance of the class + /// + public Configuration( + IDictionary defaultHeader, + IDictionary apiKey, + IDictionary apiKeyPrefix, + string basePath = "http://petstore.swagger.io:80/v2") : this() + { + if (string.IsNullOrWhiteSpace(basePath)) + throw new ArgumentException("The provided basePath is invalid.", "basePath"); + if (defaultHeader == null) + throw new ArgumentNullException("defaultHeader"); + if (apiKey == null) + throw new ArgumentNullException("apiKey"); + if (apiKeyPrefix == null) + throw new ArgumentNullException("apiKeyPrefix"); + + BasePath = basePath; + + foreach (var keyValuePair in defaultHeader) + { + DefaultHeader.Add(keyValuePair); + } + + foreach (var keyValuePair in apiKey) + { + ApiKey.Add(keyValuePair); + } + + foreach (var keyValuePair in apiKeyPrefix) + { + ApiKeyPrefix.Add(keyValuePair); + } + } + + /// + /// Initializes a new instance of the class with different settings + /// + /// Api client + /// Dictionary of default HTTP header + /// Username + /// Password + /// accessToken + /// Dictionary of API key + /// Dictionary of API key prefix + /// Temp folder path + /// DateTime format string + /// HTTP connection timeout (in milliseconds) + /// HTTP user agent + [Obsolete("Use explicit object construction and setting of properties.", true)] + public Configuration( + // ReSharper disable UnusedParameter.Local + ApiClient apiClient = null, + IDictionary defaultHeader = null, + string username = null, + string password = null, + string accessToken = null, + IDictionary apiKey = null, + IDictionary apiKeyPrefix = null, + string tempFolderPath = null, + string dateTimeFormat = null, + int timeout = 100000, + string userAgent = "Swagger-Codegen/1.0.0/csharp" + // ReSharper restore UnusedParameter.Local + ) + { + + } + + /// + /// Initializes a new instance of the Configuration class. + /// + /// Api client. + [Obsolete("This constructor caused unexpected sharing of static data. It is no longer supported.", true)] + // ReSharper disable once UnusedParameter.Local + public Configuration(ApiClient apiClient) + { + + } + + #endregion Constructors + + + #region Properties + + private ApiClient _apiClient = null; + /// + /// Gets an instance of an ApiClient for this configuration + /// + public virtual ApiClient ApiClient + { + get + { + if (_apiClient == null) _apiClient = CreateApiClient(); + return _apiClient; + } + } + + private String _basePath = null; + /// + /// Gets or sets the base path for API access. + /// + public virtual string BasePath { + get { return _basePath; } + set { + _basePath = value; + // pass-through to ApiClient if it's set. + if(_apiClient != null) { + _apiClient.RestClient.BaseUrl = new Uri(_basePath); + } + } + } + + /// + /// Gets or sets the default header. + /// + public virtual IDictionary DefaultHeader { get; set; } + + /// + /// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds. + /// + public virtual int Timeout + { + + get { return ApiClient.RestClient.Timeout; } + set { ApiClient.RestClient.Timeout = value; } + } + + /// + /// Gets or sets the HTTP user agent. + /// + /// Http user agent. + public virtual string UserAgent { get; set; } + + /// + /// Gets or sets the username (HTTP basic authentication). + /// + /// The username. + public virtual string Username { get; set; } + + /// + /// Gets or sets the password (HTTP basic authentication). + /// + /// The password. + public virtual string Password { get; set; } + + /// + /// Gets the API key with prefix. + /// + /// API key identifier (authentication scheme). + /// API key with prefix. + public string GetApiKeyWithPrefix(string apiKeyIdentifier) + { + var apiKeyValue = ""; + ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue); + var apiKeyPrefix = ""; + if (ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix)) + return apiKeyPrefix + " " + apiKeyValue; + else + return apiKeyValue; + } + + /// + /// Gets or sets the access token for OAuth2 authentication. + /// + /// The access token. + public virtual string AccessToken { get; set; } + + /// + /// Gets or sets the temporary folder path to store the files downloaded from the server. + /// + /// Folder path. + public virtual string TempFolderPath + { + get { return _tempFolderPath; } + + set + { + if (string.IsNullOrEmpty(value)) + { + // Possible breaking change since swagger-codegen 2.2.1, enforce a valid temporary path on set. + _tempFolderPath = Path.GetTempPath(); + return; + } + + // create the directory if it does not exist + if (!Directory.Exists(value)) + { + Directory.CreateDirectory(value); + } + + // check if the path contains directory separator at the end + if (value[value.Length - 1] == Path.DirectorySeparatorChar) + { + _tempFolderPath = value; + } + else + { + _tempFolderPath = value + Path.DirectorySeparatorChar; + } + } + } + + /// + /// Gets or sets the the date time format used when serializing in the ApiClient + /// By default, it's set to ISO 8601 - "o", for others see: + /// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx + /// and https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx + /// No validation is done to ensure that the string you're providing is valid + /// + /// The DateTimeFormat string + public virtual string DateTimeFormat + { + get { return _dateTimeFormat; } + set + { + if (string.IsNullOrEmpty(value)) + { + // Never allow a blank or null string, go back to the default + _dateTimeFormat = ISO8601_DATETIME_FORMAT; + return; + } + + // Caution, no validation when you choose date time format other than ISO 8601 + // Take a look at the above links + _dateTimeFormat = value; + } + } + + /// + /// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name. + /// + /// The prefix of the API key. + public virtual IDictionary ApiKeyPrefix + { + get { return _apiKeyPrefix; } + set + { + if (value == null) + { + throw new InvalidOperationException("ApiKeyPrefix collection may not be null."); + } + _apiKeyPrefix = value; + } + } + + /// + /// Gets or sets the API key based on the authentication name. + /// + /// The API key. + public virtual IDictionary ApiKey + { + get { return _apiKey; } + set + { + if (value == null) + { + throw new InvalidOperationException("ApiKey collection may not be null."); + } + _apiKey = value; + } + } + + #endregion Properties + + #region Methods + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + public void AddDefaultHeader(string key, string value) + { + DefaultHeader[key] = value; + } + + /// + /// Creates a new based on this instance. + /// + /// + public ApiClient CreateApiClient() + { + return new ApiClient(BasePath) { Configuration = this }; + } + + + /// + /// Returns a string with essential information for debugging. + /// + public static String ToDebugReport() + { + String report = "C# SDK (IO.Swagger) Debug Report:\n"; + report += " OS: " + System.Environment.OSVersion + "\n"; + report += " .NET Framework Version: " + System.Environment.Version + "\n"; + report += " Version of the API: 1.0.0\n"; + report += " SDK Package Version: 1.0.0\n"; + + return report; + } + + /// + /// Add Api Key Header. + /// + /// Api Key name. + /// Api Key value. + /// + public void AddApiKey(string key, string value) + { + ApiKey[key] = value; + } + + /// + /// Sets the API key prefix. + /// + /// Api Key name. + /// Api Key value. + public void AddApiKeyPrefix(string key, string value) + { + ApiKeyPrefix[key] = value; + } + + #endregion Methods + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/ExceptionFactory.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/ExceptionFactory.cs new file mode 100644 index 00000000000..0f16ee365e5 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/ExceptionFactory.cs @@ -0,0 +1,24 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using System; +using RestSharp; + +namespace IO.Swagger.Client +{ + /// + /// A delegate to ExceptionFactory method + /// + /// Method name + /// Response + /// Exceptions + public delegate Exception ExceptionFactory(string methodName, IRestResponse response); +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/GlobalConfiguration.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/GlobalConfiguration.cs new file mode 100644 index 00000000000..d8b196fc3e8 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/GlobalConfiguration.cs @@ -0,0 +1,34 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using System; +using System.Reflection; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; + +namespace IO.Swagger.Client +{ + /// + /// provides a compile-time extension point for globally configuring + /// API Clients. + /// + /// + /// A customized implementation via partial class may reside in another file and may + /// be excluded from automatic generation via a .swagger-codegen-ignore file. + /// + public partial class GlobalConfiguration : Configuration + { + + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/IApiAccessor.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/IApiAccessor.cs new file mode 100644 index 00000000000..20f9722af2a --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/IApiAccessor.cs @@ -0,0 +1,42 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using RestSharp; + +namespace IO.Swagger.Client +{ + /// + /// Represents configuration aspects required to interact with the API endpoints. + /// + public interface IApiAccessor + { + /// + /// Gets or sets the configuration object + /// + /// An instance of the Configuration + Configuration Configuration {get; set;} + + /// + /// Gets the base path of the API client. + /// + /// The base path + String GetBasePath(); + + /// + /// Provides a factory method hook for the creation of exceptions. + /// + ExceptionFactory ExceptionFactory { get; set; } + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/IReadableConfiguration.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/IReadableConfiguration.cs new file mode 100644 index 00000000000..32e87d6bd9a --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/IReadableConfiguration.cs @@ -0,0 +1,94 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using System.Collections.Generic; + +namespace IO.Swagger.Client +{ + /// + /// Represents a readable-only configuration contract. + /// + public interface IReadableConfiguration + { + /// + /// Gets the access token. + /// + /// Access token. + string AccessToken { get; } + + /// + /// Gets the API key. + /// + /// API key. + IDictionary ApiKey { get; } + + /// + /// Gets the API key prefix. + /// + /// API key prefix. + IDictionary ApiKeyPrefix { get; } + + /// + /// Gets the base path. + /// + /// Base path. + string BasePath { get; } + + /// + /// Gets the date time format. + /// + /// Date time foramt. + string DateTimeFormat { get; } + + /// + /// Gets the default header. + /// + /// Default header. + IDictionary DefaultHeader { get; } + + /// + /// Gets the temp folder path. + /// + /// Temp folder path. + string TempFolderPath { get; } + + /// + /// Gets the HTTP connection timeout (in milliseconds) + /// + /// HTTP connection timeout. + int Timeout { get; } + + /// + /// Gets the user agent. + /// + /// User agent. + string UserAgent { get; } + + /// + /// Gets the username. + /// + /// Username. + string Username { get; } + + /// + /// Gets the password. + /// + /// Password. + string Password { get; } + + /// + /// Gets the API key with prefix. + /// + /// API key identifier (authentication scheme). + /// API key with prefix. + string GetApiKeyWithPrefix(string apiKeyIdentifier); + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/JsonSubTypes.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/JsonSubTypes.cs new file mode 100644 index 00000000000..3a6da091b78 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/JsonSubTypes.cs @@ -0,0 +1,272 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace JsonSubTypes +{ + // Copied from project https://github.com/manuc66/JsonSubTypes + // https://raw.githubusercontent.com/manuc66/JsonSubTypes/07403192ea3f4959f6d42f5966ac56ceb0d6095b/JsonSubTypes/JsonSubtypes.cs + + public class JsonSubtypes : JsonConverter + { + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)] + public class KnownSubTypeAttribute : Attribute + { + public Type SubType { get; private set; } + public object AssociatedValue { get; private set; } + + public KnownSubTypeAttribute(Type subType, object associatedValue) + { + SubType = subType; + AssociatedValue = associatedValue; + } + } + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)] + public class KnownSubTypeWithPropertyAttribute : Attribute + { + public Type SubType { get; private set; } + public string PropertyName { get; private set; } + + public KnownSubTypeWithPropertyAttribute(Type subType, string propertyName) + { + SubType = subType; + PropertyName = propertyName; + } + } + + private readonly string _typeMappingPropertyName; + + private bool _isInsideRead; + private JsonReader _reader; + + public override bool CanRead + { + get + { + if (!_isInsideRead) + return true; + + return !string.IsNullOrEmpty(_reader.Path); + } + } + + public sealed override bool CanWrite + { + get { return false; } + } + + public JsonSubtypes() + { + } + + public JsonSubtypes(string typeMappingPropertyName) + { + _typeMappingPropertyName = typeMappingPropertyName; + } + + public override bool CanConvert(Type objectType) + { + return _typeMappingPropertyName != null; + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + throw new NotImplementedException(); + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.Comment) + reader.Read(); + + switch (reader.TokenType) + { + case JsonToken.Null: + return null; + case JsonToken.StartArray: + return ReadArray(reader, objectType, serializer); + case JsonToken.StartObject: + return ReadObject(reader, objectType, serializer); + default: + throw new Exception("Array: Unrecognized token: " + reader.TokenType); + } + } + + private IList ReadArray(JsonReader reader, Type targetType, JsonSerializer serializer) + { + var elementType = GetElementType(targetType); + + var list = CreateCompatibleList(targetType, elementType); + + while (reader.TokenType != JsonToken.EndArray && reader.Read()) + { + switch (reader.TokenType) + { + case JsonToken.Null: + list.Add(reader.Value); + break; + case JsonToken.Comment: + break; + case JsonToken.StartObject: + list.Add(ReadObject(reader, elementType, serializer)); + break; + case JsonToken.EndArray: + break; + default: + throw new Exception("Array: Unrecognized token: " + reader.TokenType); + } + } + if (targetType.IsArray) + { + var array = Array.CreateInstance(targetType.GetElementType(), list.Count); + list.CopyTo(array, 0); + list = array; + } + return list; + } + + private static IList CreateCompatibleList(Type targetContainerType, Type elementType) + { + IList list; + if (targetContainerType.IsArray || targetContainerType.GetTypeInfo().IsAbstract) + { + list = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(elementType)); + } + else + { + list = (IList)Activator.CreateInstance(targetContainerType); + } + return list; + } + + private static Type GetElementType(Type arrayOrGenericContainer) + { + Type elementType; + if (arrayOrGenericContainer.IsArray) + { + elementType = arrayOrGenericContainer.GetElementType(); + } + else + { + elementType = arrayOrGenericContainer.GenericTypeArguments[0]; + } + return elementType; + } + + private object ReadObject(JsonReader reader, Type objectType, JsonSerializer serializer) + { + var jObject = JObject.Load(reader); + + var targetType = GetType(jObject, objectType) ?? objectType; + + return _ReadJson(CreateAnotherReader(jObject, reader), targetType, null, serializer); + } + + private static JsonReader CreateAnotherReader(JObject jObject, JsonReader reader) + { + var jObjectReader = jObject.CreateReader(); + jObjectReader.Culture = reader.Culture; + jObjectReader.CloseInput = reader.CloseInput; + jObjectReader.SupportMultipleContent = reader.SupportMultipleContent; + jObjectReader.DateTimeZoneHandling = reader.DateTimeZoneHandling; + jObjectReader.FloatParseHandling = reader.FloatParseHandling; + jObjectReader.DateFormatString = reader.DateFormatString; + jObjectReader.DateParseHandling = reader.DateParseHandling; + return jObjectReader; + } + + public Type GetType(JObject jObject, Type parentType) + { + if (_typeMappingPropertyName == null) + { + return GetTypeByPropertyPresence(jObject, parentType); + } + return GetTypeFromDiscriminatorValue(jObject, parentType); + } + + private static Type GetTypeByPropertyPresence(JObject jObject, Type parentType) + { + foreach (var type in parentType.GetTypeInfo().GetCustomAttributes()) + { + JToken ignore; + if (jObject.TryGetValue(type.PropertyName, out ignore)) + { + return type.SubType; + } + } + return null; + } + + private Type GetTypeFromDiscriminatorValue(JObject jObject, Type parentType) + { + JToken jToken; + if (!jObject.TryGetValue(_typeMappingPropertyName, out jToken)) return null; + + var discriminatorValue = jToken.ToObject(); + if (discriminatorValue == null) return null; + + var typeMapping = GetSubTypeMapping(parentType); + if (typeMapping.Any()) + { + return GetTypeFromMapping(typeMapping, discriminatorValue); + } + return GetTypeByName(discriminatorValue as string, parentType); + } + + private static Type GetTypeByName(string typeName, Type parentType) + { + if (typeName == null) + return null; + + var insideAssembly = parentType.GetTypeInfo().Assembly; + + var typeByName = insideAssembly.GetType(typeName); + if (typeByName == null) + { + var searchLocation = parentType.FullName.Substring(0, parentType.FullName.Length - parentType.Name.Length); + typeByName = insideAssembly.GetType(searchLocation + typeName, false, true); + } + return typeByName; + } + + private static Type GetTypeFromMapping(IReadOnlyDictionary typeMapping, object discriminatorValue) + { + var targetlookupValueType = typeMapping.First().Key.GetType(); + var lookupValue = ConvertJsonValueToType(discriminatorValue, targetlookupValueType); + + Type targetType; + return typeMapping.TryGetValue(lookupValue, out targetType) ? targetType : null; + } + + private static Dictionary GetSubTypeMapping(Type type) + { + return type.GetTypeInfo().GetCustomAttributes().ToDictionary(x => x.AssociatedValue, x => x.SubType); + } + + private static object ConvertJsonValueToType(object objectType, Type targetlookupValueType) + { + if (targetlookupValueType.GetTypeInfo().IsEnum) + return Enum.ToObject(targetlookupValueType, objectType); + + return Convert.ChangeType(objectType, targetlookupValueType); + } + + protected object _ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + _reader = reader; + _isInsideRead = true; + try + { + return serializer.Deserialize(reader, objectType); + } + finally + { + _isInsideRead = false; + } + } + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/SwaggerDateConverter.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/SwaggerDateConverter.cs new file mode 100644 index 00000000000..82b825423dc --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Client/SwaggerDateConverter.cs @@ -0,0 +1,30 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using Newtonsoft.Json.Converters; + +namespace IO.Swagger.Client +{ + /// + /// Formatter for 'date' swagger formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types + /// + public class SwaggerDateConverter : IsoDateTimeConverter + { + /// + /// Initializes a new instance of the class. + /// + public SwaggerDateConverter() + { + // full-date = date-fullyear "-" date-month "-" date-mday + DateTimeFormat = "yyyy-MM-dd"; + } + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/IO.Swagger.csproj b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/IO.Swagger.csproj new file mode 100644 index 00000000000..fe43f0d9e52 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/IO.Swagger.csproj @@ -0,0 +1,72 @@ + + + + + + Debug + AnyCPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C} + Library + Properties + IO.Swagger + IO.Swagger + v4.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + $(SolutionDir)\packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll + ..\..\vendor\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll + + + $(SolutionDir)\packages\RestSharp.105.1.0\lib\net40\RestSharp.dll + ..\packages\RestSharp.105.1.0\lib\net40\RestSharp.dll + ..\..\packages\RestSharp.105.1.0\lib\net40\RestSharp.dll + ..\..\vendor\RestSharp.105.1.0\lib\net40\RestSharp.dll + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/IO.Swagger.nuspec b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/IO.Swagger.nuspec new file mode 100644 index 00000000000..1035d5d81e4 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/IO.Swagger.nuspec @@ -0,0 +1,41 @@ + + + + + $id$ + Swagger Library + + + $version$ + + + $author$ + + + $author$ + false + false + + + A library generated from a Swagger doc + http://swagger.io/terms/ + http://www.apache.org/licenses/LICENSE-2.0.html + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/AdditionalPropertiesClass.cs new file mode 100644 index 00000000000..ad54e625864 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/AdditionalPropertiesClass.cs @@ -0,0 +1,140 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// AdditionalPropertiesClass + /// + [DataContract] + public partial class AdditionalPropertiesClass : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// MapProperty. + /// MapOfMapProperty. + public AdditionalPropertiesClass(Dictionary MapProperty = default(Dictionary), Dictionary> MapOfMapProperty = default(Dictionary>)) + { + this.MapProperty = MapProperty; + this.MapOfMapProperty = MapOfMapProperty; + } + + /// + /// Gets or Sets MapProperty + /// + [DataMember(Name="map_property", EmitDefaultValue=false)] + public Dictionary MapProperty { get; set; } + + /// + /// Gets or Sets MapOfMapProperty + /// + [DataMember(Name="map_of_map_property", EmitDefaultValue=false)] + public Dictionary> MapOfMapProperty { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class AdditionalPropertiesClass {\n"); + sb.Append(" MapProperty: ").Append(MapProperty).Append("\n"); + sb.Append(" MapOfMapProperty: ").Append(MapOfMapProperty).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as AdditionalPropertiesClass); + } + + /// + /// Returns true if AdditionalPropertiesClass instances are equal + /// + /// Instance of AdditionalPropertiesClass to be compared + /// Boolean + public bool Equals(AdditionalPropertiesClass input) + { + if (input == null) + return false; + + return + ( + this.MapProperty == input.MapProperty || + this.MapProperty != null && + this.MapProperty.SequenceEqual(input.MapProperty) + ) && + ( + this.MapOfMapProperty == input.MapOfMapProperty || + this.MapOfMapProperty != null && + this.MapOfMapProperty.SequenceEqual(input.MapOfMapProperty) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.MapProperty != null) + hashCode = hashCode * 59 + this.MapProperty.GetHashCode(); + if (this.MapOfMapProperty != null) + hashCode = hashCode * 59 + this.MapOfMapProperty.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Animal.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Animal.cs new file mode 100644 index 00000000000..9b44060fb85 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Animal.cs @@ -0,0 +1,175 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using JsonSubTypes; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// Animal + /// + [DataContract] + [JsonConverter(typeof(JsonSubtypes), "className")] + [JsonSubtypes.KnownSubType(typeof(Dog), "Dog")] + [JsonSubtypes.KnownSubType(typeof(Cat), "Cat")] + public partial class Animal : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected Animal() { } + /// + /// Initializes a new instance of the class. + /// + /// ClassName (required). + /// Color (default to "red"). + public Animal(string ClassName = default(string), string Color = "red") + { + // to ensure "ClassName" is required (not null) + if (ClassName == null) + { + throw new InvalidDataException("ClassName is a required property for Animal and cannot be null"); + } + else + { + this.ClassName = ClassName; + } + // use default value if no "Color" provided + if (Color == null) + { + this.Color = "red"; + } + else + { + this.Color = Color; + } + } + + /// + /// Gets or Sets ClassName + /// + [DataMember(Name="className", EmitDefaultValue=false)] + public string ClassName { get; set; } + + /// + /// Gets or Sets Color + /// + [DataMember(Name="color", EmitDefaultValue=false)] + public string Color { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Animal {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Animal); + } + + /// + /// Returns true if Animal instances are equal + /// + /// Instance of Animal to be compared + /// Boolean + public bool Equals(Animal input) + { + if (input == null) + return false; + + return + ( + this.ClassName == input.ClassName || + (this.ClassName != null && + this.ClassName.Equals(input.ClassName)) + ) && + ( + this.Color == input.Color || + (this.Color != null && + this.Color.Equals(input.Color)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ClassName != null) + hashCode = hashCode * 59 + this.ClassName.GetHashCode(); + if (this.Color != null) + hashCode = hashCode * 59 + this.Color.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/AnimalFarm.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/AnimalFarm.cs new file mode 100644 index 00000000000..50767b53ec2 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/AnimalFarm.cs @@ -0,0 +1,110 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// AnimalFarm + /// + [DataContract] + public partial class AnimalFarm : List, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + public AnimalFarm() : base() + { + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class AnimalFarm {\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as AnimalFarm); + } + + /// + /// Returns true if AnimalFarm instances are equal + /// + /// Instance of AnimalFarm to be compared + /// Boolean + public bool Equals(AnimalFarm input) + { + if (input == null) + return false; + + return base.Equals(input); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ApiResponse.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ApiResponse.cs new file mode 100644 index 00000000000..fc654b07f27 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ApiResponse.cs @@ -0,0 +1,156 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// ApiResponse + /// + [DataContract] + public partial class ApiResponse : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Code. + /// Type. + /// Message. + public ApiResponse(int? Code = default(int?), string Type = default(string), string Message = default(string)) + { + this.Code = Code; + this.Type = Type; + this.Message = Message; + } + + /// + /// Gets or Sets Code + /// + [DataMember(Name="code", EmitDefaultValue=false)] + public int? Code { get; set; } + + /// + /// Gets or Sets Type + /// + [DataMember(Name="type", EmitDefaultValue=false)] + public string Type { get; set; } + + /// + /// Gets or Sets Message + /// + [DataMember(Name="message", EmitDefaultValue=false)] + public string Message { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class ApiResponse {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Type: ").Append(Type).Append("\n"); + sb.Append(" Message: ").Append(Message).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as ApiResponse); + } + + /// + /// Returns true if ApiResponse instances are equal + /// + /// Instance of ApiResponse to be compared + /// Boolean + public bool Equals(ApiResponse input) + { + if (input == null) + return false; + + return + ( + this.Code == input.Code || + (this.Code != null && + this.Code.Equals(input.Code)) + ) && + ( + this.Type == input.Type || + (this.Type != null && + this.Type.Equals(input.Type)) + ) && + ( + this.Message == input.Message || + (this.Message != null && + this.Message.Equals(input.Message)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Code != null) + hashCode = hashCode * 59 + this.Code.GetHashCode(); + if (this.Type != null) + hashCode = hashCode * 59 + this.Type.GetHashCode(); + if (this.Message != null) + hashCode = hashCode * 59 + this.Message.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ArrayOfArrayOfNumberOnly.cs new file mode 100644 index 00000000000..048483cdf48 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ArrayOfArrayOfNumberOnly.cs @@ -0,0 +1,124 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// ArrayOfArrayOfNumberOnly + /// + [DataContract] + public partial class ArrayOfArrayOfNumberOnly : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// ArrayArrayNumber. + public ArrayOfArrayOfNumberOnly(List> ArrayArrayNumber = default(List>)) + { + this.ArrayArrayNumber = ArrayArrayNumber; + } + + /// + /// Gets or Sets ArrayArrayNumber + /// + [DataMember(Name="ArrayArrayNumber", EmitDefaultValue=false)] + public List> ArrayArrayNumber { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class ArrayOfArrayOfNumberOnly {\n"); + sb.Append(" ArrayArrayNumber: ").Append(ArrayArrayNumber).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as ArrayOfArrayOfNumberOnly); + } + + /// + /// Returns true if ArrayOfArrayOfNumberOnly instances are equal + /// + /// Instance of ArrayOfArrayOfNumberOnly to be compared + /// Boolean + public bool Equals(ArrayOfArrayOfNumberOnly input) + { + if (input == null) + return false; + + return + ( + this.ArrayArrayNumber == input.ArrayArrayNumber || + this.ArrayArrayNumber != null && + this.ArrayArrayNumber.SequenceEqual(input.ArrayArrayNumber) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ArrayArrayNumber != null) + hashCode = hashCode * 59 + this.ArrayArrayNumber.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ArrayOfNumberOnly.cs new file mode 100644 index 00000000000..ccff9ee3f0e --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ArrayOfNumberOnly.cs @@ -0,0 +1,124 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// ArrayOfNumberOnly + /// + [DataContract] + public partial class ArrayOfNumberOnly : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// ArrayNumber. + public ArrayOfNumberOnly(List ArrayNumber = default(List)) + { + this.ArrayNumber = ArrayNumber; + } + + /// + /// Gets or Sets ArrayNumber + /// + [DataMember(Name="ArrayNumber", EmitDefaultValue=false)] + public List ArrayNumber { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class ArrayOfNumberOnly {\n"); + sb.Append(" ArrayNumber: ").Append(ArrayNumber).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as ArrayOfNumberOnly); + } + + /// + /// Returns true if ArrayOfNumberOnly instances are equal + /// + /// Instance of ArrayOfNumberOnly to be compared + /// Boolean + public bool Equals(ArrayOfNumberOnly input) + { + if (input == null) + return false; + + return + ( + this.ArrayNumber == input.ArrayNumber || + this.ArrayNumber != null && + this.ArrayNumber.SequenceEqual(input.ArrayNumber) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ArrayNumber != null) + hashCode = hashCode * 59 + this.ArrayNumber.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ArrayTest.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ArrayTest.cs new file mode 100644 index 00000000000..66cca739d5e --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ArrayTest.cs @@ -0,0 +1,156 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// ArrayTest + /// + [DataContract] + public partial class ArrayTest : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// ArrayOfString. + /// ArrayArrayOfInteger. + /// ArrayArrayOfModel. + public ArrayTest(List ArrayOfString = default(List), List> ArrayArrayOfInteger = default(List>), List> ArrayArrayOfModel = default(List>)) + { + this.ArrayOfString = ArrayOfString; + this.ArrayArrayOfInteger = ArrayArrayOfInteger; + this.ArrayArrayOfModel = ArrayArrayOfModel; + } + + /// + /// Gets or Sets ArrayOfString + /// + [DataMember(Name="array_of_string", EmitDefaultValue=false)] + public List ArrayOfString { get; set; } + + /// + /// Gets or Sets ArrayArrayOfInteger + /// + [DataMember(Name="array_array_of_integer", EmitDefaultValue=false)] + public List> ArrayArrayOfInteger { get; set; } + + /// + /// Gets or Sets ArrayArrayOfModel + /// + [DataMember(Name="array_array_of_model", EmitDefaultValue=false)] + public List> ArrayArrayOfModel { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class ArrayTest {\n"); + sb.Append(" ArrayOfString: ").Append(ArrayOfString).Append("\n"); + sb.Append(" ArrayArrayOfInteger: ").Append(ArrayArrayOfInteger).Append("\n"); + sb.Append(" ArrayArrayOfModel: ").Append(ArrayArrayOfModel).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as ArrayTest); + } + + /// + /// Returns true if ArrayTest instances are equal + /// + /// Instance of ArrayTest to be compared + /// Boolean + public bool Equals(ArrayTest input) + { + if (input == null) + return false; + + return + ( + this.ArrayOfString == input.ArrayOfString || + this.ArrayOfString != null && + this.ArrayOfString.SequenceEqual(input.ArrayOfString) + ) && + ( + this.ArrayArrayOfInteger == input.ArrayArrayOfInteger || + this.ArrayArrayOfInteger != null && + this.ArrayArrayOfInteger.SequenceEqual(input.ArrayArrayOfInteger) + ) && + ( + this.ArrayArrayOfModel == input.ArrayArrayOfModel || + this.ArrayArrayOfModel != null && + this.ArrayArrayOfModel.SequenceEqual(input.ArrayArrayOfModel) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ArrayOfString != null) + hashCode = hashCode * 59 + this.ArrayOfString.GetHashCode(); + if (this.ArrayArrayOfInteger != null) + hashCode = hashCode * 59 + this.ArrayArrayOfInteger.GetHashCode(); + if (this.ArrayArrayOfModel != null) + hashCode = hashCode * 59 + this.ArrayArrayOfModel.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Capitalization.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Capitalization.cs new file mode 100644 index 00000000000..b306023afd0 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Capitalization.cs @@ -0,0 +1,205 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// Capitalization + /// + [DataContract] + public partial class Capitalization : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// SmallCamel. + /// CapitalCamel. + /// SmallSnake. + /// CapitalSnake. + /// SCAETHFlowPoints. + /// Name of the pet . + public Capitalization(string SmallCamel = default(string), string CapitalCamel = default(string), string SmallSnake = default(string), string CapitalSnake = default(string), string SCAETHFlowPoints = default(string), string ATT_NAME = default(string)) + { + this.SmallCamel = SmallCamel; + this.CapitalCamel = CapitalCamel; + this.SmallSnake = SmallSnake; + this.CapitalSnake = CapitalSnake; + this.SCAETHFlowPoints = SCAETHFlowPoints; + this.ATT_NAME = ATT_NAME; + } + + /// + /// Gets or Sets SmallCamel + /// + [DataMember(Name="smallCamel", EmitDefaultValue=false)] + public string SmallCamel { get; set; } + + /// + /// Gets or Sets CapitalCamel + /// + [DataMember(Name="CapitalCamel", EmitDefaultValue=false)] + public string CapitalCamel { get; set; } + + /// + /// Gets or Sets SmallSnake + /// + [DataMember(Name="small_Snake", EmitDefaultValue=false)] + public string SmallSnake { get; set; } + + /// + /// Gets or Sets CapitalSnake + /// + [DataMember(Name="Capital_Snake", EmitDefaultValue=false)] + public string CapitalSnake { get; set; } + + /// + /// Gets or Sets SCAETHFlowPoints + /// + [DataMember(Name="SCA_ETH_Flow_Points", EmitDefaultValue=false)] + public string SCAETHFlowPoints { get; set; } + + /// + /// Name of the pet + /// + /// Name of the pet + [DataMember(Name="ATT_NAME", EmitDefaultValue=false)] + public string ATT_NAME { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Capitalization {\n"); + sb.Append(" SmallCamel: ").Append(SmallCamel).Append("\n"); + sb.Append(" CapitalCamel: ").Append(CapitalCamel).Append("\n"); + sb.Append(" SmallSnake: ").Append(SmallSnake).Append("\n"); + sb.Append(" CapitalSnake: ").Append(CapitalSnake).Append("\n"); + sb.Append(" SCAETHFlowPoints: ").Append(SCAETHFlowPoints).Append("\n"); + sb.Append(" ATT_NAME: ").Append(ATT_NAME).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Capitalization); + } + + /// + /// Returns true if Capitalization instances are equal + /// + /// Instance of Capitalization to be compared + /// Boolean + public bool Equals(Capitalization input) + { + if (input == null) + return false; + + return + ( + this.SmallCamel == input.SmallCamel || + (this.SmallCamel != null && + this.SmallCamel.Equals(input.SmallCamel)) + ) && + ( + this.CapitalCamel == input.CapitalCamel || + (this.CapitalCamel != null && + this.CapitalCamel.Equals(input.CapitalCamel)) + ) && + ( + this.SmallSnake == input.SmallSnake || + (this.SmallSnake != null && + this.SmallSnake.Equals(input.SmallSnake)) + ) && + ( + this.CapitalSnake == input.CapitalSnake || + (this.CapitalSnake != null && + this.CapitalSnake.Equals(input.CapitalSnake)) + ) && + ( + this.SCAETHFlowPoints == input.SCAETHFlowPoints || + (this.SCAETHFlowPoints != null && + this.SCAETHFlowPoints.Equals(input.SCAETHFlowPoints)) + ) && + ( + this.ATT_NAME == input.ATT_NAME || + (this.ATT_NAME != null && + this.ATT_NAME.Equals(input.ATT_NAME)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.SmallCamel != null) + hashCode = hashCode * 59 + this.SmallCamel.GetHashCode(); + if (this.CapitalCamel != null) + hashCode = hashCode * 59 + this.CapitalCamel.GetHashCode(); + if (this.SmallSnake != null) + hashCode = hashCode * 59 + this.SmallSnake.GetHashCode(); + if (this.CapitalSnake != null) + hashCode = hashCode * 59 + this.CapitalSnake.GetHashCode(); + if (this.SCAETHFlowPoints != null) + hashCode = hashCode * 59 + this.SCAETHFlowPoints.GetHashCode(); + if (this.ATT_NAME != null) + hashCode = hashCode * 59 + this.ATT_NAME.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Cat.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Cat.cs new file mode 100644 index 00000000000..b012af5de70 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Cat.cs @@ -0,0 +1,131 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// Cat + /// + [DataContract] + public partial class Cat : Animal, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected Cat() { } + /// + /// Initializes a new instance of the class. + /// + /// Declawed. + public Cat(bool? Declawed = default(bool?), string ClassName = "Cat", string Color = "red") : base(ClassName, Color) + { + this.Declawed = Declawed; + } + + /// + /// Gets or Sets Declawed + /// + [DataMember(Name="declawed", EmitDefaultValue=false)] + public bool? Declawed { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Cat {\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); + sb.Append(" Declawed: ").Append(Declawed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Cat); + } + + /// + /// Returns true if Cat instances are equal + /// + /// Instance of Cat to be compared + /// Boolean + public bool Equals(Cat input) + { + if (input == null) + return false; + + return base.Equals(input) && + ( + this.Declawed == input.Declawed || + (this.Declawed != null && + this.Declawed.Equals(input.Declawed)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + if (this.Declawed != null) + hashCode = hashCode * 59 + this.Declawed.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + foreach(var x in BaseValidate(validationContext)) yield return x; + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Category.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Category.cs new file mode 100644 index 00000000000..c2a3462cf99 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Category.cs @@ -0,0 +1,140 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// Category + /// + [DataContract] + public partial class Category : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Id. + /// Name. + public Category(long? Id = default(long?), string Name = default(string)) + { + this.Id = Id; + this.Name = Name; + } + + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Category {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Category); + } + + /// + /// Returns true if Category instances are equal + /// + /// Instance of Category to be compared + /// Boolean + public bool Equals(Category input) + { + if (input == null) + return false; + + return + ( + this.Id == input.Id || + (this.Id != null && + this.Id.Equals(input.Id)) + ) && + ( + this.Name == input.Name || + (this.Name != null && + this.Name.Equals(input.Name)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Id != null) + hashCode = hashCode * 59 + this.Id.GetHashCode(); + if (this.Name != null) + hashCode = hashCode * 59 + this.Name.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ClassModel.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ClassModel.cs new file mode 100644 index 00000000000..4d00dbef97b --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ClassModel.cs @@ -0,0 +1,124 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// Model for testing model with \"_class\" property + /// + [DataContract] + public partial class ClassModel : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// _Class. + public ClassModel(string _Class = default(string)) + { + this._Class = _Class; + } + + /// + /// Gets or Sets _Class + /// + [DataMember(Name="_class", EmitDefaultValue=false)] + public string _Class { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class ClassModel {\n"); + sb.Append(" _Class: ").Append(_Class).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as ClassModel); + } + + /// + /// Returns true if ClassModel instances are equal + /// + /// Instance of ClassModel to be compared + /// Boolean + public bool Equals(ClassModel input) + { + if (input == null) + return false; + + return + ( + this._Class == input._Class || + (this._Class != null && + this._Class.Equals(input._Class)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this._Class != null) + hashCode = hashCode * 59 + this._Class.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Dog.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Dog.cs new file mode 100644 index 00000000000..f92b01a5bfb --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Dog.cs @@ -0,0 +1,131 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// Dog + /// + [DataContract] + public partial class Dog : Animal, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected Dog() { } + /// + /// Initializes a new instance of the class. + /// + /// Breed. + public Dog(string Breed = default(string), string ClassName = "Dog", string Color = "red") : base(ClassName, Color) + { + this.Breed = Breed; + } + + /// + /// Gets or Sets Breed + /// + [DataMember(Name="breed", EmitDefaultValue=false)] + public string Breed { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Dog {\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); + sb.Append(" Breed: ").Append(Breed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Dog); + } + + /// + /// Returns true if Dog instances are equal + /// + /// Instance of Dog to be compared + /// Boolean + public bool Equals(Dog input) + { + if (input == null) + return false; + + return base.Equals(input) && + ( + this.Breed == input.Breed || + (this.Breed != null && + this.Breed.Equals(input.Breed)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + if (this.Breed != null) + hashCode = hashCode * 59 + this.Breed.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + foreach(var x in BaseValidate(validationContext)) yield return x; + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/EnumArrays.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/EnumArrays.cs new file mode 100644 index 00000000000..64f705748f2 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/EnumArrays.cs @@ -0,0 +1,181 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// EnumArrays + /// + [DataContract] + public partial class EnumArrays : IEquatable, IValidatableObject + { + /// + /// Gets or Sets JustSymbol + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum JustSymbolEnum + { + + /// + /// Enum GreaterThanOrEqualTo for ">=" + /// + [EnumMember(Value = ">=")] + GreaterThanOrEqualTo, + + /// + /// Enum Dollar for "$" + /// + [EnumMember(Value = "$")] + Dollar + } + + + /// + /// Gets or Sets ArrayEnum + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ArrayEnumEnum + { + + /// + /// Enum Fish for "fish" + /// + [EnumMember(Value = "fish")] + Fish, + + /// + /// Enum Crab for "crab" + /// + [EnumMember(Value = "crab")] + Crab + } + + /// + /// Gets or Sets JustSymbol + /// + [DataMember(Name="just_symbol", EmitDefaultValue=false)] + public JustSymbolEnum? JustSymbol { get; set; } + /// + /// Gets or Sets ArrayEnum + /// + [DataMember(Name="array_enum", EmitDefaultValue=false)] + public List ArrayEnum { get; set; } + /// + /// Initializes a new instance of the class. + /// + /// JustSymbol. + /// ArrayEnum. + public EnumArrays(JustSymbolEnum? JustSymbol = default(JustSymbolEnum?), List ArrayEnum = default(List)) + { + this.JustSymbol = JustSymbol; + this.ArrayEnum = ArrayEnum; + } + + + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class EnumArrays {\n"); + sb.Append(" JustSymbol: ").Append(JustSymbol).Append("\n"); + sb.Append(" ArrayEnum: ").Append(ArrayEnum).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as EnumArrays); + } + + /// + /// Returns true if EnumArrays instances are equal + /// + /// Instance of EnumArrays to be compared + /// Boolean + public bool Equals(EnumArrays input) + { + if (input == null) + return false; + + return + ( + this.JustSymbol == input.JustSymbol || + (this.JustSymbol != null && + this.JustSymbol.Equals(input.JustSymbol)) + ) && + ( + this.ArrayEnum == input.ArrayEnum || + this.ArrayEnum != null && + this.ArrayEnum.SequenceEqual(input.ArrayEnum) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.JustSymbol != null) + hashCode = hashCode * 59 + this.JustSymbol.GetHashCode(); + if (this.ArrayEnum != null) + hashCode = hashCode * 59 + this.ArrayEnum.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/EnumClass.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/EnumClass.cs new file mode 100644 index 00000000000..77fc0a8e299 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/EnumClass.cs @@ -0,0 +1,53 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// Defines EnumClass + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum EnumClass + { + + /// + /// Enum Abc for "_abc" + /// + [EnumMember(Value = "_abc")] + Abc, + + /// + /// Enum Efg for "-efg" + /// + [EnumMember(Value = "-efg")] + Efg, + + /// + /// Enum Xyz for "(xyz)" + /// + [EnumMember(Value = "(xyz)")] + Xyz + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/EnumTest.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/EnumTest.cs new file mode 100644 index 00000000000..ebcfe3b0e46 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/EnumTest.cs @@ -0,0 +1,238 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// EnumTest + /// + [DataContract] + public partial class EnumTest : IEquatable, IValidatableObject + { + /// + /// Gets or Sets EnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum EnumStringEnum + { + + /// + /// Enum UPPER for "UPPER" + /// + [EnumMember(Value = "UPPER")] + UPPER, + + /// + /// Enum Lower for "lower" + /// + [EnumMember(Value = "lower")] + Lower, + + /// + /// Enum Empty for "" + /// + [EnumMember(Value = "")] + Empty + } + + /// + /// Gets or Sets EnumInteger + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum EnumIntegerEnum + { + + /// + /// Enum NUMBER_1 for 1 + /// + [EnumMember(Value = "1")] + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for -1 + /// + [EnumMember(Value = "-1")] + NUMBER_MINUS_1 = -1 + } + + /// + /// Gets or Sets EnumNumber + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum EnumNumberEnum + { + + /// + /// Enum NUMBER_1_DOT_1 for 1.1 + /// + [EnumMember(Value = "1.1")] + NUMBER_1_DOT_1, + + /// + /// Enum NUMBER_MINUS_1_DOT_2 for -1.2 + /// + [EnumMember(Value = "-1.2")] + NUMBER_MINUS_1_DOT_2 + } + + /// + /// Gets or Sets EnumString + /// + [DataMember(Name="enum_string", EmitDefaultValue=false)] + public EnumStringEnum? EnumString { get; set; } + /// + /// Gets or Sets EnumInteger + /// + [DataMember(Name="enum_integer", EmitDefaultValue=false)] + public EnumIntegerEnum? EnumInteger { get; set; } + /// + /// Gets or Sets EnumNumber + /// + [DataMember(Name="enum_number", EmitDefaultValue=false)] + public EnumNumberEnum? EnumNumber { get; set; } + /// + /// Initializes a new instance of the class. + /// + /// EnumString. + /// EnumInteger. + /// EnumNumber. + /// OuterEnum. + public EnumTest(EnumStringEnum? EnumString = default(EnumStringEnum?), EnumIntegerEnum? EnumInteger = default(EnumIntegerEnum?), EnumNumberEnum? EnumNumber = default(EnumNumberEnum?), OuterEnum OuterEnum = default(OuterEnum)) + { + this.EnumString = EnumString; + this.EnumInteger = EnumInteger; + this.EnumNumber = EnumNumber; + this.OuterEnum = OuterEnum; + } + + + + + /// + /// Gets or Sets OuterEnum + /// + [DataMember(Name="outerEnum", EmitDefaultValue=false)] + public OuterEnum OuterEnum { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class EnumTest {\n"); + sb.Append(" EnumString: ").Append(EnumString).Append("\n"); + sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n"); + sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n"); + sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as EnumTest); + } + + /// + /// Returns true if EnumTest instances are equal + /// + /// Instance of EnumTest to be compared + /// Boolean + public bool Equals(EnumTest input) + { + if (input == null) + return false; + + return + ( + this.EnumString == input.EnumString || + (this.EnumString != null && + this.EnumString.Equals(input.EnumString)) + ) && + ( + this.EnumInteger == input.EnumInteger || + (this.EnumInteger != null && + this.EnumInteger.Equals(input.EnumInteger)) + ) && + ( + this.EnumNumber == input.EnumNumber || + (this.EnumNumber != null && + this.EnumNumber.Equals(input.EnumNumber)) + ) && + ( + this.OuterEnum == input.OuterEnum || + (this.OuterEnum != null && + this.OuterEnum.Equals(input.OuterEnum)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.EnumString != null) + hashCode = hashCode * 59 + this.EnumString.GetHashCode(); + if (this.EnumInteger != null) + hashCode = hashCode * 59 + this.EnumInteger.GetHashCode(); + if (this.EnumNumber != null) + hashCode = hashCode * 59 + this.EnumNumber.GetHashCode(); + if (this.OuterEnum != null) + hashCode = hashCode * 59 + this.OuterEnum.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/FormatTest.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/FormatTest.cs new file mode 100644 index 00000000000..f651fbf5d5e --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/FormatTest.cs @@ -0,0 +1,433 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// FormatTest + /// + [DataContract] + public partial class FormatTest : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected FormatTest() { } + /// + /// Initializes a new instance of the class. + /// + /// Integer. + /// Int32. + /// Int64. + /// Number (required). + /// _Float. + /// _Double. + /// _String. + /// _Byte (required). + /// Binary. + /// Date (required). + /// DateTime. + /// Uuid. + /// Password (required). + public FormatTest(int? Integer = default(int?), int? Int32 = default(int?), long? Int64 = default(long?), decimal? Number = default(decimal?), float? _Float = default(float?), double? _Double = default(double?), string _String = default(string), byte[] _Byte = default(byte[]), byte[] Binary = default(byte[]), DateTime? Date = default(DateTime?), DateTime? DateTime = default(DateTime?), Guid? Uuid = default(Guid?), string Password = default(string)) + { + // to ensure "Number" is required (not null) + if (Number == null) + { + throw new InvalidDataException("Number is a required property for FormatTest and cannot be null"); + } + else + { + this.Number = Number; + } + // to ensure "_Byte" is required (not null) + if (_Byte == null) + { + throw new InvalidDataException("_Byte is a required property for FormatTest and cannot be null"); + } + else + { + this._Byte = _Byte; + } + // to ensure "Date" is required (not null) + if (Date == null) + { + throw new InvalidDataException("Date is a required property for FormatTest and cannot be null"); + } + else + { + this.Date = Date; + } + // to ensure "Password" is required (not null) + if (Password == null) + { + throw new InvalidDataException("Password is a required property for FormatTest and cannot be null"); + } + else + { + this.Password = Password; + } + this.Integer = Integer; + this.Int32 = Int32; + this.Int64 = Int64; + this._Float = _Float; + this._Double = _Double; + this._String = _String; + this.Binary = Binary; + this.DateTime = DateTime; + this.Uuid = Uuid; + } + + /// + /// Gets or Sets Integer + /// + [DataMember(Name="integer", EmitDefaultValue=false)] + public int? Integer { get; set; } + + /// + /// Gets or Sets Int32 + /// + [DataMember(Name="int32", EmitDefaultValue=false)] + public int? Int32 { get; set; } + + /// + /// Gets or Sets Int64 + /// + [DataMember(Name="int64", EmitDefaultValue=false)] + public long? Int64 { get; set; } + + /// + /// Gets or Sets Number + /// + [DataMember(Name="number", EmitDefaultValue=false)] + public decimal? Number { get; set; } + + /// + /// Gets or Sets _Float + /// + [DataMember(Name="float", EmitDefaultValue=false)] + public float? _Float { get; set; } + + /// + /// Gets or Sets _Double + /// + [DataMember(Name="double", EmitDefaultValue=false)] + public double? _Double { get; set; } + + /// + /// Gets or Sets _String + /// + [DataMember(Name="string", EmitDefaultValue=false)] + public string _String { get; set; } + + /// + /// Gets or Sets _Byte + /// + [DataMember(Name="byte", EmitDefaultValue=false)] + public byte[] _Byte { get; set; } + + /// + /// Gets or Sets Binary + /// + [DataMember(Name="binary", EmitDefaultValue=false)] + public byte[] Binary { get; set; } + + /// + /// Gets or Sets Date + /// + [DataMember(Name="date", EmitDefaultValue=false)] + [JsonConverter(typeof(SwaggerDateConverter))] + public DateTime? Date { get; set; } + + /// + /// Gets or Sets DateTime + /// + [DataMember(Name="dateTime", EmitDefaultValue=false)] + public DateTime? DateTime { get; set; } + + /// + /// Gets or Sets Uuid + /// + [DataMember(Name="uuid", EmitDefaultValue=false)] + public Guid? Uuid { get; set; } + + /// + /// Gets or Sets Password + /// + [DataMember(Name="password", EmitDefaultValue=false)] + public string Password { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class FormatTest {\n"); + sb.Append(" Integer: ").Append(Integer).Append("\n"); + sb.Append(" Int32: ").Append(Int32).Append("\n"); + sb.Append(" Int64: ").Append(Int64).Append("\n"); + sb.Append(" Number: ").Append(Number).Append("\n"); + sb.Append(" _Float: ").Append(_Float).Append("\n"); + sb.Append(" _Double: ").Append(_Double).Append("\n"); + sb.Append(" _String: ").Append(_String).Append("\n"); + sb.Append(" _Byte: ").Append(_Byte).Append("\n"); + sb.Append(" Binary: ").Append(Binary).Append("\n"); + sb.Append(" Date: ").Append(Date).Append("\n"); + sb.Append(" DateTime: ").Append(DateTime).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as FormatTest); + } + + /// + /// Returns true if FormatTest instances are equal + /// + /// Instance of FormatTest to be compared + /// Boolean + public bool Equals(FormatTest input) + { + if (input == null) + return false; + + return + ( + this.Integer == input.Integer || + (this.Integer != null && + this.Integer.Equals(input.Integer)) + ) && + ( + this.Int32 == input.Int32 || + (this.Int32 != null && + this.Int32.Equals(input.Int32)) + ) && + ( + this.Int64 == input.Int64 || + (this.Int64 != null && + this.Int64.Equals(input.Int64)) + ) && + ( + this.Number == input.Number || + (this.Number != null && + this.Number.Equals(input.Number)) + ) && + ( + this._Float == input._Float || + (this._Float != null && + this._Float.Equals(input._Float)) + ) && + ( + this._Double == input._Double || + (this._Double != null && + this._Double.Equals(input._Double)) + ) && + ( + this._String == input._String || + (this._String != null && + this._String.Equals(input._String)) + ) && + ( + this._Byte == input._Byte || + (this._Byte != null && + this._Byte.Equals(input._Byte)) + ) && + ( + this.Binary == input.Binary || + (this.Binary != null && + this.Binary.Equals(input.Binary)) + ) && + ( + this.Date == input.Date || + (this.Date != null && + this.Date.Equals(input.Date)) + ) && + ( + this.DateTime == input.DateTime || + (this.DateTime != null && + this.DateTime.Equals(input.DateTime)) + ) && + ( + this.Uuid == input.Uuid || + (this.Uuid != null && + this.Uuid.Equals(input.Uuid)) + ) && + ( + this.Password == input.Password || + (this.Password != null && + this.Password.Equals(input.Password)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Integer != null) + hashCode = hashCode * 59 + this.Integer.GetHashCode(); + if (this.Int32 != null) + hashCode = hashCode * 59 + this.Int32.GetHashCode(); + if (this.Int64 != null) + hashCode = hashCode * 59 + this.Int64.GetHashCode(); + if (this.Number != null) + hashCode = hashCode * 59 + this.Number.GetHashCode(); + if (this._Float != null) + hashCode = hashCode * 59 + this._Float.GetHashCode(); + if (this._Double != null) + hashCode = hashCode * 59 + this._Double.GetHashCode(); + if (this._String != null) + hashCode = hashCode * 59 + this._String.GetHashCode(); + if (this._Byte != null) + hashCode = hashCode * 59 + this._Byte.GetHashCode(); + if (this.Binary != null) + hashCode = hashCode * 59 + this.Binary.GetHashCode(); + if (this.Date != null) + hashCode = hashCode * 59 + this.Date.GetHashCode(); + if (this.DateTime != null) + hashCode = hashCode * 59 + this.DateTime.GetHashCode(); + if (this.Uuid != null) + hashCode = hashCode * 59 + this.Uuid.GetHashCode(); + if (this.Password != null) + hashCode = hashCode * 59 + this.Password.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + // Integer (int?) maximum + if(this.Integer > (int?)100) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value less than or equal to 100.", new [] { "Integer" }); + } + + // Integer (int?) minimum + if(this.Integer < (int?)10) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value greater than or equal to 10.", new [] { "Integer" }); + } + + // Int32 (int?) maximum + if(this.Int32 > (int?)200) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value less than or equal to 200.", new [] { "Int32" }); + } + + // Int32 (int?) minimum + if(this.Int32 < (int?)20) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value greater than or equal to 20.", new [] { "Int32" }); + } + + // Number (decimal?) maximum + if(this.Number > (decimal?)543.2) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Number, must be a value less than or equal to 543.2.", new [] { "Number" }); + } + + // Number (decimal?) minimum + if(this.Number < (decimal?)32.1) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Number, must be a value greater than or equal to 32.1.", new [] { "Number" }); + } + + // _Float (float?) maximum + if(this._Float > (float?)987.6) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for _Float, must be a value less than or equal to 987.6.", new [] { "_Float" }); + } + + // _Float (float?) minimum + if(this._Float < (float?)54.3) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for _Float, must be a value greater than or equal to 54.3.", new [] { "_Float" }); + } + + // _Double (double?) maximum + if(this._Double > (double?)123.4) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for _Double, must be a value less than or equal to 123.4.", new [] { "_Double" }); + } + + // _Double (double?) minimum + if(this._Double < (double?)67.8) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for _Double, must be a value greater than or equal to 67.8.", new [] { "_Double" }); + } + + // _String (string) pattern + Regex regex_String = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); + if (false == regex_String.Match(this._String).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for _String, must match a pattern of " + regex_String, new [] { "_String" }); + } + + // Password (string) maxLength + if(this.Password != null && this.Password.Length > 64) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Password, length must be less than 64.", new [] { "Password" }); + } + + // Password (string) minLength + if(this.Password != null && this.Password.Length < 10) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Password, length must be greater than 10.", new [] { "Password" }); + } + + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/HasOnlyReadOnly.cs new file mode 100644 index 00000000000..8c15b451b1f --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/HasOnlyReadOnly.cs @@ -0,0 +1,137 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// HasOnlyReadOnly + /// + [DataContract] + public partial class HasOnlyReadOnly : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + public HasOnlyReadOnly() + { + } + + /// + /// Gets or Sets Bar + /// + [DataMember(Name="bar", EmitDefaultValue=false)] + public string Bar { get; private set; } + + /// + /// Gets or Sets Foo + /// + [DataMember(Name="foo", EmitDefaultValue=false)] + public string Foo { get; private set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class HasOnlyReadOnly {\n"); + sb.Append(" Bar: ").Append(Bar).Append("\n"); + sb.Append(" Foo: ").Append(Foo).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as HasOnlyReadOnly); + } + + /// + /// Returns true if HasOnlyReadOnly instances are equal + /// + /// Instance of HasOnlyReadOnly to be compared + /// Boolean + public bool Equals(HasOnlyReadOnly input) + { + if (input == null) + return false; + + return + ( + this.Bar == input.Bar || + (this.Bar != null && + this.Bar.Equals(input.Bar)) + ) && + ( + this.Foo == input.Foo || + (this.Foo != null && + this.Foo.Equals(input.Foo)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Bar != null) + hashCode = hashCode * 59 + this.Bar.GetHashCode(); + if (this.Foo != null) + hashCode = hashCode * 59 + this.Foo.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/List.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/List.cs new file mode 100644 index 00000000000..52a234d8cd5 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/List.cs @@ -0,0 +1,124 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// List + /// + [DataContract] + public partial class List : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// _123List. + public List(string _123List = default(string)) + { + this._123List = _123List; + } + + /// + /// Gets or Sets _123List + /// + [DataMember(Name="123-list", EmitDefaultValue=false)] + public string _123List { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class List {\n"); + sb.Append(" _123List: ").Append(_123List).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as List); + } + + /// + /// Returns true if List instances are equal + /// + /// Instance of List to be compared + /// Boolean + public bool Equals(List input) + { + if (input == null) + return false; + + return + ( + this._123List == input._123List || + (this._123List != null && + this._123List.Equals(input._123List)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this._123List != null) + hashCode = hashCode * 59 + this._123List.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/MapTest.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/MapTest.cs new file mode 100644 index 00000000000..d5fe36c4151 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/MapTest.cs @@ -0,0 +1,161 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// MapTest + /// + [DataContract] + public partial class MapTest : IEquatable, IValidatableObject + { + + /// + /// Gets or Sets Inner + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum InnerEnum + { + + /// + /// Enum UPPER for "UPPER" + /// + [EnumMember(Value = "UPPER")] + UPPER, + + /// + /// Enum Lower for "lower" + /// + [EnumMember(Value = "lower")] + Lower + } + + /// + /// Gets or Sets MapOfEnumString + /// + [DataMember(Name="map_of_enum_string", EmitDefaultValue=false)] + public Dictionary MapOfEnumString { get; set; } + /// + /// Initializes a new instance of the class. + /// + /// MapMapOfString. + /// MapOfEnumString. + public MapTest(Dictionary> MapMapOfString = default(Dictionary>), Dictionary MapOfEnumString = default(Dictionary)) + { + this.MapMapOfString = MapMapOfString; + this.MapOfEnumString = MapOfEnumString; + } + + /// + /// Gets or Sets MapMapOfString + /// + [DataMember(Name="map_map_of_string", EmitDefaultValue=false)] + public Dictionary> MapMapOfString { get; set; } + + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MapTest {\n"); + sb.Append(" MapMapOfString: ").Append(MapMapOfString).Append("\n"); + sb.Append(" MapOfEnumString: ").Append(MapOfEnumString).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as MapTest); + } + + /// + /// Returns true if MapTest instances are equal + /// + /// Instance of MapTest to be compared + /// Boolean + public bool Equals(MapTest input) + { + if (input == null) + return false; + + return + ( + this.MapMapOfString == input.MapMapOfString || + this.MapMapOfString != null && + this.MapMapOfString.SequenceEqual(input.MapMapOfString) + ) && + ( + this.MapOfEnumString == input.MapOfEnumString || + this.MapOfEnumString != null && + this.MapOfEnumString.SequenceEqual(input.MapOfEnumString) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.MapMapOfString != null) + hashCode = hashCode * 59 + this.MapMapOfString.GetHashCode(); + if (this.MapOfEnumString != null) + hashCode = hashCode * 59 + this.MapOfEnumString.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/MixedPropertiesAndAdditionalPropertiesClass.cs new file mode 100644 index 00000000000..fb0a3998053 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -0,0 +1,156 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// MixedPropertiesAndAdditionalPropertiesClass + /// + [DataContract] + public partial class MixedPropertiesAndAdditionalPropertiesClass : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Uuid. + /// DateTime. + /// Map. + public MixedPropertiesAndAdditionalPropertiesClass(Guid? Uuid = default(Guid?), DateTime? DateTime = default(DateTime?), Dictionary Map = default(Dictionary)) + { + this.Uuid = Uuid; + this.DateTime = DateTime; + this.Map = Map; + } + + /// + /// Gets or Sets Uuid + /// + [DataMember(Name="uuid", EmitDefaultValue=false)] + public Guid? Uuid { get; set; } + + /// + /// Gets or Sets DateTime + /// + [DataMember(Name="dateTime", EmitDefaultValue=false)] + public DateTime? DateTime { get; set; } + + /// + /// Gets or Sets Map + /// + [DataMember(Name="map", EmitDefaultValue=false)] + public Dictionary Map { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" DateTime: ").Append(DateTime).Append("\n"); + sb.Append(" Map: ").Append(Map).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as MixedPropertiesAndAdditionalPropertiesClass); + } + + /// + /// Returns true if MixedPropertiesAndAdditionalPropertiesClass instances are equal + /// + /// Instance of MixedPropertiesAndAdditionalPropertiesClass to be compared + /// Boolean + public bool Equals(MixedPropertiesAndAdditionalPropertiesClass input) + { + if (input == null) + return false; + + return + ( + this.Uuid == input.Uuid || + (this.Uuid != null && + this.Uuid.Equals(input.Uuid)) + ) && + ( + this.DateTime == input.DateTime || + (this.DateTime != null && + this.DateTime.Equals(input.DateTime)) + ) && + ( + this.Map == input.Map || + this.Map != null && + this.Map.SequenceEqual(input.Map) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Uuid != null) + hashCode = hashCode * 59 + this.Uuid.GetHashCode(); + if (this.DateTime != null) + hashCode = hashCode * 59 + this.DateTime.GetHashCode(); + if (this.Map != null) + hashCode = hashCode * 59 + this.Map.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Model200Response.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Model200Response.cs new file mode 100644 index 00000000000..3d11d1188eb --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Model200Response.cs @@ -0,0 +1,140 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// Model for testing model name starting with number + /// + [DataContract] + public partial class Model200Response : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Name. + /// _Class. + public Model200Response(int? Name = default(int?), string _Class = default(string)) + { + this.Name = Name; + this._Class = _Class; + } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public int? Name { get; set; } + + /// + /// Gets or Sets _Class + /// + [DataMember(Name="class", EmitDefaultValue=false)] + public string _Class { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Model200Response {\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" _Class: ").Append(_Class).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Model200Response); + } + + /// + /// Returns true if Model200Response instances are equal + /// + /// Instance of Model200Response to be compared + /// Boolean + public bool Equals(Model200Response input) + { + if (input == null) + return false; + + return + ( + this.Name == input.Name || + (this.Name != null && + this.Name.Equals(input.Name)) + ) && + ( + this._Class == input._Class || + (this._Class != null && + this._Class.Equals(input._Class)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Name != null) + hashCode = hashCode * 59 + this.Name.GetHashCode(); + if (this._Class != null) + hashCode = hashCode * 59 + this._Class.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ModelClient.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ModelClient.cs new file mode 100644 index 00000000000..5184c5c33d2 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ModelClient.cs @@ -0,0 +1,124 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// ModelClient + /// + [DataContract] + public partial class ModelClient : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// _Client. + public ModelClient(string _Client = default(string)) + { + this._Client = _Client; + } + + /// + /// Gets or Sets _Client + /// + [DataMember(Name="client", EmitDefaultValue=false)] + public string _Client { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class ModelClient {\n"); + sb.Append(" _Client: ").Append(_Client).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as ModelClient); + } + + /// + /// Returns true if ModelClient instances are equal + /// + /// Instance of ModelClient to be compared + /// Boolean + public bool Equals(ModelClient input) + { + if (input == null) + return false; + + return + ( + this._Client == input._Client || + (this._Client != null && + this._Client.Equals(input._Client)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this._Client != null) + hashCode = hashCode * 59 + this._Client.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ModelReturn.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ModelReturn.cs new file mode 100644 index 00000000000..9d885bdff8a --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ModelReturn.cs @@ -0,0 +1,124 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// Model for testing reserved words + /// + [DataContract] + public partial class ModelReturn : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// _Return. + public ModelReturn(int? _Return = default(int?)) + { + this._Return = _Return; + } + + /// + /// Gets or Sets _Return + /// + [DataMember(Name="return", EmitDefaultValue=false)] + public int? _Return { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class ModelReturn {\n"); + sb.Append(" _Return: ").Append(_Return).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as ModelReturn); + } + + /// + /// Returns true if ModelReturn instances are equal + /// + /// Instance of ModelReturn to be compared + /// Boolean + public bool Equals(ModelReturn input) + { + if (input == null) + return false; + + return + ( + this._Return == input._Return || + (this._Return != null && + this._Return.Equals(input._Return)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this._Return != null) + hashCode = hashCode * 59 + this._Return.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Name.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Name.cs new file mode 100644 index 00000000000..d4c149c0fad --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Name.cs @@ -0,0 +1,181 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// Model for testing model name same as property name + /// + [DataContract] + public partial class Name : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected Name() { } + /// + /// Initializes a new instance of the class. + /// + /// _Name (required). + /// Property. + public Name(int? _Name = default(int?), string Property = default(string)) + { + // to ensure "_Name" is required (not null) + if (_Name == null) + { + throw new InvalidDataException("_Name is a required property for Name and cannot be null"); + } + else + { + this._Name = _Name; + } + this.Property = Property; + } + + /// + /// Gets or Sets _Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public int? _Name { get; set; } + + /// + /// Gets or Sets SnakeCase + /// + [DataMember(Name="snake_case", EmitDefaultValue=false)] + public int? SnakeCase { get; private set; } + + /// + /// Gets or Sets Property + /// + [DataMember(Name="property", EmitDefaultValue=false)] + public string Property { get; set; } + + /// + /// Gets or Sets _123Number + /// + [DataMember(Name="123Number", EmitDefaultValue=false)] + public int? _123Number { get; private set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Name {\n"); + sb.Append(" _Name: ").Append(_Name).Append("\n"); + sb.Append(" SnakeCase: ").Append(SnakeCase).Append("\n"); + sb.Append(" Property: ").Append(Property).Append("\n"); + sb.Append(" _123Number: ").Append(_123Number).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Name); + } + + /// + /// Returns true if Name instances are equal + /// + /// Instance of Name to be compared + /// Boolean + public bool Equals(Name input) + { + if (input == null) + return false; + + return + ( + this._Name == input._Name || + (this._Name != null && + this._Name.Equals(input._Name)) + ) && + ( + this.SnakeCase == input.SnakeCase || + (this.SnakeCase != null && + this.SnakeCase.Equals(input.SnakeCase)) + ) && + ( + this.Property == input.Property || + (this.Property != null && + this.Property.Equals(input.Property)) + ) && + ( + this._123Number == input._123Number || + (this._123Number != null && + this._123Number.Equals(input._123Number)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this._Name != null) + hashCode = hashCode * 59 + this._Name.GetHashCode(); + if (this.SnakeCase != null) + hashCode = hashCode * 59 + this.SnakeCase.GetHashCode(); + if (this.Property != null) + hashCode = hashCode * 59 + this.Property.GetHashCode(); + if (this._123Number != null) + hashCode = hashCode * 59 + this._123Number.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/NumberOnly.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/NumberOnly.cs new file mode 100644 index 00000000000..61c9be60c1d --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/NumberOnly.cs @@ -0,0 +1,124 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// NumberOnly + /// + [DataContract] + public partial class NumberOnly : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// JustNumber. + public NumberOnly(decimal? JustNumber = default(decimal?)) + { + this.JustNumber = JustNumber; + } + + /// + /// Gets or Sets JustNumber + /// + [DataMember(Name="JustNumber", EmitDefaultValue=false)] + public decimal? JustNumber { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class NumberOnly {\n"); + sb.Append(" JustNumber: ").Append(JustNumber).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as NumberOnly); + } + + /// + /// Returns true if NumberOnly instances are equal + /// + /// Instance of NumberOnly to be compared + /// Boolean + public bool Equals(NumberOnly input) + { + if (input == null) + return false; + + return + ( + this.JustNumber == input.JustNumber || + (this.JustNumber != null && + this.JustNumber.Equals(input.JustNumber)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.JustNumber != null) + hashCode = hashCode * 59 + this.JustNumber.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Order.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Order.cs new file mode 100644 index 00000000000..e92a21c36c2 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Order.cs @@ -0,0 +1,240 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// Order + /// + [DataContract] + public partial class Order : IEquatable, IValidatableObject + { + /// + /// Order Status + /// + /// Order Status + [JsonConverter(typeof(StringEnumConverter))] + public enum StatusEnum + { + + /// + /// Enum Placed for "placed" + /// + [EnumMember(Value = "placed")] + Placed, + + /// + /// Enum Approved for "approved" + /// + [EnumMember(Value = "approved")] + Approved, + + /// + /// Enum Delivered for "delivered" + /// + [EnumMember(Value = "delivered")] + Delivered + } + + /// + /// Order Status + /// + /// Order Status + [DataMember(Name="status", EmitDefaultValue=false)] + public StatusEnum? Status { get; set; } + /// + /// Initializes a new instance of the class. + /// + /// Id. + /// PetId. + /// Quantity. + /// ShipDate. + /// Order Status. + /// Complete (default to false). + public Order(long? Id = default(long?), long? PetId = default(long?), int? Quantity = default(int?), DateTime? ShipDate = default(DateTime?), StatusEnum? Status = default(StatusEnum?), bool? Complete = false) + { + this.Id = Id; + this.PetId = PetId; + this.Quantity = Quantity; + this.ShipDate = ShipDate; + this.Status = Status; + // use default value if no "Complete" provided + if (Complete == null) + { + this.Complete = false; + } + else + { + this.Complete = Complete; + } + } + + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + /// + /// Gets or Sets PetId + /// + [DataMember(Name="petId", EmitDefaultValue=false)] + public long? PetId { get; set; } + + /// + /// Gets or Sets Quantity + /// + [DataMember(Name="quantity", EmitDefaultValue=false)] + public int? Quantity { get; set; } + + /// + /// Gets or Sets ShipDate + /// + [DataMember(Name="shipDate", EmitDefaultValue=false)] + public DateTime? ShipDate { get; set; } + + + /// + /// Gets or Sets Complete + /// + [DataMember(Name="complete", EmitDefaultValue=false)] + public bool? Complete { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Order {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" PetId: ").Append(PetId).Append("\n"); + sb.Append(" Quantity: ").Append(Quantity).Append("\n"); + sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append(" Complete: ").Append(Complete).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Order); + } + + /// + /// Returns true if Order instances are equal + /// + /// Instance of Order to be compared + /// Boolean + public bool Equals(Order input) + { + if (input == null) + return false; + + return + ( + this.Id == input.Id || + (this.Id != null && + this.Id.Equals(input.Id)) + ) && + ( + this.PetId == input.PetId || + (this.PetId != null && + this.PetId.Equals(input.PetId)) + ) && + ( + this.Quantity == input.Quantity || + (this.Quantity != null && + this.Quantity.Equals(input.Quantity)) + ) && + ( + this.ShipDate == input.ShipDate || + (this.ShipDate != null && + this.ShipDate.Equals(input.ShipDate)) + ) && + ( + this.Status == input.Status || + (this.Status != null && + this.Status.Equals(input.Status)) + ) && + ( + this.Complete == input.Complete || + (this.Complete != null && + this.Complete.Equals(input.Complete)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Id != null) + hashCode = hashCode * 59 + this.Id.GetHashCode(); + if (this.PetId != null) + hashCode = hashCode * 59 + this.PetId.GetHashCode(); + if (this.Quantity != null) + hashCode = hashCode * 59 + this.Quantity.GetHashCode(); + if (this.ShipDate != null) + hashCode = hashCode * 59 + this.ShipDate.GetHashCode(); + if (this.Status != null) + hashCode = hashCode * 59 + this.Status.GetHashCode(); + if (this.Complete != null) + hashCode = hashCode * 59 + this.Complete.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterBoolean.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterBoolean.cs new file mode 100644 index 00000000000..45a3382919f --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterBoolean.cs @@ -0,0 +1,109 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// OuterBoolean + /// + [DataContract] + public partial class OuterBoolean : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + public OuterBoolean() + { + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class OuterBoolean {\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as OuterBoolean); + } + + /// + /// Returns true if OuterBoolean instances are equal + /// + /// Instance of OuterBoolean to be compared + /// Boolean + public bool Equals(OuterBoolean input) + { + if (input == null) + return false; + + return false; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterComposite.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterComposite.cs new file mode 100644 index 00000000000..4c12290c2ee --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterComposite.cs @@ -0,0 +1,156 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// OuterComposite + /// + [DataContract] + public partial class OuterComposite : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// MyNumber. + /// MyString. + /// MyBoolean. + public OuterComposite(OuterNumber MyNumber = default(OuterNumber), OuterString MyString = default(OuterString), OuterBoolean MyBoolean = default(OuterBoolean)) + { + this.MyNumber = MyNumber; + this.MyString = MyString; + this.MyBoolean = MyBoolean; + } + + /// + /// Gets or Sets MyNumber + /// + [DataMember(Name="my_number", EmitDefaultValue=false)] + public OuterNumber MyNumber { get; set; } + + /// + /// Gets or Sets MyString + /// + [DataMember(Name="my_string", EmitDefaultValue=false)] + public OuterString MyString { get; set; } + + /// + /// Gets or Sets MyBoolean + /// + [DataMember(Name="my_boolean", EmitDefaultValue=false)] + public OuterBoolean MyBoolean { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class OuterComposite {\n"); + sb.Append(" MyNumber: ").Append(MyNumber).Append("\n"); + sb.Append(" MyString: ").Append(MyString).Append("\n"); + sb.Append(" MyBoolean: ").Append(MyBoolean).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as OuterComposite); + } + + /// + /// Returns true if OuterComposite instances are equal + /// + /// Instance of OuterComposite to be compared + /// Boolean + public bool Equals(OuterComposite input) + { + if (input == null) + return false; + + return + ( + this.MyNumber == input.MyNumber || + (this.MyNumber != null && + this.MyNumber.Equals(input.MyNumber)) + ) && + ( + this.MyString == input.MyString || + (this.MyString != null && + this.MyString.Equals(input.MyString)) + ) && + ( + this.MyBoolean == input.MyBoolean || + (this.MyBoolean != null && + this.MyBoolean.Equals(input.MyBoolean)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.MyNumber != null) + hashCode = hashCode * 59 + this.MyNumber.GetHashCode(); + if (this.MyString != null) + hashCode = hashCode * 59 + this.MyString.GetHashCode(); + if (this.MyBoolean != null) + hashCode = hashCode * 59 + this.MyBoolean.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterEnum.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterEnum.cs new file mode 100644 index 00000000000..16135a6a052 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterEnum.cs @@ -0,0 +1,53 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// Defines OuterEnum + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum OuterEnum + { + + /// + /// Enum Placed for "placed" + /// + [EnumMember(Value = "placed")] + Placed, + + /// + /// Enum Approved for "approved" + /// + [EnumMember(Value = "approved")] + Approved, + + /// + /// Enum Delivered for "delivered" + /// + [EnumMember(Value = "delivered")] + Delivered + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterNumber.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterNumber.cs new file mode 100644 index 00000000000..395239a27c1 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterNumber.cs @@ -0,0 +1,109 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// OuterNumber + /// + [DataContract] + public partial class OuterNumber : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + public OuterNumber() + { + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class OuterNumber {\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as OuterNumber); + } + + /// + /// Returns true if OuterNumber instances are equal + /// + /// Instance of OuterNumber to be compared + /// Boolean + public bool Equals(OuterNumber input) + { + if (input == null) + return false; + + return false; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterString.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterString.cs new file mode 100644 index 00000000000..4a08ab3f7f7 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/OuterString.cs @@ -0,0 +1,109 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// OuterString + /// + [DataContract] + public partial class OuterString : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + public OuterString() + { + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class OuterString {\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as OuterString); + } + + /// + /// Returns true if OuterString instances are equal + /// + /// Instance of OuterString to be compared + /// Boolean + public bool Equals(OuterString input) + { + if (input == null) + return false; + + return false; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Pet.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Pet.cs new file mode 100644 index 00000000000..fa39a5da19c --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Pet.cs @@ -0,0 +1,253 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// Pet + /// + [DataContract] + public partial class Pet : IEquatable, IValidatableObject + { + /// + /// pet status in the store + /// + /// pet status in the store + [JsonConverter(typeof(StringEnumConverter))] + public enum StatusEnum + { + + /// + /// Enum Available for "available" + /// + [EnumMember(Value = "available")] + Available, + + /// + /// Enum Pending for "pending" + /// + [EnumMember(Value = "pending")] + Pending, + + /// + /// Enum Sold for "sold" + /// + [EnumMember(Value = "sold")] + Sold + } + + /// + /// pet status in the store + /// + /// pet status in the store + [DataMember(Name="status", EmitDefaultValue=false)] + public StatusEnum? Status { get; set; } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected Pet() { } + /// + /// Initializes a new instance of the class. + /// + /// Id. + /// Category. + /// Name (required). + /// PhotoUrls (required). + /// Tags. + /// pet status in the store. + public Pet(long? Id = default(long?), Category Category = default(Category), string Name = default(string), List PhotoUrls = default(List), List Tags = default(List), StatusEnum? Status = default(StatusEnum?)) + { + // to ensure "Name" is required (not null) + if (Name == null) + { + throw new InvalidDataException("Name is a required property for Pet and cannot be null"); + } + else + { + this.Name = Name; + } + // to ensure "PhotoUrls" is required (not null) + if (PhotoUrls == null) + { + throw new InvalidDataException("PhotoUrls is a required property for Pet and cannot be null"); + } + else + { + this.PhotoUrls = PhotoUrls; + } + this.Id = Id; + this.Category = Category; + this.Tags = Tags; + this.Status = Status; + } + + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + /// + /// Gets or Sets Category + /// + [DataMember(Name="category", EmitDefaultValue=false)] + public Category Category { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Gets or Sets PhotoUrls + /// + [DataMember(Name="photoUrls", EmitDefaultValue=false)] + public List PhotoUrls { get; set; } + + /// + /// Gets or Sets Tags + /// + [DataMember(Name="tags", EmitDefaultValue=false)] + public List Tags { get; set; } + + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Pet {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Category: ").Append(Category).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); + sb.Append(" Tags: ").Append(Tags).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Pet); + } + + /// + /// Returns true if Pet instances are equal + /// + /// Instance of Pet to be compared + /// Boolean + public bool Equals(Pet input) + { + if (input == null) + return false; + + return + ( + this.Id == input.Id || + (this.Id != null && + this.Id.Equals(input.Id)) + ) && + ( + this.Category == input.Category || + (this.Category != null && + this.Category.Equals(input.Category)) + ) && + ( + this.Name == input.Name || + (this.Name != null && + this.Name.Equals(input.Name)) + ) && + ( + this.PhotoUrls == input.PhotoUrls || + this.PhotoUrls != null && + this.PhotoUrls.SequenceEqual(input.PhotoUrls) + ) && + ( + this.Tags == input.Tags || + this.Tags != null && + this.Tags.SequenceEqual(input.Tags) + ) && + ( + this.Status == input.Status || + (this.Status != null && + this.Status.Equals(input.Status)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Id != null) + hashCode = hashCode * 59 + this.Id.GetHashCode(); + if (this.Category != null) + hashCode = hashCode * 59 + this.Category.GetHashCode(); + if (this.Name != null) + hashCode = hashCode * 59 + this.Name.GetHashCode(); + if (this.PhotoUrls != null) + hashCode = hashCode * 59 + this.PhotoUrls.GetHashCode(); + if (this.Tags != null) + hashCode = hashCode * 59 + this.Tags.GetHashCode(); + if (this.Status != null) + hashCode = hashCode * 59 + this.Status.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ReadOnlyFirst.cs new file mode 100644 index 00000000000..fa281fdecf7 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/ReadOnlyFirst.cs @@ -0,0 +1,138 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// ReadOnlyFirst + /// + [DataContract] + public partial class ReadOnlyFirst : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Baz. + public ReadOnlyFirst(string Baz = default(string)) + { + this.Baz = Baz; + } + + /// + /// Gets or Sets Bar + /// + [DataMember(Name="bar", EmitDefaultValue=false)] + public string Bar { get; private set; } + + /// + /// Gets or Sets Baz + /// + [DataMember(Name="baz", EmitDefaultValue=false)] + public string Baz { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class ReadOnlyFirst {\n"); + sb.Append(" Bar: ").Append(Bar).Append("\n"); + sb.Append(" Baz: ").Append(Baz).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as ReadOnlyFirst); + } + + /// + /// Returns true if ReadOnlyFirst instances are equal + /// + /// Instance of ReadOnlyFirst to be compared + /// Boolean + public bool Equals(ReadOnlyFirst input) + { + if (input == null) + return false; + + return + ( + this.Bar == input.Bar || + (this.Bar != null && + this.Bar.Equals(input.Bar)) + ) && + ( + this.Baz == input.Baz || + (this.Baz != null && + this.Baz.Equals(input.Baz)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Bar != null) + hashCode = hashCode * 59 + this.Bar.GetHashCode(); + if (this.Baz != null) + hashCode = hashCode * 59 + this.Baz.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/SpecialModelName.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/SpecialModelName.cs new file mode 100644 index 00000000000..198a04fee71 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/SpecialModelName.cs @@ -0,0 +1,124 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// SpecialModelName + /// + [DataContract] + public partial class SpecialModelName : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// SpecialPropertyName. + public SpecialModelName(long? SpecialPropertyName = default(long?)) + { + this.SpecialPropertyName = SpecialPropertyName; + } + + /// + /// Gets or Sets SpecialPropertyName + /// + [DataMember(Name="$special[property.name]", EmitDefaultValue=false)] + public long? SpecialPropertyName { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class SpecialModelName {\n"); + sb.Append(" SpecialPropertyName: ").Append(SpecialPropertyName).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as SpecialModelName); + } + + /// + /// Returns true if SpecialModelName instances are equal + /// + /// Instance of SpecialModelName to be compared + /// Boolean + public bool Equals(SpecialModelName input) + { + if (input == null) + return false; + + return + ( + this.SpecialPropertyName == input.SpecialPropertyName || + (this.SpecialPropertyName != null && + this.SpecialPropertyName.Equals(input.SpecialPropertyName)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.SpecialPropertyName != null) + hashCode = hashCode * 59 + this.SpecialPropertyName.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Tag.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Tag.cs new file mode 100644 index 00000000000..a4ae373b979 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/Tag.cs @@ -0,0 +1,140 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// Tag + /// + [DataContract] + public partial class Tag : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Id. + /// Name. + public Tag(long? Id = default(long?), string Name = default(string)) + { + this.Id = Id; + this.Name = Name; + } + + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Tag {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Tag); + } + + /// + /// Returns true if Tag instances are equal + /// + /// Instance of Tag to be compared + /// Boolean + public bool Equals(Tag input) + { + if (input == null) + return false; + + return + ( + this.Id == input.Id || + (this.Id != null && + this.Id.Equals(input.Id)) + ) && + ( + this.Name == input.Name || + (this.Name != null && + this.Name.Equals(input.Name)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Id != null) + hashCode = hashCode * 59 + this.Id.GetHashCode(); + if (this.Name != null) + hashCode = hashCode * 59 + this.Name.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/User.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/User.cs new file mode 100644 index 00000000000..ada8d682356 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Model/User.cs @@ -0,0 +1,237 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; + +namespace IO.Swagger.Model +{ + /// + /// User + /// + [DataContract] + public partial class User : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Id. + /// Username. + /// FirstName. + /// LastName. + /// Email. + /// Password. + /// Phone. + /// User Status. + public User(long? Id = default(long?), string Username = default(string), string FirstName = default(string), string LastName = default(string), string Email = default(string), string Password = default(string), string Phone = default(string), int? UserStatus = default(int?)) + { + this.Id = Id; + this.Username = Username; + this.FirstName = FirstName; + this.LastName = LastName; + this.Email = Email; + this.Password = Password; + this.Phone = Phone; + this.UserStatus = UserStatus; + } + + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + /// + /// Gets or Sets Username + /// + [DataMember(Name="username", EmitDefaultValue=false)] + public string Username { get; set; } + + /// + /// Gets or Sets FirstName + /// + [DataMember(Name="firstName", EmitDefaultValue=false)] + public string FirstName { get; set; } + + /// + /// Gets or Sets LastName + /// + [DataMember(Name="lastName", EmitDefaultValue=false)] + public string LastName { get; set; } + + /// + /// Gets or Sets Email + /// + [DataMember(Name="email", EmitDefaultValue=false)] + public string Email { get; set; } + + /// + /// Gets or Sets Password + /// + [DataMember(Name="password", EmitDefaultValue=false)] + public string Password { get; set; } + + /// + /// Gets or Sets Phone + /// + [DataMember(Name="phone", EmitDefaultValue=false)] + public string Phone { get; set; } + + /// + /// User Status + /// + /// User Status + [DataMember(Name="userStatus", EmitDefaultValue=false)] + public int? UserStatus { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class User {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Username: ").Append(Username).Append("\n"); + sb.Append(" FirstName: ").Append(FirstName).Append("\n"); + sb.Append(" LastName: ").Append(LastName).Append("\n"); + sb.Append(" Email: ").Append(Email).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append(" Phone: ").Append(Phone).Append("\n"); + sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as User); + } + + /// + /// Returns true if User instances are equal + /// + /// Instance of User to be compared + /// Boolean + public bool Equals(User input) + { + if (input == null) + return false; + + return + ( + this.Id == input.Id || + (this.Id != null && + this.Id.Equals(input.Id)) + ) && + ( + this.Username == input.Username || + (this.Username != null && + this.Username.Equals(input.Username)) + ) && + ( + this.FirstName == input.FirstName || + (this.FirstName != null && + this.FirstName.Equals(input.FirstName)) + ) && + ( + this.LastName == input.LastName || + (this.LastName != null && + this.LastName.Equals(input.LastName)) + ) && + ( + this.Email == input.Email || + (this.Email != null && + this.Email.Equals(input.Email)) + ) && + ( + this.Password == input.Password || + (this.Password != null && + this.Password.Equals(input.Password)) + ) && + ( + this.Phone == input.Phone || + (this.Phone != null && + this.Phone.Equals(input.Phone)) + ) && + ( + this.UserStatus == input.UserStatus || + (this.UserStatus != null && + this.UserStatus.Equals(input.UserStatus)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Id != null) + hashCode = hashCode * 59 + this.Id.GetHashCode(); + if (this.Username != null) + hashCode = hashCode * 59 + this.Username.GetHashCode(); + if (this.FirstName != null) + hashCode = hashCode * 59 + this.FirstName.GetHashCode(); + if (this.LastName != null) + hashCode = hashCode * 59 + this.LastName.GetHashCode(); + if (this.Email != null) + hashCode = hashCode * 59 + this.Email.GetHashCode(); + if (this.Password != null) + hashCode = hashCode * 59 + this.Password.GetHashCode(); + if (this.Phone != null) + hashCode = hashCode * 59 + this.Phone.GetHashCode(); + if (this.UserStatus != null) + hashCode = hashCode * 59 + this.UserStatus.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Properties/AssemblyInfo.cs b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..f3b9f7d1d14 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/Properties/AssemblyInfo.cs @@ -0,0 +1,32 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Swagger Library")] +[assembly: AssemblyDescription("A library generated from a Swagger doc")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Swagger")] +[assembly: AssemblyProduct("SwaggerLibrary")] +[assembly: AssemblyCopyright("No Copyright")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0")] +[assembly: AssemblyFileVersion("1.0.0")] diff --git a/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/packages.config b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/packages.config new file mode 100644 index 00000000000..b464072993f --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNet40/src/IO.Swagger/packages.config @@ -0,0 +1,5 @@ + + + + + diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex b/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex index e25a05c4fb0..8dce861d196 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex @@ -247,6 +247,32 @@ defmodule SwaggerPetstore.Api.Fake do |> decode(false) end + @doc """ + test inline additionalProperties + + + ## Parameters + + - connection (SwaggerPetstore.Connection): Connection to server + - param (Object): request body + - opts (KeywordList): [optional] Optional parameters + + ## Returns + + {:ok, %{}} on success + {:error, info} on failure + """ + @spec test_inline_additional_properties(Tesla.Env.client, SwaggerPetstore.Model.Object.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} + def test_inline_additional_properties(connection, param, _opts \\ []) do + %{} + |> method(:post) + |> url("/fake/inline-additionalProperties") + |> add_param(:body, :"param", param) + |> Enum.into([]) + |> (&Connection.request(connection, &1)).() + |> decode(false) + end + @doc """ test json serialization of form data diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/request_builder.ex b/samples/client/petstore/elixir/lib/swagger_petstore/request_builder.ex index 01512b7e278..a1aca31bd6c 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/request_builder.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/request_builder.ex @@ -13,13 +13,13 @@ defmodule SwaggerPetstore.RequestBuilder do ## Parameters - request (Map) - Collected request options - - m (String) - Request method + - m (atom) - Request method ## Returns Map """ - @spec method(map(), String.t) :: map() + @spec method(map(), atom) :: map() def method(request, m) do Map.put_new(request, :method, m) end @@ -54,7 +54,7 @@ defmodule SwaggerPetstore.RequestBuilder do Map """ - @spec add_optional_params(map(), %{optional(:atom) => :atom}, keyword()) :: map() + @spec add_optional_params(map(), %{optional(atom) => atom}, keyword()) :: map() def add_optional_params(request, _, []), do: request def add_optional_params(request, definitions, [{key, value} | tail]) do case definitions do @@ -81,7 +81,7 @@ defmodule SwaggerPetstore.RequestBuilder do Map """ - @spec add_param(map(), :atom, :atom, any()) :: map() + @spec add_param(map(), atom, atom, any()) :: map() def add_param(request, :body, :body, value), do: Map.put(request, :body, value) def add_param(request, :body, key, value) do request @@ -106,25 +106,20 @@ defmodule SwaggerPetstore.RequestBuilder do ## Parameters - - env (Tesla.Env) - The response object - - struct - The shape of the struct to deserialize into + - arg1 (Tesla.Env.t | term) - The response object + - arg2 (:false | struct | [struct]) - The shape of the struct to deserialize into ## Returns {:ok, struct} on success - {:error, info} on failure + {:error, term} on failure """ - @spec decode(Tesla.Env.t) :: {:ok, struct()} | {:error, Tesla.Env.t} + @spec decode(Tesla.Env.t | term()) :: {:ok, struct()} | {:error, Tesla.Env.t} | {:error, term()} def decode(%Tesla.Env{status: 200, body: body}), do: Poison.decode(body) - def decode(response) do - {:error, response} - end - @spec decode(Tesla.Env.t, struct()) :: {:ok, struct()} | {:error, Tesla.Env.t} + def decode(response), do: {:error, response} + + @spec decode(Tesla.Env.t | term(), :false | struct() | [struct()]) :: {:ok, struct()} | {:error, Tesla.Env.t} | {:error, term()} def decode(%Tesla.Env{status: 200} = env, false), do: {:ok, env} - def decode(%Tesla.Env{status: 200, body: body}, struct) do - Poison.decode(body, as: struct) - end - def decode(response, _struct) do - {:error, response} - end + def decode(%Tesla.Env{status: 200, body: body}, struct), do: Poison.decode(body, as: struct) + def decode(response, _struct), do: {:error, response} end diff --git a/samples/client/petstore/haskell-http-client/README.md b/samples/client/petstore/haskell-http-client/README.md index 2f2a6b4ca70..647be0928f4 100644 --- a/samples/client/petstore/haskell-http-client/README.md +++ b/samples/client/petstore/haskell-http-client/README.md @@ -48,11 +48,6 @@ haskell-http-client * Model Inheritance -* Default Parameter Values - -* Enum Parameters - - This is beta software; other cases may not be supported. ### Codegen "additional properties" parameters @@ -67,6 +62,7 @@ These options allow some customization of the code generation process. | allowToJsonNulls | allow emitting JSON Null during model encoding to JSON | false | false | | dateFormat | format string used to parse/render a date | %Y-%m-%d | %Y-%m-%d | | dateTimeFormat | format string used to parse/render a datetime. (Defaults to [formatISO8601Millis][1] when not provided) | | | +| generateEnums | Generate specific datatypes for swagger enums | true | true | | generateFormUrlEncodedInstances | Generate FromForm/ToForm instances for models used by x-www-form-urlencoded operations (model fields must be primitive types) | true | true | | generateLenses | Generate Lens optics for Models | true | true | | generateModelConstructors | Generate smart constructors (only supply required fields) for models | true | true | diff --git a/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-API.html b/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-API.html index 4390d97a497..b729f19e936 100644 --- a/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-API.html +++ b/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-API.html @@ -1,4 +1,4 @@ SwaggerPetstore.API

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Safe HaskellNone
LanguageHaskell2010

SwaggerPetstore.API

Description

 

Synopsis

Operations

AnotherFake

testSpecialTags

testSpecialTags Source #

Arguments

:: (Consumes TestSpecialTags contentType, MimeRender contentType Client) 
=> contentType

request content-type (MimeType)

-> Client

"body" - client model

-> SwaggerPetstoreRequest TestSpecialTags contentType Client 
PATCH /another-fake/dummy

To test special tags

To test special tags

data TestSpecialTags Source #

Instances

Fake

fakeOuterBooleanSerialize

fakeOuterBooleanSerialize Source #

Arguments

:: Consumes FakeOuterBooleanSerialize contentType 
=> contentType

request content-type (MimeType)

-> SwaggerPetstoreRequest FakeOuterBooleanSerialize contentType OuterBoolean 
POST /fake/outer/boolean

Test serialization of outer boolean types

fakeOuterCompositeSerialize

fakeOuterCompositeSerialize Source #

Arguments

:: Consumes FakeOuterCompositeSerialize contentType 
=> contentType

request content-type (MimeType)

-> SwaggerPetstoreRequest FakeOuterCompositeSerialize contentType OuterComposite 
POST /fake/outer/composite

Test serialization of object with outer number type

fakeOuterNumberSerialize

fakeOuterNumberSerialize Source #

Arguments

:: Consumes FakeOuterNumberSerialize contentType 
=> contentType

request content-type (MimeType)

-> SwaggerPetstoreRequest FakeOuterNumberSerialize contentType OuterNumber 
POST /fake/outer/number

Test serialization of outer number types

fakeOuterStringSerialize

fakeOuterStringSerialize Source #

Arguments

:: Consumes FakeOuterStringSerialize contentType 
=> contentType

request content-type (MimeType)

-> SwaggerPetstoreRequest FakeOuterStringSerialize contentType OuterString 
POST /fake/outer/string

Test serialization of outer string types

testClientModel

testClientModel Source #

Arguments

:: (Consumes TestClientModel contentType, MimeRender contentType Client) 
=> contentType

request content-type (MimeType)

-> Client

"body" - client model

-> SwaggerPetstoreRequest TestClientModel contentType Client 
PATCH /fake

To test "client" model

To test "client" model

data TestClientModel Source #

Instances

testEndpointParameters

testEndpointParameters Source #

Arguments

:: Consumes TestEndpointParameters contentType 
=> contentType

request content-type (MimeType)

-> Number

"number" - None

-> ParamDouble

"double" - None

-> PatternWithoutDelimiter

"patternWithoutDelimiter" - None

-> Byte

"byte" - None

-> SwaggerPetstoreRequest TestEndpointParameters contentType res 
POST /fake

Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트

Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트

AuthMethod: AuthBasicHttpBasicTest

Note: Has Produces instances, but no response schema

data TestEndpointParameters Source #

Instances

Produces TestEndpointParameters MimeXmlCharsetutf8 Source #
application/xml; charset=utf-8
Produces TestEndpointParameters MimeJsonCharsetutf8 Source #
application/json; charset=utf-8
Consumes TestEndpointParameters MimeXmlCharsetutf8 Source #
application/xml; charset=utf-8
Consumes TestEndpointParameters MimeJsonCharsetutf8 Source #
application/json; charset=utf-8
HasOptionalParam TestEndpointParameters Password Source #

Optional Param "password" - None

HasOptionalParam TestEndpointParameters ParamString Source #

Optional Param "string" - None

HasOptionalParam TestEndpointParameters ParamInteger Source #

Optional Param "integer" - None

HasOptionalParam TestEndpointParameters ParamFloat Source #

Optional Param "float" - None

HasOptionalParam TestEndpointParameters ParamDateTime Source #

Optional Param "dateTime" - None

HasOptionalParam TestEndpointParameters ParamDate Source #

Optional Param "date" - None

HasOptionalParam TestEndpointParameters ParamBinary Source #

Optional Param "binary" - None

HasOptionalParam TestEndpointParameters Int64 Source #

Optional Param "int64" - None

HasOptionalParam TestEndpointParameters Int32 Source #

Optional Param "int32" - None

HasOptionalParam TestEndpointParameters Callback Source #

Optional Param "callback" - None

testEnumParameters

testEnumParameters Source #

Arguments

:: Consumes TestEnumParameters contentType 
=> contentType

request content-type (MimeType)

-> SwaggerPetstoreRequest TestEnumParameters contentType res 
GET /fake

To test enum parameters

To test enum parameters

Note: Has Produces instances, but no response schema

data TestEnumParameters Source #

Instances

Produces TestEnumParameters MimeAny Source #
*/*
Consumes TestEnumParameters MimeAny Source #
*/*
HasOptionalParam TestEnumParameters EnumQueryStringArray Source #

Optional Param "enum_query_string_array" - Query parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumQueryString Source #

Optional Param "enum_query_string" - Query parameter enum test (string)

HasOptionalParam TestEnumParameters EnumQueryInteger Source #

Optional Param "enum_query_integer" - Query parameter enum test (double)

HasOptionalParam TestEnumParameters EnumQueryDouble Source #

Optional Param "enum_query_double" - Query parameter enum test (double)

HasOptionalParam TestEnumParameters EnumHeaderStringArray Source #

Optional Param "enum_header_string_array" - Header parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumHeaderString Source #

Optional Param "enum_header_string" - Header parameter enum test (string)

HasOptionalParam TestEnumParameters EnumFormStringArray Source #

Optional Param "enum_form_string_array" - Form parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumFormString Source #

Optional Param "enum_form_string" - Form parameter enum test (string)

testJsonFormData

testJsonFormData Source #

Arguments

:: Consumes TestJsonFormData contentType 
=> contentType

request content-type (MimeType)

-> Param

"param" - field1

-> Param2

"param2" - field2

-> SwaggerPetstoreRequest TestJsonFormData contentType NoContent 
GET /fake/jsonFormData

test json serialization of form data

FakeClassnameTags123

testClassname

testClassname Source #

Arguments

:: (Consumes TestClassname contentType, MimeRender contentType Client) 
=> contentType

request content-type (MimeType)

-> Client

"body" - client model

-> SwaggerPetstoreRequest TestClassname contentType Client 
PATCH /fake_classname_test

To test class name in snake case

AuthMethod: AuthApiKeyApiKeyQuery

data TestClassname Source #

Instances

Produces TestClassname MimeJSON Source #
application/json
Consumes TestClassname MimeJSON Source #
application/json
HasBodyParam TestClassname Client Source #

Body Param "body" - client model

Methods

setBodyParam :: (Consumes TestClassname contentType, MimeRender contentType Client) => SwaggerPetstoreRequest TestClassname contentType res -> Client -> SwaggerPetstoreRequest TestClassname contentType res Source #

Pet

addPet

addPet Source #

Arguments

:: (Consumes AddPet contentType, MimeRender contentType Pet) 
=> contentType

request content-type (MimeType)

-> Pet

"body" - Pet object that needs to be added to the store

-> SwaggerPetstoreRequest AddPet contentType res 
POST /pet

Add a new pet to the store

AuthMethod: AuthOAuthPetstoreAuth

Note: Has Produces instances, but no response schema

data AddPet Source #

Instances

Produces AddPet MimeXML Source #
application/xml
Produces AddPet MimeJSON Source #
application/json
Consumes AddPet MimeXML Source #
application/xml
Consumes AddPet MimeJSON Source #
application/json
HasBodyParam AddPet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes AddPet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest AddPet contentType res -> Pet -> SwaggerPetstoreRequest AddPet contentType res Source #

deletePet

deletePet Source #

Arguments

:: PetId

"petId" - Pet id to delete

-> SwaggerPetstoreRequest DeletePet MimeNoContent res 
DELETE /pet/{petId}

Deletes a pet

AuthMethod: AuthOAuthPetstoreAuth

Note: Has Produces instances, but no response schema

findPetsByStatus

findPetsByStatus Source #

Arguments

:: Status

"status" - Status values that need to be considered for filter

-> SwaggerPetstoreRequest FindPetsByStatus MimeNoContent [Pet] 
GET /pet/findByStatus

Finds Pets by status

Multiple status values can be provided with comma separated strings

AuthMethod: AuthOAuthPetstoreAuth

findPetsByTags

findPetsByTags Source #

Arguments

:: Tags

"tags" - Tags to filter by

-> SwaggerPetstoreRequest FindPetsByTags MimeNoContent [Pet] 

Deprecated:

GET /pet/findByTags

Finds Pets by tags

Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.

AuthMethod: AuthOAuthPetstoreAuth

getPetById

getPetById Source #

Arguments

:: PetId

"petId" - ID of pet to return

-> SwaggerPetstoreRequest GetPetById MimeNoContent Pet 
GET /pet/{petId}

Find pet by ID

Returns a single pet

AuthMethod: AuthApiKeyApiKey

data GetPetById Source #

Instances

updatePet

updatePet Source #

Arguments

:: (Consumes UpdatePet contentType, MimeRender contentType Pet) 
=> contentType

request content-type (MimeType)

-> Pet

"body" - Pet object that needs to be added to the store

-> SwaggerPetstoreRequest UpdatePet contentType res 
PUT /pet

Update an existing pet

AuthMethod: AuthOAuthPetstoreAuth

Note: Has Produces instances, but no response schema

data UpdatePet Source #

Instances

Produces UpdatePet MimeXML Source #
application/xml
Produces UpdatePet MimeJSON Source #
application/json
Consumes UpdatePet MimeXML Source #
application/xml
Consumes UpdatePet MimeJSON Source #
application/json
HasBodyParam UpdatePet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes UpdatePet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest UpdatePet contentType res -> Pet -> SwaggerPetstoreRequest UpdatePet contentType res Source #

updatePetWithForm

updatePetWithForm Source #

Arguments

:: Consumes UpdatePetWithForm contentType 
=> contentType

request content-type (MimeType)

-> PetId

"petId" - ID of pet that needs to be updated

-> SwaggerPetstoreRequest UpdatePetWithForm contentType res 
POST /pet/{petId}

Updates a pet in the store with form data

AuthMethod: AuthOAuthPetstoreAuth

Note: Has Produces instances, but no response schema

uploadFile

uploadFile Source #

Arguments

:: Consumes UploadFile contentType 
=> contentType

request content-type (MimeType)

-> PetId

"petId" - ID of pet to update

-> SwaggerPetstoreRequest UploadFile contentType ApiResponse 
POST /pet/{petId}/uploadImage

uploads an image

AuthMethod: AuthOAuthPetstoreAuth

data UploadFile Source #

Instances

Produces UploadFile MimeJSON Source #
application/json
Consumes UploadFile MimeMultipartFormData Source #
multipart/form-data
HasOptionalParam UploadFile File Source #

Optional Param "file" - file to upload

HasOptionalParam UploadFile AdditionalMetadata Source #

Optional Param "additionalMetadata" - Additional data to pass to server

Store

deleteOrder

deleteOrder Source #

Arguments

:: OrderIdText

"orderId" - ID of the order that needs to be deleted

-> SwaggerPetstoreRequest DeleteOrder MimeNoContent res 
DELETE /store/order/{order_id}

Delete purchase order by ID

For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors

Note: Has Produces instances, but no response schema

data DeleteOrder Source #

Instances

getInventory

getInventory :: SwaggerPetstoreRequest GetInventory MimeNoContent (Map String Int) Source #

GET /store/inventory

Returns pet inventories by status

Returns a map of status codes to quantities

AuthMethod: AuthApiKeyApiKey

data GetInventory Source #

Instances

getOrderById

getOrderById Source #

Arguments

:: OrderId

"orderId" - ID of pet that needs to be fetched

-> SwaggerPetstoreRequest GetOrderById MimeNoContent Order 
GET /store/order/{order_id}

Find purchase order by ID

For valid response try integer IDs with value 5 or 10. Other values will generated exceptions

placeOrder

placeOrder Source #

Arguments

:: (Consumes PlaceOrder contentType, MimeRender contentType Order) 
=> contentType

request content-type (MimeType)

-> Order

"body" - order placed for purchasing the pet

-> SwaggerPetstoreRequest PlaceOrder contentType Order 
POST /store/order

Place an order for a pet

data PlaceOrder Source #

Instances

Produces PlaceOrder MimeXML Source #
application/xml
Produces PlaceOrder MimeJSON Source #
application/json
HasBodyParam PlaceOrder Order Source #

Body Param "body" - order placed for purchasing the pet

Methods

setBodyParam :: (Consumes PlaceOrder contentType, MimeRender contentType Order) => SwaggerPetstoreRequest PlaceOrder contentType res -> Order -> SwaggerPetstoreRequest PlaceOrder contentType res Source #

User

createUser

createUser Source #

Arguments

:: (Consumes CreateUser contentType, MimeRender contentType User) 
=> contentType

request content-type (MimeType)

-> User

"body" - Created user object

-> SwaggerPetstoreRequest CreateUser contentType res 
POST /user

Create user

This can only be done by the logged in user.

Note: Has Produces instances, but no response schema

data CreateUser Source #

Instances

Produces CreateUser MimeXML Source #
application/xml
Produces CreateUser MimeJSON Source #
application/json
HasBodyParam CreateUser User Source #

Body Param "body" - Created user object

Methods

setBodyParam :: (Consumes CreateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest CreateUser contentType res -> User -> SwaggerPetstoreRequest CreateUser contentType res Source #

createUsersWithArrayInput

createUsersWithArrayInput Source #

Arguments

:: (Consumes CreateUsersWithArrayInput contentType, MimeRender contentType Body) 
=> contentType

request content-type (MimeType)

-> Body

"body" - List of user object

-> SwaggerPetstoreRequest CreateUsersWithArrayInput contentType res 
POST /user/createWithArray

Creates list of users with given input array

Note: Has Produces instances, but no response schema

createUsersWithListInput

createUsersWithListInput Source #

Arguments

:: (Consumes CreateUsersWithListInput contentType, MimeRender contentType Body) 
=> contentType

request content-type (MimeType)

-> Body

"body" - List of user object

-> SwaggerPetstoreRequest CreateUsersWithListInput contentType res 
POST /user/createWithList

Creates list of users with given input array

Note: Has Produces instances, but no response schema

deleteUser

deleteUser Source #

Arguments

:: Username

"username" - The name that needs to be deleted

-> SwaggerPetstoreRequest DeleteUser MimeNoContent res 
DELETE /user/{username}

Delete user

This can only be done by the logged in user.

Note: Has Produces instances, but no response schema

data DeleteUser Source #

Instances

getUserByName

getUserByName Source #

Arguments

:: Username

"username" - The name that needs to be fetched. Use user1 for testing.

-> SwaggerPetstoreRequest GetUserByName MimeNoContent User 
GET /user/{username}

Get user by user name

loginUser

loginUser Source #

Arguments

:: Username

"username" - The user name for login

-> Password

"password" - The password for login in clear text

-> SwaggerPetstoreRequest LoginUser MimeNoContent Text 
GET /user/login

Logs user into the system

data LoginUser Source #

Instances

logoutUser

logoutUser :: SwaggerPetstoreRequest LogoutUser MimeNoContent res Source #

GET /user/logout

Logs out current logged in user session

Note: Has Produces instances, but no response schema

data LogoutUser Source #

Instances

updateUser

updateUser Source #

Arguments

:: (Consumes UpdateUser contentType, MimeRender contentType User) 
=> contentType

request content-type (MimeType)

-> Username

"username" - name that need to be deleted

-> User

"body" - Updated user object

-> SwaggerPetstoreRequest UpdateUser contentType res 
PUT /user/{username}

Updated user

This can only be done by the logged in user.

Note: Has Produces instances, but no response schema

data UpdateUser Source #

Instances

Produces UpdateUser MimeXML Source #
application/xml
Produces UpdateUser MimeJSON Source #
application/json
HasBodyParam UpdateUser User Source #

Body Param "body" - Updated user object

Methods

setBodyParam :: (Consumes UpdateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest UpdateUser contentType res -> User -> SwaggerPetstoreRequest UpdateUser contentType res Source #

Parameter newtypes

newtype Body Source #

Constructors

Body 

Fields

newtype Byte Source #

Constructors

Byte 

Fields

Instances

Eq Byte Source # 

Methods

(==) :: Byte -> Byte -> Bool #

(/=) :: Byte -> Byte -> Bool #

Show Byte Source # 

Methods

showsPrec :: Int -> Byte -> ShowS #

show :: Byte -> String #

showList :: [Byte] -> ShowS #

newtype File Source #

Constructors

File 

Fields

Instances

Eq File Source # 

Methods

(==) :: File -> File -> Bool #

(/=) :: File -> File -> Bool #

Show File Source # 

Methods

showsPrec :: Int -> File -> ShowS #

show :: File -> String #

showList :: [File] -> ShowS #

HasOptionalParam UploadFile File Source #

Optional Param "file" - file to upload

newtype Name2 Source #

Constructors

Name2 

Fields

newtype Number Source #

Constructors

Number 

Fields

Instances

newtype OrderId Source #

Constructors

OrderId 

Fields

newtype Param Source #

Constructors

Param 

Fields

Instances

Eq Param Source # 

Methods

(==) :: Param -> Param -> Bool #

(/=) :: Param -> Param -> Bool #

Show Param Source # 

Methods

showsPrec :: Int -> Param -> ShowS #

show :: Param -> String #

showList :: [Param] -> ShowS #

newtype Param2 Source #

Constructors

Param2 

Fields

Instances

newtype PetId Source #

Constructors

PetId 

Fields

Instances

Eq PetId Source # 

Methods

(==) :: PetId -> PetId -> Bool #

(/=) :: PetId -> PetId -> Bool #

Show PetId Source # 

Methods

showsPrec :: Int -> PetId -> ShowS #

show :: PetId -> String #

showList :: [PetId] -> ShowS #

newtype Status Source #

Constructors

Status 

Fields

Instances

newtype Tags Source #

Constructors

Tags 

Fields

Instances

Eq Tags Source # 

Methods

(==) :: Tags -> Tags -> Bool #

(/=) :: Tags -> Tags -> Bool #

Show Tags Source # 

Methods

showsPrec :: Int -> Tags -> ShowS #

show :: Tags -> String #

showList :: [Tags] -> ShowS #

newtype Username Source #

Constructors

Username 

Fields

Auth Methods

AuthApiKeyApiKey

AuthApiKeyApiKeyQuery

AuthBasicHttpBasicTest

AuthOAuthPetstoreAuth

Custom Mime Types

MimeJsonCharsetutf8

MimeXmlCharsetutf8

\ No newline at end of file +

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Safe HaskellNone
LanguageHaskell2010

SwaggerPetstore.API

Description

 

Synopsis

Operations

AnotherFake

testSpecialTags

testSpecialTags Source #

Arguments

:: (Consumes TestSpecialTags contentType, MimeRender contentType Client) 
=> contentType

request content-type (MimeType)

-> Client

"body" - client model

-> SwaggerPetstoreRequest TestSpecialTags contentType Client 
PATCH /another-fake/dummy

To test special tags

To test special tags

data TestSpecialTags Source #

Instances

Fake

fakeOuterBooleanSerialize

fakeOuterBooleanSerialize Source #

Arguments

:: Consumes FakeOuterBooleanSerialize contentType 
=> contentType

request content-type (MimeType)

-> SwaggerPetstoreRequest FakeOuterBooleanSerialize contentType OuterBoolean 
POST /fake/outer/boolean

Test serialization of outer boolean types

fakeOuterCompositeSerialize

fakeOuterCompositeSerialize Source #

Arguments

:: Consumes FakeOuterCompositeSerialize contentType 
=> contentType

request content-type (MimeType)

-> SwaggerPetstoreRequest FakeOuterCompositeSerialize contentType OuterComposite 
POST /fake/outer/composite

Test serialization of object with outer number type

fakeOuterNumberSerialize

fakeOuterNumberSerialize Source #

Arguments

:: Consumes FakeOuterNumberSerialize contentType 
=> contentType

request content-type (MimeType)

-> SwaggerPetstoreRequest FakeOuterNumberSerialize contentType OuterNumber 
POST /fake/outer/number

Test serialization of outer number types

fakeOuterStringSerialize

fakeOuterStringSerialize Source #

Arguments

:: Consumes FakeOuterStringSerialize contentType 
=> contentType

request content-type (MimeType)

-> SwaggerPetstoreRequest FakeOuterStringSerialize contentType OuterString 
POST /fake/outer/string

Test serialization of outer string types

testClientModel

testClientModel Source #

Arguments

:: (Consumes TestClientModel contentType, MimeRender contentType Client) 
=> contentType

request content-type (MimeType)

-> Client

"body" - client model

-> SwaggerPetstoreRequest TestClientModel contentType Client 
PATCH /fake

To test "client" model

To test "client" model

data TestClientModel Source #

Instances

testEndpointParameters

testEndpointParameters Source #

Arguments

:: Consumes TestEndpointParameters contentType 
=> contentType

request content-type (MimeType)

-> Number

"number" - None

-> ParamDouble

"double" - None

-> PatternWithoutDelimiter

"patternWithoutDelimiter" - None

-> Byte

"byte" - None

-> SwaggerPetstoreRequest TestEndpointParameters contentType res 
POST /fake

Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트

Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트

AuthMethod: AuthBasicHttpBasicTest

Note: Has Produces instances, but no response schema

data TestEndpointParameters Source #

Instances

Produces TestEndpointParameters MimeXmlCharsetutf8 Source #
application/xml; charset=utf-8
Produces TestEndpointParameters MimeJsonCharsetutf8 Source #
application/json; charset=utf-8
Consumes TestEndpointParameters MimeXmlCharsetutf8 Source #
application/xml; charset=utf-8
Consumes TestEndpointParameters MimeJsonCharsetutf8 Source #
application/json; charset=utf-8
HasOptionalParam TestEndpointParameters Password Source #

Optional Param "password" - None

HasOptionalParam TestEndpointParameters ParamString Source #

Optional Param "string" - None

HasOptionalParam TestEndpointParameters ParamInteger Source #

Optional Param "integer" - None

HasOptionalParam TestEndpointParameters ParamFloat Source #

Optional Param "float" - None

HasOptionalParam TestEndpointParameters ParamDateTime Source #

Optional Param "dateTime" - None

HasOptionalParam TestEndpointParameters ParamDate Source #

Optional Param "date" - None

HasOptionalParam TestEndpointParameters ParamBinary Source #

Optional Param "binary" - None

HasOptionalParam TestEndpointParameters Int64 Source #

Optional Param "int64" - None

HasOptionalParam TestEndpointParameters Int32 Source #

Optional Param "int32" - None

HasOptionalParam TestEndpointParameters Callback Source #

Optional Param "callback" - None

testEnumParameters

testEnumParameters Source #

Arguments

:: Consumes TestEnumParameters contentType 
=> contentType

request content-type (MimeType)

-> SwaggerPetstoreRequest TestEnumParameters contentType res 
GET /fake

To test enum parameters

To test enum parameters

Note: Has Produces instances, but no response schema

data TestEnumParameters Source #

Instances

Produces TestEnumParameters MimeAny Source #
*/*
Consumes TestEnumParameters MimeAny Source #
*/*
HasOptionalParam TestEnumParameters EnumQueryStringArray Source #

Optional Param "enum_query_string_array" - Query parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumQueryString Source #

Optional Param "enum_query_string" - Query parameter enum test (string)

HasOptionalParam TestEnumParameters EnumQueryInteger Source #

Optional Param "enum_query_integer" - Query parameter enum test (double)

HasOptionalParam TestEnumParameters EnumQueryDouble Source #

Optional Param "enum_query_double" - Query parameter enum test (double)

HasOptionalParam TestEnumParameters EnumHeaderStringArray Source #

Optional Param "enum_header_string_array" - Header parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumHeaderString Source #

Optional Param "enum_header_string" - Header parameter enum test (string)

HasOptionalParam TestEnumParameters EnumFormStringArray Source #

Optional Param "enum_form_string_array" - Form parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumFormString Source #

Optional Param "enum_form_string" - Form parameter enum test (string)

testInlineAdditionalProperties

testInlineAdditionalProperties Source #

Arguments

:: (Consumes TestInlineAdditionalProperties contentType, MimeRender contentType Value) 
=> contentType

request content-type (MimeType)

-> Value

"param" - request body

-> SwaggerPetstoreRequest TestInlineAdditionalProperties contentType NoContent 
POST /fake/inline-additionalProperties

test inline additionalProperties

testJsonFormData

testJsonFormData Source #

Arguments

:: Consumes TestJsonFormData contentType 
=> contentType

request content-type (MimeType)

-> Param

"param" - field1

-> Param2

"param2" - field2

-> SwaggerPetstoreRequest TestJsonFormData contentType NoContent 
GET /fake/jsonFormData

test json serialization of form data

FakeClassnameTags123

testClassname

testClassname Source #

Arguments

:: (Consumes TestClassname contentType, MimeRender contentType Client) 
=> contentType

request content-type (MimeType)

-> Client

"body" - client model

-> SwaggerPetstoreRequest TestClassname contentType Client 
PATCH /fake_classname_test

To test class name in snake case

AuthMethod: AuthApiKeyApiKeyQuery

data TestClassname Source #

Instances

Produces TestClassname MimeJSON Source #
application/json
Consumes TestClassname MimeJSON Source #
application/json
HasBodyParam TestClassname Client Source #

Body Param "body" - client model

Methods

setBodyParam :: (Consumes TestClassname contentType, MimeRender contentType Client) => SwaggerPetstoreRequest TestClassname contentType res -> Client -> SwaggerPetstoreRequest TestClassname contentType res Source #

Pet

addPet

addPet Source #

Arguments

:: (Consumes AddPet contentType, MimeRender contentType Pet) 
=> contentType

request content-type (MimeType)

-> Pet

"body" - Pet object that needs to be added to the store

-> SwaggerPetstoreRequest AddPet contentType res 
POST /pet

Add a new pet to the store

AuthMethod: AuthOAuthPetstoreAuth

Note: Has Produces instances, but no response schema

data AddPet Source #

Instances

Produces AddPet MimeXML Source #
application/xml
Produces AddPet MimeJSON Source #
application/json
Consumes AddPet MimeXML Source #
application/xml
Consumes AddPet MimeJSON Source #
application/json
HasBodyParam AddPet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes AddPet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest AddPet contentType res -> Pet -> SwaggerPetstoreRequest AddPet contentType res Source #

deletePet

deletePet Source #

Arguments

:: PetId

"petId" - Pet id to delete

-> SwaggerPetstoreRequest DeletePet MimeNoContent res 
DELETE /pet/{petId}

Deletes a pet

AuthMethod: AuthOAuthPetstoreAuth

Note: Has Produces instances, but no response schema

findPetsByStatus

findPetsByStatus Source #

Arguments

:: Status

"status" - Status values that need to be considered for filter

-> SwaggerPetstoreRequest FindPetsByStatus MimeNoContent [Pet] 
GET /pet/findByStatus

Finds Pets by status

Multiple status values can be provided with comma separated strings

AuthMethod: AuthOAuthPetstoreAuth

findPetsByTags

findPetsByTags Source #

Arguments

:: Tags

"tags" - Tags to filter by

-> SwaggerPetstoreRequest FindPetsByTags MimeNoContent [Pet] 

Deprecated:

GET /pet/findByTags

Finds Pets by tags

Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.

AuthMethod: AuthOAuthPetstoreAuth

getPetById

getPetById Source #

Arguments

:: PetId

"petId" - ID of pet to return

-> SwaggerPetstoreRequest GetPetById MimeNoContent Pet 
GET /pet/{petId}

Find pet by ID

Returns a single pet

AuthMethod: AuthApiKeyApiKey

data GetPetById Source #

Instances

updatePet

updatePet Source #

Arguments

:: (Consumes UpdatePet contentType, MimeRender contentType Pet) 
=> contentType

request content-type (MimeType)

-> Pet

"body" - Pet object that needs to be added to the store

-> SwaggerPetstoreRequest UpdatePet contentType res 
PUT /pet

Update an existing pet

AuthMethod: AuthOAuthPetstoreAuth

Note: Has Produces instances, but no response schema

data UpdatePet Source #

Instances

Produces UpdatePet MimeXML Source #
application/xml
Produces UpdatePet MimeJSON Source #
application/json
Consumes UpdatePet MimeXML Source #
application/xml
Consumes UpdatePet MimeJSON Source #
application/json
HasBodyParam UpdatePet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes UpdatePet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest UpdatePet contentType res -> Pet -> SwaggerPetstoreRequest UpdatePet contentType res Source #

updatePetWithForm

updatePetWithForm Source #

Arguments

:: Consumes UpdatePetWithForm contentType 
=> contentType

request content-type (MimeType)

-> PetId

"petId" - ID of pet that needs to be updated

-> SwaggerPetstoreRequest UpdatePetWithForm contentType res 
POST /pet/{petId}

Updates a pet in the store with form data

AuthMethod: AuthOAuthPetstoreAuth

Note: Has Produces instances, but no response schema

uploadFile

uploadFile Source #

Arguments

:: Consumes UploadFile contentType 
=> contentType

request content-type (MimeType)

-> PetId

"petId" - ID of pet to update

-> SwaggerPetstoreRequest UploadFile contentType ApiResponse 
POST /pet/{petId}/uploadImage

uploads an image

AuthMethod: AuthOAuthPetstoreAuth

data UploadFile Source #

Instances

Produces UploadFile MimeJSON Source #
application/json
Consumes UploadFile MimeMultipartFormData Source #
multipart/form-data
HasOptionalParam UploadFile File Source #

Optional Param "file" - file to upload

HasOptionalParam UploadFile AdditionalMetadata Source #

Optional Param "additionalMetadata" - Additional data to pass to server

Store

deleteOrder

deleteOrder Source #

Arguments

:: OrderIdText

"orderId" - ID of the order that needs to be deleted

-> SwaggerPetstoreRequest DeleteOrder MimeNoContent res 
DELETE /store/order/{order_id}

Delete purchase order by ID

For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors

Note: Has Produces instances, but no response schema

data DeleteOrder Source #

Instances

getInventory

getInventory :: SwaggerPetstoreRequest GetInventory MimeNoContent (Map String Int) Source #

GET /store/inventory

Returns pet inventories by status

Returns a map of status codes to quantities

AuthMethod: AuthApiKeyApiKey

data GetInventory Source #

Instances

getOrderById

getOrderById Source #

Arguments

:: OrderId

"orderId" - ID of pet that needs to be fetched

-> SwaggerPetstoreRequest GetOrderById MimeNoContent Order 
GET /store/order/{order_id}

Find purchase order by ID

For valid response try integer IDs with value 5 or 10. Other values will generated exceptions

placeOrder

placeOrder Source #

Arguments

:: (Consumes PlaceOrder contentType, MimeRender contentType Order) 
=> contentType

request content-type (MimeType)

-> Order

"body" - order placed for purchasing the pet

-> SwaggerPetstoreRequest PlaceOrder contentType Order 
POST /store/order

Place an order for a pet

data PlaceOrder Source #

Instances

Produces PlaceOrder MimeXML Source #
application/xml
Produces PlaceOrder MimeJSON Source #
application/json
HasBodyParam PlaceOrder Order Source #

Body Param "body" - order placed for purchasing the pet

Methods

setBodyParam :: (Consumes PlaceOrder contentType, MimeRender contentType Order) => SwaggerPetstoreRequest PlaceOrder contentType res -> Order -> SwaggerPetstoreRequest PlaceOrder contentType res Source #

User

createUser

createUser Source #

Arguments

:: (Consumes CreateUser contentType, MimeRender contentType User) 
=> contentType

request content-type (MimeType)

-> User

"body" - Created user object

-> SwaggerPetstoreRequest CreateUser contentType res 
POST /user

Create user

This can only be done by the logged in user.

Note: Has Produces instances, but no response schema

data CreateUser Source #

Instances

Produces CreateUser MimeXML Source #
application/xml
Produces CreateUser MimeJSON Source #
application/json
HasBodyParam CreateUser User Source #

Body Param "body" - Created user object

Methods

setBodyParam :: (Consumes CreateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest CreateUser contentType res -> User -> SwaggerPetstoreRequest CreateUser contentType res Source #

createUsersWithArrayInput

createUsersWithArrayInput Source #

Arguments

:: (Consumes CreateUsersWithArrayInput contentType, MimeRender contentType Body) 
=> contentType

request content-type (MimeType)

-> Body

"body" - List of user object

-> SwaggerPetstoreRequest CreateUsersWithArrayInput contentType res 
POST /user/createWithArray

Creates list of users with given input array

Note: Has Produces instances, but no response schema

createUsersWithListInput

createUsersWithListInput Source #

Arguments

:: (Consumes CreateUsersWithListInput contentType, MimeRender contentType Body) 
=> contentType

request content-type (MimeType)

-> Body

"body" - List of user object

-> SwaggerPetstoreRequest CreateUsersWithListInput contentType res 
POST /user/createWithList

Creates list of users with given input array

Note: Has Produces instances, but no response schema

deleteUser

deleteUser Source #

Arguments

:: Username

"username" - The name that needs to be deleted

-> SwaggerPetstoreRequest DeleteUser MimeNoContent res 
DELETE /user/{username}

Delete user

This can only be done by the logged in user.

Note: Has Produces instances, but no response schema

data DeleteUser Source #

Instances

getUserByName

getUserByName Source #

Arguments

:: Username

"username" - The name that needs to be fetched. Use user1 for testing.

-> SwaggerPetstoreRequest GetUserByName MimeNoContent User 
GET /user/{username}

Get user by user name

loginUser

loginUser Source #

Arguments

:: Username

"username" - The user name for login

-> Password

"password" - The password for login in clear text

-> SwaggerPetstoreRequest LoginUser MimeNoContent Text 
GET /user/login

Logs user into the system

data LoginUser Source #

Instances

logoutUser

logoutUser :: SwaggerPetstoreRequest LogoutUser MimeNoContent res Source #

GET /user/logout

Logs out current logged in user session

Note: Has Produces instances, but no response schema

data LogoutUser Source #

Instances

updateUser

updateUser Source #

Arguments

:: (Consumes UpdateUser contentType, MimeRender contentType User) 
=> contentType

request content-type (MimeType)

-> Username

"username" - name that need to be deleted

-> User

"body" - Updated user object

-> SwaggerPetstoreRequest UpdateUser contentType res 
PUT /user/{username}

Updated user

This can only be done by the logged in user.

Note: Has Produces instances, but no response schema

data UpdateUser Source #

Instances

Produces UpdateUser MimeXML Source #
application/xml
Produces UpdateUser MimeJSON Source #
application/json
HasBodyParam UpdateUser User Source #

Body Param "body" - Updated user object

Methods

setBodyParam :: (Consumes UpdateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest UpdateUser contentType res -> User -> SwaggerPetstoreRequest UpdateUser contentType res Source #

Parameter newtypes

newtype Body Source #

Constructors

Body 

Fields

newtype Byte Source #

Constructors

Byte 

Fields

Instances

Eq Byte Source # 

Methods

(==) :: Byte -> Byte -> Bool #

(/=) :: Byte -> Byte -> Bool #

Show Byte Source # 

Methods

showsPrec :: Int -> Byte -> ShowS #

show :: Byte -> String #

showList :: [Byte] -> ShowS #

newtype File Source #

Constructors

File 

Fields

Instances

Eq File Source # 

Methods

(==) :: File -> File -> Bool #

(/=) :: File -> File -> Bool #

Show File Source # 

Methods

showsPrec :: Int -> File -> ShowS #

show :: File -> String #

showList :: [File] -> ShowS #

HasOptionalParam UploadFile File Source #

Optional Param "file" - file to upload

newtype Name2 Source #

Constructors

Name2 

Fields

newtype Number Source #

Constructors

Number 

Fields

Instances

newtype OrderId Source #

Constructors

OrderId 

Fields

newtype Param Source #

Constructors

Param 

Fields

Instances

Eq Param Source # 

Methods

(==) :: Param -> Param -> Bool #

(/=) :: Param -> Param -> Bool #

Show Param Source # 

Methods

showsPrec :: Int -> Param -> ShowS #

show :: Param -> String #

showList :: [Param] -> ShowS #

newtype Param2 Source #

Constructors

Param2 

Fields

Instances

newtype PetId Source #

Constructors

PetId 

Fields

Instances

Eq PetId Source # 

Methods

(==) :: PetId -> PetId -> Bool #

(/=) :: PetId -> PetId -> Bool #

Show PetId Source # 

Methods

showsPrec :: Int -> PetId -> ShowS #

show :: PetId -> String #

showList :: [PetId] -> ShowS #

newtype Status Source #

Constructors

Status 

Fields

Instances

newtype Tags Source #

Constructors

Tags 

Fields

Instances

Eq Tags Source # 

Methods

(==) :: Tags -> Tags -> Bool #

(/=) :: Tags -> Tags -> Bool #

Show Tags Source # 

Methods

showsPrec :: Int -> Tags -> ShowS #

show :: Tags -> String #

showList :: [Tags] -> ShowS #

newtype Username Source #

Constructors

Username 

Fields

Auth Methods

AuthApiKeyApiKey

AuthApiKeyApiKeyQuery

AuthBasicHttpBasicTest

AuthOAuthPetstoreAuth

Custom Mime Types

MimeJsonCharsetutf8

MimeXmlCharsetutf8

\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Core.html b/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Core.html index 684f3ff14b6..8872db499a6 100644 --- a/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Core.html +++ b/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Core.html @@ -1,4 +1,4 @@ SwaggerPetstore.Core

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Safe HaskellNone
LanguageHaskell2010

SwaggerPetstore.Core

Description

 

Synopsis

SwaggerPetstoreConfig

data SwaggerPetstoreConfig Source #

Constructors

SwaggerPetstoreConfig 

Fields

newConfig :: IO SwaggerPetstoreConfig Source #

constructs a default SwaggerPetstoreConfig

configHost:

http://petstore.swagger.io:80/v2

configUserAgent:

"swagger-haskell-http-client/1.0.0"

addAuthMethod :: AuthMethod auth => SwaggerPetstoreConfig -> auth -> SwaggerPetstoreConfig Source #

updates config use AuthMethod on matching requests

withStdoutLogging :: SwaggerPetstoreConfig -> IO SwaggerPetstoreConfig Source #

updates the config to use stdout logging

withStderrLogging :: SwaggerPetstoreConfig -> IO SwaggerPetstoreConfig Source #

updates the config to use stderr logging

withNoLogging :: SwaggerPetstoreConfig -> SwaggerPetstoreConfig Source #

updates the config to disable logging

SwaggerPetstoreRequest

data SwaggerPetstoreRequest req contentType res Source #

Represents a request. The "req" type variable is the request type. The "res" type variable is the response type.

Constructors

SwaggerPetstoreRequest 

Fields

Instances

Show (SwaggerPetstoreRequest req contentType res) Source # 

Methods

showsPrec :: Int -> SwaggerPetstoreRequest req contentType res -> ShowS #

show :: SwaggerPetstoreRequest req contentType res -> String #

showList :: [SwaggerPetstoreRequest req contentType res] -> ShowS #

HasBodyParam

class HasBodyParam req param where Source #

Designates the body parameter of a request

Methods

setBodyParam :: forall contentType res. (Consumes req contentType, MimeRender contentType param) => SwaggerPetstoreRequest req contentType res -> param -> SwaggerPetstoreRequest req contentType res Source #

Instances

HasBodyParam UpdateUser User Source #

Body Param "body" - Updated user object

Methods

setBodyParam :: (Consumes UpdateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest UpdateUser contentType res -> User -> SwaggerPetstoreRequest UpdateUser contentType res Source #

HasBodyParam CreateUsersWithListInput Body Source #

Body Param "body" - List of user object

HasBodyParam CreateUsersWithArrayInput Body Source #

Body Param "body" - List of user object

HasBodyParam CreateUser User Source #

Body Param "body" - Created user object

Methods

setBodyParam :: (Consumes CreateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest CreateUser contentType res -> User -> SwaggerPetstoreRequest CreateUser contentType res Source #

HasBodyParam PlaceOrder Order Source #

Body Param "body" - order placed for purchasing the pet

Methods

setBodyParam :: (Consumes PlaceOrder contentType, MimeRender contentType Order) => SwaggerPetstoreRequest PlaceOrder contentType res -> Order -> SwaggerPetstoreRequest PlaceOrder contentType res Source #

HasBodyParam UpdatePet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes UpdatePet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest UpdatePet contentType res -> Pet -> SwaggerPetstoreRequest UpdatePet contentType res Source #

HasBodyParam AddPet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes AddPet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest AddPet contentType res -> Pet -> SwaggerPetstoreRequest AddPet contentType res Source #

HasBodyParam TestClassname Client Source #

Body Param "body" - client model

Methods

setBodyParam :: (Consumes TestClassname contentType, MimeRender contentType Client) => SwaggerPetstoreRequest TestClassname contentType res -> Client -> SwaggerPetstoreRequest TestClassname contentType res Source #

HasBodyParam TestClientModel Client Source #

Body Param "body" - client model

HasBodyParam FakeOuterStringSerialize OuterString Source #

Body Param "body" - Input string as post body

HasBodyParam FakeOuterNumberSerialize OuterNumber Source #

Body Param "body" - Input number as post body

HasBodyParam FakeOuterCompositeSerialize OuterComposite Source #

Body Param "body" - Input composite as post body

HasBodyParam FakeOuterBooleanSerialize OuterBoolean Source #

Body Param "body" - Input boolean as post body

HasBodyParam TestSpecialTags Client Source #

Body Param "body" - client model

HasOptionalParam

class HasOptionalParam req param where Source #

Designates the optional parameters of a request

Minimal complete definition

applyOptionalParam | (-&-)

Methods

applyOptionalParam :: SwaggerPetstoreRequest req contentType res -> param -> SwaggerPetstoreRequest req contentType res Source #

Apply an optional parameter to a request

(-&-) :: SwaggerPetstoreRequest req contentType res -> param -> SwaggerPetstoreRequest req contentType res infixl 2 Source #

infix operator / alias for addOptionalParam

Instances

HasOptionalParam UploadFile File Source #

Optional Param "file" - file to upload

HasOptionalParam UploadFile AdditionalMetadata Source #

Optional Param "additionalMetadata" - Additional data to pass to server

HasOptionalParam UpdatePetWithForm StatusText Source #

Optional Param "status" - Updated status of the pet

HasOptionalParam UpdatePetWithForm Name2 Source #

Optional Param "name" - Updated name of the pet

HasOptionalParam DeletePet ApiKey Source # 
HasOptionalParam TestEnumParameters EnumQueryStringArray Source #

Optional Param "enum_query_string_array" - Query parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumQueryString Source #

Optional Param "enum_query_string" - Query parameter enum test (string)

HasOptionalParam TestEnumParameters EnumQueryInteger Source #

Optional Param "enum_query_integer" - Query parameter enum test (double)

HasOptionalParam TestEnumParameters EnumQueryDouble Source #

Optional Param "enum_query_double" - Query parameter enum test (double)

HasOptionalParam TestEnumParameters EnumHeaderStringArray Source #

Optional Param "enum_header_string_array" - Header parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumHeaderString Source #

Optional Param "enum_header_string" - Header parameter enum test (string)

HasOptionalParam TestEnumParameters EnumFormStringArray Source #

Optional Param "enum_form_string_array" - Form parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumFormString Source #

Optional Param "enum_form_string" - Form parameter enum test (string)

HasOptionalParam TestEndpointParameters Password Source #

Optional Param "password" - None

HasOptionalParam TestEndpointParameters ParamString Source #

Optional Param "string" - None

HasOptionalParam TestEndpointParameters ParamInteger Source #

Optional Param "integer" - None

HasOptionalParam TestEndpointParameters ParamFloat Source #

Optional Param "float" - None

HasOptionalParam TestEndpointParameters ParamDateTime Source #

Optional Param "dateTime" - None

HasOptionalParam TestEndpointParameters ParamDate Source #

Optional Param "date" - None

HasOptionalParam TestEndpointParameters ParamBinary Source #

Optional Param "binary" - None

HasOptionalParam TestEndpointParameters Int64 Source #

Optional Param "int64" - None

HasOptionalParam TestEndpointParameters Int32 Source #

Optional Param "int32" - None

HasOptionalParam TestEndpointParameters Callback Source #

Optional Param "callback" - None

data Params Source #

Request Params

Instances

SwaggerPetstoreRequest Utils

_mkRequest Source #

Arguments

:: Method

Method

-> [ByteString]

Endpoint

-> SwaggerPetstoreRequest req contentType res

req: Request Type, res: Response Type

setHeader :: SwaggerPetstoreRequest req contentType res -> [Header] -> SwaggerPetstoreRequest req contentType res Source #

removeHeader :: SwaggerPetstoreRequest req contentType res -> [HeaderName] -> SwaggerPetstoreRequest req contentType res Source #

_setContentTypeHeader :: forall req contentType res. MimeType contentType => SwaggerPetstoreRequest req contentType res -> SwaggerPetstoreRequest req contentType res Source #

_setAcceptHeader :: forall req contentType res accept. MimeType accept => SwaggerPetstoreRequest req contentType res -> accept -> SwaggerPetstoreRequest req contentType res Source #

setQuery :: SwaggerPetstoreRequest req contentType res -> [QueryItem] -> SwaggerPetstoreRequest req contentType res Source #

addForm :: SwaggerPetstoreRequest req contentType res -> Form -> SwaggerPetstoreRequest req contentType res Source #

_addMultiFormPart :: SwaggerPetstoreRequest req contentType res -> Part -> SwaggerPetstoreRequest req contentType res Source #

_setBodyBS :: SwaggerPetstoreRequest req contentType res -> ByteString -> SwaggerPetstoreRequest req contentType res Source #

_setBodyLBS :: SwaggerPetstoreRequest req contentType res -> ByteString -> SwaggerPetstoreRequest req contentType res Source #

_hasAuthType :: AuthMethod authMethod => SwaggerPetstoreRequest req contentType res -> Proxy authMethod -> SwaggerPetstoreRequest req contentType res Source #

Params Utils

Swagger CollectionFormat Utils

data CollectionFormat Source #

Determines the format of the array if type array is used.

Constructors

CommaSeparated

CSV format for multiple parameters.

SpaceSeparated

Also called SSV

TabSeparated

Also called TSV

PipeSeparated

`value1|value2|value2`

MultiParamArray

Using multiple GET parameters, e.g. `foo=bar&foo=baz`. This is valid only for parameters in "query" (Query) or "formData" (Form)

_toColl :: Traversable f => CollectionFormat -> (f a -> [(b, ByteString)]) -> f [a] -> [(b, ByteString)] Source #

_toCollA :: (Traversable f, Traversable t, Alternative t) => CollectionFormat -> (f (t a) -> [(b, t ByteString)]) -> f (t [a]) -> [(b, t ByteString)] Source #

_toCollA' :: (Monoid c, Traversable f, Traversable t, Alternative t) => CollectionFormat -> (f (t a) -> [(b, t c)]) -> (Char -> c) -> f (t [a]) -> [(b, t c)] Source #

AuthMethods

data AnyAuthMethod Source #

An existential wrapper for any AuthMethod

Constructors

AuthMethod a => AnyAuthMethod a 

_applyAuthMethods :: SwaggerPetstoreRequest req contentType res -> SwaggerPetstoreConfig -> IO (SwaggerPetstoreRequest req contentType res) Source #

apply all matching AuthMethods in config to request

Utils

_omitNulls :: [(Text, Value)] -> Value Source #

Removes Null fields. (OpenAPI-Specification 2.0 does not allow Null in JSON)

_toFormItem :: (ToHttpApiData a, Functor f) => t -> f a -> f (t, [Text]) Source #

Encodes fields using WH.toQueryParam

_emptyToNothing :: Maybe String -> Maybe String Source #

Collapse (Just "") to Nothing

_memptyToNothing :: (Monoid a, Eq a) => Maybe a -> Maybe a Source #

Collapse (Just mempty) to Nothing

DateTime Formatting

newtype DateTime Source #

Constructors

DateTime 

Fields

Instances

Eq DateTime Source # 
Data DateTime Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DateTime -> c DateTime #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DateTime #

toConstr :: DateTime -> Constr #

dataTypeOf :: DateTime -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c DateTime) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DateTime) #

gmapT :: (forall b. Data b => b -> b) -> DateTime -> DateTime #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DateTime -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DateTime -> r #

gmapQ :: (forall d. Data d => d -> u) -> DateTime -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> DateTime -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime #

Ord DateTime Source # 
Show DateTime Source # 
ToJSON DateTime Source # 
FromJSON DateTime Source # 
NFData DateTime Source # 

Methods

rnf :: DateTime -> () #

ToHttpApiData DateTime Source # 
FromHttpApiData DateTime Source # 
FormatTime DateTime Source # 
ParseTime DateTime Source # 
MimeRender MimeMultipartFormData DateTime Source # 

_readDateTime :: (ParseTime t, Monad m, Alternative m) => String -> m t Source #

_parseISO8601

_showDateTime :: (t ~ UTCTime, FormatTime t) => t -> String Source #

TI.formatISO8601Millis

_parseISO8601 :: (ParseTime t, Monad m, Alternative m) => String -> m t Source #

parse an ISO8601 date-time string

Date Formatting

newtype Date Source #

Constructors

Date 

Fields

Instances

Enum Date Source # 

Methods

succ :: Date -> Date #

pred :: Date -> Date #

toEnum :: Int -> Date #

fromEnum :: Date -> Int #

enumFrom :: Date -> [Date] #

enumFromThen :: Date -> Date -> [Date] #

enumFromTo :: Date -> Date -> [Date] #

enumFromThenTo :: Date -> Date -> Date -> [Date] #

Eq Date Source # 

Methods

(==) :: Date -> Date -> Bool #

(/=) :: Date -> Date -> Bool #

Data Date Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Date -> c Date #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Date #

toConstr :: Date -> Constr #

dataTypeOf :: Date -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Date) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Date) #

gmapT :: (forall b. Data b => b -> b) -> Date -> Date #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Date -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Date -> r #

gmapQ :: (forall d. Data d => d -> u) -> Date -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Date -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Date -> m Date #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Date -> m Date #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Date -> m Date #

Ord Date Source # 

Methods

compare :: Date -> Date -> Ordering #

(<) :: Date -> Date -> Bool #

(<=) :: Date -> Date -> Bool #

(>) :: Date -> Date -> Bool #

(>=) :: Date -> Date -> Bool #

max :: Date -> Date -> Date #

min :: Date -> Date -> Date #

Show Date Source # 

Methods

showsPrec :: Int -> Date -> ShowS #

show :: Date -> String #

showList :: [Date] -> ShowS #

Ix Date Source # 

Methods

range :: (Date, Date) -> [Date] #

index :: (Date, Date) -> Date -> Int #

unsafeIndex :: (Date, Date) -> Date -> Int

inRange :: (Date, Date) -> Date -> Bool #

rangeSize :: (Date, Date) -> Int #

unsafeRangeSize :: (Date, Date) -> Int

ToJSON Date Source # 
FromJSON Date Source # 
NFData Date Source # 

Methods

rnf :: Date -> () #

ToHttpApiData Date Source # 
FromHttpApiData Date Source # 
FormatTime Date Source # 
ParseTime Date Source # 

Methods

buildTime :: TimeLocale -> [(Char, String)] -> Maybe Date #

MimeRender MimeMultipartFormData Date Source # 

_readDate :: (ParseTime t, Monad m) => String -> m t Source #

TI.parseTimeM True TI.defaultTimeLocale "%Y-%m-%d"

_showDate :: FormatTime t => t -> String Source #

TI.formatTime TI.defaultTimeLocale "%Y-%m-%d"

Byte/Binary Formatting

newtype ByteArray Source #

base64 encoded characters

Constructors

ByteArray 

Instances

Eq ByteArray Source # 
Data ByteArray Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ByteArray -> c ByteArray #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ByteArray #

toConstr :: ByteArray -> Constr #

dataTypeOf :: ByteArray -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c ByteArray) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ByteArray) #

gmapT :: (forall b. Data b => b -> b) -> ByteArray -> ByteArray #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ByteArray -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ByteArray -> r #

gmapQ :: (forall d. Data d => d -> u) -> ByteArray -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ByteArray -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ByteArray -> m ByteArray #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteArray -> m ByteArray #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteArray -> m ByteArray #

Ord ByteArray Source # 
Show ByteArray Source # 
ToJSON ByteArray Source # 
FromJSON ByteArray Source # 
NFData ByteArray Source # 

Methods

rnf :: ByteArray -> () #

ToHttpApiData ByteArray Source # 
FromHttpApiData ByteArray Source # 
MimeRender MimeMultipartFormData ByteArray Source # 

_readByteArray :: Monad m => Text -> m ByteArray Source #

read base64 encoded characters

_showByteArray :: ByteArray -> Text Source #

show base64 encoded characters

newtype Binary Source #

any sequence of octets

Constructors

Binary 

Fields

Instances

Eq Binary Source # 

Methods

(==) :: Binary -> Binary -> Bool #

(/=) :: Binary -> Binary -> Bool #

Data Binary Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Binary -> c Binary #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Binary #

toConstr :: Binary -> Constr #

dataTypeOf :: Binary -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Binary) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Binary) #

gmapT :: (forall b. Data b => b -> b) -> Binary -> Binary #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Binary -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Binary -> r #

gmapQ :: (forall d. Data d => d -> u) -> Binary -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Binary -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Binary -> m Binary #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Binary -> m Binary #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Binary -> m Binary #

Ord Binary Source # 
Show Binary Source # 
ToJSON Binary Source # 
FromJSON Binary Source # 
NFData Binary Source # 

Methods

rnf :: Binary -> () #

ToHttpApiData Binary Source # 
FromHttpApiData Binary Source # 
MimeRender MimeMultipartFormData Binary Source # 

Lens Type Aliases

type Lens_' s a = Lens_ s s a a Source #

type Lens_ s t a b = forall f. Functor f => (a -> f b) -> s -> f t Source #

\ No newline at end of file +

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Safe HaskellNone
LanguageHaskell2010

SwaggerPetstore.Core

Description

 

Synopsis

SwaggerPetstoreConfig

data SwaggerPetstoreConfig Source #

Constructors

SwaggerPetstoreConfig 

Fields

newConfig :: IO SwaggerPetstoreConfig Source #

constructs a default SwaggerPetstoreConfig

configHost:

http://petstore.swagger.io:80/v2

configUserAgent:

"swagger-haskell-http-client/1.0.0"

addAuthMethod :: AuthMethod auth => SwaggerPetstoreConfig -> auth -> SwaggerPetstoreConfig Source #

updates config use AuthMethod on matching requests

withStdoutLogging :: SwaggerPetstoreConfig -> IO SwaggerPetstoreConfig Source #

updates the config to use stdout logging

withStderrLogging :: SwaggerPetstoreConfig -> IO SwaggerPetstoreConfig Source #

updates the config to use stderr logging

withNoLogging :: SwaggerPetstoreConfig -> SwaggerPetstoreConfig Source #

updates the config to disable logging

SwaggerPetstoreRequest

data SwaggerPetstoreRequest req contentType res Source #

Represents a request. The "req" type variable is the request type. The "res" type variable is the response type.

Constructors

SwaggerPetstoreRequest 

Fields

Instances

Show (SwaggerPetstoreRequest req contentType res) Source # 

Methods

showsPrec :: Int -> SwaggerPetstoreRequest req contentType res -> ShowS #

show :: SwaggerPetstoreRequest req contentType res -> String #

showList :: [SwaggerPetstoreRequest req contentType res] -> ShowS #

HasBodyParam

class HasBodyParam req param where Source #

Designates the body parameter of a request

Methods

setBodyParam :: forall contentType res. (Consumes req contentType, MimeRender contentType param) => SwaggerPetstoreRequest req contentType res -> param -> SwaggerPetstoreRequest req contentType res Source #

Instances

HasBodyParam UpdateUser User Source #

Body Param "body" - Updated user object

Methods

setBodyParam :: (Consumes UpdateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest UpdateUser contentType res -> User -> SwaggerPetstoreRequest UpdateUser contentType res Source #

HasBodyParam CreateUsersWithListInput Body Source #

Body Param "body" - List of user object

HasBodyParam CreateUsersWithArrayInput Body Source #

Body Param "body" - List of user object

HasBodyParam CreateUser User Source #

Body Param "body" - Created user object

Methods

setBodyParam :: (Consumes CreateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest CreateUser contentType res -> User -> SwaggerPetstoreRequest CreateUser contentType res Source #

HasBodyParam PlaceOrder Order Source #

Body Param "body" - order placed for purchasing the pet

Methods

setBodyParam :: (Consumes PlaceOrder contentType, MimeRender contentType Order) => SwaggerPetstoreRequest PlaceOrder contentType res -> Order -> SwaggerPetstoreRequest PlaceOrder contentType res Source #

HasBodyParam UpdatePet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes UpdatePet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest UpdatePet contentType res -> Pet -> SwaggerPetstoreRequest UpdatePet contentType res Source #

HasBodyParam AddPet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes AddPet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest AddPet contentType res -> Pet -> SwaggerPetstoreRequest AddPet contentType res Source #

HasBodyParam TestClassname Client Source #

Body Param "body" - client model

Methods

setBodyParam :: (Consumes TestClassname contentType, MimeRender contentType Client) => SwaggerPetstoreRequest TestClassname contentType res -> Client -> SwaggerPetstoreRequest TestClassname contentType res Source #

HasBodyParam TestInlineAdditionalProperties Value Source #

Body Param "param" - request body

HasBodyParam TestClientModel Client Source #

Body Param "body" - client model

HasBodyParam FakeOuterStringSerialize OuterString Source #

Body Param "body" - Input string as post body

HasBodyParam FakeOuterNumberSerialize OuterNumber Source #

Body Param "body" - Input number as post body

HasBodyParam FakeOuterCompositeSerialize OuterComposite Source #

Body Param "body" - Input composite as post body

HasBodyParam FakeOuterBooleanSerialize OuterBoolean Source #

Body Param "body" - Input boolean as post body

HasBodyParam TestSpecialTags Client Source #

Body Param "body" - client model

HasOptionalParam

class HasOptionalParam req param where Source #

Designates the optional parameters of a request

Minimal complete definition

applyOptionalParam | (-&-)

Methods

applyOptionalParam :: SwaggerPetstoreRequest req contentType res -> param -> SwaggerPetstoreRequest req contentType res Source #

Apply an optional parameter to a request

(-&-) :: SwaggerPetstoreRequest req contentType res -> param -> SwaggerPetstoreRequest req contentType res infixl 2 Source #

infix operator / alias for addOptionalParam

Instances

HasOptionalParam UploadFile File Source #

Optional Param "file" - file to upload

HasOptionalParam UploadFile AdditionalMetadata Source #

Optional Param "additionalMetadata" - Additional data to pass to server

HasOptionalParam UpdatePetWithForm StatusText Source #

Optional Param "status" - Updated status of the pet

HasOptionalParam UpdatePetWithForm Name2 Source #

Optional Param "name" - Updated name of the pet

HasOptionalParam DeletePet ApiKey Source # 
HasOptionalParam TestEnumParameters EnumQueryStringArray Source #

Optional Param "enum_query_string_array" - Query parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumQueryString Source #

Optional Param "enum_query_string" - Query parameter enum test (string)

HasOptionalParam TestEnumParameters EnumQueryInteger Source #

Optional Param "enum_query_integer" - Query parameter enum test (double)

HasOptionalParam TestEnumParameters EnumQueryDouble Source #

Optional Param "enum_query_double" - Query parameter enum test (double)

HasOptionalParam TestEnumParameters EnumHeaderStringArray Source #

Optional Param "enum_header_string_array" - Header parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumHeaderString Source #

Optional Param "enum_header_string" - Header parameter enum test (string)

HasOptionalParam TestEnumParameters EnumFormStringArray Source #

Optional Param "enum_form_string_array" - Form parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumFormString Source #

Optional Param "enum_form_string" - Form parameter enum test (string)

HasOptionalParam TestEndpointParameters Password Source #

Optional Param "password" - None

HasOptionalParam TestEndpointParameters ParamString Source #

Optional Param "string" - None

HasOptionalParam TestEndpointParameters ParamInteger Source #

Optional Param "integer" - None

HasOptionalParam TestEndpointParameters ParamFloat Source #

Optional Param "float" - None

HasOptionalParam TestEndpointParameters ParamDateTime Source #

Optional Param "dateTime" - None

HasOptionalParam TestEndpointParameters ParamDate Source #

Optional Param "date" - None

HasOptionalParam TestEndpointParameters ParamBinary Source #

Optional Param "binary" - None

HasOptionalParam TestEndpointParameters Int64 Source #

Optional Param "int64" - None

HasOptionalParam TestEndpointParameters Int32 Source #

Optional Param "int32" - None

HasOptionalParam TestEndpointParameters Callback Source #

Optional Param "callback" - None

data Params Source #

Request Params

Instances

SwaggerPetstoreRequest Utils

_mkRequest Source #

Arguments

:: Method

Method

-> [ByteString]

Endpoint

-> SwaggerPetstoreRequest req contentType res

req: Request Type, res: Response Type

setHeader :: SwaggerPetstoreRequest req contentType res -> [Header] -> SwaggerPetstoreRequest req contentType res Source #

removeHeader :: SwaggerPetstoreRequest req contentType res -> [HeaderName] -> SwaggerPetstoreRequest req contentType res Source #

_setContentTypeHeader :: forall req contentType res. MimeType contentType => SwaggerPetstoreRequest req contentType res -> SwaggerPetstoreRequest req contentType res Source #

_setAcceptHeader :: forall req contentType res accept. MimeType accept => SwaggerPetstoreRequest req contentType res -> accept -> SwaggerPetstoreRequest req contentType res Source #

setQuery :: SwaggerPetstoreRequest req contentType res -> [QueryItem] -> SwaggerPetstoreRequest req contentType res Source #

addForm :: SwaggerPetstoreRequest req contentType res -> Form -> SwaggerPetstoreRequest req contentType res Source #

_addMultiFormPart :: SwaggerPetstoreRequest req contentType res -> Part -> SwaggerPetstoreRequest req contentType res Source #

_setBodyBS :: SwaggerPetstoreRequest req contentType res -> ByteString -> SwaggerPetstoreRequest req contentType res Source #

_setBodyLBS :: SwaggerPetstoreRequest req contentType res -> ByteString -> SwaggerPetstoreRequest req contentType res Source #

_hasAuthType :: AuthMethod authMethod => SwaggerPetstoreRequest req contentType res -> Proxy authMethod -> SwaggerPetstoreRequest req contentType res Source #

Params Utils

Swagger CollectionFormat Utils

data CollectionFormat Source #

Determines the format of the array if type array is used.

Constructors

CommaSeparated

CSV format for multiple parameters.

SpaceSeparated

Also called SSV

TabSeparated

Also called TSV

PipeSeparated

`value1|value2|value2`

MultiParamArray

Using multiple GET parameters, e.g. `foo=bar&foo=baz`. This is valid only for parameters in "query" (Query) or "formData" (Form)

_toColl :: Traversable f => CollectionFormat -> (f a -> [(b, ByteString)]) -> f [a] -> [(b, ByteString)] Source #

_toCollA :: (Traversable f, Traversable t, Alternative t) => CollectionFormat -> (f (t a) -> [(b, t ByteString)]) -> f (t [a]) -> [(b, t ByteString)] Source #

_toCollA' :: (Monoid c, Traversable f, Traversable t, Alternative t) => CollectionFormat -> (f (t a) -> [(b, t c)]) -> (Char -> c) -> f (t [a]) -> [(b, t c)] Source #

AuthMethods

data AnyAuthMethod Source #

An existential wrapper for any AuthMethod

Constructors

AuthMethod a => AnyAuthMethod a 

_applyAuthMethods :: SwaggerPetstoreRequest req contentType res -> SwaggerPetstoreConfig -> IO (SwaggerPetstoreRequest req contentType res) Source #

apply all matching AuthMethods in config to request

Utils

_omitNulls :: [(Text, Value)] -> Value Source #

Removes Null fields. (OpenAPI-Specification 2.0 does not allow Null in JSON)

_toFormItem :: (ToHttpApiData a, Functor f) => t -> f a -> f (t, [Text]) Source #

Encodes fields using WH.toQueryParam

_emptyToNothing :: Maybe String -> Maybe String Source #

Collapse (Just "") to Nothing

_memptyToNothing :: (Monoid a, Eq a) => Maybe a -> Maybe a Source #

Collapse (Just mempty) to Nothing

DateTime Formatting

newtype DateTime Source #

Constructors

DateTime 

Fields

Instances

Eq DateTime Source # 
Data DateTime Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DateTime -> c DateTime #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DateTime #

toConstr :: DateTime -> Constr #

dataTypeOf :: DateTime -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c DateTime) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DateTime) #

gmapT :: (forall b. Data b => b -> b) -> DateTime -> DateTime #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DateTime -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DateTime -> r #

gmapQ :: (forall d. Data d => d -> u) -> DateTime -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> DateTime -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime #

Ord DateTime Source # 
Show DateTime Source # 
ToJSON DateTime Source # 
FromJSON DateTime Source # 
NFData DateTime Source # 

Methods

rnf :: DateTime -> () #

ToHttpApiData DateTime Source # 
FromHttpApiData DateTime Source # 
FormatTime DateTime Source # 
ParseTime DateTime Source # 
MimeRender MimeMultipartFormData DateTime Source # 

_readDateTime :: (ParseTime t, Monad m, Alternative m) => String -> m t Source #

_parseISO8601

_showDateTime :: (t ~ UTCTime, FormatTime t) => t -> String Source #

TI.formatISO8601Millis

_parseISO8601 :: (ParseTime t, Monad m, Alternative m) => String -> m t Source #

parse an ISO8601 date-time string

Date Formatting

newtype Date Source #

Constructors

Date 

Fields

Instances

Enum Date Source # 

Methods

succ :: Date -> Date #

pred :: Date -> Date #

toEnum :: Int -> Date #

fromEnum :: Date -> Int #

enumFrom :: Date -> [Date] #

enumFromThen :: Date -> Date -> [Date] #

enumFromTo :: Date -> Date -> [Date] #

enumFromThenTo :: Date -> Date -> Date -> [Date] #

Eq Date Source # 

Methods

(==) :: Date -> Date -> Bool #

(/=) :: Date -> Date -> Bool #

Data Date Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Date -> c Date #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Date #

toConstr :: Date -> Constr #

dataTypeOf :: Date -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Date) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Date) #

gmapT :: (forall b. Data b => b -> b) -> Date -> Date #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Date -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Date -> r #

gmapQ :: (forall d. Data d => d -> u) -> Date -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Date -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Date -> m Date #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Date -> m Date #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Date -> m Date #

Ord Date Source # 

Methods

compare :: Date -> Date -> Ordering #

(<) :: Date -> Date -> Bool #

(<=) :: Date -> Date -> Bool #

(>) :: Date -> Date -> Bool #

(>=) :: Date -> Date -> Bool #

max :: Date -> Date -> Date #

min :: Date -> Date -> Date #

Show Date Source # 

Methods

showsPrec :: Int -> Date -> ShowS #

show :: Date -> String #

showList :: [Date] -> ShowS #

Ix Date Source # 

Methods

range :: (Date, Date) -> [Date] #

index :: (Date, Date) -> Date -> Int #

unsafeIndex :: (Date, Date) -> Date -> Int

inRange :: (Date, Date) -> Date -> Bool #

rangeSize :: (Date, Date) -> Int #

unsafeRangeSize :: (Date, Date) -> Int

ToJSON Date Source # 
FromJSON Date Source # 
NFData Date Source # 

Methods

rnf :: Date -> () #

ToHttpApiData Date Source # 
FromHttpApiData Date Source # 
FormatTime Date Source # 
ParseTime Date Source # 

Methods

buildTime :: TimeLocale -> [(Char, String)] -> Maybe Date #

MimeRender MimeMultipartFormData Date Source # 

_readDate :: (ParseTime t, Monad m) => String -> m t Source #

TI.parseTimeM True TI.defaultTimeLocale "%Y-%m-%d"

_showDate :: FormatTime t => t -> String Source #

TI.formatTime TI.defaultTimeLocale "%Y-%m-%d"

Byte/Binary Formatting

newtype ByteArray Source #

base64 encoded characters

Constructors

ByteArray 

Instances

Eq ByteArray Source # 
Data ByteArray Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ByteArray -> c ByteArray #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ByteArray #

toConstr :: ByteArray -> Constr #

dataTypeOf :: ByteArray -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c ByteArray) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ByteArray) #

gmapT :: (forall b. Data b => b -> b) -> ByteArray -> ByteArray #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ByteArray -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ByteArray -> r #

gmapQ :: (forall d. Data d => d -> u) -> ByteArray -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ByteArray -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ByteArray -> m ByteArray #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteArray -> m ByteArray #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteArray -> m ByteArray #

Ord ByteArray Source # 
Show ByteArray Source # 
ToJSON ByteArray Source # 
FromJSON ByteArray Source # 
NFData ByteArray Source # 

Methods

rnf :: ByteArray -> () #

ToHttpApiData ByteArray Source # 
FromHttpApiData ByteArray Source # 
MimeRender MimeMultipartFormData ByteArray Source # 

_readByteArray :: Monad m => Text -> m ByteArray Source #

read base64 encoded characters

_showByteArray :: ByteArray -> Text Source #

show base64 encoded characters

newtype Binary Source #

any sequence of octets

Constructors

Binary 

Fields

Instances

Eq Binary Source # 

Methods

(==) :: Binary -> Binary -> Bool #

(/=) :: Binary -> Binary -> Bool #

Data Binary Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Binary -> c Binary #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Binary #

toConstr :: Binary -> Constr #

dataTypeOf :: Binary -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Binary) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Binary) #

gmapT :: (forall b. Data b => b -> b) -> Binary -> Binary #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Binary -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Binary -> r #

gmapQ :: (forall d. Data d => d -> u) -> Binary -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Binary -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Binary -> m Binary #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Binary -> m Binary #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Binary -> m Binary #

Ord Binary Source # 
Show Binary Source # 
ToJSON Binary Source # 
FromJSON Binary Source # 
NFData Binary Source # 

Methods

rnf :: Binary -> () #

ToHttpApiData Binary Source # 
FromHttpApiData Binary Source # 
MimeRender MimeMultipartFormData Binary Source # 

Lens Type Aliases

type Lens_' s a = Lens_ s s a a Source #

type Lens_ s t a b = forall f. Functor f => (a -> f b) -> s -> f t Source #

\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Logging.html b/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Logging.html index b99e0a66fba..dec96646845 100644 --- a/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Logging.html +++ b/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Logging.html @@ -1,4 +1,4 @@ SwaggerPetstore.Logging

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Safe HaskellNone
LanguageHaskell2010

SwaggerPetstore.Logging

Description

Katip Logging functions

Type Aliases (for compatability)

type LogExecWithContext = forall m. MonadIO m => LogContext -> LogExec m Source #

Runs a Katip logging block with the Log environment

type LogExec m = forall a. KatipT m a -> m a Source #

A Katip logging block

type LogContext = LogEnv Source #

A Katip Log environment

type LogLevel = Severity Source #

A Katip Log severity

default logger

initLogContext :: IO LogContext Source #

the default log environment

runDefaultLogExecWithContext :: LogExecWithContext Source #

Runs a Katip logging block with the Log environment

stdout logger

stdoutLoggingExec :: LogExecWithContext Source #

Runs a Katip logging block with the Log environment

stdoutLoggingContext :: LogContext -> IO LogContext Source #

A Katip Log environment which targets stdout

stderr logger

stderrLoggingExec :: LogExecWithContext Source #

Runs a Katip logging block with the Log environment

stderrLoggingContext :: LogContext -> IO LogContext Source #

A Katip Log environment which targets stderr

Null logger

runNullLogExec :: LogExecWithContext Source #

Disables Katip logging

Log Msg

_log :: (Applicative m, Katip m) => Text -> LogLevel -> Text -> m () Source #

Log a katip message

Log Exceptions

logExceptions :: (Katip m, MonadCatch m, Applicative m) => Text -> m a -> m a Source #

re-throws exceptions after logging them

Log Level

\ No newline at end of file +

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Safe HaskellNone
LanguageHaskell2010

SwaggerPetstore.Logging

Description

Katip Logging functions

Type Aliases (for compatability)

type LogExecWithContext = forall m. MonadIO m => LogContext -> LogExec m Source #

Runs a Katip logging block with the Log environment

type LogExec m = forall a. KatipT m a -> m a Source #

A Katip logging block

type LogContext = LogEnv Source #

A Katip Log environment

type LogLevel = Severity Source #

A Katip Log severity

default logger

initLogContext :: IO LogContext Source #

the default log environment

runDefaultLogExecWithContext :: LogExecWithContext Source #

Runs a Katip logging block with the Log environment

stdout logger

stdoutLoggingExec :: LogExecWithContext Source #

Runs a Katip logging block with the Log environment

stdoutLoggingContext :: LogContext -> IO LogContext Source #

A Katip Log environment which targets stdout

stderr logger

stderrLoggingExec :: LogExecWithContext Source #

Runs a Katip logging block with the Log environment

stderrLoggingContext :: LogContext -> IO LogContext Source #

A Katip Log environment which targets stderr

Null logger

runNullLogExec :: LogExecWithContext Source #

Disables Katip logging

Log Msg

_log :: (Applicative m, Katip m) => Text -> LogLevel -> Text -> m () Source #

Log a katip message

Log Exceptions

logExceptions :: (Katip m, MonadCatch m, Applicative m) => Text -> m a -> m a Source #

re-throws exceptions after logging them

Log Level

\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-MimeTypes.html b/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-MimeTypes.html index c63828e7d60..8e035cf190b 100644 --- a/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-MimeTypes.html +++ b/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-MimeTypes.html @@ -1,4 +1,4 @@ SwaggerPetstore.MimeTypes

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Safe HaskellNone
LanguageHaskell2010

SwaggerPetstore.MimeTypes

Description

 

Consumes Class

Produces Class

class MimeType mtype => Produces req mtype Source #

Instances

Produces UpdateUser MimeXML Source #
application/xml
Produces UpdateUser MimeJSON Source #
application/json
Produces LogoutUser MimeXML Source #
application/xml
Produces LogoutUser MimeJSON Source #
application/json
Produces LoginUser MimeXML Source #
application/xml
Produces LoginUser MimeJSON Source #
application/json
Produces GetUserByName MimeXML Source #
application/xml
Produces GetUserByName MimeJSON Source #
application/json
Produces DeleteUser MimeXML Source #
application/xml
Produces DeleteUser MimeJSON Source #
application/json
Produces CreateUsersWithListInput MimeXML Source #
application/xml
Produces CreateUsersWithListInput MimeJSON Source #
application/json
Produces CreateUsersWithArrayInput MimeXML Source #
application/xml
Produces CreateUsersWithArrayInput MimeJSON Source #
application/json
Produces CreateUser MimeXML Source #
application/xml
Produces CreateUser MimeJSON Source #
application/json
Produces PlaceOrder MimeXML Source #
application/xml
Produces PlaceOrder MimeJSON Source #
application/json
Produces GetOrderById MimeXML Source #
application/xml
Produces GetOrderById MimeJSON Source #
application/json
Produces GetInventory MimeJSON Source #
application/json
Produces DeleteOrder MimeXML Source #
application/xml
Produces DeleteOrder MimeJSON Source #
application/json
Produces UploadFile MimeJSON Source #
application/json
Produces UpdatePetWithForm MimeXML Source #
application/xml
Produces UpdatePetWithForm MimeJSON Source #
application/json
Produces UpdatePet MimeXML Source #
application/xml
Produces UpdatePet MimeJSON Source #
application/json
Produces GetPetById MimeXML Source #
application/xml
Produces GetPetById MimeJSON Source #
application/json
Produces FindPetsByTags MimeXML Source #
application/xml
Produces FindPetsByTags MimeJSON Source #
application/json
Produces FindPetsByStatus MimeXML Source #
application/xml
Produces FindPetsByStatus MimeJSON Source #
application/json
Produces DeletePet MimeXML Source #
application/xml
Produces DeletePet MimeJSON Source #
application/json
Produces AddPet MimeXML Source #
application/xml
Produces AddPet MimeJSON Source #
application/json
Produces TestClassname MimeJSON Source #
application/json
Produces TestEnumParameters MimeAny Source #
*/*
Produces TestEndpointParameters MimeXmlCharsetutf8 Source #
application/xml; charset=utf-8
Produces TestEndpointParameters MimeJsonCharsetutf8 Source #
application/json; charset=utf-8
Produces TestClientModel MimeJSON Source #
application/json
Produces TestSpecialTags MimeJSON Source #
application/json

Default Mime Types

data MimeJSON Source #

Constructors

MimeJSON 

Instances

MimeType MimeJSON Source #
application/json; charset=utf-8
FromJSON a => MimeUnrender MimeJSON a Source #
A.eitherDecode
ToJSON a => MimeRender MimeJSON a Source #

encode

Produces UpdateUser MimeJSON Source #
application/json
Produces LogoutUser MimeJSON Source #
application/json
Produces LoginUser MimeJSON Source #
application/json
Produces GetUserByName MimeJSON Source #
application/json
Produces DeleteUser MimeJSON Source #
application/json
Produces CreateUsersWithListInput MimeJSON Source #
application/json
Produces CreateUsersWithArrayInput MimeJSON Source #
application/json
Produces CreateUser MimeJSON Source #
application/json
Produces PlaceOrder MimeJSON Source #
application/json
Produces GetOrderById MimeJSON Source #
application/json
Produces GetInventory MimeJSON Source #
application/json
Produces DeleteOrder MimeJSON Source #
application/json
Produces UploadFile MimeJSON Source #
application/json
Produces UpdatePetWithForm MimeJSON Source #
application/json
Produces UpdatePet MimeJSON Source #
application/json
Produces GetPetById MimeJSON Source #
application/json
Produces FindPetsByTags MimeJSON Source #
application/json
Produces FindPetsByStatus MimeJSON Source #
application/json
Produces DeletePet MimeJSON Source #
application/json
Produces AddPet MimeJSON Source #
application/json
Produces TestClassname MimeJSON Source #
application/json
Produces TestClientModel MimeJSON Source #
application/json
Produces TestSpecialTags MimeJSON Source #
application/json
Consumes UpdatePet MimeJSON Source #
application/json
Consumes AddPet MimeJSON Source #
application/json
Consumes TestClassname MimeJSON Source #
application/json
Consumes TestJsonFormData MimeJSON Source #
application/json
Consumes TestClientModel MimeJSON Source #
application/json
Consumes TestSpecialTags MimeJSON Source #
application/json

data MimePlainText Source #

Constructors

MimePlainText 

Instances

MimeType MimePlainText Source #
text/plain; charset=utf-8
MimeUnrender MimePlainText ByteString Source #
P.Right . P.id
MimeUnrender MimePlainText String Source #
P.Right . BCL.unpack
MimeUnrender MimePlainText Text Source #
P.left P.show . TL.decodeUtf8'
MimeRender MimePlainText ByteString Source #
P.id
MimeRender MimePlainText String Source #
BCL.pack
MimeRender MimePlainText Text Source #
BL.fromStrict . T.encodeUtf8

data MimeMultipartFormData Source #

Constructors

MimeMultipartFormData 

Instances

MimeType MimeMultipartFormData Source #
multipart/form-data
MimeRender MimeMultipartFormData Bool Source # 
MimeRender MimeMultipartFormData Char Source # 
MimeRender MimeMultipartFormData Double Source # 
MimeRender MimeMultipartFormData Float Source # 
MimeRender MimeMultipartFormData Int Source # 
MimeRender MimeMultipartFormData Integer Source # 
MimeRender MimeMultipartFormData ByteString Source # 
MimeRender MimeMultipartFormData String Source # 
MimeRender MimeMultipartFormData Text Source # 
MimeRender MimeMultipartFormData Binary Source # 
MimeRender MimeMultipartFormData ByteArray Source # 
MimeRender MimeMultipartFormData Date Source # 
MimeRender MimeMultipartFormData DateTime Source # 
Consumes UploadFile MimeMultipartFormData Source #
multipart/form-data

data MimeOctetStream Source #

Constructors

MimeOctetStream 

Instances

MimeType MimeOctetStream Source #
application/octet-stream
MimeUnrender MimeOctetStream ByteString Source #
P.Right . P.id
MimeUnrender MimeOctetStream String Source #
P.Right . BCL.unpack
MimeUnrender MimeOctetStream Text Source #
P.left P.show . T.decodeUtf8' . BL.toStrict
MimeRender MimeOctetStream ByteString Source #
P.id
MimeRender MimeOctetStream String Source #
BCL.pack
MimeRender MimeOctetStream Text Source #
BL.fromStrict . T.encodeUtf8

MimeType Class

class Typeable mtype => MimeType mtype where Source #

Minimal complete definition

mimeType | mimeTypes

Instances

MimeType MimeAny Source #
"*/*"
MimeType MimeNoContent Source # 
MimeType MimeOctetStream Source #
application/octet-stream
MimeType MimeMultipartFormData Source #
multipart/form-data
MimeType MimeFormUrlEncoded Source #
application/x-www-form-urlencoded
MimeType MimePlainText Source #
text/plain; charset=utf-8
MimeType MimeXML Source #
application/xml; charset=utf-8
MimeType MimeJSON Source #
application/json; charset=utf-8
MimeType MimeXmlCharsetutf8 Source #
application/xml; charset=utf-8
MimeType MimeJsonCharsetutf8 Source #
application/json; charset=utf-8

MimeRender Class

class MimeType mtype => MimeRender mtype x where Source #

Minimal complete definition

mimeRender

Methods

mimeRender :: Proxy mtype -> x -> ByteString Source #

mimeRender' :: mtype -> x -> ByteString Source #

Instances

MimeRender MimeNoContent NoContent Source #
P.Right . P.const NoContent
MimeRender MimeOctetStream ByteString Source #
P.id
MimeRender MimeOctetStream String Source #
BCL.pack
MimeRender MimeOctetStream Text Source #
BL.fromStrict . T.encodeUtf8
MimeRender MimeMultipartFormData Bool Source # 
MimeRender MimeMultipartFormData Char Source # 
MimeRender MimeMultipartFormData Double Source # 
MimeRender MimeMultipartFormData Float Source # 
MimeRender MimeMultipartFormData Int Source # 
MimeRender MimeMultipartFormData Integer Source # 
MimeRender MimeMultipartFormData ByteString Source # 
MimeRender MimeMultipartFormData String Source # 
MimeRender MimeMultipartFormData Text Source # 
MimeRender MimeMultipartFormData Binary Source # 
MimeRender MimeMultipartFormData ByteArray Source # 
MimeRender MimeMultipartFormData Date Source # 
MimeRender MimeMultipartFormData DateTime Source # 
ToForm a => MimeRender MimeFormUrlEncoded a Source #
WH.urlEncodeAsForm
MimeRender MimePlainText ByteString Source #
P.id
MimeRender MimePlainText String Source #
BCL.pack
MimeRender MimePlainText Text Source #
BL.fromStrict . T.encodeUtf8
ToJSON a => MimeRender MimeJSON a Source #

encode

ToJSON a => MimeRender MimeJsonCharsetutf8 a Source # 

MimeUnrender Class

class MimeType mtype => MimeUnrender mtype o where Source #

Minimal complete definition

mimeUnrender

Instances

MimeUnrender MimeNoContent NoContent Source #
P.Right . P.const NoContent
MimeUnrender MimeOctetStream ByteString Source #
P.Right . P.id
MimeUnrender MimeOctetStream String Source #
P.Right . BCL.unpack
MimeUnrender MimeOctetStream Text Source #
P.left P.show . T.decodeUtf8' . BL.toStrict
FromForm a => MimeUnrender MimeFormUrlEncoded a Source #
P.left T.unpack . WH.urlDecodeAsForm
MimeUnrender MimePlainText ByteString Source #
P.Right . P.id
MimeUnrender MimePlainText String Source #
P.Right . BCL.unpack
MimeUnrender MimePlainText Text Source #
P.left P.show . TL.decodeUtf8'
FromJSON a => MimeUnrender MimeJSON a Source #
A.eitherDecode
FromJSON a => MimeUnrender MimeJsonCharsetutf8 a Source # 
\ No newline at end of file +

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Safe HaskellNone
LanguageHaskell2010

SwaggerPetstore.MimeTypes

Description

 

Consumes Class

Produces Class

class MimeType mtype => Produces req mtype Source #

Instances

Produces UpdateUser MimeXML Source #
application/xml
Produces UpdateUser MimeJSON Source #
application/json
Produces LogoutUser MimeXML Source #
application/xml
Produces LogoutUser MimeJSON Source #
application/json
Produces LoginUser MimeXML Source #
application/xml
Produces LoginUser MimeJSON Source #
application/json
Produces GetUserByName MimeXML Source #
application/xml
Produces GetUserByName MimeJSON Source #
application/json
Produces DeleteUser MimeXML Source #
application/xml
Produces DeleteUser MimeJSON Source #
application/json
Produces CreateUsersWithListInput MimeXML Source #
application/xml
Produces CreateUsersWithListInput MimeJSON Source #
application/json
Produces CreateUsersWithArrayInput MimeXML Source #
application/xml
Produces CreateUsersWithArrayInput MimeJSON Source #
application/json
Produces CreateUser MimeXML Source #
application/xml
Produces CreateUser MimeJSON Source #
application/json
Produces PlaceOrder MimeXML Source #
application/xml
Produces PlaceOrder MimeJSON Source #
application/json
Produces GetOrderById MimeXML Source #
application/xml
Produces GetOrderById MimeJSON Source #
application/json
Produces GetInventory MimeJSON Source #
application/json
Produces DeleteOrder MimeXML Source #
application/xml
Produces DeleteOrder MimeJSON Source #
application/json
Produces UploadFile MimeJSON Source #
application/json
Produces UpdatePetWithForm MimeXML Source #
application/xml
Produces UpdatePetWithForm MimeJSON Source #
application/json
Produces UpdatePet MimeXML Source #
application/xml
Produces UpdatePet MimeJSON Source #
application/json
Produces GetPetById MimeXML Source #
application/xml
Produces GetPetById MimeJSON Source #
application/json
Produces FindPetsByTags MimeXML Source #
application/xml
Produces FindPetsByTags MimeJSON Source #
application/json
Produces FindPetsByStatus MimeXML Source #
application/xml
Produces FindPetsByStatus MimeJSON Source #
application/json
Produces DeletePet MimeXML Source #
application/xml
Produces DeletePet MimeJSON Source #
application/json
Produces AddPet MimeXML Source #
application/xml
Produces AddPet MimeJSON Source #
application/json
Produces TestClassname MimeJSON Source #
application/json
Produces TestEnumParameters MimeAny Source #
*/*
Produces TestEndpointParameters MimeXmlCharsetutf8 Source #
application/xml; charset=utf-8
Produces TestEndpointParameters MimeJsonCharsetutf8 Source #
application/json; charset=utf-8
Produces TestClientModel MimeJSON Source #
application/json
Produces TestSpecialTags MimeJSON Source #
application/json

Default Mime Types

data MimeJSON Source #

Constructors

MimeJSON 

Instances

MimeType MimeJSON Source #
application/json; charset=utf-8
FromJSON a => MimeUnrender MimeJSON a Source #
A.eitherDecode
ToJSON a => MimeRender MimeJSON a Source #

encode

Produces UpdateUser MimeJSON Source #
application/json
Produces LogoutUser MimeJSON Source #
application/json
Produces LoginUser MimeJSON Source #
application/json
Produces GetUserByName MimeJSON Source #
application/json
Produces DeleteUser MimeJSON Source #
application/json
Produces CreateUsersWithListInput MimeJSON Source #
application/json
Produces CreateUsersWithArrayInput MimeJSON Source #
application/json
Produces CreateUser MimeJSON Source #
application/json
Produces PlaceOrder MimeJSON Source #
application/json
Produces GetOrderById MimeJSON Source #
application/json
Produces GetInventory MimeJSON Source #
application/json
Produces DeleteOrder MimeJSON Source #
application/json
Produces UploadFile MimeJSON Source #
application/json
Produces UpdatePetWithForm MimeJSON Source #
application/json
Produces UpdatePet MimeJSON Source #
application/json
Produces GetPetById MimeJSON Source #
application/json
Produces FindPetsByTags MimeJSON Source #
application/json
Produces FindPetsByStatus MimeJSON Source #
application/json
Produces DeletePet MimeJSON Source #
application/json
Produces AddPet MimeJSON Source #
application/json
Produces TestClassname MimeJSON Source #
application/json
Produces TestClientModel MimeJSON Source #
application/json
Produces TestSpecialTags MimeJSON Source #
application/json
Consumes UpdatePet MimeJSON Source #
application/json
Consumes AddPet MimeJSON Source #
application/json
Consumes TestClassname MimeJSON Source #
application/json
Consumes TestJsonFormData MimeJSON Source #
application/json
Consumes TestInlineAdditionalProperties MimeJSON Source #
application/json
Consumes TestClientModel MimeJSON Source #
application/json
Consumes TestSpecialTags MimeJSON Source #
application/json

data MimePlainText Source #

Constructors

MimePlainText 

Instances

MimeType MimePlainText Source #
text/plain; charset=utf-8
MimeUnrender MimePlainText ByteString Source #
P.Right . P.id
MimeUnrender MimePlainText String Source #
P.Right . BCL.unpack
MimeUnrender MimePlainText Text Source #
P.left P.show . TL.decodeUtf8'
MimeRender MimePlainText ByteString Source #
P.id
MimeRender MimePlainText String Source #
BCL.pack
MimeRender MimePlainText Text Source #
BL.fromStrict . T.encodeUtf8

data MimeMultipartFormData Source #

Constructors

MimeMultipartFormData 

Instances

MimeType MimeMultipartFormData Source #
multipart/form-data
MimeRender MimeMultipartFormData Bool Source # 
MimeRender MimeMultipartFormData Char Source # 
MimeRender MimeMultipartFormData Double Source # 
MimeRender MimeMultipartFormData Float Source # 
MimeRender MimeMultipartFormData Int Source # 
MimeRender MimeMultipartFormData Integer Source # 
MimeRender MimeMultipartFormData ByteString Source # 
MimeRender MimeMultipartFormData String Source # 
MimeRender MimeMultipartFormData Text Source # 
MimeRender MimeMultipartFormData Binary Source # 
MimeRender MimeMultipartFormData ByteArray Source # 
MimeRender MimeMultipartFormData Date Source # 
MimeRender MimeMultipartFormData DateTime Source # 
MimeRender MimeMultipartFormData OuterEnum Source # 
MimeRender MimeMultipartFormData EnumClass Source # 
MimeRender MimeMultipartFormData E'Status2 Source # 
MimeRender MimeMultipartFormData E'Status Source # 
MimeRender MimeMultipartFormData E'JustSymbol Source # 
MimeRender MimeMultipartFormData E'Inner2 Source # 
MimeRender MimeMultipartFormData E'Inner Source # 
MimeRender MimeMultipartFormData E'EnumString Source # 
MimeRender MimeMultipartFormData E'EnumQueryInteger Source # 
MimeRender MimeMultipartFormData E'EnumNumber Source # 
MimeRender MimeMultipartFormData E'EnumInteger Source # 
MimeRender MimeMultipartFormData E'EnumFormString Source # 
MimeRender MimeMultipartFormData E'ArrayEnum Source # 
Consumes UploadFile MimeMultipartFormData Source #
multipart/form-data

data MimeOctetStream Source #

Constructors

MimeOctetStream 

Instances

MimeType MimeOctetStream Source #
application/octet-stream
MimeUnrender MimeOctetStream ByteString Source #
P.Right . P.id
MimeUnrender MimeOctetStream String Source #
P.Right . BCL.unpack
MimeUnrender MimeOctetStream Text Source #
P.left P.show . T.decodeUtf8' . BL.toStrict
MimeRender MimeOctetStream ByteString Source #
P.id
MimeRender MimeOctetStream String Source #
BCL.pack
MimeRender MimeOctetStream Text Source #
BL.fromStrict . T.encodeUtf8

MimeType Class

class Typeable mtype => MimeType mtype where Source #

Minimal complete definition

mimeType | mimeTypes

Instances

MimeType MimeAny Source #
"*/*"
MimeType MimeNoContent Source # 
MimeType MimeOctetStream Source #
application/octet-stream
MimeType MimeMultipartFormData Source #
multipart/form-data
MimeType MimeFormUrlEncoded Source #
application/x-www-form-urlencoded
MimeType MimePlainText Source #
text/plain; charset=utf-8
MimeType MimeXML Source #
application/xml; charset=utf-8
MimeType MimeJSON Source #
application/json; charset=utf-8
MimeType MimeXmlCharsetutf8 Source #
application/xml; charset=utf-8
MimeType MimeJsonCharsetutf8 Source #
application/json; charset=utf-8

MimeRender Class

class MimeType mtype => MimeRender mtype x where Source #

Minimal complete definition

mimeRender

Methods

mimeRender :: Proxy mtype -> x -> ByteString Source #

mimeRender' :: mtype -> x -> ByteString Source #

Instances

MimeRender MimeNoContent NoContent Source #
P.Right . P.const NoContent
MimeRender MimeOctetStream ByteString Source #
P.id
MimeRender MimeOctetStream String Source #
BCL.pack
MimeRender MimeOctetStream Text Source #
BL.fromStrict . T.encodeUtf8
MimeRender MimeMultipartFormData Bool Source # 
MimeRender MimeMultipartFormData Char Source # 
MimeRender MimeMultipartFormData Double Source # 
MimeRender MimeMultipartFormData Float Source # 
MimeRender MimeMultipartFormData Int Source # 
MimeRender MimeMultipartFormData Integer Source # 
MimeRender MimeMultipartFormData ByteString Source # 
MimeRender MimeMultipartFormData String Source # 
MimeRender MimeMultipartFormData Text Source # 
MimeRender MimeMultipartFormData Binary Source # 
MimeRender MimeMultipartFormData ByteArray Source # 
MimeRender MimeMultipartFormData Date Source # 
MimeRender MimeMultipartFormData DateTime Source # 
MimeRender MimeMultipartFormData OuterEnum Source # 
MimeRender MimeMultipartFormData EnumClass Source # 
MimeRender MimeMultipartFormData E'Status2 Source # 
MimeRender MimeMultipartFormData E'Status Source # 
MimeRender MimeMultipartFormData E'JustSymbol Source # 
MimeRender MimeMultipartFormData E'Inner2 Source # 
MimeRender MimeMultipartFormData E'Inner Source # 
MimeRender MimeMultipartFormData E'EnumString Source # 
MimeRender MimeMultipartFormData E'EnumQueryInteger Source # 
MimeRender MimeMultipartFormData E'EnumNumber Source # 
MimeRender MimeMultipartFormData E'EnumInteger Source # 
MimeRender MimeMultipartFormData E'EnumFormString Source # 
MimeRender MimeMultipartFormData E'ArrayEnum Source # 
ToForm a => MimeRender MimeFormUrlEncoded a Source #
WH.urlEncodeAsForm
MimeRender MimePlainText ByteString Source #
P.id
MimeRender MimePlainText String Source #
BCL.pack
MimeRender MimePlainText Text Source #
BL.fromStrict . T.encodeUtf8
ToJSON a => MimeRender MimeJSON a Source #

encode

ToJSON a => MimeRender MimeJsonCharsetutf8 a Source # 

MimeUnrender Class

class MimeType mtype => MimeUnrender mtype o where Source #

Minimal complete definition

mimeUnrender

Instances

MimeUnrender MimeNoContent NoContent Source #
P.Right . P.const NoContent
MimeUnrender MimeOctetStream ByteString Source #
P.Right . P.id
MimeUnrender MimeOctetStream String Source #
P.Right . BCL.unpack
MimeUnrender MimeOctetStream Text Source #
P.left P.show . T.decodeUtf8' . BL.toStrict
FromForm a => MimeUnrender MimeFormUrlEncoded a Source #
P.left T.unpack . WH.urlDecodeAsForm
MimeUnrender MimePlainText ByteString Source #
P.Right . P.id
MimeUnrender MimePlainText String Source #
P.Right . BCL.unpack
MimeUnrender MimePlainText Text Source #
P.left P.show . TL.decodeUtf8'
FromJSON a => MimeUnrender MimeJSON a Source #
A.eitherDecode
FromJSON a => MimeUnrender MimeJsonCharsetutf8 a Source # 
\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Model.html b/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Model.html index ebfe14e31db..ad8b9099d71 100644 --- a/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Model.html +++ b/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Model.html @@ -1,8 +1,10 @@ SwaggerPetstore.Model

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Safe HaskellNone
LanguageHaskell2010

SwaggerPetstore.Model

Description

 

Synopsis

Models

AdditionalPropertiesClass

mkAdditionalPropertiesClass :: AdditionalPropertiesClass Source #

Construct a value of type AdditionalPropertiesClass (by applying it's required fields, if any)

Animal

data Animal Source #

Animal

Constructors

Animal 

Fields

mkAnimal Source #

Arguments

:: Text

animalClassName

-> Animal 

Construct a value of type Animal (by applying it's required fields, if any)

AnimalFarm

mkAnimalFarm :: AnimalFarm Source #

Construct a value of type AnimalFarm (by applying it's required fields, if any)

ApiResponse

mkApiResponse :: ApiResponse Source #

Construct a value of type ApiResponse (by applying it's required fields, if any)

ArrayOfArrayOfNumberOnly

mkArrayOfArrayOfNumberOnly :: ArrayOfArrayOfNumberOnly Source #

Construct a value of type ArrayOfArrayOfNumberOnly (by applying it's required fields, if any)

ArrayOfNumberOnly

mkArrayOfNumberOnly :: ArrayOfNumberOnly Source #

Construct a value of type ArrayOfNumberOnly (by applying it's required fields, if any)

ArrayTest

mkArrayTest :: ArrayTest Source #

Construct a value of type ArrayTest (by applying it's required fields, if any)

Capitalization

mkCapitalization :: Capitalization Source #

Construct a value of type Capitalization (by applying it's required fields, if any)

Category

mkCategory :: Category Source #

Construct a value of type Category (by applying it's required fields, if any)

ClassModel

data ClassModel Source #

ClassModel - Model for testing model with "_class" property

Constructors

ClassModel 

Fields

mkClassModel :: ClassModel Source #

Construct a value of type ClassModel (by applying it's required fields, if any)

Client

data Client Source #

Client

Constructors

Client 

Fields

Instances

Eq Client Source # 

Methods

(==) :: Client -> Client -> Bool #

(/=) :: Client -> Client -> Bool #

Show Client Source # 
ToJSON Client Source #

ToJSON Client

FromJSON Client Source #

FromJSON Client

HasBodyParam TestClassname Client Source #

Body Param "body" - client model

Methods

setBodyParam :: (Consumes TestClassname contentType, MimeRender contentType Client) => SwaggerPetstoreRequest TestClassname contentType res -> Client -> SwaggerPetstoreRequest TestClassname contentType res Source #

HasBodyParam TestClientModel Client Source #

Body Param "body" - client model

HasBodyParam TestSpecialTags Client Source #

Body Param "body" - client model

mkClient :: Client Source #

Construct a value of type Client (by applying it's required fields, if any)

EnumArrays

mkEnumArrays :: EnumArrays Source #

Construct a value of type EnumArrays (by applying it's required fields, if any)

EnumClass

mkEnumClass :: EnumClass Source #

Construct a value of type EnumClass (by applying it's required fields, if any)

EnumTest

mkEnumTest :: EnumTest Source #

Construct a value of type EnumTest (by applying it's required fields, if any)

FormatTest

mkFormatTest Source #

Construct a value of type FormatTest (by applying it's required fields, if any)

HasOnlyReadOnly

mkHasOnlyReadOnly :: HasOnlyReadOnly Source #

Construct a value of type HasOnlyReadOnly (by applying it's required fields, if any)

MapTest

data MapTest Source #

MapTest

Constructors

MapTest 

Fields

mkMapTest :: MapTest Source #

Construct a value of type MapTest (by applying it's required fields, if any)

MixedPropertiesAndAdditionalPropertiesClass

data MixedPropertiesAndAdditionalPropertiesClass Source #

MixedPropertiesAndAdditionalPropertiesClass

Model200Response

mkModel200Response :: Model200Response Source #

Construct a value of type Model200Response (by applying it's required fields, if any)

ModelList

mkModelList :: ModelList Source #

Construct a value of type ModelList (by applying it's required fields, if any)

ModelReturn

mkModelReturn :: ModelReturn Source #

Construct a value of type ModelReturn (by applying it's required fields, if any)

Name

data Name Source #

Name - Model for testing model name same as property name

Constructors

Name 

Fields

Instances

mkName Source #

Arguments

:: Int

nameName

-> Name 

Construct a value of type Name (by applying it's required fields, if any)

NumberOnly

mkNumberOnly :: NumberOnly Source #

Construct a value of type NumberOnly (by applying it's required fields, if any)

Order

data Order Source #

Order

Constructors

Order 

Fields

Instances

Eq Order Source # 

Methods

(==) :: Order -> Order -> Bool #

(/=) :: Order -> Order -> Bool #

Show Order Source # 

Methods

showsPrec :: Int -> Order -> ShowS #

show :: Order -> String #

showList :: [Order] -> ShowS #

ToJSON Order Source #

ToJSON Order

FromJSON Order Source #

FromJSON Order

HasBodyParam PlaceOrder Order Source #

Body Param "body" - order placed for purchasing the pet

Methods

setBodyParam :: (Consumes PlaceOrder contentType, MimeRender contentType Order) => SwaggerPetstoreRequest PlaceOrder contentType res -> Order -> SwaggerPetstoreRequest PlaceOrder contentType res Source #

mkOrder :: Order Source #

Construct a value of type Order (by applying it's required fields, if any)

OuterBoolean

OuterComposite

mkOuterComposite :: OuterComposite Source #

Construct a value of type OuterComposite (by applying it's required fields, if any)

OuterEnum

mkOuterEnum :: OuterEnum Source #

Construct a value of type OuterEnum (by applying it's required fields, if any)

OuterNumber

OuterString

Pet

data Pet Source #

Pet

Constructors

Pet 

Fields

Instances

Eq Pet Source # 

Methods

(==) :: Pet -> Pet -> Bool #

(/=) :: Pet -> Pet -> Bool #

Show Pet Source # 

Methods

showsPrec :: Int -> Pet -> ShowS #

show :: Pet -> String #

showList :: [Pet] -> ShowS #

ToJSON Pet Source #

ToJSON Pet

FromJSON Pet Source #

FromJSON Pet

HasBodyParam UpdatePet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes UpdatePet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest UpdatePet contentType res -> Pet -> SwaggerPetstoreRequest UpdatePet contentType res Source #

HasBodyParam AddPet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes AddPet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest AddPet contentType res -> Pet -> SwaggerPetstoreRequest AddPet contentType res Source #

mkPet Source #

Arguments

:: Text

petName

-> [Text]

petPhotoUrls

-> Pet 

Construct a value of type Pet (by applying it's required fields, if any)

ReadOnlyFirst

mkReadOnlyFirst :: ReadOnlyFirst Source #

Construct a value of type ReadOnlyFirst (by applying it's required fields, if any)

SpecialModelName

mkSpecialModelName :: SpecialModelName Source #

Construct a value of type SpecialModelName (by applying it's required fields, if any)

Tag

data Tag Source #

Tag

Constructors

Tag 

Fields

Instances

Eq Tag Source # 

Methods

(==) :: Tag -> Tag -> Bool #

(/=) :: Tag -> Tag -> Bool #

Show Tag Source # 

Methods

showsPrec :: Int -> Tag -> ShowS #

show :: Tag -> String #

showList :: [Tag] -> ShowS #

ToJSON Tag Source #

ToJSON Tag

FromJSON Tag Source #

FromJSON Tag

mkTag :: Tag Source #

Construct a value of type Tag (by applying it's required fields, if any)

User

data User Source #

User

Constructors

User 

Fields

Instances

Eq User Source # 

Methods

(==) :: User -> User -> Bool #

(/=) :: User -> User -> Bool #

Show User Source # 

Methods

showsPrec :: Int -> User -> ShowS #

show :: User -> String #

showList :: [User] -> ShowS #

ToJSON User Source #

ToJSON User

FromJSON User Source #

FromJSON User

HasBodyParam UpdateUser User Source #

Body Param "body" - Updated user object

Methods

setBodyParam :: (Consumes UpdateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest UpdateUser contentType res -> User -> SwaggerPetstoreRequest UpdateUser contentType res Source #

HasBodyParam CreateUser User Source #

Body Param "body" - Created user object

Methods

setBodyParam :: (Consumes CreateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest CreateUser contentType res -> User -> SwaggerPetstoreRequest CreateUser contentType res Source #

mkUser :: User Source #

Construct a value of type User (by applying it's required fields, if any)

Cat

data Cat Source #

Cat

Constructors

Cat 

Fields

Instances

Eq Cat Source # 

Methods

(==) :: Cat -> Cat -> Bool #

(/=) :: Cat -> Cat -> Bool #

Show Cat Source # 

Methods

showsPrec :: Int -> Cat -> ShowS #

show :: Cat -> String #

showList :: [Cat] -> ShowS #

ToJSON Cat Source #

ToJSON Cat

FromJSON Cat Source #

FromJSON Cat

mkCat Source #

Arguments

:: Text

catClassName

-> Cat 

Construct a value of type Cat (by applying it's required fields, if any)

Dog

data Dog Source #

Dog

Constructors

Dog 

Fields

Instances

Eq Dog Source # 

Methods

(==) :: Dog -> Dog -> Bool #

(/=) :: Dog -> Dog -> Bool #

Show Dog Source # 

Methods

showsPrec :: Int -> Dog -> ShowS #

show :: Dog -> String #

showList :: [Dog] -> ShowS #

ToJSON Dog Source #

ToJSON Dog

FromJSON Dog Source #

FromJSON Dog

mkDog Source #

Arguments

:: Text

dogClassName

-> Dog 

Construct a value of type Dog (by applying it's required fields, if any)

\ No newline at end of file +

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Safe HaskellNone
LanguageHaskell2010

SwaggerPetstore.Model

Description

 

Synopsis

Models

AdditionalPropertiesClass

mkAdditionalPropertiesClass :: AdditionalPropertiesClass Source #

Construct a value of type AdditionalPropertiesClass (by applying it's required fields, if any)

Animal

data Animal Source #

Animal

Constructors

Animal 

Fields

mkAnimal Source #

Arguments

:: Text

animalClassName

-> Animal 

Construct a value of type Animal (by applying it's required fields, if any)

AnimalFarm

mkAnimalFarm :: AnimalFarm Source #

Construct a value of type AnimalFarm (by applying it's required fields, if any)

ApiResponse

mkApiResponse :: ApiResponse Source #

Construct a value of type ApiResponse (by applying it's required fields, if any)

ArrayOfArrayOfNumberOnly

mkArrayOfArrayOfNumberOnly :: ArrayOfArrayOfNumberOnly Source #

Construct a value of type ArrayOfArrayOfNumberOnly (by applying it's required fields, if any)

ArrayOfNumberOnly

mkArrayOfNumberOnly :: ArrayOfNumberOnly Source #

Construct a value of type ArrayOfNumberOnly (by applying it's required fields, if any)

ArrayTest

mkArrayTest :: ArrayTest Source #

Construct a value of type ArrayTest (by applying it's required fields, if any)

Capitalization

mkCapitalization :: Capitalization Source #

Construct a value of type Capitalization (by applying it's required fields, if any)

Category

mkCategory :: Category Source #

Construct a value of type Category (by applying it's required fields, if any)

ClassModel

data ClassModel Source #

ClassModel + Model for testing model with "_class" property

Constructors

ClassModel 

Fields

mkClassModel :: ClassModel Source #

Construct a value of type ClassModel (by applying it's required fields, if any)

Client

data Client Source #

Client

Constructors

Client 

Fields

Instances

Eq Client Source # 

Methods

(==) :: Client -> Client -> Bool #

(/=) :: Client -> Client -> Bool #

Show Client Source # 
ToJSON Client Source #

ToJSON Client

FromJSON Client Source #

FromJSON Client

HasBodyParam TestClassname Client Source #

Body Param "body" - client model

Methods

setBodyParam :: (Consumes TestClassname contentType, MimeRender contentType Client) => SwaggerPetstoreRequest TestClassname contentType res -> Client -> SwaggerPetstoreRequest TestClassname contentType res Source #

HasBodyParam TestClientModel Client Source #

Body Param "body" - client model

HasBodyParam TestSpecialTags Client Source #

Body Param "body" - client model

mkClient :: Client Source #

Construct a value of type Client (by applying it's required fields, if any)

EnumArrays

mkEnumArrays :: EnumArrays Source #

Construct a value of type EnumArrays (by applying it's required fields, if any)

EnumTest

mkEnumTest :: EnumTest Source #

Construct a value of type EnumTest (by applying it's required fields, if any)

FormatTest

mkFormatTest Source #

Construct a value of type FormatTest (by applying it's required fields, if any)

HasOnlyReadOnly

mkHasOnlyReadOnly :: HasOnlyReadOnly Source #

Construct a value of type HasOnlyReadOnly (by applying it's required fields, if any)

MapTest

data MapTest Source #

MapTest

Constructors

MapTest 

Fields

mkMapTest :: MapTest Source #

Construct a value of type MapTest (by applying it's required fields, if any)

MixedPropertiesAndAdditionalPropertiesClass

data MixedPropertiesAndAdditionalPropertiesClass Source #

MixedPropertiesAndAdditionalPropertiesClass

Model200Response

mkModel200Response :: Model200Response Source #

Construct a value of type Model200Response (by applying it's required fields, if any)

ModelList

mkModelList :: ModelList Source #

Construct a value of type ModelList (by applying it's required fields, if any)

ModelReturn

mkModelReturn :: ModelReturn Source #

Construct a value of type ModelReturn (by applying it's required fields, if any)

Name

data Name Source #

Name + Model for testing model name same as property name

Constructors

Name 

Fields

Instances

mkName Source #

Arguments

:: Int

nameName

-> Name 

Construct a value of type Name (by applying it's required fields, if any)

NumberOnly

mkNumberOnly :: NumberOnly Source #

Construct a value of type NumberOnly (by applying it's required fields, if any)

Order

data Order Source #

Order

Constructors

Order 

Fields

Instances

Eq Order Source # 

Methods

(==) :: Order -> Order -> Bool #

(/=) :: Order -> Order -> Bool #

Show Order Source # 

Methods

showsPrec :: Int -> Order -> ShowS #

show :: Order -> String #

showList :: [Order] -> ShowS #

ToJSON Order Source #

ToJSON Order

FromJSON Order Source #

FromJSON Order

HasBodyParam PlaceOrder Order Source #

Body Param "body" - order placed for purchasing the pet

Methods

setBodyParam :: (Consumes PlaceOrder contentType, MimeRender contentType Order) => SwaggerPetstoreRequest PlaceOrder contentType res -> Order -> SwaggerPetstoreRequest PlaceOrder contentType res Source #

mkOrder :: Order Source #

Construct a value of type Order (by applying it's required fields, if any)

OuterBoolean

OuterComposite

mkOuterComposite :: OuterComposite Source #

Construct a value of type OuterComposite (by applying it's required fields, if any)

OuterNumber

OuterString

Pet

data Pet Source #

Pet

Constructors

Pet 

Fields

Instances

Eq Pet Source # 

Methods

(==) :: Pet -> Pet -> Bool #

(/=) :: Pet -> Pet -> Bool #

Show Pet Source # 

Methods

showsPrec :: Int -> Pet -> ShowS #

show :: Pet -> String #

showList :: [Pet] -> ShowS #

ToJSON Pet Source #

ToJSON Pet

FromJSON Pet Source #

FromJSON Pet

HasBodyParam UpdatePet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes UpdatePet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest UpdatePet contentType res -> Pet -> SwaggerPetstoreRequest UpdatePet contentType res Source #

HasBodyParam AddPet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes AddPet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest AddPet contentType res -> Pet -> SwaggerPetstoreRequest AddPet contentType res Source #

mkPet Source #

Arguments

:: Text

petName

-> [Text]

petPhotoUrls

-> Pet 

Construct a value of type Pet (by applying it's required fields, if any)

ReadOnlyFirst

mkReadOnlyFirst :: ReadOnlyFirst Source #

Construct a value of type ReadOnlyFirst (by applying it's required fields, if any)

SpecialModelName

mkSpecialModelName :: SpecialModelName Source #

Construct a value of type SpecialModelName (by applying it's required fields, if any)

Tag

data Tag Source #

Tag

Constructors

Tag 

Fields

Instances

Eq Tag Source # 

Methods

(==) :: Tag -> Tag -> Bool #

(/=) :: Tag -> Tag -> Bool #

Show Tag Source # 

Methods

showsPrec :: Int -> Tag -> ShowS #

show :: Tag -> String #

showList :: [Tag] -> ShowS #

ToJSON Tag Source #

ToJSON Tag

FromJSON Tag Source #

FromJSON Tag

mkTag :: Tag Source #

Construct a value of type Tag (by applying it's required fields, if any)

User

data User Source #

User

Constructors

User 

Fields

Instances

Eq User Source # 

Methods

(==) :: User -> User -> Bool #

(/=) :: User -> User -> Bool #

Show User Source # 

Methods

showsPrec :: Int -> User -> ShowS #

show :: User -> String #

showList :: [User] -> ShowS #

ToJSON User Source #

ToJSON User

FromJSON User Source #

FromJSON User

HasBodyParam UpdateUser User Source #

Body Param "body" - Updated user object

Methods

setBodyParam :: (Consumes UpdateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest UpdateUser contentType res -> User -> SwaggerPetstoreRequest UpdateUser contentType res Source #

HasBodyParam CreateUser User Source #

Body Param "body" - Created user object

Methods

setBodyParam :: (Consumes CreateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest CreateUser contentType res -> User -> SwaggerPetstoreRequest CreateUser contentType res Source #

mkUser :: User Source #

Construct a value of type User (by applying it's required fields, if any)

Cat

data Cat Source #

Cat

Constructors

Cat 

Fields

Instances

Eq Cat Source # 

Methods

(==) :: Cat -> Cat -> Bool #

(/=) :: Cat -> Cat -> Bool #

Show Cat Source # 

Methods

showsPrec :: Int -> Cat -> ShowS #

show :: Cat -> String #

showList :: [Cat] -> ShowS #

ToJSON Cat Source #

ToJSON Cat

FromJSON Cat Source #

FromJSON Cat

mkCat Source #

Arguments

:: Text

catClassName

-> Cat 

Construct a value of type Cat (by applying it's required fields, if any)

Dog

data Dog Source #

Dog

Constructors

Dog 

Fields

Instances

Eq Dog Source # 

Methods

(==) :: Dog -> Dog -> Bool #

(/=) :: Dog -> Dog -> Bool #

Show Dog Source # 

Methods

showsPrec :: Int -> Dog -> ShowS #

show :: Dog -> String #

showList :: [Dog] -> ShowS #

ToJSON Dog Source #

ToJSON Dog

FromJSON Dog Source #

FromJSON Dog

mkDog Source #

Arguments

:: Text

dogClassName

-> Dog 

Construct a value of type Dog (by applying it's required fields, if any)

Enums

E'ArrayEnum

data E'ArrayEnum Source #

Enum of Text

Constructors

E'ArrayEnum'Fish
"fish"
E'ArrayEnum'Crab
"crab"

Instances

Bounded E'ArrayEnum Source # 
Enum E'ArrayEnum Source # 
Eq E'ArrayEnum Source # 
Ord E'ArrayEnum Source # 
Show E'ArrayEnum Source # 
ToJSON E'ArrayEnum Source # 
FromJSON E'ArrayEnum Source # 
ToHttpApiData E'ArrayEnum Source # 
FromHttpApiData E'ArrayEnum Source # 
MimeRender MimeMultipartFormData E'ArrayEnum Source # 

E'EnumFormString

data E'EnumFormString Source #

Enum of Text

Instances

Bounded E'EnumFormString Source # 
Enum E'EnumFormString Source # 
Eq E'EnumFormString Source # 
Ord E'EnumFormString Source # 
Show E'EnumFormString Source # 
ToJSON E'EnumFormString Source # 
FromJSON E'EnumFormString Source # 
ToHttpApiData E'EnumFormString Source # 
FromHttpApiData E'EnumFormString Source # 
MimeRender MimeMultipartFormData E'EnumFormString Source # 

E'EnumInteger

data E'EnumInteger Source #

Enum of Int

Instances

Bounded E'EnumInteger Source # 
Enum E'EnumInteger Source # 
Eq E'EnumInteger Source # 
Ord E'EnumInteger Source # 
Show E'EnumInteger Source # 
ToJSON E'EnumInteger Source # 
FromJSON E'EnumInteger Source # 
ToHttpApiData E'EnumInteger Source # 
FromHttpApiData E'EnumInteger Source # 
MimeRender MimeMultipartFormData E'EnumInteger Source # 

E'EnumNumber

data E'EnumNumber Source #

Enum of Double

Instances

Bounded E'EnumNumber Source # 
Enum E'EnumNumber Source # 
Eq E'EnumNumber Source # 
Ord E'EnumNumber Source # 
Show E'EnumNumber Source # 
ToJSON E'EnumNumber Source # 
FromJSON E'EnumNumber Source # 
ToHttpApiData E'EnumNumber Source # 
FromHttpApiData E'EnumNumber Source # 
MimeRender MimeMultipartFormData E'EnumNumber Source # 

E'EnumQueryInteger

data E'EnumQueryInteger Source #

Enum of Int

Instances

Bounded E'EnumQueryInteger Source # 
Enum E'EnumQueryInteger Source # 
Eq E'EnumQueryInteger Source # 
Ord E'EnumQueryInteger Source # 
Show E'EnumQueryInteger Source # 
ToJSON E'EnumQueryInteger Source # 
FromJSON E'EnumQueryInteger Source # 
ToHttpApiData E'EnumQueryInteger Source # 
FromHttpApiData E'EnumQueryInteger Source # 
MimeRender MimeMultipartFormData E'EnumQueryInteger Source # 

E'EnumString

data E'EnumString Source #

Enum of Text

Instances

Bounded E'EnumString Source # 
Enum E'EnumString Source # 
Eq E'EnumString Source # 
Ord E'EnumString Source # 
Show E'EnumString Source # 
ToJSON E'EnumString Source # 
FromJSON E'EnumString Source # 
ToHttpApiData E'EnumString Source # 
FromHttpApiData E'EnumString Source # 
MimeRender MimeMultipartFormData E'EnumString Source # 

E'Inner

data E'Inner Source #

Enum of Text

Instances

Bounded E'Inner Source # 
Enum E'Inner Source # 
Eq E'Inner Source # 

Methods

(==) :: E'Inner -> E'Inner -> Bool #

(/=) :: E'Inner -> E'Inner -> Bool #

Ord E'Inner Source # 
Show E'Inner Source # 
ToJSON E'Inner Source # 
FromJSON E'Inner Source # 
ToHttpApiData E'Inner Source # 
FromHttpApiData E'Inner Source # 
MimeRender MimeMultipartFormData E'Inner Source # 

E'Inner2

data E'Inner2 Source #

Enum of Text

Instances

Bounded E'Inner2 Source # 
Enum E'Inner2 Source # 
Eq E'Inner2 Source # 
Ord E'Inner2 Source # 
Show E'Inner2 Source # 
ToJSON E'Inner2 Source # 
FromJSON E'Inner2 Source # 
ToHttpApiData E'Inner2 Source # 
FromHttpApiData E'Inner2 Source # 
MimeRender MimeMultipartFormData E'Inner2 Source # 

E'JustSymbol

data E'JustSymbol Source #

Enum of Text

Instances

Bounded E'JustSymbol Source # 
Enum E'JustSymbol Source # 
Eq E'JustSymbol Source # 
Ord E'JustSymbol Source # 
Show E'JustSymbol Source # 
ToJSON E'JustSymbol Source # 
FromJSON E'JustSymbol Source # 
ToHttpApiData E'JustSymbol Source # 
FromHttpApiData E'JustSymbol Source # 
MimeRender MimeMultipartFormData E'JustSymbol Source # 

E'Status

data E'Status Source #

Enum of Text . + Order Status

Constructors

E'Status'Placed
"placed"
E'Status'Approved
"approved"
E'Status'Delivered
"delivered"

Instances

Bounded E'Status Source # 
Enum E'Status Source # 
Eq E'Status Source # 
Ord E'Status Source # 
Show E'Status Source # 
ToJSON E'Status Source # 
FromJSON E'Status Source # 
ToHttpApiData E'Status Source # 
FromHttpApiData E'Status Source # 
MimeRender MimeMultipartFormData E'Status Source # 

E'Status2

data E'Status2 Source #

Enum of Text . + pet status in the store

Constructors

E'Status2'Available
"available"
E'Status2'Pending
"pending"
E'Status2'Sold
"sold"

Instances

Bounded E'Status2 Source # 
Enum E'Status2 Source # 
Eq E'Status2 Source # 
Ord E'Status2 Source # 
Show E'Status2 Source # 
ToJSON E'Status2 Source # 
FromJSON E'Status2 Source # 
ToHttpApiData E'Status2 Source # 
FromHttpApiData E'Status2 Source # 
MimeRender MimeMultipartFormData E'Status2 Source # 

EnumClass

data EnumClass Source #

Enum of Text

Constructors

EnumClass'_abc
"_abc"
EnumClass'_efg
"-efg"
EnumClass'_xyz
"(xyz)"

Instances

Bounded EnumClass Source # 
Enum EnumClass Source # 
Eq EnumClass Source # 
Ord EnumClass Source # 
Show EnumClass Source # 
ToJSON EnumClass Source # 
FromJSON EnumClass Source # 
ToHttpApiData EnumClass Source # 
FromHttpApiData EnumClass Source # 
MimeRender MimeMultipartFormData EnumClass Source # 

OuterEnum

data OuterEnum Source #

Enum of Text

Constructors

OuterEnum'Placed
"placed"
OuterEnum'Approved
"approved"
OuterEnum'Delivered
"delivered"

Instances

Bounded OuterEnum Source # 
Enum OuterEnum Source # 
Eq OuterEnum Source # 
Ord OuterEnum Source # 
Show OuterEnum Source # 
ToJSON OuterEnum Source # 
FromJSON OuterEnum Source # 
ToHttpApiData OuterEnum Source # 
FromHttpApiData OuterEnum Source # 
MimeRender MimeMultipartFormData OuterEnum Source # 
\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-ModelLens.html b/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-ModelLens.html index 57c81e18d67..bdcb9960694 100644 --- a/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-ModelLens.html +++ b/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-ModelLens.html @@ -1,4 +1,4 @@ SwaggerPetstore.ModelLens

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Safe HaskellNone
LanguageHaskell2010

SwaggerPetstore.ModelLens

Description

 

Synopsis

AdditionalPropertiesClass

Animal

AnimalFarm

ApiResponse

ArrayOfArrayOfNumberOnly

ArrayOfNumberOnly

ArrayTest

Capitalization

Category

ClassModel

Client

EnumArrays

EnumClass

EnumTest

FormatTest

HasOnlyReadOnly

MapTest

MixedPropertiesAndAdditionalPropertiesClass

Model200Response

ModelList

ModelReturn

Name

NumberOnly

Order

OuterBoolean

OuterComposite

OuterEnum

OuterNumber

OuterString

Pet

ReadOnlyFirst

SpecialModelName

Tag

User

Cat

Dog

\ No newline at end of file +

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Safe HaskellNone
LanguageHaskell2010

SwaggerPetstore.ModelLens

Description

 

Synopsis

AdditionalPropertiesClass

Animal

AnimalFarm

ApiResponse

ArrayOfArrayOfNumberOnly

ArrayOfNumberOnly

ArrayTest

Capitalization

Category

ClassModel

Client

EnumArrays

EnumClass

EnumTest

FormatTest

HasOnlyReadOnly

MapTest

MixedPropertiesAndAdditionalPropertiesClass

Model200Response

ModelList

ModelReturn

Name

NumberOnly

Order

OuterBoolean

OuterComposite

OuterEnum

OuterNumber

OuterString

Pet

ReadOnlyFirst

SpecialModelName

Tag

User

Cat

Dog

\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/doc-index-All.html b/samples/client/petstore/haskell-http-client/docs/doc-index-All.html index b7e2456a6ab..0259c0c59ca 100644 --- a/samples/client/petstore/haskell-http-client/docs/doc-index-All.html +++ b/samples/client/petstore/haskell-http-client/docs/doc-index-All.html @@ -1,4 +1,4 @@ swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client (Index)

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Index

-&-SwaggerPetstore.Core, SwaggerPetstore
addAuthMethodSwaggerPetstore.Core, SwaggerPetstore
addFormSwaggerPetstore.Core, SwaggerPetstore
AdditionalMetadata 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
AdditionalPropertiesClass 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
additionalPropertiesClassMapOfMapPropertySwaggerPetstore.Model, SwaggerPetstore
additionalPropertiesClassMapOfMapPropertyLSwaggerPetstore.ModelLens, SwaggerPetstore
additionalPropertiesClassMapPropertySwaggerPetstore.Model, SwaggerPetstore
additionalPropertiesClassMapPropertyLSwaggerPetstore.ModelLens, SwaggerPetstore
AddPetSwaggerPetstore.API, SwaggerPetstore
addPetSwaggerPetstore.API, SwaggerPetstore
Animal 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
animalClassNameSwaggerPetstore.Model, SwaggerPetstore
animalClassNameLSwaggerPetstore.ModelLens, SwaggerPetstore
animalColorSwaggerPetstore.Model, SwaggerPetstore
animalColorLSwaggerPetstore.ModelLens, SwaggerPetstore
AnimalFarm 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
AnyAuthMethod 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
ApiKey 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ApiResponse 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
apiResponseCodeSwaggerPetstore.Model, SwaggerPetstore
apiResponseCodeLSwaggerPetstore.ModelLens, SwaggerPetstore
apiResponseMessageSwaggerPetstore.Model, SwaggerPetstore
apiResponseMessageLSwaggerPetstore.ModelLens, SwaggerPetstore
apiResponseTypeSwaggerPetstore.Model, SwaggerPetstore
apiResponseTypeLSwaggerPetstore.ModelLens, SwaggerPetstore
applyAuthMethodSwaggerPetstore.Core, SwaggerPetstore
applyOptionalParamSwaggerPetstore.Core, SwaggerPetstore
ArrayOfArrayOfNumberOnly 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
arrayOfArrayOfNumberOnlyArrayArrayNumberSwaggerPetstore.Model, SwaggerPetstore
arrayOfArrayOfNumberOnlyArrayArrayNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
ArrayOfNumberOnly 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
arrayOfNumberOnlyArrayNumberSwaggerPetstore.Model, SwaggerPetstore
arrayOfNumberOnlyArrayNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
ArrayTest 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
arrayTestArrayArrayOfIntegerSwaggerPetstore.Model, SwaggerPetstore
arrayTestArrayArrayOfIntegerLSwaggerPetstore.ModelLens, SwaggerPetstore
arrayTestArrayArrayOfModelSwaggerPetstore.Model, SwaggerPetstore
arrayTestArrayArrayOfModelLSwaggerPetstore.ModelLens, SwaggerPetstore
arrayTestArrayOfStringSwaggerPetstore.Model, SwaggerPetstore
arrayTestArrayOfStringLSwaggerPetstore.ModelLens, SwaggerPetstore
AuthApiKeyApiKey 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
AuthApiKeyApiKeyQuery 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
AuthBasicHttpBasicTest 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
AuthMethodSwaggerPetstore.Core, SwaggerPetstore
AuthOAuthPetstoreAuth 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Binary 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
Body 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Byte 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ByteArray 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
Callback 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Capitalization 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
capitalizationAttNameSwaggerPetstore.Model, SwaggerPetstore
capitalizationAttNameLSwaggerPetstore.ModelLens, SwaggerPetstore
capitalizationCapitalCamelSwaggerPetstore.Model, SwaggerPetstore
capitalizationCapitalCamelLSwaggerPetstore.ModelLens, SwaggerPetstore
capitalizationCapitalSnakeSwaggerPetstore.Model, SwaggerPetstore
capitalizationCapitalSnakeLSwaggerPetstore.ModelLens, SwaggerPetstore
capitalizationScaEthFlowPointsSwaggerPetstore.Model, SwaggerPetstore
capitalizationScaEthFlowPointsLSwaggerPetstore.ModelLens, SwaggerPetstore
capitalizationSmallCamelSwaggerPetstore.Model, SwaggerPetstore
capitalizationSmallCamelLSwaggerPetstore.ModelLens, SwaggerPetstore
capitalizationSmallSnakeSwaggerPetstore.Model, SwaggerPetstore
capitalizationSmallSnakeLSwaggerPetstore.ModelLens, SwaggerPetstore
Cat 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
catClassNameSwaggerPetstore.Model, SwaggerPetstore
catClassNameLSwaggerPetstore.ModelLens, SwaggerPetstore
catColorSwaggerPetstore.Model, SwaggerPetstore
catColorLSwaggerPetstore.ModelLens, SwaggerPetstore
catDeclawedSwaggerPetstore.Model, SwaggerPetstore
catDeclawedLSwaggerPetstore.ModelLens, SwaggerPetstore
Category 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
categoryIdSwaggerPetstore.Model, SwaggerPetstore
categoryIdLSwaggerPetstore.ModelLens, SwaggerPetstore
categoryNameSwaggerPetstore.Model, SwaggerPetstore
categoryNameLSwaggerPetstore.ModelLens, SwaggerPetstore
ClassModel 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
classModelClassSwaggerPetstore.Model, SwaggerPetstore
classModelClassLSwaggerPetstore.ModelLens, SwaggerPetstore
Client 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
clientClientSwaggerPetstore.Model, SwaggerPetstore
clientClientLSwaggerPetstore.ModelLens, SwaggerPetstore
CollectionFormatSwaggerPetstore.Core, SwaggerPetstore
CommaSeparatedSwaggerPetstore.Core, SwaggerPetstore
configAuthMethodsSwaggerPetstore.Core, SwaggerPetstore
configHostSwaggerPetstore.Core, SwaggerPetstore
configLogContextSwaggerPetstore.Core, SwaggerPetstore
configLogExecWithContextSwaggerPetstore.Core, SwaggerPetstore
configUserAgentSwaggerPetstore.Core, SwaggerPetstore
configValidateAuthMethodsSwaggerPetstore.Core, SwaggerPetstore
ConsumesSwaggerPetstore.MimeTypes, SwaggerPetstore
CreateUserSwaggerPetstore.API, SwaggerPetstore
createUserSwaggerPetstore.API, SwaggerPetstore
CreateUsersWithArrayInputSwaggerPetstore.API, SwaggerPetstore
createUsersWithArrayInputSwaggerPetstore.API, SwaggerPetstore
CreateUsersWithListInputSwaggerPetstore.API, SwaggerPetstore
createUsersWithListInputSwaggerPetstore.API, SwaggerPetstore
Date 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
DateTime 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
DeleteOrderSwaggerPetstore.API, SwaggerPetstore
deleteOrderSwaggerPetstore.API, SwaggerPetstore
DeletePetSwaggerPetstore.API, SwaggerPetstore
deletePetSwaggerPetstore.API, SwaggerPetstore
DeleteUserSwaggerPetstore.API, SwaggerPetstore
deleteUserSwaggerPetstore.API, SwaggerPetstore
dispatchInitUnsafeSwaggerPetstore.Client, SwaggerPetstore
dispatchLbsSwaggerPetstore.Client, SwaggerPetstore
dispatchLbsUnsafeSwaggerPetstore.Client, SwaggerPetstore
dispatchMimeSwaggerPetstore.Client, SwaggerPetstore
dispatchMime'SwaggerPetstore.Client, SwaggerPetstore
Dog 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
dogBreedSwaggerPetstore.Model, SwaggerPetstore
dogBreedLSwaggerPetstore.ModelLens, SwaggerPetstore
dogClassNameSwaggerPetstore.Model, SwaggerPetstore
dogClassNameLSwaggerPetstore.ModelLens, SwaggerPetstore
dogColorSwaggerPetstore.Model, SwaggerPetstore
dogColorLSwaggerPetstore.ModelLens, SwaggerPetstore
EnumArrays 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
enumArraysArrayEnumSwaggerPetstore.Model, SwaggerPetstore
enumArraysArrayEnumLSwaggerPetstore.ModelLens, SwaggerPetstore
enumArraysJustSymbolSwaggerPetstore.Model, SwaggerPetstore
enumArraysJustSymbolLSwaggerPetstore.ModelLens, SwaggerPetstore
EnumClass 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
EnumFormString 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumFormStringArray 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumHeaderString 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumHeaderStringArray 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryDouble 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryInteger 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryString 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryStringArray 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumTest 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
enumTestEnumIntegerSwaggerPetstore.Model, SwaggerPetstore
enumTestEnumIntegerLSwaggerPetstore.ModelLens, SwaggerPetstore
enumTestEnumNumberSwaggerPetstore.Model, SwaggerPetstore
enumTestEnumNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
enumTestEnumStringSwaggerPetstore.Model, SwaggerPetstore
enumTestEnumStringLSwaggerPetstore.ModelLens, SwaggerPetstore
enumTestOuterEnumSwaggerPetstore.Model, SwaggerPetstore
enumTestOuterEnumLSwaggerPetstore.ModelLens, SwaggerPetstore
FakeOuterBooleanSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterBooleanSerializeSwaggerPetstore.API, SwaggerPetstore
FakeOuterCompositeSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterCompositeSerializeSwaggerPetstore.API, SwaggerPetstore
FakeOuterNumberSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterNumberSerializeSwaggerPetstore.API, SwaggerPetstore
FakeOuterStringSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterStringSerializeSwaggerPetstore.API, SwaggerPetstore
File 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
FindPetsByStatusSwaggerPetstore.API, SwaggerPetstore
findPetsByStatusSwaggerPetstore.API, SwaggerPetstore
FindPetsByTagsSwaggerPetstore.API, SwaggerPetstore
findPetsByTagsSwaggerPetstore.API, SwaggerPetstore
FormatTest 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
formatTestBinarySwaggerPetstore.Model, SwaggerPetstore
formatTestBinaryLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestByteSwaggerPetstore.Model, SwaggerPetstore
formatTestByteLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestDateSwaggerPetstore.Model, SwaggerPetstore
formatTestDateLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestDateTimeSwaggerPetstore.Model, SwaggerPetstore
formatTestDateTimeLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestDoubleSwaggerPetstore.Model, SwaggerPetstore
formatTestDoubleLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestFloatSwaggerPetstore.Model, SwaggerPetstore
formatTestFloatLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestInt32SwaggerPetstore.Model, SwaggerPetstore
formatTestInt32LSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestInt64SwaggerPetstore.Model, SwaggerPetstore
formatTestInt64LSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestIntegerSwaggerPetstore.Model, SwaggerPetstore
formatTestIntegerLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestNumberSwaggerPetstore.Model, SwaggerPetstore
formatTestNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestPasswordSwaggerPetstore.Model, SwaggerPetstore
formatTestPasswordLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestStringSwaggerPetstore.Model, SwaggerPetstore
formatTestStringLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestUuidSwaggerPetstore.Model, SwaggerPetstore
formatTestUuidLSwaggerPetstore.ModelLens, SwaggerPetstore
GetInventorySwaggerPetstore.API, SwaggerPetstore
getInventorySwaggerPetstore.API, SwaggerPetstore
GetOrderByIdSwaggerPetstore.API, SwaggerPetstore
getOrderByIdSwaggerPetstore.API, SwaggerPetstore
GetPetByIdSwaggerPetstore.API, SwaggerPetstore
getPetByIdSwaggerPetstore.API, SwaggerPetstore
GetUserByNameSwaggerPetstore.API, SwaggerPetstore
getUserByNameSwaggerPetstore.API, SwaggerPetstore
HasBodyParamSwaggerPetstore.Core, SwaggerPetstore
HasOnlyReadOnly 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
hasOnlyReadOnlyBarSwaggerPetstore.Model, SwaggerPetstore
hasOnlyReadOnlyBarLSwaggerPetstore.ModelLens, SwaggerPetstore
hasOnlyReadOnlyFooSwaggerPetstore.Model, SwaggerPetstore
hasOnlyReadOnlyFooLSwaggerPetstore.ModelLens, SwaggerPetstore
HasOptionalParamSwaggerPetstore.Core, SwaggerPetstore
initLogContextSwaggerPetstore.Logging, SwaggerPetstore
InitRequest 
1 (Type/Class)SwaggerPetstore.Client, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Client, SwaggerPetstore
Int32 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Int64 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Lens_SwaggerPetstore.Core, SwaggerPetstore
Lens_'SwaggerPetstore.Core, SwaggerPetstore
levelDebugSwaggerPetstore.Logging, SwaggerPetstore
levelErrorSwaggerPetstore.Logging, SwaggerPetstore
levelInfoSwaggerPetstore.Logging, SwaggerPetstore
LogContextSwaggerPetstore.Logging, SwaggerPetstore
logExceptionsSwaggerPetstore.Logging, SwaggerPetstore
LogExecSwaggerPetstore.Logging, SwaggerPetstore
LogExecWithContextSwaggerPetstore.Logging, SwaggerPetstore
LoginUserSwaggerPetstore.API, SwaggerPetstore
loginUserSwaggerPetstore.API, SwaggerPetstore
LogLevelSwaggerPetstore.Logging, SwaggerPetstore
LogoutUserSwaggerPetstore.API, SwaggerPetstore
logoutUserSwaggerPetstore.API, SwaggerPetstore
MapTest 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
mapTestMapMapOfStringSwaggerPetstore.Model, SwaggerPetstore
mapTestMapMapOfStringLSwaggerPetstore.ModelLens, SwaggerPetstore
mapTestMapOfEnumStringSwaggerPetstore.Model, SwaggerPetstore
mapTestMapOfEnumStringLSwaggerPetstore.ModelLens, SwaggerPetstore
MimeAny 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeError 
1 (Type/Class)SwaggerPetstore.Client, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Client, SwaggerPetstore
mimeErrorSwaggerPetstore.Client, SwaggerPetstore
mimeErrorResponseSwaggerPetstore.Client, SwaggerPetstore
MimeFormUrlEncoded 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeJSON 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeJsonCharsetutf8 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
MimeMultipartFormData 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeNoContent 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeOctetStream 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimePlainText 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeRenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeRenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeRender'SwaggerPetstore.MimeTypes, SwaggerPetstore
mimeRenderDefaultMultipartFormDataSwaggerPetstore.MimeTypes, SwaggerPetstore
MimeResult 
1 (Type/Class)SwaggerPetstore.Client, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Client, SwaggerPetstore
mimeResultSwaggerPetstore.Client, SwaggerPetstore
mimeResultResponseSwaggerPetstore.Client, SwaggerPetstore
MimeTypeSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeTypeSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeType'SwaggerPetstore.MimeTypes, SwaggerPetstore
mimeTypesSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeTypes'SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeUnrenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeUnrenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeUnrender'SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeXML 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeXmlCharsetutf8 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
MixedPropertiesAndAdditionalPropertiesClass 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassDateTimeSwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassDateTimeLSwaggerPetstore.ModelLens, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassMapSwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassMapLSwaggerPetstore.ModelLens, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassUuidSwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassUuidLSwaggerPetstore.ModelLens, SwaggerPetstore
mkAdditionalPropertiesClassSwaggerPetstore.Model, SwaggerPetstore
mkAnimalSwaggerPetstore.Model, SwaggerPetstore
mkAnimalFarmSwaggerPetstore.Model, SwaggerPetstore
mkApiResponseSwaggerPetstore.Model, SwaggerPetstore
mkArrayOfArrayOfNumberOnlySwaggerPetstore.Model, SwaggerPetstore
mkArrayOfNumberOnlySwaggerPetstore.Model, SwaggerPetstore
mkArrayTestSwaggerPetstore.Model, SwaggerPetstore
mkCapitalizationSwaggerPetstore.Model, SwaggerPetstore
mkCatSwaggerPetstore.Model, SwaggerPetstore
mkCategorySwaggerPetstore.Model, SwaggerPetstore
mkClassModelSwaggerPetstore.Model, SwaggerPetstore
mkClientSwaggerPetstore.Model, SwaggerPetstore
mkDogSwaggerPetstore.Model, SwaggerPetstore
mkEnumArraysSwaggerPetstore.Model, SwaggerPetstore
mkEnumClassSwaggerPetstore.Model, SwaggerPetstore
mkEnumTestSwaggerPetstore.Model, SwaggerPetstore
mkFormatTestSwaggerPetstore.Model, SwaggerPetstore
mkHasOnlyReadOnlySwaggerPetstore.Model, SwaggerPetstore
mkMapTestSwaggerPetstore.Model, SwaggerPetstore
mkMixedPropertiesAndAdditionalPropertiesClassSwaggerPetstore.Model, SwaggerPetstore
mkModel200ResponseSwaggerPetstore.Model, SwaggerPetstore
mkModelListSwaggerPetstore.Model, SwaggerPetstore
mkModelReturnSwaggerPetstore.Model, SwaggerPetstore
mkNameSwaggerPetstore.Model, SwaggerPetstore
mkNumberOnlySwaggerPetstore.Model, SwaggerPetstore
mkOrderSwaggerPetstore.Model, SwaggerPetstore
mkOuterCompositeSwaggerPetstore.Model, SwaggerPetstore
mkOuterEnumSwaggerPetstore.Model, SwaggerPetstore
mkPetSwaggerPetstore.Model, SwaggerPetstore
mkReadOnlyFirstSwaggerPetstore.Model, SwaggerPetstore
mkSpecialModelNameSwaggerPetstore.Model, SwaggerPetstore
mkTagSwaggerPetstore.Model, SwaggerPetstore
mkUserSwaggerPetstore.Model, SwaggerPetstore
Model200Response 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
model200ResponseClassSwaggerPetstore.Model, SwaggerPetstore
model200ResponseClassLSwaggerPetstore.ModelLens, SwaggerPetstore
model200ResponseNameSwaggerPetstore.Model, SwaggerPetstore
model200ResponseNameLSwaggerPetstore.ModelLens, SwaggerPetstore
ModelList 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
modelList123ListSwaggerPetstore.Model, SwaggerPetstore
modelList123ListLSwaggerPetstore.ModelLens, SwaggerPetstore
ModelReturn 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
modelReturnReturnSwaggerPetstore.Model, SwaggerPetstore
modelReturnReturnLSwaggerPetstore.ModelLens, SwaggerPetstore
modifyInitRequestSwaggerPetstore.Client, SwaggerPetstore
modifyInitRequestMSwaggerPetstore.Client, SwaggerPetstore
MultiParamArraySwaggerPetstore.Core, SwaggerPetstore
Name 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
name123NumberSwaggerPetstore.Model, SwaggerPetstore
name123NumberLSwaggerPetstore.ModelLens, SwaggerPetstore
Name2 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
nameNameSwaggerPetstore.Model, SwaggerPetstore
nameNameLSwaggerPetstore.ModelLens, SwaggerPetstore
namePropertySwaggerPetstore.Model, SwaggerPetstore
namePropertyLSwaggerPetstore.ModelLens, SwaggerPetstore
nameSnakeCaseSwaggerPetstore.Model, SwaggerPetstore
nameSnakeCaseLSwaggerPetstore.ModelLens, SwaggerPetstore
newConfigSwaggerPetstore.Core, SwaggerPetstore
NoContent 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
Number 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
NumberOnly 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
numberOnlyJustNumberSwaggerPetstore.Model, SwaggerPetstore
numberOnlyJustNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
Order 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
orderCompleteSwaggerPetstore.Model, SwaggerPetstore
orderCompleteLSwaggerPetstore.ModelLens, SwaggerPetstore
OrderId 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
orderIdSwaggerPetstore.Model, SwaggerPetstore
orderIdLSwaggerPetstore.ModelLens, SwaggerPetstore
OrderIdText 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
orderPetIdSwaggerPetstore.Model, SwaggerPetstore
orderPetIdLSwaggerPetstore.ModelLens, SwaggerPetstore
orderQuantitySwaggerPetstore.Model, SwaggerPetstore
orderQuantityLSwaggerPetstore.ModelLens, SwaggerPetstore
orderShipDateSwaggerPetstore.Model, SwaggerPetstore
orderShipDateLSwaggerPetstore.ModelLens, SwaggerPetstore
orderStatusSwaggerPetstore.Model, SwaggerPetstore
orderStatusLSwaggerPetstore.ModelLens, SwaggerPetstore
OuterBoolean 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
OuterComposite 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyBooleanSwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyBooleanLSwaggerPetstore.ModelLens, SwaggerPetstore
outerCompositeMyNumberSwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
outerCompositeMyStringSwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyStringLSwaggerPetstore.ModelLens, SwaggerPetstore
OuterEnum 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
OuterNumber 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
OuterString 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
Param 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Param2 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ParamBinary 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ParamBodySwaggerPetstore.Core, SwaggerPetstore
ParamBodyBSwaggerPetstore.Core, SwaggerPetstore
ParamBodyBLSwaggerPetstore.Core, SwaggerPetstore
ParamBodyFormUrlEncodedSwaggerPetstore.Core, SwaggerPetstore
ParamBodyMultipartFormDataSwaggerPetstore.Core, SwaggerPetstore
ParamBodyNoneSwaggerPetstore.Core, SwaggerPetstore
ParamDate 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ParamDateTime 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ParamDouble 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ParamFloat 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ParamInteger 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Params 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
paramsBodySwaggerPetstore.Core, SwaggerPetstore
paramsBodyLSwaggerPetstore.Core, SwaggerPetstore
paramsHeadersSwaggerPetstore.Core, SwaggerPetstore
paramsHeadersLSwaggerPetstore.Core, SwaggerPetstore
paramsQuerySwaggerPetstore.Core, SwaggerPetstore
paramsQueryLSwaggerPetstore.Core, SwaggerPetstore
ParamString 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Password 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
PatternWithoutDelimiter 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Pet 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
petCategorySwaggerPetstore.Model, SwaggerPetstore
petCategoryLSwaggerPetstore.ModelLens, SwaggerPetstore
PetId 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
petIdSwaggerPetstore.Model, SwaggerPetstore
petIdLSwaggerPetstore.ModelLens, SwaggerPetstore
petNameSwaggerPetstore.Model, SwaggerPetstore
petNameLSwaggerPetstore.ModelLens, SwaggerPetstore
petPhotoUrlsSwaggerPetstore.Model, SwaggerPetstore
petPhotoUrlsLSwaggerPetstore.ModelLens, SwaggerPetstore
petStatusSwaggerPetstore.Model, SwaggerPetstore
petStatusLSwaggerPetstore.ModelLens, SwaggerPetstore
petTagsSwaggerPetstore.Model, SwaggerPetstore
petTagsLSwaggerPetstore.ModelLens, SwaggerPetstore
PipeSeparatedSwaggerPetstore.Core, SwaggerPetstore
PlaceOrderSwaggerPetstore.API, SwaggerPetstore
placeOrderSwaggerPetstore.API, SwaggerPetstore
ProducesSwaggerPetstore.MimeTypes, SwaggerPetstore
rAuthTypesSwaggerPetstore.Core, SwaggerPetstore
rAuthTypesLSwaggerPetstore.Core, SwaggerPetstore
ReadOnlyFirst 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
readOnlyFirstBarSwaggerPetstore.Model, SwaggerPetstore
readOnlyFirstBarLSwaggerPetstore.ModelLens, SwaggerPetstore
readOnlyFirstBazSwaggerPetstore.Model, SwaggerPetstore
readOnlyFirstBazLSwaggerPetstore.ModelLens, SwaggerPetstore
removeHeaderSwaggerPetstore.Core, SwaggerPetstore
rMethodSwaggerPetstore.Core, SwaggerPetstore
rMethodLSwaggerPetstore.Core, SwaggerPetstore
rParamsSwaggerPetstore.Core, SwaggerPetstore
rParamsLSwaggerPetstore.Core, SwaggerPetstore
runConfigLogSwaggerPetstore.Client, SwaggerPetstore
runConfigLogWithExceptionsSwaggerPetstore.Client, SwaggerPetstore
runDefaultLogExecWithContextSwaggerPetstore.Logging, SwaggerPetstore
runNullLogExecSwaggerPetstore.Logging, SwaggerPetstore
rUrlPathSwaggerPetstore.Core, SwaggerPetstore
rUrlPathLSwaggerPetstore.Core, SwaggerPetstore
setBodyParamSwaggerPetstore.Core, SwaggerPetstore
setHeaderSwaggerPetstore.Core, SwaggerPetstore
setQuerySwaggerPetstore.Core, SwaggerPetstore
SpaceSeparatedSwaggerPetstore.Core, SwaggerPetstore
SpecialModelName 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
specialModelNameSpecialPropertyNameSwaggerPetstore.Model, SwaggerPetstore
specialModelNameSpecialPropertyNameLSwaggerPetstore.ModelLens, SwaggerPetstore
Status 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
StatusText 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
stderrLoggingContextSwaggerPetstore.Logging, SwaggerPetstore
stderrLoggingExecSwaggerPetstore.Logging, SwaggerPetstore
stdoutLoggingContextSwaggerPetstore.Logging, SwaggerPetstore
stdoutLoggingExecSwaggerPetstore.Logging, SwaggerPetstore
SwaggerPetstoreConfig 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
SwaggerPetstoreRequest 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
TabSeparatedSwaggerPetstore.Core, SwaggerPetstore
Tag 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
tagIdSwaggerPetstore.Model, SwaggerPetstore
tagIdLSwaggerPetstore.ModelLens, SwaggerPetstore
tagNameSwaggerPetstore.Model, SwaggerPetstore
tagNameLSwaggerPetstore.ModelLens, SwaggerPetstore
Tags 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
TestClassnameSwaggerPetstore.API, SwaggerPetstore
testClassnameSwaggerPetstore.API, SwaggerPetstore
TestClientModelSwaggerPetstore.API, SwaggerPetstore
testClientModelSwaggerPetstore.API, SwaggerPetstore
TestEndpointParametersSwaggerPetstore.API, SwaggerPetstore
testEndpointParametersSwaggerPetstore.API, SwaggerPetstore
TestEnumParametersSwaggerPetstore.API, SwaggerPetstore
testEnumParametersSwaggerPetstore.API, SwaggerPetstore
TestJsonFormDataSwaggerPetstore.API, SwaggerPetstore
testJsonFormDataSwaggerPetstore.API, SwaggerPetstore
TestSpecialTagsSwaggerPetstore.API, SwaggerPetstore
testSpecialTagsSwaggerPetstore.API, SwaggerPetstore
toFormSwaggerPetstore.Core, SwaggerPetstore
toFormCollSwaggerPetstore.Core, SwaggerPetstore
toHeaderSwaggerPetstore.Core, SwaggerPetstore
toHeaderCollSwaggerPetstore.Core, SwaggerPetstore
toPathSwaggerPetstore.Core, SwaggerPetstore
toQuerySwaggerPetstore.Core, SwaggerPetstore
toQueryCollSwaggerPetstore.Core, SwaggerPetstore
unAdditionalMetadataSwaggerPetstore.API, SwaggerPetstore
unApiKeySwaggerPetstore.API, SwaggerPetstore
unBinarySwaggerPetstore.Core, SwaggerPetstore
unBodySwaggerPetstore.API, SwaggerPetstore
unByteSwaggerPetstore.API, SwaggerPetstore
unByteArraySwaggerPetstore.Core, SwaggerPetstore
unCallbackSwaggerPetstore.API, SwaggerPetstore
unDateSwaggerPetstore.Core, SwaggerPetstore
unDateTimeSwaggerPetstore.Core, SwaggerPetstore
unEnumFormStringSwaggerPetstore.API, SwaggerPetstore
unEnumFormStringArraySwaggerPetstore.API, SwaggerPetstore
unEnumHeaderStringSwaggerPetstore.API, SwaggerPetstore
unEnumHeaderStringArraySwaggerPetstore.API, SwaggerPetstore
unEnumQueryDoubleSwaggerPetstore.API, SwaggerPetstore
unEnumQueryIntegerSwaggerPetstore.API, SwaggerPetstore
unEnumQueryStringSwaggerPetstore.API, SwaggerPetstore
unEnumQueryStringArraySwaggerPetstore.API, SwaggerPetstore
unFileSwaggerPetstore.API, SwaggerPetstore
unInitRequestSwaggerPetstore.Client, SwaggerPetstore
unInt32SwaggerPetstore.API, SwaggerPetstore
unInt64SwaggerPetstore.API, SwaggerPetstore
unName2SwaggerPetstore.API, SwaggerPetstore
unNumberSwaggerPetstore.API, SwaggerPetstore
unOrderIdSwaggerPetstore.API, SwaggerPetstore
unOrderIdTextSwaggerPetstore.API, SwaggerPetstore
unOuterBooleanSwaggerPetstore.Model, SwaggerPetstore
unOuterNumberSwaggerPetstore.Model, SwaggerPetstore
unOuterStringSwaggerPetstore.Model, SwaggerPetstore
unParamSwaggerPetstore.API, SwaggerPetstore
unParam2SwaggerPetstore.API, SwaggerPetstore
unParamBinarySwaggerPetstore.API, SwaggerPetstore
unParamDateSwaggerPetstore.API, SwaggerPetstore
unParamDateTimeSwaggerPetstore.API, SwaggerPetstore
unParamDoubleSwaggerPetstore.API, SwaggerPetstore
unParamFloatSwaggerPetstore.API, SwaggerPetstore
unParamIntegerSwaggerPetstore.API, SwaggerPetstore
unParamStringSwaggerPetstore.API, SwaggerPetstore
unPasswordSwaggerPetstore.API, SwaggerPetstore
unPatternWithoutDelimiterSwaggerPetstore.API, SwaggerPetstore
unPetIdSwaggerPetstore.API, SwaggerPetstore
unStatusSwaggerPetstore.API, SwaggerPetstore
unStatusTextSwaggerPetstore.API, SwaggerPetstore
unTagsSwaggerPetstore.API, SwaggerPetstore
unUsernameSwaggerPetstore.API, SwaggerPetstore
UpdatePetSwaggerPetstore.API, SwaggerPetstore
updatePetSwaggerPetstore.API, SwaggerPetstore
UpdatePetWithFormSwaggerPetstore.API, SwaggerPetstore
updatePetWithFormSwaggerPetstore.API, SwaggerPetstore
UpdateUserSwaggerPetstore.API, SwaggerPetstore
updateUserSwaggerPetstore.API, SwaggerPetstore
UploadFileSwaggerPetstore.API, SwaggerPetstore
uploadFileSwaggerPetstore.API, SwaggerPetstore
User 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
userEmailSwaggerPetstore.Model, SwaggerPetstore
userEmailLSwaggerPetstore.ModelLens, SwaggerPetstore
userFirstNameSwaggerPetstore.Model, SwaggerPetstore
userFirstNameLSwaggerPetstore.ModelLens, SwaggerPetstore
userIdSwaggerPetstore.Model, SwaggerPetstore
userIdLSwaggerPetstore.ModelLens, SwaggerPetstore
userLastNameSwaggerPetstore.Model, SwaggerPetstore
userLastNameLSwaggerPetstore.ModelLens, SwaggerPetstore
Username 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
userPasswordSwaggerPetstore.Model, SwaggerPetstore
userPasswordLSwaggerPetstore.ModelLens, SwaggerPetstore
userPhoneSwaggerPetstore.Model, SwaggerPetstore
userPhoneLSwaggerPetstore.ModelLens, SwaggerPetstore
userUsernameSwaggerPetstore.Model, SwaggerPetstore
userUsernameLSwaggerPetstore.ModelLens, SwaggerPetstore
userUserStatusSwaggerPetstore.Model, SwaggerPetstore
userUserStatusLSwaggerPetstore.ModelLens, SwaggerPetstore
withNoLoggingSwaggerPetstore.Core, SwaggerPetstore
withStderrLoggingSwaggerPetstore.Core, SwaggerPetstore
withStdoutLoggingSwaggerPetstore.Core, SwaggerPetstore
_addMultiFormPartSwaggerPetstore.Core, SwaggerPetstore
_applyAuthMethodsSwaggerPetstore.Core, SwaggerPetstore
_emptyToNothingSwaggerPetstore.Core, SwaggerPetstore
_hasAuthTypeSwaggerPetstore.Core, SwaggerPetstore
_logSwaggerPetstore.Logging, SwaggerPetstore
_memptyToNothingSwaggerPetstore.Core, SwaggerPetstore
_mkParamsSwaggerPetstore.Core, SwaggerPetstore
_mkRequestSwaggerPetstore.Core, SwaggerPetstore
_omitNullsSwaggerPetstore.Core, SwaggerPetstore
_parseISO8601SwaggerPetstore.Core, SwaggerPetstore
_readBinaryBase64SwaggerPetstore.Core, SwaggerPetstore
_readByteArraySwaggerPetstore.Core, SwaggerPetstore
_readDateSwaggerPetstore.Core, SwaggerPetstore
_readDateTimeSwaggerPetstore.Core, SwaggerPetstore
_setAcceptHeaderSwaggerPetstore.Core, SwaggerPetstore
_setBodyBSSwaggerPetstore.Core, SwaggerPetstore
_setBodyLBSSwaggerPetstore.Core, SwaggerPetstore
_setContentTypeHeaderSwaggerPetstore.Core, SwaggerPetstore
_showBinaryBase64SwaggerPetstore.Core, SwaggerPetstore
_showByteArraySwaggerPetstore.Core, SwaggerPetstore
_showDateSwaggerPetstore.Core, SwaggerPetstore
_showDateTimeSwaggerPetstore.Core, SwaggerPetstore
_toCollSwaggerPetstore.Core, SwaggerPetstore
_toCollASwaggerPetstore.Core, SwaggerPetstore
_toCollA'SwaggerPetstore.Core, SwaggerPetstore
_toFormItemSwaggerPetstore.Core, SwaggerPetstore
_toInitRequestSwaggerPetstore.Client, SwaggerPetstore
\ No newline at end of file +

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Index

-&-SwaggerPetstore.Core, SwaggerPetstore
addAuthMethodSwaggerPetstore.Core, SwaggerPetstore
addFormSwaggerPetstore.Core, SwaggerPetstore
AdditionalMetadata 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
AdditionalPropertiesClass 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
additionalPropertiesClassMapOfMapPropertySwaggerPetstore.Model, SwaggerPetstore
additionalPropertiesClassMapOfMapPropertyLSwaggerPetstore.ModelLens, SwaggerPetstore
additionalPropertiesClassMapPropertySwaggerPetstore.Model, SwaggerPetstore
additionalPropertiesClassMapPropertyLSwaggerPetstore.ModelLens, SwaggerPetstore
AddPetSwaggerPetstore.API, SwaggerPetstore
addPetSwaggerPetstore.API, SwaggerPetstore
Animal 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
animalClassNameSwaggerPetstore.Model, SwaggerPetstore
animalClassNameLSwaggerPetstore.ModelLens, SwaggerPetstore
animalColorSwaggerPetstore.Model, SwaggerPetstore
animalColorLSwaggerPetstore.ModelLens, SwaggerPetstore
AnimalFarm 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
AnyAuthMethod 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
ApiKey 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ApiResponse 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
apiResponseCodeSwaggerPetstore.Model, SwaggerPetstore
apiResponseCodeLSwaggerPetstore.ModelLens, SwaggerPetstore
apiResponseMessageSwaggerPetstore.Model, SwaggerPetstore
apiResponseMessageLSwaggerPetstore.ModelLens, SwaggerPetstore
apiResponseTypeSwaggerPetstore.Model, SwaggerPetstore
apiResponseTypeLSwaggerPetstore.ModelLens, SwaggerPetstore
applyAuthMethodSwaggerPetstore.Core, SwaggerPetstore
applyOptionalParamSwaggerPetstore.Core, SwaggerPetstore
ArrayOfArrayOfNumberOnly 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
arrayOfArrayOfNumberOnlyArrayArrayNumberSwaggerPetstore.Model, SwaggerPetstore
arrayOfArrayOfNumberOnlyArrayArrayNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
ArrayOfNumberOnly 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
arrayOfNumberOnlyArrayNumberSwaggerPetstore.Model, SwaggerPetstore
arrayOfNumberOnlyArrayNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
ArrayTest 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
arrayTestArrayArrayOfIntegerSwaggerPetstore.Model, SwaggerPetstore
arrayTestArrayArrayOfIntegerLSwaggerPetstore.ModelLens, SwaggerPetstore
arrayTestArrayArrayOfModelSwaggerPetstore.Model, SwaggerPetstore
arrayTestArrayArrayOfModelLSwaggerPetstore.ModelLens, SwaggerPetstore
arrayTestArrayOfStringSwaggerPetstore.Model, SwaggerPetstore
arrayTestArrayOfStringLSwaggerPetstore.ModelLens, SwaggerPetstore
AuthApiKeyApiKey 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
AuthApiKeyApiKeyQuery 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
AuthBasicHttpBasicTest 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
AuthMethodSwaggerPetstore.Core, SwaggerPetstore
AuthOAuthPetstoreAuth 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Binary 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
Body 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Byte 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ByteArray 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
Callback 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Capitalization 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
capitalizationAttNameSwaggerPetstore.Model, SwaggerPetstore
capitalizationAttNameLSwaggerPetstore.ModelLens, SwaggerPetstore
capitalizationCapitalCamelSwaggerPetstore.Model, SwaggerPetstore
capitalizationCapitalCamelLSwaggerPetstore.ModelLens, SwaggerPetstore
capitalizationCapitalSnakeSwaggerPetstore.Model, SwaggerPetstore
capitalizationCapitalSnakeLSwaggerPetstore.ModelLens, SwaggerPetstore
capitalizationScaEthFlowPointsSwaggerPetstore.Model, SwaggerPetstore
capitalizationScaEthFlowPointsLSwaggerPetstore.ModelLens, SwaggerPetstore
capitalizationSmallCamelSwaggerPetstore.Model, SwaggerPetstore
capitalizationSmallCamelLSwaggerPetstore.ModelLens, SwaggerPetstore
capitalizationSmallSnakeSwaggerPetstore.Model, SwaggerPetstore
capitalizationSmallSnakeLSwaggerPetstore.ModelLens, SwaggerPetstore
Cat 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
catClassNameSwaggerPetstore.Model, SwaggerPetstore
catClassNameLSwaggerPetstore.ModelLens, SwaggerPetstore
catColorSwaggerPetstore.Model, SwaggerPetstore
catColorLSwaggerPetstore.ModelLens, SwaggerPetstore
catDeclawedSwaggerPetstore.Model, SwaggerPetstore
catDeclawedLSwaggerPetstore.ModelLens, SwaggerPetstore
Category 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
categoryIdSwaggerPetstore.Model, SwaggerPetstore
categoryIdLSwaggerPetstore.ModelLens, SwaggerPetstore
categoryNameSwaggerPetstore.Model, SwaggerPetstore
categoryNameLSwaggerPetstore.ModelLens, SwaggerPetstore
ClassModel 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
classModelClassSwaggerPetstore.Model, SwaggerPetstore
classModelClassLSwaggerPetstore.ModelLens, SwaggerPetstore
Client 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
clientClientSwaggerPetstore.Model, SwaggerPetstore
clientClientLSwaggerPetstore.ModelLens, SwaggerPetstore
CollectionFormatSwaggerPetstore.Core, SwaggerPetstore
CommaSeparatedSwaggerPetstore.Core, SwaggerPetstore
configAuthMethodsSwaggerPetstore.Core, SwaggerPetstore
configHostSwaggerPetstore.Core, SwaggerPetstore
configLogContextSwaggerPetstore.Core, SwaggerPetstore
configLogExecWithContextSwaggerPetstore.Core, SwaggerPetstore
configUserAgentSwaggerPetstore.Core, SwaggerPetstore
configValidateAuthMethodsSwaggerPetstore.Core, SwaggerPetstore
ConsumesSwaggerPetstore.MimeTypes, SwaggerPetstore
CreateUserSwaggerPetstore.API, SwaggerPetstore
createUserSwaggerPetstore.API, SwaggerPetstore
CreateUsersWithArrayInputSwaggerPetstore.API, SwaggerPetstore
createUsersWithArrayInputSwaggerPetstore.API, SwaggerPetstore
CreateUsersWithListInputSwaggerPetstore.API, SwaggerPetstore
createUsersWithListInputSwaggerPetstore.API, SwaggerPetstore
Date 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
DateTime 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
DeleteOrderSwaggerPetstore.API, SwaggerPetstore
deleteOrderSwaggerPetstore.API, SwaggerPetstore
DeletePetSwaggerPetstore.API, SwaggerPetstore
deletePetSwaggerPetstore.API, SwaggerPetstore
DeleteUserSwaggerPetstore.API, SwaggerPetstore
deleteUserSwaggerPetstore.API, SwaggerPetstore
dispatchInitUnsafeSwaggerPetstore.Client, SwaggerPetstore
dispatchLbsSwaggerPetstore.Client, SwaggerPetstore
dispatchLbsUnsafeSwaggerPetstore.Client, SwaggerPetstore
dispatchMimeSwaggerPetstore.Client, SwaggerPetstore
dispatchMime'SwaggerPetstore.Client, SwaggerPetstore
Dog 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
dogBreedSwaggerPetstore.Model, SwaggerPetstore
dogBreedLSwaggerPetstore.ModelLens, SwaggerPetstore
dogClassNameSwaggerPetstore.Model, SwaggerPetstore
dogClassNameLSwaggerPetstore.ModelLens, SwaggerPetstore
dogColorSwaggerPetstore.Model, SwaggerPetstore
dogColorLSwaggerPetstore.ModelLens, SwaggerPetstore
E'ArrayEnumSwaggerPetstore.Model, SwaggerPetstore
E'ArrayEnum'CrabSwaggerPetstore.Model, SwaggerPetstore
E'ArrayEnum'FishSwaggerPetstore.Model, SwaggerPetstore
E'EnumFormStringSwaggerPetstore.Model, SwaggerPetstore
E'EnumFormString'_abcSwaggerPetstore.Model, SwaggerPetstore
E'EnumFormString'_efgSwaggerPetstore.Model, SwaggerPetstore
E'EnumFormString'_xyzSwaggerPetstore.Model, SwaggerPetstore
E'EnumIntegerSwaggerPetstore.Model, SwaggerPetstore
E'EnumInteger'Num1SwaggerPetstore.Model, SwaggerPetstore
E'EnumInteger'NumMinus_1SwaggerPetstore.Model, SwaggerPetstore
E'EnumNumberSwaggerPetstore.Model, SwaggerPetstore
E'EnumNumber'Num1_Dot_1SwaggerPetstore.Model, SwaggerPetstore
E'EnumNumber'NumMinus_1_Dot_2SwaggerPetstore.Model, SwaggerPetstore
E'EnumQueryIntegerSwaggerPetstore.Model, SwaggerPetstore
E'EnumQueryInteger'Num1SwaggerPetstore.Model, SwaggerPetstore
E'EnumQueryInteger'NumMinus_2SwaggerPetstore.Model, SwaggerPetstore
E'EnumStringSwaggerPetstore.Model, SwaggerPetstore
E'EnumString'EmptySwaggerPetstore.Model, SwaggerPetstore
E'EnumString'LowerSwaggerPetstore.Model, SwaggerPetstore
E'EnumString'UPPERSwaggerPetstore.Model, SwaggerPetstore
E'InnerSwaggerPetstore.Model, SwaggerPetstore
E'Inner'LowerSwaggerPetstore.Model, SwaggerPetstore
E'Inner'UPPERSwaggerPetstore.Model, SwaggerPetstore
E'Inner2SwaggerPetstore.Model, SwaggerPetstore
E'Inner2'DollarSwaggerPetstore.Model, SwaggerPetstore
E'Inner2'GreaterThanSwaggerPetstore.Model, SwaggerPetstore
E'JustSymbolSwaggerPetstore.Model, SwaggerPetstore
E'JustSymbol'DollarSwaggerPetstore.Model, SwaggerPetstore
E'JustSymbol'Greater_Than_Or_Equal_ToSwaggerPetstore.Model, SwaggerPetstore
E'StatusSwaggerPetstore.Model, SwaggerPetstore
E'Status'ApprovedSwaggerPetstore.Model, SwaggerPetstore
E'Status'DeliveredSwaggerPetstore.Model, SwaggerPetstore
E'Status'PlacedSwaggerPetstore.Model, SwaggerPetstore
E'Status2SwaggerPetstore.Model, SwaggerPetstore
E'Status2'AvailableSwaggerPetstore.Model, SwaggerPetstore
E'Status2'PendingSwaggerPetstore.Model, SwaggerPetstore
E'Status2'SoldSwaggerPetstore.Model, SwaggerPetstore
EnumArrays 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
enumArraysArrayEnumSwaggerPetstore.Model, SwaggerPetstore
enumArraysArrayEnumLSwaggerPetstore.ModelLens, SwaggerPetstore
enumArraysJustSymbolSwaggerPetstore.Model, SwaggerPetstore
enumArraysJustSymbolLSwaggerPetstore.ModelLens, SwaggerPetstore
EnumClassSwaggerPetstore.Model, SwaggerPetstore
EnumClass'_abcSwaggerPetstore.Model, SwaggerPetstore
EnumClass'_efgSwaggerPetstore.Model, SwaggerPetstore
EnumClass'_xyzSwaggerPetstore.Model, SwaggerPetstore
EnumFormString 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumFormStringArray 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumHeaderString 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumHeaderStringArray 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryDouble 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryInteger 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryString 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryStringArray 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumTest 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
enumTestEnumIntegerSwaggerPetstore.Model, SwaggerPetstore
enumTestEnumIntegerLSwaggerPetstore.ModelLens, SwaggerPetstore
enumTestEnumNumberSwaggerPetstore.Model, SwaggerPetstore
enumTestEnumNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
enumTestEnumStringSwaggerPetstore.Model, SwaggerPetstore
enumTestEnumStringLSwaggerPetstore.ModelLens, SwaggerPetstore
enumTestOuterEnumSwaggerPetstore.Model, SwaggerPetstore
enumTestOuterEnumLSwaggerPetstore.ModelLens, SwaggerPetstore
FakeOuterBooleanSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterBooleanSerializeSwaggerPetstore.API, SwaggerPetstore
FakeOuterCompositeSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterCompositeSerializeSwaggerPetstore.API, SwaggerPetstore
FakeOuterNumberSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterNumberSerializeSwaggerPetstore.API, SwaggerPetstore
FakeOuterStringSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterStringSerializeSwaggerPetstore.API, SwaggerPetstore
File 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
FindPetsByStatusSwaggerPetstore.API, SwaggerPetstore
findPetsByStatusSwaggerPetstore.API, SwaggerPetstore
FindPetsByTagsSwaggerPetstore.API, SwaggerPetstore
findPetsByTagsSwaggerPetstore.API, SwaggerPetstore
FormatTest 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
formatTestBinarySwaggerPetstore.Model, SwaggerPetstore
formatTestBinaryLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestByteSwaggerPetstore.Model, SwaggerPetstore
formatTestByteLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestDateSwaggerPetstore.Model, SwaggerPetstore
formatTestDateLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestDateTimeSwaggerPetstore.Model, SwaggerPetstore
formatTestDateTimeLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestDoubleSwaggerPetstore.Model, SwaggerPetstore
formatTestDoubleLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestFloatSwaggerPetstore.Model, SwaggerPetstore
formatTestFloatLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestInt32SwaggerPetstore.Model, SwaggerPetstore
formatTestInt32LSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestInt64SwaggerPetstore.Model, SwaggerPetstore
formatTestInt64LSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestIntegerSwaggerPetstore.Model, SwaggerPetstore
formatTestIntegerLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestNumberSwaggerPetstore.Model, SwaggerPetstore
formatTestNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestPasswordSwaggerPetstore.Model, SwaggerPetstore
formatTestPasswordLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestStringSwaggerPetstore.Model, SwaggerPetstore
formatTestStringLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestUuidSwaggerPetstore.Model, SwaggerPetstore
formatTestUuidLSwaggerPetstore.ModelLens, SwaggerPetstore
fromE'ArrayEnumSwaggerPetstore.Model, SwaggerPetstore
fromE'EnumFormStringSwaggerPetstore.Model, SwaggerPetstore
fromE'EnumIntegerSwaggerPetstore.Model, SwaggerPetstore
fromE'EnumNumberSwaggerPetstore.Model, SwaggerPetstore
fromE'EnumQueryIntegerSwaggerPetstore.Model, SwaggerPetstore
fromE'EnumStringSwaggerPetstore.Model, SwaggerPetstore
fromE'InnerSwaggerPetstore.Model, SwaggerPetstore
fromE'Inner2SwaggerPetstore.Model, SwaggerPetstore
fromE'JustSymbolSwaggerPetstore.Model, SwaggerPetstore
fromE'StatusSwaggerPetstore.Model, SwaggerPetstore
fromE'Status2SwaggerPetstore.Model, SwaggerPetstore
fromEnumClassSwaggerPetstore.Model, SwaggerPetstore
fromOuterEnumSwaggerPetstore.Model, SwaggerPetstore
GetInventorySwaggerPetstore.API, SwaggerPetstore
getInventorySwaggerPetstore.API, SwaggerPetstore
GetOrderByIdSwaggerPetstore.API, SwaggerPetstore
getOrderByIdSwaggerPetstore.API, SwaggerPetstore
GetPetByIdSwaggerPetstore.API, SwaggerPetstore
getPetByIdSwaggerPetstore.API, SwaggerPetstore
GetUserByNameSwaggerPetstore.API, SwaggerPetstore
getUserByNameSwaggerPetstore.API, SwaggerPetstore
HasBodyParamSwaggerPetstore.Core, SwaggerPetstore
HasOnlyReadOnly 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
hasOnlyReadOnlyBarSwaggerPetstore.Model, SwaggerPetstore
hasOnlyReadOnlyBarLSwaggerPetstore.ModelLens, SwaggerPetstore
hasOnlyReadOnlyFooSwaggerPetstore.Model, SwaggerPetstore
hasOnlyReadOnlyFooLSwaggerPetstore.ModelLens, SwaggerPetstore
HasOptionalParamSwaggerPetstore.Core, SwaggerPetstore
initLogContextSwaggerPetstore.Logging, SwaggerPetstore
InitRequest 
1 (Type/Class)SwaggerPetstore.Client, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Client, SwaggerPetstore
Int32 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Int64 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Lens_SwaggerPetstore.Core, SwaggerPetstore
Lens_'SwaggerPetstore.Core, SwaggerPetstore
levelDebugSwaggerPetstore.Logging, SwaggerPetstore
levelErrorSwaggerPetstore.Logging, SwaggerPetstore
levelInfoSwaggerPetstore.Logging, SwaggerPetstore
LogContextSwaggerPetstore.Logging, SwaggerPetstore
logExceptionsSwaggerPetstore.Logging, SwaggerPetstore
LogExecSwaggerPetstore.Logging, SwaggerPetstore
LogExecWithContextSwaggerPetstore.Logging, SwaggerPetstore
LoginUserSwaggerPetstore.API, SwaggerPetstore
loginUserSwaggerPetstore.API, SwaggerPetstore
LogLevelSwaggerPetstore.Logging, SwaggerPetstore
LogoutUserSwaggerPetstore.API, SwaggerPetstore
logoutUserSwaggerPetstore.API, SwaggerPetstore
MapTest 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
mapTestMapMapOfStringSwaggerPetstore.Model, SwaggerPetstore
mapTestMapMapOfStringLSwaggerPetstore.ModelLens, SwaggerPetstore
mapTestMapOfEnumStringSwaggerPetstore.Model, SwaggerPetstore
mapTestMapOfEnumStringLSwaggerPetstore.ModelLens, SwaggerPetstore
MimeAny 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeError 
1 (Type/Class)SwaggerPetstore.Client, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Client, SwaggerPetstore
mimeErrorSwaggerPetstore.Client, SwaggerPetstore
mimeErrorResponseSwaggerPetstore.Client, SwaggerPetstore
MimeFormUrlEncoded 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeJSON 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeJsonCharsetutf8 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
MimeMultipartFormData 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeNoContent 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeOctetStream 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimePlainText 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeRenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeRenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeRender'SwaggerPetstore.MimeTypes, SwaggerPetstore
mimeRenderDefaultMultipartFormDataSwaggerPetstore.MimeTypes, SwaggerPetstore
MimeResult 
1 (Type/Class)SwaggerPetstore.Client, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Client, SwaggerPetstore
mimeResultSwaggerPetstore.Client, SwaggerPetstore
mimeResultResponseSwaggerPetstore.Client, SwaggerPetstore
MimeTypeSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeTypeSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeType'SwaggerPetstore.MimeTypes, SwaggerPetstore
mimeTypesSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeTypes'SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeUnrenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeUnrenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeUnrender'SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeXML 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeXmlCharsetutf8 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
MixedPropertiesAndAdditionalPropertiesClass 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassDateTimeSwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassDateTimeLSwaggerPetstore.ModelLens, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassMapSwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassMapLSwaggerPetstore.ModelLens, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassUuidSwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassUuidLSwaggerPetstore.ModelLens, SwaggerPetstore
mkAdditionalPropertiesClassSwaggerPetstore.Model, SwaggerPetstore
mkAnimalSwaggerPetstore.Model, SwaggerPetstore
mkAnimalFarmSwaggerPetstore.Model, SwaggerPetstore
mkApiResponseSwaggerPetstore.Model, SwaggerPetstore
mkArrayOfArrayOfNumberOnlySwaggerPetstore.Model, SwaggerPetstore
mkArrayOfNumberOnlySwaggerPetstore.Model, SwaggerPetstore
mkArrayTestSwaggerPetstore.Model, SwaggerPetstore
mkCapitalizationSwaggerPetstore.Model, SwaggerPetstore
mkCatSwaggerPetstore.Model, SwaggerPetstore
mkCategorySwaggerPetstore.Model, SwaggerPetstore
mkClassModelSwaggerPetstore.Model, SwaggerPetstore
mkClientSwaggerPetstore.Model, SwaggerPetstore
mkDogSwaggerPetstore.Model, SwaggerPetstore
mkEnumArraysSwaggerPetstore.Model, SwaggerPetstore
mkEnumTestSwaggerPetstore.Model, SwaggerPetstore
mkFormatTestSwaggerPetstore.Model, SwaggerPetstore
mkHasOnlyReadOnlySwaggerPetstore.Model, SwaggerPetstore
mkMapTestSwaggerPetstore.Model, SwaggerPetstore
mkMixedPropertiesAndAdditionalPropertiesClassSwaggerPetstore.Model, SwaggerPetstore
mkModel200ResponseSwaggerPetstore.Model, SwaggerPetstore
mkModelListSwaggerPetstore.Model, SwaggerPetstore
mkModelReturnSwaggerPetstore.Model, SwaggerPetstore
mkNameSwaggerPetstore.Model, SwaggerPetstore
mkNumberOnlySwaggerPetstore.Model, SwaggerPetstore
mkOrderSwaggerPetstore.Model, SwaggerPetstore
mkOuterCompositeSwaggerPetstore.Model, SwaggerPetstore
mkPetSwaggerPetstore.Model, SwaggerPetstore
mkReadOnlyFirstSwaggerPetstore.Model, SwaggerPetstore
mkSpecialModelNameSwaggerPetstore.Model, SwaggerPetstore
mkTagSwaggerPetstore.Model, SwaggerPetstore
mkUserSwaggerPetstore.Model, SwaggerPetstore
Model200Response 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
model200ResponseClassSwaggerPetstore.Model, SwaggerPetstore
model200ResponseClassLSwaggerPetstore.ModelLens, SwaggerPetstore
model200ResponseNameSwaggerPetstore.Model, SwaggerPetstore
model200ResponseNameLSwaggerPetstore.ModelLens, SwaggerPetstore
ModelList 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
modelList123ListSwaggerPetstore.Model, SwaggerPetstore
modelList123ListLSwaggerPetstore.ModelLens, SwaggerPetstore
ModelReturn 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
modelReturnReturnSwaggerPetstore.Model, SwaggerPetstore
modelReturnReturnLSwaggerPetstore.ModelLens, SwaggerPetstore
modifyInitRequestSwaggerPetstore.Client, SwaggerPetstore
modifyInitRequestMSwaggerPetstore.Client, SwaggerPetstore
MultiParamArraySwaggerPetstore.Core, SwaggerPetstore
Name 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
name123NumberSwaggerPetstore.Model, SwaggerPetstore
name123NumberLSwaggerPetstore.ModelLens, SwaggerPetstore
Name2 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
nameNameSwaggerPetstore.Model, SwaggerPetstore
nameNameLSwaggerPetstore.ModelLens, SwaggerPetstore
namePropertySwaggerPetstore.Model, SwaggerPetstore
namePropertyLSwaggerPetstore.ModelLens, SwaggerPetstore
nameSnakeCaseSwaggerPetstore.Model, SwaggerPetstore
nameSnakeCaseLSwaggerPetstore.ModelLens, SwaggerPetstore
newConfigSwaggerPetstore.Core, SwaggerPetstore
NoContent 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
Number 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
NumberOnly 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
numberOnlyJustNumberSwaggerPetstore.Model, SwaggerPetstore
numberOnlyJustNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
Order 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
orderCompleteSwaggerPetstore.Model, SwaggerPetstore
orderCompleteLSwaggerPetstore.ModelLens, SwaggerPetstore
OrderId 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
orderIdSwaggerPetstore.Model, SwaggerPetstore
orderIdLSwaggerPetstore.ModelLens, SwaggerPetstore
OrderIdText 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
orderPetIdSwaggerPetstore.Model, SwaggerPetstore
orderPetIdLSwaggerPetstore.ModelLens, SwaggerPetstore
orderQuantitySwaggerPetstore.Model, SwaggerPetstore
orderQuantityLSwaggerPetstore.ModelLens, SwaggerPetstore
orderShipDateSwaggerPetstore.Model, SwaggerPetstore
orderShipDateLSwaggerPetstore.ModelLens, SwaggerPetstore
orderStatusSwaggerPetstore.Model, SwaggerPetstore
orderStatusLSwaggerPetstore.ModelLens, SwaggerPetstore
OuterBoolean 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
OuterComposite 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyBooleanSwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyBooleanLSwaggerPetstore.ModelLens, SwaggerPetstore
outerCompositeMyNumberSwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
outerCompositeMyStringSwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyStringLSwaggerPetstore.ModelLens, SwaggerPetstore
OuterEnumSwaggerPetstore.Model, SwaggerPetstore
OuterEnum'ApprovedSwaggerPetstore.Model, SwaggerPetstore
OuterEnum'DeliveredSwaggerPetstore.Model, SwaggerPetstore
OuterEnum'PlacedSwaggerPetstore.Model, SwaggerPetstore
OuterNumber 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
OuterString 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
Param 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Param2 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ParamBinary 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ParamBodySwaggerPetstore.Core, SwaggerPetstore
ParamBodyBSwaggerPetstore.Core, SwaggerPetstore
ParamBodyBLSwaggerPetstore.Core, SwaggerPetstore
ParamBodyFormUrlEncodedSwaggerPetstore.Core, SwaggerPetstore
ParamBodyMultipartFormDataSwaggerPetstore.Core, SwaggerPetstore
ParamBodyNoneSwaggerPetstore.Core, SwaggerPetstore
ParamDate 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ParamDateTime 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ParamDouble 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ParamFloat 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
ParamInteger 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Params 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
paramsBodySwaggerPetstore.Core, SwaggerPetstore
paramsBodyLSwaggerPetstore.Core, SwaggerPetstore
paramsHeadersSwaggerPetstore.Core, SwaggerPetstore
paramsHeadersLSwaggerPetstore.Core, SwaggerPetstore
paramsQuerySwaggerPetstore.Core, SwaggerPetstore
paramsQueryLSwaggerPetstore.Core, SwaggerPetstore
ParamString 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Password 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
PatternWithoutDelimiter 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
Pet 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
petCategorySwaggerPetstore.Model, SwaggerPetstore
petCategoryLSwaggerPetstore.ModelLens, SwaggerPetstore
PetId 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
petIdSwaggerPetstore.Model, SwaggerPetstore
petIdLSwaggerPetstore.ModelLens, SwaggerPetstore
petNameSwaggerPetstore.Model, SwaggerPetstore
petNameLSwaggerPetstore.ModelLens, SwaggerPetstore
petPhotoUrlsSwaggerPetstore.Model, SwaggerPetstore
petPhotoUrlsLSwaggerPetstore.ModelLens, SwaggerPetstore
petStatusSwaggerPetstore.Model, SwaggerPetstore
petStatusLSwaggerPetstore.ModelLens, SwaggerPetstore
petTagsSwaggerPetstore.Model, SwaggerPetstore
petTagsLSwaggerPetstore.ModelLens, SwaggerPetstore
PipeSeparatedSwaggerPetstore.Core, SwaggerPetstore
PlaceOrderSwaggerPetstore.API, SwaggerPetstore
placeOrderSwaggerPetstore.API, SwaggerPetstore
ProducesSwaggerPetstore.MimeTypes, SwaggerPetstore
rAuthTypesSwaggerPetstore.Core, SwaggerPetstore
rAuthTypesLSwaggerPetstore.Core, SwaggerPetstore
ReadOnlyFirst 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
readOnlyFirstBarSwaggerPetstore.Model, SwaggerPetstore
readOnlyFirstBarLSwaggerPetstore.ModelLens, SwaggerPetstore
readOnlyFirstBazSwaggerPetstore.Model, SwaggerPetstore
readOnlyFirstBazLSwaggerPetstore.ModelLens, SwaggerPetstore
removeHeaderSwaggerPetstore.Core, SwaggerPetstore
rMethodSwaggerPetstore.Core, SwaggerPetstore
rMethodLSwaggerPetstore.Core, SwaggerPetstore
rParamsSwaggerPetstore.Core, SwaggerPetstore
rParamsLSwaggerPetstore.Core, SwaggerPetstore
runConfigLogSwaggerPetstore.Client, SwaggerPetstore
runConfigLogWithExceptionsSwaggerPetstore.Client, SwaggerPetstore
runDefaultLogExecWithContextSwaggerPetstore.Logging, SwaggerPetstore
runNullLogExecSwaggerPetstore.Logging, SwaggerPetstore
rUrlPathSwaggerPetstore.Core, SwaggerPetstore
rUrlPathLSwaggerPetstore.Core, SwaggerPetstore
setBodyParamSwaggerPetstore.Core, SwaggerPetstore
setHeaderSwaggerPetstore.Core, SwaggerPetstore
setQuerySwaggerPetstore.Core, SwaggerPetstore
SpaceSeparatedSwaggerPetstore.Core, SwaggerPetstore
SpecialModelName 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
specialModelNameSpecialPropertyNameSwaggerPetstore.Model, SwaggerPetstore
specialModelNameSpecialPropertyNameLSwaggerPetstore.ModelLens, SwaggerPetstore
Status 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
StatusText 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
stderrLoggingContextSwaggerPetstore.Logging, SwaggerPetstore
stderrLoggingExecSwaggerPetstore.Logging, SwaggerPetstore
stdoutLoggingContextSwaggerPetstore.Logging, SwaggerPetstore
stdoutLoggingExecSwaggerPetstore.Logging, SwaggerPetstore
SwaggerPetstoreConfig 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
SwaggerPetstoreRequest 
1 (Type/Class)SwaggerPetstore.Core, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Core, SwaggerPetstore
TabSeparatedSwaggerPetstore.Core, SwaggerPetstore
Tag 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
tagIdSwaggerPetstore.Model, SwaggerPetstore
tagIdLSwaggerPetstore.ModelLens, SwaggerPetstore
tagNameSwaggerPetstore.Model, SwaggerPetstore
tagNameLSwaggerPetstore.ModelLens, SwaggerPetstore
Tags 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
TestClassnameSwaggerPetstore.API, SwaggerPetstore
testClassnameSwaggerPetstore.API, SwaggerPetstore
TestClientModelSwaggerPetstore.API, SwaggerPetstore
testClientModelSwaggerPetstore.API, SwaggerPetstore
TestEndpointParametersSwaggerPetstore.API, SwaggerPetstore
testEndpointParametersSwaggerPetstore.API, SwaggerPetstore
TestEnumParametersSwaggerPetstore.API, SwaggerPetstore
testEnumParametersSwaggerPetstore.API, SwaggerPetstore
TestInlineAdditionalPropertiesSwaggerPetstore.API, SwaggerPetstore
testInlineAdditionalPropertiesSwaggerPetstore.API, SwaggerPetstore
TestJsonFormDataSwaggerPetstore.API, SwaggerPetstore
testJsonFormDataSwaggerPetstore.API, SwaggerPetstore
TestSpecialTagsSwaggerPetstore.API, SwaggerPetstore
testSpecialTagsSwaggerPetstore.API, SwaggerPetstore
toE'ArrayEnumSwaggerPetstore.Model, SwaggerPetstore
toE'EnumFormStringSwaggerPetstore.Model, SwaggerPetstore
toE'EnumIntegerSwaggerPetstore.Model, SwaggerPetstore
toE'EnumNumberSwaggerPetstore.Model, SwaggerPetstore
toE'EnumQueryIntegerSwaggerPetstore.Model, SwaggerPetstore
toE'EnumStringSwaggerPetstore.Model, SwaggerPetstore
toE'InnerSwaggerPetstore.Model, SwaggerPetstore
toE'Inner2SwaggerPetstore.Model, SwaggerPetstore
toE'JustSymbolSwaggerPetstore.Model, SwaggerPetstore
toE'StatusSwaggerPetstore.Model, SwaggerPetstore
toE'Status2SwaggerPetstore.Model, SwaggerPetstore
toEnumClassSwaggerPetstore.Model, SwaggerPetstore
toFormSwaggerPetstore.Core, SwaggerPetstore
toFormCollSwaggerPetstore.Core, SwaggerPetstore
toHeaderSwaggerPetstore.Core, SwaggerPetstore
toHeaderCollSwaggerPetstore.Core, SwaggerPetstore
toOuterEnumSwaggerPetstore.Model, SwaggerPetstore
toPathSwaggerPetstore.Core, SwaggerPetstore
toQuerySwaggerPetstore.Core, SwaggerPetstore
toQueryCollSwaggerPetstore.Core, SwaggerPetstore
unAdditionalMetadataSwaggerPetstore.API, SwaggerPetstore
unApiKeySwaggerPetstore.API, SwaggerPetstore
unBinarySwaggerPetstore.Core, SwaggerPetstore
unBodySwaggerPetstore.API, SwaggerPetstore
unByteSwaggerPetstore.API, SwaggerPetstore
unByteArraySwaggerPetstore.Core, SwaggerPetstore
unCallbackSwaggerPetstore.API, SwaggerPetstore
unDateSwaggerPetstore.Core, SwaggerPetstore
unDateTimeSwaggerPetstore.Core, SwaggerPetstore
unEnumFormStringSwaggerPetstore.API, SwaggerPetstore
unEnumFormStringArraySwaggerPetstore.API, SwaggerPetstore
unEnumHeaderStringSwaggerPetstore.API, SwaggerPetstore
unEnumHeaderStringArraySwaggerPetstore.API, SwaggerPetstore
unEnumQueryDoubleSwaggerPetstore.API, SwaggerPetstore
unEnumQueryIntegerSwaggerPetstore.API, SwaggerPetstore
unEnumQueryStringSwaggerPetstore.API, SwaggerPetstore
unEnumQueryStringArraySwaggerPetstore.API, SwaggerPetstore
unFileSwaggerPetstore.API, SwaggerPetstore
unInitRequestSwaggerPetstore.Client, SwaggerPetstore
unInt32SwaggerPetstore.API, SwaggerPetstore
unInt64SwaggerPetstore.API, SwaggerPetstore
unName2SwaggerPetstore.API, SwaggerPetstore
unNumberSwaggerPetstore.API, SwaggerPetstore
unOrderIdSwaggerPetstore.API, SwaggerPetstore
unOrderIdTextSwaggerPetstore.API, SwaggerPetstore
unOuterBooleanSwaggerPetstore.Model, SwaggerPetstore
unOuterNumberSwaggerPetstore.Model, SwaggerPetstore
unOuterStringSwaggerPetstore.Model, SwaggerPetstore
unParamSwaggerPetstore.API, SwaggerPetstore
unParam2SwaggerPetstore.API, SwaggerPetstore
unParamBinarySwaggerPetstore.API, SwaggerPetstore
unParamDateSwaggerPetstore.API, SwaggerPetstore
unParamDateTimeSwaggerPetstore.API, SwaggerPetstore
unParamDoubleSwaggerPetstore.API, SwaggerPetstore
unParamFloatSwaggerPetstore.API, SwaggerPetstore
unParamIntegerSwaggerPetstore.API, SwaggerPetstore
unParamStringSwaggerPetstore.API, SwaggerPetstore
unPasswordSwaggerPetstore.API, SwaggerPetstore
unPatternWithoutDelimiterSwaggerPetstore.API, SwaggerPetstore
unPetIdSwaggerPetstore.API, SwaggerPetstore
unStatusSwaggerPetstore.API, SwaggerPetstore
unStatusTextSwaggerPetstore.API, SwaggerPetstore
unTagsSwaggerPetstore.API, SwaggerPetstore
unUsernameSwaggerPetstore.API, SwaggerPetstore
UpdatePetSwaggerPetstore.API, SwaggerPetstore
updatePetSwaggerPetstore.API, SwaggerPetstore
UpdatePetWithFormSwaggerPetstore.API, SwaggerPetstore
updatePetWithFormSwaggerPetstore.API, SwaggerPetstore
UpdateUserSwaggerPetstore.API, SwaggerPetstore
updateUserSwaggerPetstore.API, SwaggerPetstore
UploadFileSwaggerPetstore.API, SwaggerPetstore
uploadFileSwaggerPetstore.API, SwaggerPetstore
User 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
userEmailSwaggerPetstore.Model, SwaggerPetstore
userEmailLSwaggerPetstore.ModelLens, SwaggerPetstore
userFirstNameSwaggerPetstore.Model, SwaggerPetstore
userFirstNameLSwaggerPetstore.ModelLens, SwaggerPetstore
userIdSwaggerPetstore.Model, SwaggerPetstore
userIdLSwaggerPetstore.ModelLens, SwaggerPetstore
userLastNameSwaggerPetstore.Model, SwaggerPetstore
userLastNameLSwaggerPetstore.ModelLens, SwaggerPetstore
Username 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
userPasswordSwaggerPetstore.Model, SwaggerPetstore
userPasswordLSwaggerPetstore.ModelLens, SwaggerPetstore
userPhoneSwaggerPetstore.Model, SwaggerPetstore
userPhoneLSwaggerPetstore.ModelLens, SwaggerPetstore
userUsernameSwaggerPetstore.Model, SwaggerPetstore
userUsernameLSwaggerPetstore.ModelLens, SwaggerPetstore
userUserStatusSwaggerPetstore.Model, SwaggerPetstore
userUserStatusLSwaggerPetstore.ModelLens, SwaggerPetstore
withNoLoggingSwaggerPetstore.Core, SwaggerPetstore
withStderrLoggingSwaggerPetstore.Core, SwaggerPetstore
withStdoutLoggingSwaggerPetstore.Core, SwaggerPetstore
_addMultiFormPartSwaggerPetstore.Core, SwaggerPetstore
_applyAuthMethodsSwaggerPetstore.Core, SwaggerPetstore
_emptyToNothingSwaggerPetstore.Core, SwaggerPetstore
_hasAuthTypeSwaggerPetstore.Core, SwaggerPetstore
_logSwaggerPetstore.Logging, SwaggerPetstore
_memptyToNothingSwaggerPetstore.Core, SwaggerPetstore
_mkParamsSwaggerPetstore.Core, SwaggerPetstore
_mkRequestSwaggerPetstore.Core, SwaggerPetstore
_omitNullsSwaggerPetstore.Core, SwaggerPetstore
_parseISO8601SwaggerPetstore.Core, SwaggerPetstore
_readBinaryBase64SwaggerPetstore.Core, SwaggerPetstore
_readByteArraySwaggerPetstore.Core, SwaggerPetstore
_readDateSwaggerPetstore.Core, SwaggerPetstore
_readDateTimeSwaggerPetstore.Core, SwaggerPetstore
_setAcceptHeaderSwaggerPetstore.Core, SwaggerPetstore
_setBodyBSSwaggerPetstore.Core, SwaggerPetstore
_setBodyLBSSwaggerPetstore.Core, SwaggerPetstore
_setContentTypeHeaderSwaggerPetstore.Core, SwaggerPetstore
_showBinaryBase64SwaggerPetstore.Core, SwaggerPetstore
_showByteArraySwaggerPetstore.Core, SwaggerPetstore
_showDateSwaggerPetstore.Core, SwaggerPetstore
_showDateTimeSwaggerPetstore.Core, SwaggerPetstore
_toCollSwaggerPetstore.Core, SwaggerPetstore
_toCollASwaggerPetstore.Core, SwaggerPetstore
_toCollA'SwaggerPetstore.Core, SwaggerPetstore
_toFormItemSwaggerPetstore.Core, SwaggerPetstore
_toInitRequestSwaggerPetstore.Client, SwaggerPetstore
\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/doc-index-E.html b/samples/client/petstore/haskell-http-client/docs/doc-index-E.html index 1fe9136d8ee..a02d55d519f 100644 --- a/samples/client/petstore/haskell-http-client/docs/doc-index-E.html +++ b/samples/client/petstore/haskell-http-client/docs/doc-index-E.html @@ -1,4 +1,4 @@ swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client (Index - E)

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Index - E

EnumArrays 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
enumArraysArrayEnumSwaggerPetstore.Model, SwaggerPetstore
enumArraysArrayEnumLSwaggerPetstore.ModelLens, SwaggerPetstore
enumArraysJustSymbolSwaggerPetstore.Model, SwaggerPetstore
enumArraysJustSymbolLSwaggerPetstore.ModelLens, SwaggerPetstore
EnumClass 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
EnumFormString 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumFormStringArray 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumHeaderString 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumHeaderStringArray 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryDouble 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryInteger 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryString 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryStringArray 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumTest 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
enumTestEnumIntegerSwaggerPetstore.Model, SwaggerPetstore
enumTestEnumIntegerLSwaggerPetstore.ModelLens, SwaggerPetstore
enumTestEnumNumberSwaggerPetstore.Model, SwaggerPetstore
enumTestEnumNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
enumTestEnumStringSwaggerPetstore.Model, SwaggerPetstore
enumTestEnumStringLSwaggerPetstore.ModelLens, SwaggerPetstore
enumTestOuterEnumSwaggerPetstore.Model, SwaggerPetstore
enumTestOuterEnumLSwaggerPetstore.ModelLens, SwaggerPetstore
\ No newline at end of file +

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Index - E

E'ArrayEnumSwaggerPetstore.Model, SwaggerPetstore
E'ArrayEnum'CrabSwaggerPetstore.Model, SwaggerPetstore
E'ArrayEnum'FishSwaggerPetstore.Model, SwaggerPetstore
E'EnumFormStringSwaggerPetstore.Model, SwaggerPetstore
E'EnumFormString'_abcSwaggerPetstore.Model, SwaggerPetstore
E'EnumFormString'_efgSwaggerPetstore.Model, SwaggerPetstore
E'EnumFormString'_xyzSwaggerPetstore.Model, SwaggerPetstore
E'EnumIntegerSwaggerPetstore.Model, SwaggerPetstore
E'EnumInteger'Num1SwaggerPetstore.Model, SwaggerPetstore
E'EnumInteger'NumMinus_1SwaggerPetstore.Model, SwaggerPetstore
E'EnumNumberSwaggerPetstore.Model, SwaggerPetstore
E'EnumNumber'Num1_Dot_1SwaggerPetstore.Model, SwaggerPetstore
E'EnumNumber'NumMinus_1_Dot_2SwaggerPetstore.Model, SwaggerPetstore
E'EnumQueryIntegerSwaggerPetstore.Model, SwaggerPetstore
E'EnumQueryInteger'Num1SwaggerPetstore.Model, SwaggerPetstore
E'EnumQueryInteger'NumMinus_2SwaggerPetstore.Model, SwaggerPetstore
E'EnumStringSwaggerPetstore.Model, SwaggerPetstore
E'EnumString'EmptySwaggerPetstore.Model, SwaggerPetstore
E'EnumString'LowerSwaggerPetstore.Model, SwaggerPetstore
E'EnumString'UPPERSwaggerPetstore.Model, SwaggerPetstore
E'InnerSwaggerPetstore.Model, SwaggerPetstore
E'Inner'LowerSwaggerPetstore.Model, SwaggerPetstore
E'Inner'UPPERSwaggerPetstore.Model, SwaggerPetstore
E'Inner2SwaggerPetstore.Model, SwaggerPetstore
E'Inner2'DollarSwaggerPetstore.Model, SwaggerPetstore
E'Inner2'GreaterThanSwaggerPetstore.Model, SwaggerPetstore
E'JustSymbolSwaggerPetstore.Model, SwaggerPetstore
E'JustSymbol'DollarSwaggerPetstore.Model, SwaggerPetstore
E'JustSymbol'Greater_Than_Or_Equal_ToSwaggerPetstore.Model, SwaggerPetstore
E'StatusSwaggerPetstore.Model, SwaggerPetstore
E'Status'ApprovedSwaggerPetstore.Model, SwaggerPetstore
E'Status'DeliveredSwaggerPetstore.Model, SwaggerPetstore
E'Status'PlacedSwaggerPetstore.Model, SwaggerPetstore
E'Status2SwaggerPetstore.Model, SwaggerPetstore
E'Status2'AvailableSwaggerPetstore.Model, SwaggerPetstore
E'Status2'PendingSwaggerPetstore.Model, SwaggerPetstore
E'Status2'SoldSwaggerPetstore.Model, SwaggerPetstore
EnumArrays 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
enumArraysArrayEnumSwaggerPetstore.Model, SwaggerPetstore
enumArraysArrayEnumLSwaggerPetstore.ModelLens, SwaggerPetstore
enumArraysJustSymbolSwaggerPetstore.Model, SwaggerPetstore
enumArraysJustSymbolLSwaggerPetstore.ModelLens, SwaggerPetstore
EnumClassSwaggerPetstore.Model, SwaggerPetstore
EnumClass'_abcSwaggerPetstore.Model, SwaggerPetstore
EnumClass'_efgSwaggerPetstore.Model, SwaggerPetstore
EnumClass'_xyzSwaggerPetstore.Model, SwaggerPetstore
EnumFormString 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumFormStringArray 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumHeaderString 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumHeaderStringArray 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryDouble 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryInteger 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryString 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumQueryStringArray 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
EnumTest 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
enumTestEnumIntegerSwaggerPetstore.Model, SwaggerPetstore
enumTestEnumIntegerLSwaggerPetstore.ModelLens, SwaggerPetstore
enumTestEnumNumberSwaggerPetstore.Model, SwaggerPetstore
enumTestEnumNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
enumTestEnumStringSwaggerPetstore.Model, SwaggerPetstore
enumTestEnumStringLSwaggerPetstore.ModelLens, SwaggerPetstore
enumTestOuterEnumSwaggerPetstore.Model, SwaggerPetstore
enumTestOuterEnumLSwaggerPetstore.ModelLens, SwaggerPetstore
\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/doc-index-F.html b/samples/client/petstore/haskell-http-client/docs/doc-index-F.html index 43bb244eb57..e32e228d7f2 100644 --- a/samples/client/petstore/haskell-http-client/docs/doc-index-F.html +++ b/samples/client/petstore/haskell-http-client/docs/doc-index-F.html @@ -1,4 +1,4 @@ swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client (Index - F)

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Index - F

FakeOuterBooleanSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterBooleanSerializeSwaggerPetstore.API, SwaggerPetstore
FakeOuterCompositeSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterCompositeSerializeSwaggerPetstore.API, SwaggerPetstore
FakeOuterNumberSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterNumberSerializeSwaggerPetstore.API, SwaggerPetstore
FakeOuterStringSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterStringSerializeSwaggerPetstore.API, SwaggerPetstore
File 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
FindPetsByStatusSwaggerPetstore.API, SwaggerPetstore
findPetsByStatusSwaggerPetstore.API, SwaggerPetstore
FindPetsByTagsSwaggerPetstore.API, SwaggerPetstore
findPetsByTagsSwaggerPetstore.API, SwaggerPetstore
FormatTest 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
formatTestBinarySwaggerPetstore.Model, SwaggerPetstore
formatTestBinaryLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestByteSwaggerPetstore.Model, SwaggerPetstore
formatTestByteLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestDateSwaggerPetstore.Model, SwaggerPetstore
formatTestDateLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestDateTimeSwaggerPetstore.Model, SwaggerPetstore
formatTestDateTimeLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestDoubleSwaggerPetstore.Model, SwaggerPetstore
formatTestDoubleLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestFloatSwaggerPetstore.Model, SwaggerPetstore
formatTestFloatLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestInt32SwaggerPetstore.Model, SwaggerPetstore
formatTestInt32LSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestInt64SwaggerPetstore.Model, SwaggerPetstore
formatTestInt64LSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestIntegerSwaggerPetstore.Model, SwaggerPetstore
formatTestIntegerLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestNumberSwaggerPetstore.Model, SwaggerPetstore
formatTestNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestPasswordSwaggerPetstore.Model, SwaggerPetstore
formatTestPasswordLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestStringSwaggerPetstore.Model, SwaggerPetstore
formatTestStringLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestUuidSwaggerPetstore.Model, SwaggerPetstore
formatTestUuidLSwaggerPetstore.ModelLens, SwaggerPetstore
\ No newline at end of file +

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Index - F

FakeOuterBooleanSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterBooleanSerializeSwaggerPetstore.API, SwaggerPetstore
FakeOuterCompositeSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterCompositeSerializeSwaggerPetstore.API, SwaggerPetstore
FakeOuterNumberSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterNumberSerializeSwaggerPetstore.API, SwaggerPetstore
FakeOuterStringSerializeSwaggerPetstore.API, SwaggerPetstore
fakeOuterStringSerializeSwaggerPetstore.API, SwaggerPetstore
File 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
FindPetsByStatusSwaggerPetstore.API, SwaggerPetstore
findPetsByStatusSwaggerPetstore.API, SwaggerPetstore
FindPetsByTagsSwaggerPetstore.API, SwaggerPetstore
findPetsByTagsSwaggerPetstore.API, SwaggerPetstore
FormatTest 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
formatTestBinarySwaggerPetstore.Model, SwaggerPetstore
formatTestBinaryLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestByteSwaggerPetstore.Model, SwaggerPetstore
formatTestByteLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestDateSwaggerPetstore.Model, SwaggerPetstore
formatTestDateLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestDateTimeSwaggerPetstore.Model, SwaggerPetstore
formatTestDateTimeLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestDoubleSwaggerPetstore.Model, SwaggerPetstore
formatTestDoubleLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestFloatSwaggerPetstore.Model, SwaggerPetstore
formatTestFloatLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestInt32SwaggerPetstore.Model, SwaggerPetstore
formatTestInt32LSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestInt64SwaggerPetstore.Model, SwaggerPetstore
formatTestInt64LSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestIntegerSwaggerPetstore.Model, SwaggerPetstore
formatTestIntegerLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestNumberSwaggerPetstore.Model, SwaggerPetstore
formatTestNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestPasswordSwaggerPetstore.Model, SwaggerPetstore
formatTestPasswordLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestStringSwaggerPetstore.Model, SwaggerPetstore
formatTestStringLSwaggerPetstore.ModelLens, SwaggerPetstore
formatTestUuidSwaggerPetstore.Model, SwaggerPetstore
formatTestUuidLSwaggerPetstore.ModelLens, SwaggerPetstore
fromE'ArrayEnumSwaggerPetstore.Model, SwaggerPetstore
fromE'EnumFormStringSwaggerPetstore.Model, SwaggerPetstore
fromE'EnumIntegerSwaggerPetstore.Model, SwaggerPetstore
fromE'EnumNumberSwaggerPetstore.Model, SwaggerPetstore
fromE'EnumQueryIntegerSwaggerPetstore.Model, SwaggerPetstore
fromE'EnumStringSwaggerPetstore.Model, SwaggerPetstore
fromE'InnerSwaggerPetstore.Model, SwaggerPetstore
fromE'Inner2SwaggerPetstore.Model, SwaggerPetstore
fromE'JustSymbolSwaggerPetstore.Model, SwaggerPetstore
fromE'StatusSwaggerPetstore.Model, SwaggerPetstore
fromE'Status2SwaggerPetstore.Model, SwaggerPetstore
fromEnumClassSwaggerPetstore.Model, SwaggerPetstore
fromOuterEnumSwaggerPetstore.Model, SwaggerPetstore
\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/doc-index-M.html b/samples/client/petstore/haskell-http-client/docs/doc-index-M.html index 8286f28c991..c7c2031d61e 100644 --- a/samples/client/petstore/haskell-http-client/docs/doc-index-M.html +++ b/samples/client/petstore/haskell-http-client/docs/doc-index-M.html @@ -1,4 +1,4 @@ swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client (Index - M)

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Index - M

MapTest 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
mapTestMapMapOfStringSwaggerPetstore.Model, SwaggerPetstore
mapTestMapMapOfStringLSwaggerPetstore.ModelLens, SwaggerPetstore
mapTestMapOfEnumStringSwaggerPetstore.Model, SwaggerPetstore
mapTestMapOfEnumStringLSwaggerPetstore.ModelLens, SwaggerPetstore
MimeAny 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeError 
1 (Type/Class)SwaggerPetstore.Client, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Client, SwaggerPetstore
mimeErrorSwaggerPetstore.Client, SwaggerPetstore
mimeErrorResponseSwaggerPetstore.Client, SwaggerPetstore
MimeFormUrlEncoded 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeJSON 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeJsonCharsetutf8 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
MimeMultipartFormData 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeNoContent 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeOctetStream 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimePlainText 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeRenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeRenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeRender'SwaggerPetstore.MimeTypes, SwaggerPetstore
mimeRenderDefaultMultipartFormDataSwaggerPetstore.MimeTypes, SwaggerPetstore
MimeResult 
1 (Type/Class)SwaggerPetstore.Client, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Client, SwaggerPetstore
mimeResultSwaggerPetstore.Client, SwaggerPetstore
mimeResultResponseSwaggerPetstore.Client, SwaggerPetstore
MimeTypeSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeTypeSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeType'SwaggerPetstore.MimeTypes, SwaggerPetstore
mimeTypesSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeTypes'SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeUnrenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeUnrenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeUnrender'SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeXML 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeXmlCharsetutf8 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
MixedPropertiesAndAdditionalPropertiesClass 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassDateTimeSwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassDateTimeLSwaggerPetstore.ModelLens, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassMapSwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassMapLSwaggerPetstore.ModelLens, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassUuidSwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassUuidLSwaggerPetstore.ModelLens, SwaggerPetstore
mkAdditionalPropertiesClassSwaggerPetstore.Model, SwaggerPetstore
mkAnimalSwaggerPetstore.Model, SwaggerPetstore
mkAnimalFarmSwaggerPetstore.Model, SwaggerPetstore
mkApiResponseSwaggerPetstore.Model, SwaggerPetstore
mkArrayOfArrayOfNumberOnlySwaggerPetstore.Model, SwaggerPetstore
mkArrayOfNumberOnlySwaggerPetstore.Model, SwaggerPetstore
mkArrayTestSwaggerPetstore.Model, SwaggerPetstore
mkCapitalizationSwaggerPetstore.Model, SwaggerPetstore
mkCatSwaggerPetstore.Model, SwaggerPetstore
mkCategorySwaggerPetstore.Model, SwaggerPetstore
mkClassModelSwaggerPetstore.Model, SwaggerPetstore
mkClientSwaggerPetstore.Model, SwaggerPetstore
mkDogSwaggerPetstore.Model, SwaggerPetstore
mkEnumArraysSwaggerPetstore.Model, SwaggerPetstore
mkEnumClassSwaggerPetstore.Model, SwaggerPetstore
mkEnumTestSwaggerPetstore.Model, SwaggerPetstore
mkFormatTestSwaggerPetstore.Model, SwaggerPetstore
mkHasOnlyReadOnlySwaggerPetstore.Model, SwaggerPetstore
mkMapTestSwaggerPetstore.Model, SwaggerPetstore
mkMixedPropertiesAndAdditionalPropertiesClassSwaggerPetstore.Model, SwaggerPetstore
mkModel200ResponseSwaggerPetstore.Model, SwaggerPetstore
mkModelListSwaggerPetstore.Model, SwaggerPetstore
mkModelReturnSwaggerPetstore.Model, SwaggerPetstore
mkNameSwaggerPetstore.Model, SwaggerPetstore
mkNumberOnlySwaggerPetstore.Model, SwaggerPetstore
mkOrderSwaggerPetstore.Model, SwaggerPetstore
mkOuterCompositeSwaggerPetstore.Model, SwaggerPetstore
mkOuterEnumSwaggerPetstore.Model, SwaggerPetstore
mkPetSwaggerPetstore.Model, SwaggerPetstore
mkReadOnlyFirstSwaggerPetstore.Model, SwaggerPetstore
mkSpecialModelNameSwaggerPetstore.Model, SwaggerPetstore
mkTagSwaggerPetstore.Model, SwaggerPetstore
mkUserSwaggerPetstore.Model, SwaggerPetstore
Model200Response 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
model200ResponseClassSwaggerPetstore.Model, SwaggerPetstore
model200ResponseClassLSwaggerPetstore.ModelLens, SwaggerPetstore
model200ResponseNameSwaggerPetstore.Model, SwaggerPetstore
model200ResponseNameLSwaggerPetstore.ModelLens, SwaggerPetstore
ModelList 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
modelList123ListSwaggerPetstore.Model, SwaggerPetstore
modelList123ListLSwaggerPetstore.ModelLens, SwaggerPetstore
ModelReturn 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
modelReturnReturnSwaggerPetstore.Model, SwaggerPetstore
modelReturnReturnLSwaggerPetstore.ModelLens, SwaggerPetstore
modifyInitRequestSwaggerPetstore.Client, SwaggerPetstore
modifyInitRequestMSwaggerPetstore.Client, SwaggerPetstore
MultiParamArraySwaggerPetstore.Core, SwaggerPetstore
\ No newline at end of file +

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Index - M

MapTest 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
mapTestMapMapOfStringSwaggerPetstore.Model, SwaggerPetstore
mapTestMapMapOfStringLSwaggerPetstore.ModelLens, SwaggerPetstore
mapTestMapOfEnumStringSwaggerPetstore.Model, SwaggerPetstore
mapTestMapOfEnumStringLSwaggerPetstore.ModelLens, SwaggerPetstore
MimeAny 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeError 
1 (Type/Class)SwaggerPetstore.Client, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Client, SwaggerPetstore
mimeErrorSwaggerPetstore.Client, SwaggerPetstore
mimeErrorResponseSwaggerPetstore.Client, SwaggerPetstore
MimeFormUrlEncoded 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeJSON 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeJsonCharsetutf8 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
MimeMultipartFormData 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeNoContent 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeOctetStream 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimePlainText 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeRenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeRenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeRender'SwaggerPetstore.MimeTypes, SwaggerPetstore
mimeRenderDefaultMultipartFormDataSwaggerPetstore.MimeTypes, SwaggerPetstore
MimeResult 
1 (Type/Class)SwaggerPetstore.Client, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Client, SwaggerPetstore
mimeResultSwaggerPetstore.Client, SwaggerPetstore
mimeResultResponseSwaggerPetstore.Client, SwaggerPetstore
MimeTypeSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeTypeSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeType'SwaggerPetstore.MimeTypes, SwaggerPetstore
mimeTypesSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeTypes'SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeUnrenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeUnrenderSwaggerPetstore.MimeTypes, SwaggerPetstore
mimeUnrender'SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeXML 
1 (Type/Class)SwaggerPetstore.MimeTypes, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.MimeTypes, SwaggerPetstore
MimeXmlCharsetutf8 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
MixedPropertiesAndAdditionalPropertiesClass 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassDateTimeSwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassDateTimeLSwaggerPetstore.ModelLens, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassMapSwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassMapLSwaggerPetstore.ModelLens, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassUuidSwaggerPetstore.Model, SwaggerPetstore
mixedPropertiesAndAdditionalPropertiesClassUuidLSwaggerPetstore.ModelLens, SwaggerPetstore
mkAdditionalPropertiesClassSwaggerPetstore.Model, SwaggerPetstore
mkAnimalSwaggerPetstore.Model, SwaggerPetstore
mkAnimalFarmSwaggerPetstore.Model, SwaggerPetstore
mkApiResponseSwaggerPetstore.Model, SwaggerPetstore
mkArrayOfArrayOfNumberOnlySwaggerPetstore.Model, SwaggerPetstore
mkArrayOfNumberOnlySwaggerPetstore.Model, SwaggerPetstore
mkArrayTestSwaggerPetstore.Model, SwaggerPetstore
mkCapitalizationSwaggerPetstore.Model, SwaggerPetstore
mkCatSwaggerPetstore.Model, SwaggerPetstore
mkCategorySwaggerPetstore.Model, SwaggerPetstore
mkClassModelSwaggerPetstore.Model, SwaggerPetstore
mkClientSwaggerPetstore.Model, SwaggerPetstore
mkDogSwaggerPetstore.Model, SwaggerPetstore
mkEnumArraysSwaggerPetstore.Model, SwaggerPetstore
mkEnumTestSwaggerPetstore.Model, SwaggerPetstore
mkFormatTestSwaggerPetstore.Model, SwaggerPetstore
mkHasOnlyReadOnlySwaggerPetstore.Model, SwaggerPetstore
mkMapTestSwaggerPetstore.Model, SwaggerPetstore
mkMixedPropertiesAndAdditionalPropertiesClassSwaggerPetstore.Model, SwaggerPetstore
mkModel200ResponseSwaggerPetstore.Model, SwaggerPetstore
mkModelListSwaggerPetstore.Model, SwaggerPetstore
mkModelReturnSwaggerPetstore.Model, SwaggerPetstore
mkNameSwaggerPetstore.Model, SwaggerPetstore
mkNumberOnlySwaggerPetstore.Model, SwaggerPetstore
mkOrderSwaggerPetstore.Model, SwaggerPetstore
mkOuterCompositeSwaggerPetstore.Model, SwaggerPetstore
mkPetSwaggerPetstore.Model, SwaggerPetstore
mkReadOnlyFirstSwaggerPetstore.Model, SwaggerPetstore
mkSpecialModelNameSwaggerPetstore.Model, SwaggerPetstore
mkTagSwaggerPetstore.Model, SwaggerPetstore
mkUserSwaggerPetstore.Model, SwaggerPetstore
Model200Response 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
model200ResponseClassSwaggerPetstore.Model, SwaggerPetstore
model200ResponseClassLSwaggerPetstore.ModelLens, SwaggerPetstore
model200ResponseNameSwaggerPetstore.Model, SwaggerPetstore
model200ResponseNameLSwaggerPetstore.ModelLens, SwaggerPetstore
ModelList 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
modelList123ListSwaggerPetstore.Model, SwaggerPetstore
modelList123ListLSwaggerPetstore.ModelLens, SwaggerPetstore
ModelReturn 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
modelReturnReturnSwaggerPetstore.Model, SwaggerPetstore
modelReturnReturnLSwaggerPetstore.ModelLens, SwaggerPetstore
modifyInitRequestSwaggerPetstore.Client, SwaggerPetstore
modifyInitRequestMSwaggerPetstore.Client, SwaggerPetstore
MultiParamArraySwaggerPetstore.Core, SwaggerPetstore
\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/doc-index-O.html b/samples/client/petstore/haskell-http-client/docs/doc-index-O.html index ad118f965bc..08faaae547c 100644 --- a/samples/client/petstore/haskell-http-client/docs/doc-index-O.html +++ b/samples/client/petstore/haskell-http-client/docs/doc-index-O.html @@ -1,4 +1,4 @@ swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client (Index - O)

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Index - O

Order 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
orderCompleteSwaggerPetstore.Model, SwaggerPetstore
orderCompleteLSwaggerPetstore.ModelLens, SwaggerPetstore
OrderId 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
orderIdSwaggerPetstore.Model, SwaggerPetstore
orderIdLSwaggerPetstore.ModelLens, SwaggerPetstore
OrderIdText 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
orderPetIdSwaggerPetstore.Model, SwaggerPetstore
orderPetIdLSwaggerPetstore.ModelLens, SwaggerPetstore
orderQuantitySwaggerPetstore.Model, SwaggerPetstore
orderQuantityLSwaggerPetstore.ModelLens, SwaggerPetstore
orderShipDateSwaggerPetstore.Model, SwaggerPetstore
orderShipDateLSwaggerPetstore.ModelLens, SwaggerPetstore
orderStatusSwaggerPetstore.Model, SwaggerPetstore
orderStatusLSwaggerPetstore.ModelLens, SwaggerPetstore
OuterBoolean 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
OuterComposite 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyBooleanSwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyBooleanLSwaggerPetstore.ModelLens, SwaggerPetstore
outerCompositeMyNumberSwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
outerCompositeMyStringSwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyStringLSwaggerPetstore.ModelLens, SwaggerPetstore
OuterEnum 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
OuterNumber 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
OuterString 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
\ No newline at end of file +

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Index - O

Order 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
orderCompleteSwaggerPetstore.Model, SwaggerPetstore
orderCompleteLSwaggerPetstore.ModelLens, SwaggerPetstore
OrderId 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
orderIdSwaggerPetstore.Model, SwaggerPetstore
orderIdLSwaggerPetstore.ModelLens, SwaggerPetstore
OrderIdText 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
orderPetIdSwaggerPetstore.Model, SwaggerPetstore
orderPetIdLSwaggerPetstore.ModelLens, SwaggerPetstore
orderQuantitySwaggerPetstore.Model, SwaggerPetstore
orderQuantityLSwaggerPetstore.ModelLens, SwaggerPetstore
orderShipDateSwaggerPetstore.Model, SwaggerPetstore
orderShipDateLSwaggerPetstore.ModelLens, SwaggerPetstore
orderStatusSwaggerPetstore.Model, SwaggerPetstore
orderStatusLSwaggerPetstore.ModelLens, SwaggerPetstore
OuterBoolean 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
OuterComposite 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyBooleanSwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyBooleanLSwaggerPetstore.ModelLens, SwaggerPetstore
outerCompositeMyNumberSwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyNumberLSwaggerPetstore.ModelLens, SwaggerPetstore
outerCompositeMyStringSwaggerPetstore.Model, SwaggerPetstore
outerCompositeMyStringLSwaggerPetstore.ModelLens, SwaggerPetstore
OuterEnumSwaggerPetstore.Model, SwaggerPetstore
OuterEnum'ApprovedSwaggerPetstore.Model, SwaggerPetstore
OuterEnum'DeliveredSwaggerPetstore.Model, SwaggerPetstore
OuterEnum'PlacedSwaggerPetstore.Model, SwaggerPetstore
OuterNumber 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
OuterString 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/doc-index-T.html b/samples/client/petstore/haskell-http-client/docs/doc-index-T.html index 4a11f437a62..e0e98a350ec 100644 --- a/samples/client/petstore/haskell-http-client/docs/doc-index-T.html +++ b/samples/client/petstore/haskell-http-client/docs/doc-index-T.html @@ -1,4 +1,4 @@ swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client (Index - T)

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Index - T

TabSeparatedSwaggerPetstore.Core, SwaggerPetstore
Tag 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
tagIdSwaggerPetstore.Model, SwaggerPetstore
tagIdLSwaggerPetstore.ModelLens, SwaggerPetstore
tagNameSwaggerPetstore.Model, SwaggerPetstore
tagNameLSwaggerPetstore.ModelLens, SwaggerPetstore
Tags 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
TestClassnameSwaggerPetstore.API, SwaggerPetstore
testClassnameSwaggerPetstore.API, SwaggerPetstore
TestClientModelSwaggerPetstore.API, SwaggerPetstore
testClientModelSwaggerPetstore.API, SwaggerPetstore
TestEndpointParametersSwaggerPetstore.API, SwaggerPetstore
testEndpointParametersSwaggerPetstore.API, SwaggerPetstore
TestEnumParametersSwaggerPetstore.API, SwaggerPetstore
testEnumParametersSwaggerPetstore.API, SwaggerPetstore
TestJsonFormDataSwaggerPetstore.API, SwaggerPetstore
testJsonFormDataSwaggerPetstore.API, SwaggerPetstore
TestSpecialTagsSwaggerPetstore.API, SwaggerPetstore
testSpecialTagsSwaggerPetstore.API, SwaggerPetstore
toFormSwaggerPetstore.Core, SwaggerPetstore
toFormCollSwaggerPetstore.Core, SwaggerPetstore
toHeaderSwaggerPetstore.Core, SwaggerPetstore
toHeaderCollSwaggerPetstore.Core, SwaggerPetstore
toPathSwaggerPetstore.Core, SwaggerPetstore
toQuerySwaggerPetstore.Core, SwaggerPetstore
toQueryCollSwaggerPetstore.Core, SwaggerPetstore
\ No newline at end of file +

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Index - T

TabSeparatedSwaggerPetstore.Core, SwaggerPetstore
Tag 
1 (Type/Class)SwaggerPetstore.Model, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.Model, SwaggerPetstore
tagIdSwaggerPetstore.Model, SwaggerPetstore
tagIdLSwaggerPetstore.ModelLens, SwaggerPetstore
tagNameSwaggerPetstore.Model, SwaggerPetstore
tagNameLSwaggerPetstore.ModelLens, SwaggerPetstore
Tags 
1 (Type/Class)SwaggerPetstore.API, SwaggerPetstore
2 (Data Constructor)SwaggerPetstore.API, SwaggerPetstore
TestClassnameSwaggerPetstore.API, SwaggerPetstore
testClassnameSwaggerPetstore.API, SwaggerPetstore
TestClientModelSwaggerPetstore.API, SwaggerPetstore
testClientModelSwaggerPetstore.API, SwaggerPetstore
TestEndpointParametersSwaggerPetstore.API, SwaggerPetstore
testEndpointParametersSwaggerPetstore.API, SwaggerPetstore
TestEnumParametersSwaggerPetstore.API, SwaggerPetstore
testEnumParametersSwaggerPetstore.API, SwaggerPetstore
TestInlineAdditionalPropertiesSwaggerPetstore.API, SwaggerPetstore
testInlineAdditionalPropertiesSwaggerPetstore.API, SwaggerPetstore
TestJsonFormDataSwaggerPetstore.API, SwaggerPetstore
testJsonFormDataSwaggerPetstore.API, SwaggerPetstore
TestSpecialTagsSwaggerPetstore.API, SwaggerPetstore
testSpecialTagsSwaggerPetstore.API, SwaggerPetstore
toE'ArrayEnumSwaggerPetstore.Model, SwaggerPetstore
toE'EnumFormStringSwaggerPetstore.Model, SwaggerPetstore
toE'EnumIntegerSwaggerPetstore.Model, SwaggerPetstore
toE'EnumNumberSwaggerPetstore.Model, SwaggerPetstore
toE'EnumQueryIntegerSwaggerPetstore.Model, SwaggerPetstore
toE'EnumStringSwaggerPetstore.Model, SwaggerPetstore
toE'InnerSwaggerPetstore.Model, SwaggerPetstore
toE'Inner2SwaggerPetstore.Model, SwaggerPetstore
toE'JustSymbolSwaggerPetstore.Model, SwaggerPetstore
toE'StatusSwaggerPetstore.Model, SwaggerPetstore
toE'Status2SwaggerPetstore.Model, SwaggerPetstore
toEnumClassSwaggerPetstore.Model, SwaggerPetstore
toFormSwaggerPetstore.Core, SwaggerPetstore
toFormCollSwaggerPetstore.Core, SwaggerPetstore
toHeaderSwaggerPetstore.Core, SwaggerPetstore
toHeaderCollSwaggerPetstore.Core, SwaggerPetstore
toOuterEnumSwaggerPetstore.Model, SwaggerPetstore
toPathSwaggerPetstore.Core, SwaggerPetstore
toQuerySwaggerPetstore.Core, SwaggerPetstore
toQueryCollSwaggerPetstore.Core, SwaggerPetstore
\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/mini_SwaggerPetstore-API.html b/samples/client/petstore/haskell-http-client/docs/mini_SwaggerPetstore-API.html index dc389c7b979..9e01b1aa39b 100644 --- a/samples/client/petstore/haskell-http-client/docs/mini_SwaggerPetstore-API.html +++ b/samples/client/petstore/haskell-http-client/docs/mini_SwaggerPetstore-API.html @@ -1,4 +1,4 @@ SwaggerPetstore.API

SwaggerPetstore.API

Operations

AnotherFake

testSpecialTags

Fake

fakeOuterBooleanSerialize

fakeOuterCompositeSerialize

fakeOuterNumberSerialize

fakeOuterStringSerialize

testClientModel

testEndpointParameters

testEnumParameters

testJsonFormData

FakeClassnameTags123

testClassname

Pet

addPet

data AddPet

deletePet

findPetsByStatus

findPetsByTags

getPetById

updatePet

updatePetWithForm

uploadFile

Store

deleteOrder

getInventory

getOrderById

placeOrder

User

createUser

createUsersWithArrayInput

createUsersWithListInput

deleteUser

getUserByName

loginUser

logoutUser

updateUser

Parameter newtypes

data ApiKey

data Body

data Byte

data File

data Int32

data Int64

data Name2

data Number

data OrderId

data Param

data Param2

data PetId

data Status

data Tags

Auth Methods

AuthApiKeyApiKey

AuthApiKeyApiKeyQuery

AuthBasicHttpBasicTest

AuthOAuthPetstoreAuth

Custom Mime Types

MimeJsonCharsetutf8

MimeXmlCharsetutf8

\ No newline at end of file +

SwaggerPetstore.API

Operations

AnotherFake

testSpecialTags

Fake

fakeOuterBooleanSerialize

fakeOuterCompositeSerialize

fakeOuterNumberSerialize

fakeOuterStringSerialize

testClientModel

testEndpointParameters

testEnumParameters

testInlineAdditionalProperties

testJsonFormData

FakeClassnameTags123

testClassname

Pet

addPet

data AddPet

deletePet

findPetsByStatus

findPetsByTags

getPetById

updatePet

updatePetWithForm

uploadFile

Store

deleteOrder

getInventory

getOrderById

placeOrder

User

createUser

createUsersWithArrayInput

createUsersWithListInput

deleteUser

getUserByName

loginUser

logoutUser

updateUser

Parameter newtypes

data ApiKey

data Body

data Byte

data File

data Int32

data Int64

data Name2

data Number

data OrderId

data Param

data Param2

data PetId

data Status

data Tags

Auth Methods

AuthApiKeyApiKey

AuthApiKeyApiKeyQuery

AuthBasicHttpBasicTest

AuthOAuthPetstoreAuth

Custom Mime Types

MimeJsonCharsetutf8

MimeXmlCharsetutf8

\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/mini_SwaggerPetstore-Model.html b/samples/client/petstore/haskell-http-client/docs/mini_SwaggerPetstore-Model.html index 99d6cf89bf1..529a1d4113a 100644 --- a/samples/client/petstore/haskell-http-client/docs/mini_SwaggerPetstore-Model.html +++ b/samples/client/petstore/haskell-http-client/docs/mini_SwaggerPetstore-Model.html @@ -1,4 +1,4 @@ SwaggerPetstore.Model

SwaggerPetstore.Model

Models

AdditionalPropertiesClass

Animal

data Animal

AnimalFarm

ApiResponse

ArrayOfArrayOfNumberOnly

ArrayOfNumberOnly

ArrayTest

Capitalization

Category

ClassModel

Client

data Client

EnumArrays

EnumClass

EnumTest

FormatTest

HasOnlyReadOnly

MapTest

data MapTest

MixedPropertiesAndAdditionalPropertiesClass

Model200Response

ModelList

ModelReturn

Name

data Name

NumberOnly

Order

data Order

OuterBoolean

OuterComposite

OuterEnum

OuterNumber

OuterString

Pet

data Pet

ReadOnlyFirst

SpecialModelName

Tag

data Tag

User

data User

Cat

data Cat

Dog

data Dog

\ No newline at end of file +

SwaggerPetstore.Model

Models

AdditionalPropertiesClass

Animal

data Animal

AnimalFarm

ApiResponse

ArrayOfArrayOfNumberOnly

ArrayOfNumberOnly

ArrayTest

Capitalization

Category

ClassModel

Client

data Client

EnumArrays

EnumTest

FormatTest

HasOnlyReadOnly

MapTest

data MapTest

MixedPropertiesAndAdditionalPropertiesClass

Model200Response

ModelList

ModelReturn

Name

data Name

NumberOnly

Order

data Order

OuterBoolean

OuterComposite

OuterNumber

OuterString

Pet

data Pet

ReadOnlyFirst

SpecialModelName

Tag

data Tag

User

data User

Cat

data Cat

Dog

data Dog

Enums

E'ArrayEnum

E'EnumFormString

E'EnumInteger

E'EnumNumber

E'EnumQueryInteger

E'EnumString

E'Inner

data E'Inner

E'Inner2

E'JustSymbol

E'Status

E'Status2

EnumClass

OuterEnum

\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/src/Paths_swagger_petstore.html b/samples/client/petstore/haskell-http-client/docs/src/Paths_swagger_petstore.html index 3bba33b677f..ce21d34bbb1 100644 --- a/samples/client/petstore/haskell-http-client/docs/src/Paths_swagger_petstore.html +++ b/samples/client/petstore/haskell-http-client/docs/src/Paths_swagger_petstore.html @@ -15,7 +15,7 @@ #if defined(VERSION_base) #if MIN_VERSION_base(4,0,0) -catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a +catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a #else catchIO :: IO a -> (Exception.Exception -> IO a) -> IO a #endif @@ -29,12 +29,12 @@ version = Version [0,1,0,0] [] bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath -bindir = "/home/jon/fs/git/swagger-codegen/samples/client/petstore/haskell-http-client/.stack-work/install/x86_64-linux-nopie/lts-9.0/8.0.2/bin" -libdir = "/home/jon/fs/git/swagger-codegen/samples/client/petstore/haskell-http-client/.stack-work/install/x86_64-linux-nopie/lts-9.0/8.0.2/lib/x86_64-linux-ghc-8.0.2/swagger-petstore-0.1.0.0-6vvnt0nNbFQ21xc4iZiS7J" -dynlibdir = "/home/jon/fs/git/swagger-codegen/samples/client/petstore/haskell-http-client/.stack-work/install/x86_64-linux-nopie/lts-9.0/8.0.2/lib/x86_64-linux-ghc-8.0.2" -datadir = "/home/jon/fs/git/swagger-codegen/samples/client/petstore/haskell-http-client/.stack-work/install/x86_64-linux-nopie/lts-9.0/8.0.2/share/x86_64-linux-ghc-8.0.2/swagger-petstore-0.1.0.0" -libexecdir = "/home/jon/fs/git/swagger-codegen/samples/client/petstore/haskell-http-client/.stack-work/install/x86_64-linux-nopie/lts-9.0/8.0.2/libexec" -sysconfdir = "/home/jon/fs/git/swagger-codegen/samples/client/petstore/haskell-http-client/.stack-work/install/x86_64-linux-nopie/lts-9.0/8.0.2/etc" +bindir = "/home/jon/fs/git/swagger-codegen/samples/client/petstore/haskell-http-client/.stack-work/install/x86_64-linux-nopie/lts-9.10/8.0.2/bin" +libdir = "/home/jon/fs/git/swagger-codegen/samples/client/petstore/haskell-http-client/.stack-work/install/x86_64-linux-nopie/lts-9.10/8.0.2/lib/x86_64-linux-ghc-8.0.2/swagger-petstore-0.1.0.0-G0PVVG38xKf22jM35QKNTa" +dynlibdir = "/home/jon/fs/git/swagger-codegen/samples/client/petstore/haskell-http-client/.stack-work/install/x86_64-linux-nopie/lts-9.10/8.0.2/lib/x86_64-linux-ghc-8.0.2" +datadir = "/home/jon/fs/git/swagger-codegen/samples/client/petstore/haskell-http-client/.stack-work/install/x86_64-linux-nopie/lts-9.10/8.0.2/share/x86_64-linux-ghc-8.0.2/swagger-petstore-0.1.0.0" +libexecdir = "/home/jon/fs/git/swagger-codegen/samples/client/petstore/haskell-http-client/.stack-work/install/x86_64-linux-nopie/lts-9.10/8.0.2/libexec" +sysconfdir = "/home/jon/fs/git/swagger-codegen/samples/client/petstore/haskell-http-client/.stack-work/install/x86_64-linux-nopie/lts-9.10/8.0.2/etc" getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath getBinDir = catchIO (getEnv "swagger_petstore_bindir") (\_ -> return bindir) @@ -45,7 +45,7 @@ getSysconfDir = catchIO (getEnv "swagger_petstore_sysconfdir") (\_ -> return sysconfdir) getDataFileName :: FilePath -> IO FilePath -getDataFileName name = do - dir <- getDataDir - return (dir ++ "/" ++ name) +getDataFileName name = do + dir <- getDataDir + return (dir ++ "/" ++ name) \ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.API.html b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.API.html index 1b60e4447ab..0740cf90dab 100644 --- a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.API.html +++ b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.API.html @@ -79,13 +79,13 @@ Module : SwaggerPetstore.API -- To test special tags -- testSpecialTags - :: (Consumes TestSpecialTags contentType, MimeRender contentType Client) - => contentType -- ^ request content-type ('MimeType') + :: (Consumes TestSpecialTags contentType, MimeRender contentType Client) + => contentType -- ^ request content-type ('MimeType') -> Client -- ^ "body" - client model - -> SwaggerPetstoreRequest TestSpecialTags contentType Client -testSpecialTags _ body = + -> SwaggerPetstoreRequest TestSpecialTags contentType Client +testSpecialTags _ body = _mkRequest "PATCH" ["/another-fake/dummy"] - `setBodyParam` body + `setBodyParam` body data TestSpecialTags @@ -108,9 +108,9 @@ Module : SwaggerPetstore.API -- Test serialization of outer boolean types -- fakeOuterBooleanSerialize - :: (Consumes FakeOuterBooleanSerialize contentType) - => contentType -- ^ request content-type ('MimeType') - -> SwaggerPetstoreRequest FakeOuterBooleanSerialize contentType OuterBoolean + :: (Consumes FakeOuterBooleanSerialize contentType) + => contentType -- ^ request content-type ('MimeType') + -> SwaggerPetstoreRequest FakeOuterBooleanSerialize contentType OuterBoolean fakeOuterBooleanSerialize _ = _mkRequest "POST" ["/fake/outer/boolean"] @@ -126,9 +126,9 @@ Module : SwaggerPetstore.API -- Test serialization of object with outer number type -- fakeOuterCompositeSerialize - :: (Consumes FakeOuterCompositeSerialize contentType) - => contentType -- ^ request content-type ('MimeType') - -> SwaggerPetstoreRequest FakeOuterCompositeSerialize contentType OuterComposite + :: (Consumes FakeOuterCompositeSerialize contentType) + => contentType -- ^ request content-type ('MimeType') + -> SwaggerPetstoreRequest FakeOuterCompositeSerialize contentType OuterComposite fakeOuterCompositeSerialize _ = _mkRequest "POST" ["/fake/outer/composite"] @@ -144,9 +144,9 @@ Module : SwaggerPetstore.API -- Test serialization of outer number types -- fakeOuterNumberSerialize - :: (Consumes FakeOuterNumberSerialize contentType) - => contentType -- ^ request content-type ('MimeType') - -> SwaggerPetstoreRequest FakeOuterNumberSerialize contentType OuterNumber + :: (Consumes FakeOuterNumberSerialize contentType) + => contentType -- ^ request content-type ('MimeType') + -> SwaggerPetstoreRequest FakeOuterNumberSerialize contentType OuterNumber fakeOuterNumberSerialize _ = _mkRequest "POST" ["/fake/outer/number"] @@ -162,9 +162,9 @@ Module : SwaggerPetstore.API -- Test serialization of outer string types -- fakeOuterStringSerialize - :: (Consumes FakeOuterStringSerialize contentType) - => contentType -- ^ request content-type ('MimeType') - -> SwaggerPetstoreRequest FakeOuterStringSerialize contentType OuterString + :: (Consumes FakeOuterStringSerialize contentType) + => contentType -- ^ request content-type ('MimeType') + -> SwaggerPetstoreRequest FakeOuterStringSerialize contentType OuterString fakeOuterStringSerialize _ = _mkRequest "POST" ["/fake/outer/string"] @@ -182,13 +182,13 @@ Module : SwaggerPetstore.API -- To test \"client\" model -- testClientModel - :: (Consumes TestClientModel contentType, MimeRender contentType Client) - => contentType -- ^ request content-type ('MimeType') + :: (Consumes TestClientModel contentType, MimeRender contentType Client) + => contentType -- ^ request content-type ('MimeType') -> Client -- ^ "body" - client model - -> SwaggerPetstoreRequest TestClientModel contentType Client -testClientModel _ body = + -> SwaggerPetstoreRequest TestClientModel contentType Client +testClientModel _ body = _mkRequest "PATCH" ["/fake"] - `setBodyParam` body + `setBodyParam` body data TestClientModel @@ -215,72 +215,72 @@ Module : SwaggerPetstore.API -- Note: Has 'Produces' instances, but no response schema -- testEndpointParameters - :: (Consumes TestEndpointParameters contentType) - => contentType -- ^ request content-type ('MimeType') + :: (Consumes TestEndpointParameters contentType) + => contentType -- ^ request content-type ('MimeType') -> Number -- ^ "number" - None -> ParamDouble -- ^ "double" - None -> PatternWithoutDelimiter -- ^ "patternWithoutDelimiter" - None -> Byte -- ^ "byte" - None - -> SwaggerPetstoreRequest TestEndpointParameters contentType res -testEndpointParameters _ (Number number) (ParamDouble double) (PatternWithoutDelimiter patternWithoutDelimiter) (Byte byte) = + -> SwaggerPetstoreRequest TestEndpointParameters contentType res +testEndpointParameters _ (Number number) (ParamDouble double) (PatternWithoutDelimiter patternWithoutDelimiter) (Byte byte) = _mkRequest "POST" ["/fake"] `_hasAuthType` (P.Proxy :: P.Proxy AuthBasicHttpBasicTest) - `addForm` toForm ("number", number) - `addForm` toForm ("double", double) - `addForm` toForm ("pattern_without_delimiter", patternWithoutDelimiter) - `addForm` toForm ("byte", byte) + `addForm` toForm ("number", number) + `addForm` toForm ("double", double) + `addForm` toForm ("pattern_without_delimiter", patternWithoutDelimiter) + `addForm` toForm ("byte", byte) data TestEndpointParameters -- | /Optional Param/ "integer" - None instance HasOptionalParam TestEndpointParameters ParamInteger where - applyOptionalParam req (ParamInteger xs) = - req `addForm` toForm ("integer", xs) + applyOptionalParam req (ParamInteger xs) = + req `addForm` toForm ("integer", xs) -- | /Optional Param/ "int32" - None instance HasOptionalParam TestEndpointParameters Int32 where - applyOptionalParam req (Int32 xs) = - req `addForm` toForm ("int32", xs) + applyOptionalParam req (Int32 xs) = + req `addForm` toForm ("int32", xs) -- | /Optional Param/ "int64" - None instance HasOptionalParam TestEndpointParameters Int64 where - applyOptionalParam req (Int64 xs) = - req `addForm` toForm ("int64", xs) + applyOptionalParam req (Int64 xs) = + req `addForm` toForm ("int64", xs) -- | /Optional Param/ "float" - None instance HasOptionalParam TestEndpointParameters ParamFloat where - applyOptionalParam req (ParamFloat xs) = - req `addForm` toForm ("float", xs) + applyOptionalParam req (ParamFloat xs) = + req `addForm` toForm ("float", xs) -- | /Optional Param/ "string" - None instance HasOptionalParam TestEndpointParameters ParamString where - applyOptionalParam req (ParamString xs) = - req `addForm` toForm ("string", xs) + applyOptionalParam req (ParamString xs) = + req `addForm` toForm ("string", xs) -- | /Optional Param/ "binary" - None instance HasOptionalParam TestEndpointParameters ParamBinary where - applyOptionalParam req (ParamBinary xs) = - req `addForm` toForm ("binary", xs) + applyOptionalParam req (ParamBinary xs) = + req `addForm` toForm ("binary", xs) -- | /Optional Param/ "date" - None instance HasOptionalParam TestEndpointParameters ParamDate where - applyOptionalParam req (ParamDate xs) = - req `addForm` toForm ("date", xs) + applyOptionalParam req (ParamDate xs) = + req `addForm` toForm ("date", xs) -- | /Optional Param/ "dateTime" - None instance HasOptionalParam TestEndpointParameters ParamDateTime where - applyOptionalParam req (ParamDateTime xs) = - req `addForm` toForm ("dateTime", xs) + applyOptionalParam req (ParamDateTime xs) = + req `addForm` toForm ("dateTime", xs) -- | /Optional Param/ "password" - None instance HasOptionalParam TestEndpointParameters Password where - applyOptionalParam req (Password xs) = - req `addForm` toForm ("password", xs) + applyOptionalParam req (Password xs) = + req `addForm` toForm ("password", xs) -- | /Optional Param/ "callback" - None instance HasOptionalParam TestEndpointParameters Callback where - applyOptionalParam req (Callback xs) = - req `addForm` toForm ("callback", xs) + applyOptionalParam req (Callback xs) = + req `addForm` toForm ("callback", xs) -- | @application/xml; charset=utf-8@ instance Consumes TestEndpointParameters MimeXmlCharsetutf8 @@ -304,9 +304,9 @@ Module : SwaggerPetstore.API -- Note: Has 'Produces' instances, but no response schema -- testEnumParameters - :: (Consumes TestEnumParameters contentType) - => contentType -- ^ request content-type ('MimeType') - -> SwaggerPetstoreRequest TestEnumParameters contentType res + :: (Consumes TestEnumParameters contentType) + => contentType -- ^ request content-type ('MimeType') + -> SwaggerPetstoreRequest TestEnumParameters contentType res testEnumParameters _ = _mkRequest "GET" ["/fake"] @@ -314,43 +314,43 @@ Module : SwaggerPetstore.API -- | /Optional Param/ "enum_form_string_array" - Form parameter enum test (string array) instance HasOptionalParam TestEnumParameters EnumFormStringArray where - applyOptionalParam req (EnumFormStringArray xs) = - req `addForm` toFormColl CommaSeparated ("enum_form_string_array", xs) + applyOptionalParam req (EnumFormStringArray xs) = + req `addForm` toFormColl CommaSeparated ("enum_form_string_array", xs) -- | /Optional Param/ "enum_form_string" - Form parameter enum test (string) instance HasOptionalParam TestEnumParameters EnumFormString where - applyOptionalParam req (EnumFormString xs) = - req `addForm` toForm ("enum_form_string", xs) + applyOptionalParam req (EnumFormString xs) = + req `addForm` toForm ("enum_form_string", xs) -- | /Optional Param/ "enum_header_string_array" - Header parameter enum test (string array) instance HasOptionalParam TestEnumParameters EnumHeaderStringArray where - applyOptionalParam req (EnumHeaderStringArray xs) = - req `setHeader` toHeaderColl CommaSeparated ("enum_header_string_array", xs) + applyOptionalParam req (EnumHeaderStringArray xs) = + req `setHeader` toHeaderColl CommaSeparated ("enum_header_string_array", xs) -- | /Optional Param/ "enum_header_string" - Header parameter enum test (string) instance HasOptionalParam TestEnumParameters EnumHeaderString where - applyOptionalParam req (EnumHeaderString xs) = - req `setHeader` toHeader ("enum_header_string", xs) + applyOptionalParam req (EnumHeaderString xs) = + req `setHeader` toHeader ("enum_header_string", xs) -- | /Optional Param/ "enum_query_string_array" - Query parameter enum test (string array) instance HasOptionalParam TestEnumParameters EnumQueryStringArray where - applyOptionalParam req (EnumQueryStringArray xs) = - req `setQuery` toQueryColl CommaSeparated ("enum_query_string_array", Just xs) + applyOptionalParam req (EnumQueryStringArray xs) = + req `setQuery` toQueryColl CommaSeparated ("enum_query_string_array", Just xs) -- | /Optional Param/ "enum_query_string" - Query parameter enum test (string) instance HasOptionalParam TestEnumParameters EnumQueryString where - applyOptionalParam req (EnumQueryString xs) = - req `setQuery` toQuery ("enum_query_string", Just xs) + applyOptionalParam req (EnumQueryString xs) = + req `setQuery` toQuery ("enum_query_string", Just xs) -- | /Optional Param/ "enum_query_integer" - Query parameter enum test (double) instance HasOptionalParam TestEnumParameters EnumQueryInteger where - applyOptionalParam req (EnumQueryInteger xs) = - req `setQuery` toQuery ("enum_query_integer", Just xs) + applyOptionalParam req (EnumQueryInteger xs) = + req `setQuery` toQuery ("enum_query_integer", Just xs) -- | /Optional Param/ "enum_query_double" - Query parameter enum test (double) instance HasOptionalParam TestEnumParameters EnumQueryDouble where - applyOptionalParam req (EnumQueryDouble xs) = - req `addForm` toForm ("enum_query_double", xs) + applyOptionalParam req (EnumQueryDouble xs) = + req `addForm` toForm ("enum_query_double", xs) -- | @*/*@ instance Consumes TestEnumParameters MimeAny @@ -359,749 +359,775 @@ Module : SwaggerPetstore.API instance Produces TestEnumParameters MimeAny --- *** testJsonFormData +-- *** testInlineAdditionalProperties --- | @GET \/fake\/jsonFormData@ +-- | @POST \/fake\/inline-additionalProperties@ -- --- test json serialization of form data +-- test inline additionalProperties -- -- -- -testJsonFormData - :: (Consumes TestJsonFormData contentType) - => contentType -- ^ request content-type ('MimeType') - -> Param -- ^ "param" - field1 - -> Param2 -- ^ "param2" - field2 - -> SwaggerPetstoreRequest TestJsonFormData contentType NoContent -testJsonFormData _ (Param param) (Param2 param2) = - _mkRequest "GET" ["/fake/jsonFormData"] - `addForm` toForm ("param", param) - `addForm` toForm ("param2", param2) +testInlineAdditionalProperties + :: (Consumes TestInlineAdditionalProperties contentType, MimeRender contentType A.Value) + => contentType -- ^ request content-type ('MimeType') + -> A.Value -- ^ "param" - request body + -> SwaggerPetstoreRequest TestInlineAdditionalProperties contentType NoContent +testInlineAdditionalProperties _ param = + _mkRequest "POST" ["/fake/inline-additionalProperties"] + `setBodyParam` param + +data TestInlineAdditionalProperties -data TestJsonFormData - --- | @application/json@ -instance Consumes TestJsonFormData MimeJSON - +-- | /Body Param/ "param" - request body +instance HasBodyParam TestInlineAdditionalProperties A.Value + +-- | @application/json@ +instance Consumes TestInlineAdditionalProperties MimeJSON --- ** FakeClassnameTags123 - --- *** testClassname - --- | @PATCH \/fake_classname_test@ --- --- To test class name in snake case + +-- *** testJsonFormData + +-- | @GET \/fake\/jsonFormData@ +-- +-- test json serialization of form data +-- -- --- AuthMethod: 'AuthApiKeyApiKeyQuery' --- -testClassname - :: (Consumes TestClassname contentType, MimeRender contentType Client) - => contentType -- ^ request content-type ('MimeType') - -> Client -- ^ "body" - client model - -> SwaggerPetstoreRequest TestClassname contentType Client -testClassname _ body = - _mkRequest "PATCH" ["/fake_classname_test"] - `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKeyQuery) - `setBodyParam` body +-- +testJsonFormData + :: (Consumes TestJsonFormData contentType) + => contentType -- ^ request content-type ('MimeType') + -> Param -- ^ "param" - field1 + -> Param2 -- ^ "param2" - field2 + -> SwaggerPetstoreRequest TestJsonFormData contentType NoContent +testJsonFormData _ (Param param) (Param2 param2) = + _mkRequest "GET" ["/fake/jsonFormData"] + `addForm` toForm ("param", param) + `addForm` toForm ("param2", param2) -data TestClassname +data TestJsonFormData --- | /Body Param/ "body" - client model -instance HasBodyParam TestClassname Client +-- | @application/json@ +instance Consumes TestJsonFormData MimeJSON --- | @application/json@ -instance Consumes TestClassname MimeJSON + +-- ** FakeClassnameTags123 --- | @application/json@ -instance Produces TestClassname MimeJSON - - --- ** Pet - --- *** addPet - --- | @POST \/pet@ --- --- Add a new pet to the store --- --- --- --- AuthMethod: 'AuthOAuthPetstoreAuth' --- --- Note: Has 'Produces' instances, but no response schema --- -addPet - :: (Consumes AddPet contentType, MimeRender contentType Pet) - => contentType -- ^ request content-type ('MimeType') - -> Pet -- ^ "body" - Pet object that needs to be added to the store - -> SwaggerPetstoreRequest AddPet contentType res -addPet _ body = - _mkRequest "POST" ["/pet"] - `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) - `setBodyParam` body - -data AddPet +-- *** testClassname + +-- | @PATCH \/fake_classname_test@ +-- +-- To test class name in snake case +-- +-- AuthMethod: 'AuthApiKeyApiKeyQuery' +-- +testClassname + :: (Consumes TestClassname contentType, MimeRender contentType Client) + => contentType -- ^ request content-type ('MimeType') + -> Client -- ^ "body" - client model + -> SwaggerPetstoreRequest TestClassname contentType Client +testClassname _ body = + _mkRequest "PATCH" ["/fake_classname_test"] + `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKeyQuery) + `setBodyParam` body + +data TestClassname + +-- | /Body Param/ "body" - client model +instance HasBodyParam TestClassname Client + +-- | @application/json@ +instance Consumes TestClassname MimeJSON + +-- | @application/json@ +instance Produces TestClassname MimeJSON + --- | /Body Param/ "body" - Pet object that needs to be added to the store -instance HasBodyParam AddPet Pet - --- | @application/json@ -instance Consumes AddPet MimeJSON --- | @application/xml@ -instance Consumes AddPet MimeXML - --- | @application/xml@ -instance Produces AddPet MimeXML --- | @application/json@ -instance Produces AddPet MimeJSON - - --- *** deletePet - --- | @DELETE \/pet\/{petId}@ --- --- Deletes a pet --- --- --- --- AuthMethod: 'AuthOAuthPetstoreAuth' --- --- Note: Has 'Produces' instances, but no response schema --- -deletePet - :: PetId -- ^ "petId" - Pet id to delete - -> SwaggerPetstoreRequest DeletePet MimeNoContent res -deletePet (PetId petId) = - _mkRequest "DELETE" ["/pet/",toPath petId] - `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) - -data DeletePet -instance HasOptionalParam DeletePet ApiKey where - applyOptionalParam req (ApiKey xs) = - req `setHeader` toHeader ("api_key", xs) --- | @application/xml@ -instance Produces DeletePet MimeXML --- | @application/json@ -instance Produces DeletePet MimeJSON +-- ** Pet + +-- *** addPet + +-- | @POST \/pet@ +-- +-- Add a new pet to the store +-- +-- +-- +-- AuthMethod: 'AuthOAuthPetstoreAuth' +-- +-- Note: Has 'Produces' instances, but no response schema +-- +addPet + :: (Consumes AddPet contentType, MimeRender contentType Pet) + => contentType -- ^ request content-type ('MimeType') + -> Pet -- ^ "body" - Pet object that needs to be added to the store + -> SwaggerPetstoreRequest AddPet contentType res +addPet _ body = + _mkRequest "POST" ["/pet"] + `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) + `setBodyParam` body + +data AddPet + +-- | /Body Param/ "body" - Pet object that needs to be added to the store +instance HasBodyParam AddPet Pet + +-- | @application/json@ +instance Consumes AddPet MimeJSON +-- | @application/xml@ +instance Consumes AddPet MimeXML + +-- | @application/xml@ +instance Produces AddPet MimeXML +-- | @application/json@ +instance Produces AddPet MimeJSON + + +-- *** deletePet - --- *** findPetsByStatus - --- | @GET \/pet\/findByStatus@ +-- | @DELETE \/pet\/{petId}@ +-- +-- Deletes a pet +-- -- --- Finds Pets by status --- --- Multiple status values can be provided with comma separated strings --- --- AuthMethod: 'AuthOAuthPetstoreAuth' --- -findPetsByStatus - :: Status -- ^ "status" - Status values that need to be considered for filter - -> SwaggerPetstoreRequest FindPetsByStatus MimeNoContent [Pet] -findPetsByStatus (Status status) = - _mkRequest "GET" ["/pet/findByStatus"] - `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) - `setQuery` toQueryColl CommaSeparated ("status", Just status) - -data FindPetsByStatus --- | @application/xml@ -instance Produces FindPetsByStatus MimeXML --- | @application/json@ -instance Produces FindPetsByStatus MimeJSON - +-- +-- AuthMethod: 'AuthOAuthPetstoreAuth' +-- +-- Note: Has 'Produces' instances, but no response schema +-- +deletePet + :: PetId -- ^ "petId" - Pet id to delete + -> SwaggerPetstoreRequest DeletePet MimeNoContent res +deletePet (PetId petId) = + _mkRequest "DELETE" ["/pet/",toPath petId] + `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) + +data DeletePet +instance HasOptionalParam DeletePet ApiKey where + applyOptionalParam req (ApiKey xs) = + req `setHeader` toHeader ("api_key", xs) +-- | @application/xml@ +instance Produces DeletePet MimeXML +-- | @application/json@ +instance Produces DeletePet MimeJSON --- *** findPetsByTags - --- | @GET \/pet\/findByTags@ --- --- Finds Pets by tags --- --- Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. --- --- AuthMethod: 'AuthOAuthPetstoreAuth' --- -findPetsByTags - :: Tags -- ^ "tags" - Tags to filter by - -> SwaggerPetstoreRequest FindPetsByTags MimeNoContent [Pet] -findPetsByTags (Tags tags) = - _mkRequest "GET" ["/pet/findByTags"] - `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) - `setQuery` toQueryColl CommaSeparated ("tags", Just tags) - -{-# DEPRECATED findPetsByTags "" #-} - -data FindPetsByTags --- | @application/xml@ -instance Produces FindPetsByTags MimeXML --- | @application/json@ -instance Produces FindPetsByTags MimeJSON + +-- *** findPetsByStatus + +-- | @GET \/pet\/findByStatus@ +-- +-- Finds Pets by status +-- +-- Multiple status values can be provided with comma separated strings +-- +-- AuthMethod: 'AuthOAuthPetstoreAuth' +-- +findPetsByStatus + :: Status -- ^ "status" - Status values that need to be considered for filter + -> SwaggerPetstoreRequest FindPetsByStatus MimeNoContent [Pet] +findPetsByStatus (Status status) = + _mkRequest "GET" ["/pet/findByStatus"] + `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) + `setQuery` toQueryColl CommaSeparated ("status", Just status) + +data FindPetsByStatus +-- | @application/xml@ +instance Produces FindPetsByStatus MimeXML +-- | @application/json@ +instance Produces FindPetsByStatus MimeJSON + - --- *** getPetById - --- | @GET \/pet\/{petId}@ --- --- Find pet by ID --- --- Returns a single pet --- --- AuthMethod: 'AuthApiKeyApiKey' --- -getPetById - :: PetId -- ^ "petId" - ID of pet to return - -> SwaggerPetstoreRequest GetPetById MimeNoContent Pet -getPetById (PetId petId) = - _mkRequest "GET" ["/pet/",toPath petId] - `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKey) +-- *** findPetsByTags + +-- | @GET \/pet\/findByTags@ +-- +-- Finds Pets by tags +-- +-- Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. +-- +-- AuthMethod: 'AuthOAuthPetstoreAuth' +-- +findPetsByTags + :: Tags -- ^ "tags" - Tags to filter by + -> SwaggerPetstoreRequest FindPetsByTags MimeNoContent [Pet] +findPetsByTags (Tags tags) = + _mkRequest "GET" ["/pet/findByTags"] + `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) + `setQuery` toQueryColl CommaSeparated ("tags", Just tags) -data GetPetById --- | @application/xml@ -instance Produces GetPetById MimeXML --- | @application/json@ -instance Produces GetPetById MimeJSON - - --- *** updatePet +{-# DEPRECATED findPetsByTags "" #-} + +data FindPetsByTags +-- | @application/xml@ +instance Produces FindPetsByTags MimeXML +-- | @application/json@ +instance Produces FindPetsByTags MimeJSON + --- | @PUT \/pet@ --- --- Update an existing pet +-- *** getPetById + +-- | @GET \/pet\/{petId}@ -- --- +-- Find pet by ID -- --- AuthMethod: 'AuthOAuthPetstoreAuth' +-- Returns a single pet -- --- Note: Has 'Produces' instances, but no response schema +-- AuthMethod: 'AuthApiKeyApiKey' -- -updatePet - :: (Consumes UpdatePet contentType, MimeRender contentType Pet) - => contentType -- ^ request content-type ('MimeType') - -> Pet -- ^ "body" - Pet object that needs to be added to the store - -> SwaggerPetstoreRequest UpdatePet contentType res -updatePet _ body = - _mkRequest "PUT" ["/pet"] - `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) - `setBodyParam` body - -data UpdatePet - --- | /Body Param/ "body" - Pet object that needs to be added to the store -instance HasBodyParam UpdatePet Pet - --- | @application/json@ -instance Consumes UpdatePet MimeJSON --- | @application/xml@ -instance Consumes UpdatePet MimeXML - --- | @application/xml@ -instance Produces UpdatePet MimeXML --- | @application/json@ -instance Produces UpdatePet MimeJSON - - --- *** updatePetWithForm - --- | @POST \/pet\/{petId}@ --- --- Updates a pet in the store with form data --- --- --- --- AuthMethod: 'AuthOAuthPetstoreAuth' --- --- Note: Has 'Produces' instances, but no response schema --- -updatePetWithForm - :: (Consumes UpdatePetWithForm contentType) - => contentType -- ^ request content-type ('MimeType') - -> PetId -- ^ "petId" - ID of pet that needs to be updated - -> SwaggerPetstoreRequest UpdatePetWithForm contentType res -updatePetWithForm _ (PetId petId) = - _mkRequest "POST" ["/pet/",toPath petId] - `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) - -data UpdatePetWithForm - --- | /Optional Param/ "name" - Updated name of the pet -instance HasOptionalParam UpdatePetWithForm Name2 where - applyOptionalParam req (Name2 xs) = - req `addForm` toForm ("name", xs) +getPetById + :: PetId -- ^ "petId" - ID of pet to return + -> SwaggerPetstoreRequest GetPetById MimeNoContent Pet +getPetById (PetId petId) = + _mkRequest "GET" ["/pet/",toPath petId] + `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKey) + +data GetPetById +-- | @application/xml@ +instance Produces GetPetById MimeXML +-- | @application/json@ +instance Produces GetPetById MimeJSON + + +-- *** updatePet + +-- | @PUT \/pet@ +-- +-- Update an existing pet +-- +-- +-- +-- AuthMethod: 'AuthOAuthPetstoreAuth' +-- +-- Note: Has 'Produces' instances, but no response schema +-- +updatePet + :: (Consumes UpdatePet contentType, MimeRender contentType Pet) + => contentType -- ^ request content-type ('MimeType') + -> Pet -- ^ "body" - Pet object that needs to be added to the store + -> SwaggerPetstoreRequest UpdatePet contentType res +updatePet _ body = + _mkRequest "PUT" ["/pet"] + `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) + `setBodyParam` body + +data UpdatePet + +-- | /Body Param/ "body" - Pet object that needs to be added to the store +instance HasBodyParam UpdatePet Pet + +-- | @application/json@ +instance Consumes UpdatePet MimeJSON +-- | @application/xml@ +instance Consumes UpdatePet MimeXML + +-- | @application/xml@ +instance Produces UpdatePet MimeXML +-- | @application/json@ +instance Produces UpdatePet MimeJSON + + +-- *** updatePetWithForm --- | /Optional Param/ "status" - Updated status of the pet -instance HasOptionalParam UpdatePetWithForm StatusText where - applyOptionalParam req (StatusText xs) = - req `addForm` toForm ("status", xs) - --- | @application/x-www-form-urlencoded@ -instance Consumes UpdatePetWithForm MimeFormUrlEncoded - --- | @application/xml@ -instance Produces UpdatePetWithForm MimeXML --- | @application/json@ -instance Produces UpdatePetWithForm MimeJSON - - --- *** uploadFile - --- | @POST \/pet\/{petId}\/uploadImage@ --- --- uploads an image --- --- --- --- AuthMethod: 'AuthOAuthPetstoreAuth' --- -uploadFile - :: (Consumes UploadFile contentType) - => contentType -- ^ request content-type ('MimeType') - -> PetId -- ^ "petId" - ID of pet to update - -> SwaggerPetstoreRequest UploadFile contentType ApiResponse -uploadFile _ (PetId petId) = - _mkRequest "POST" ["/pet/",toPath petId,"/uploadImage"] - `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) - -data UploadFile - --- | /Optional Param/ "additionalMetadata" - Additional data to pass to server -instance HasOptionalParam UploadFile AdditionalMetadata where - applyOptionalParam req (AdditionalMetadata xs) = - req `_addMultiFormPart` NH.partLBS "additionalMetadata" (mimeRender' MimeMultipartFormData xs) +-- | @POST \/pet\/{petId}@ +-- +-- Updates a pet in the store with form data +-- +-- +-- +-- AuthMethod: 'AuthOAuthPetstoreAuth' +-- +-- Note: Has 'Produces' instances, but no response schema +-- +updatePetWithForm + :: (Consumes UpdatePetWithForm contentType) + => contentType -- ^ request content-type ('MimeType') + -> PetId -- ^ "petId" - ID of pet that needs to be updated + -> SwaggerPetstoreRequest UpdatePetWithForm contentType res +updatePetWithForm _ (PetId petId) = + _mkRequest "POST" ["/pet/",toPath petId] + `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) + +data UpdatePetWithForm + +-- | /Optional Param/ "name" - Updated name of the pet +instance HasOptionalParam UpdatePetWithForm Name2 where + applyOptionalParam req (Name2 xs) = + req `addForm` toForm ("name", xs) + +-- | /Optional Param/ "status" - Updated status of the pet +instance HasOptionalParam UpdatePetWithForm StatusText where + applyOptionalParam req (StatusText xs) = + req `addForm` toForm ("status", xs) + +-- | @application/x-www-form-urlencoded@ +instance Consumes UpdatePetWithForm MimeFormUrlEncoded + +-- | @application/xml@ +instance Produces UpdatePetWithForm MimeXML +-- | @application/json@ +instance Produces UpdatePetWithForm MimeJSON + --- | /Optional Param/ "file" - file to upload -instance HasOptionalParam UploadFile File where - applyOptionalParam req (File xs) = - req `_addMultiFormPart` NH.partFileSource "file" xs - --- | @multipart/form-data@ -instance Consumes UploadFile MimeMultipartFormData - --- | @application/json@ -instance Produces UploadFile MimeJSON - - --- ** Store - --- *** deleteOrder - --- | @DELETE \/store\/order\/{order_id}@ --- --- Delete purchase order by ID --- --- For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors --- --- Note: Has 'Produces' instances, but no response schema --- -deleteOrder - :: OrderIdText -- ^ "orderId" - ID of the order that needs to be deleted - -> SwaggerPetstoreRequest DeleteOrder MimeNoContent res -deleteOrder (OrderIdText orderId) = - _mkRequest "DELETE" ["/store/order/",toPath orderId] - -data DeleteOrder --- | @application/xml@ -instance Produces DeleteOrder MimeXML --- | @application/json@ -instance Produces DeleteOrder MimeJSON - +-- *** uploadFile + +-- | @POST \/pet\/{petId}\/uploadImage@ +-- +-- uploads an image +-- +-- +-- +-- AuthMethod: 'AuthOAuthPetstoreAuth' +-- +uploadFile + :: (Consumes UploadFile contentType) + => contentType -- ^ request content-type ('MimeType') + -> PetId -- ^ "petId" - ID of pet to update + -> SwaggerPetstoreRequest UploadFile contentType ApiResponse +uploadFile _ (PetId petId) = + _mkRequest "POST" ["/pet/",toPath petId,"/uploadImage"] + `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) + +data UploadFile + +-- | /Optional Param/ "additionalMetadata" - Additional data to pass to server +instance HasOptionalParam UploadFile AdditionalMetadata where + applyOptionalParam req (AdditionalMetadata xs) = + req `_addMultiFormPart` NH.partLBS "additionalMetadata" (mimeRender' MimeMultipartFormData xs) + +-- | /Optional Param/ "file" - file to upload +instance HasOptionalParam UploadFile File where + applyOptionalParam req (File xs) = + req `_addMultiFormPart` NH.partFileSource "file" xs + +-- | @multipart/form-data@ +instance Consumes UploadFile MimeMultipartFormData + +-- | @application/json@ +instance Produces UploadFile MimeJSON --- *** getInventory - --- | @GET \/store\/inventory@ --- --- Returns pet inventories by status --- --- Returns a map of status codes to quantities --- --- AuthMethod: 'AuthApiKeyApiKey' --- -getInventory - :: SwaggerPetstoreRequest GetInventory MimeNoContent ((Map.Map String Int)) -getInventory = - _mkRequest "GET" ["/store/inventory"] - `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKey) - -data GetInventory --- | @application/json@ -instance Produces GetInventory MimeJSON - - --- *** getOrderById - --- | @GET \/store\/order\/{order_id}@ --- --- Find purchase order by ID --- --- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions --- -getOrderById - :: OrderId -- ^ "orderId" - ID of pet that needs to be fetched - -> SwaggerPetstoreRequest GetOrderById MimeNoContent Order -getOrderById (OrderId orderId) = - _mkRequest "GET" ["/store/order/",toPath orderId] - -data GetOrderById --- | @application/xml@ -instance Produces GetOrderById MimeXML --- | @application/json@ -instance Produces GetOrderById MimeJSON - + +-- ** Store + +-- *** deleteOrder + +-- | @DELETE \/store\/order\/{order_id}@ +-- +-- Delete purchase order by ID +-- +-- For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors +-- +-- Note: Has 'Produces' instances, but no response schema +-- +deleteOrder + :: OrderIdText -- ^ "orderId" - ID of the order that needs to be deleted + -> SwaggerPetstoreRequest DeleteOrder MimeNoContent res +deleteOrder (OrderIdText orderId) = + _mkRequest "DELETE" ["/store/order/",toPath orderId] + +data DeleteOrder +-- | @application/xml@ +instance Produces DeleteOrder MimeXML +-- | @application/json@ +instance Produces DeleteOrder MimeJSON + + +-- *** getInventory + +-- | @GET \/store\/inventory@ +-- +-- Returns pet inventories by status +-- +-- Returns a map of status codes to quantities +-- +-- AuthMethod: 'AuthApiKeyApiKey' +-- +getInventory + :: SwaggerPetstoreRequest GetInventory MimeNoContent ((Map.Map String Int)) +getInventory = + _mkRequest "GET" ["/store/inventory"] + `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKey) --- *** placeOrder - --- | @POST \/store\/order@ --- --- Place an order for a pet --- --- --- -placeOrder - :: (Consumes PlaceOrder contentType, MimeRender contentType Order) - => contentType -- ^ request content-type ('MimeType') - -> Order -- ^ "body" - order placed for purchasing the pet - -> SwaggerPetstoreRequest PlaceOrder contentType Order -placeOrder _ body = - _mkRequest "POST" ["/store/order"] - `setBodyParam` body - -data PlaceOrder +data GetInventory +-- | @application/json@ +instance Produces GetInventory MimeJSON + + +-- *** getOrderById + +-- | @GET \/store\/order\/{order_id}@ +-- +-- Find purchase order by ID +-- +-- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions +-- +getOrderById + :: OrderId -- ^ "orderId" - ID of pet that needs to be fetched + -> SwaggerPetstoreRequest GetOrderById MimeNoContent Order +getOrderById (OrderId orderId) = + _mkRequest "GET" ["/store/order/",toPath orderId] --- | /Body Param/ "body" - order placed for purchasing the pet -instance HasBodyParam PlaceOrder Order --- | @application/xml@ -instance Produces PlaceOrder MimeXML --- | @application/json@ -instance Produces PlaceOrder MimeJSON +data GetOrderById +-- | @application/xml@ +instance Produces GetOrderById MimeXML +-- | @application/json@ +instance Produces GetOrderById MimeJSON + - --- ** User - --- *** createUser - --- | @POST \/user@ +-- *** placeOrder + +-- | @POST \/store\/order@ +-- +-- Place an order for a pet +-- -- --- Create user --- --- This can only be done by the logged in user. --- --- Note: Has 'Produces' instances, but no response schema --- -createUser - :: (Consumes CreateUser contentType, MimeRender contentType User) - => contentType -- ^ request content-type ('MimeType') - -> User -- ^ "body" - Created user object - -> SwaggerPetstoreRequest CreateUser contentType res -createUser _ body = - _mkRequest "POST" ["/user"] - `setBodyParam` body - -data CreateUser - --- | /Body Param/ "body" - Created user object -instance HasBodyParam CreateUser User --- | @application/xml@ -instance Produces CreateUser MimeXML --- | @application/json@ -instance Produces CreateUser MimeJSON +-- +placeOrder + :: (Consumes PlaceOrder contentType, MimeRender contentType Order) + => contentType -- ^ request content-type ('MimeType') + -> Order -- ^ "body" - order placed for purchasing the pet + -> SwaggerPetstoreRequest PlaceOrder contentType Order +placeOrder _ body = + _mkRequest "POST" ["/store/order"] + `setBodyParam` body + +data PlaceOrder + +-- | /Body Param/ "body" - order placed for purchasing the pet +instance HasBodyParam PlaceOrder Order +-- | @application/xml@ +instance Produces PlaceOrder MimeXML +-- | @application/json@ +instance Produces PlaceOrder MimeJSON + + +-- ** User + +-- *** createUser - --- *** createUsersWithArrayInput - --- | @POST \/user\/createWithArray@ --- --- Creates list of users with given input array --- +-- | @POST \/user@ +-- +-- Create user +-- +-- This can only be done by the logged in user. +-- +-- Note: Has 'Produces' instances, but no response schema -- --- --- Note: Has 'Produces' instances, but no response schema --- -createUsersWithArrayInput - :: (Consumes CreateUsersWithArrayInput contentType, MimeRender contentType Body) - => contentType -- ^ request content-type ('MimeType') - -> Body -- ^ "body" - List of user object - -> SwaggerPetstoreRequest CreateUsersWithArrayInput contentType res -createUsersWithArrayInput _ body = - _mkRequest "POST" ["/user/createWithArray"] - `setBodyParam` body - -data CreateUsersWithArrayInput - --- | /Body Param/ "body" - List of user object -instance HasBodyParam CreateUsersWithArrayInput Body --- | @application/xml@ -instance Produces CreateUsersWithArrayInput MimeXML --- | @application/json@ -instance Produces CreateUsersWithArrayInput MimeJSON +createUser + :: (Consumes CreateUser contentType, MimeRender contentType User) + => contentType -- ^ request content-type ('MimeType') + -> User -- ^ "body" - Created user object + -> SwaggerPetstoreRequest CreateUser contentType res +createUser _ body = + _mkRequest "POST" ["/user"] + `setBodyParam` body + +data CreateUser + +-- | /Body Param/ "body" - Created user object +instance HasBodyParam CreateUser User +-- | @application/xml@ +instance Produces CreateUser MimeXML +-- | @application/json@ +instance Produces CreateUser MimeJSON + + +-- *** createUsersWithArrayInput - --- *** createUsersWithListInput - --- | @POST \/user\/createWithList@ +-- | @POST \/user\/createWithArray@ +-- +-- Creates list of users with given input array +-- -- --- Creates list of users with given input array --- +-- +-- Note: Has 'Produces' instances, but no response schema -- --- --- Note: Has 'Produces' instances, but no response schema --- -createUsersWithListInput - :: (Consumes CreateUsersWithListInput contentType, MimeRender contentType Body) - => contentType -- ^ request content-type ('MimeType') - -> Body -- ^ "body" - List of user object - -> SwaggerPetstoreRequest CreateUsersWithListInput contentType res -createUsersWithListInput _ body = - _mkRequest "POST" ["/user/createWithList"] - `setBodyParam` body - -data CreateUsersWithListInput - --- | /Body Param/ "body" - List of user object -instance HasBodyParam CreateUsersWithListInput Body --- | @application/xml@ -instance Produces CreateUsersWithListInput MimeXML --- | @application/json@ -instance Produces CreateUsersWithListInput MimeJSON +createUsersWithArrayInput + :: (Consumes CreateUsersWithArrayInput contentType, MimeRender contentType Body) + => contentType -- ^ request content-type ('MimeType') + -> Body -- ^ "body" - List of user object + -> SwaggerPetstoreRequest CreateUsersWithArrayInput contentType res +createUsersWithArrayInput _ body = + _mkRequest "POST" ["/user/createWithArray"] + `setBodyParam` body + +data CreateUsersWithArrayInput + +-- | /Body Param/ "body" - List of user object +instance HasBodyParam CreateUsersWithArrayInput Body +-- | @application/xml@ +instance Produces CreateUsersWithArrayInput MimeXML +-- | @application/json@ +instance Produces CreateUsersWithArrayInput MimeJSON + + +-- *** createUsersWithListInput - --- *** deleteUser - --- | @DELETE \/user\/{username}@ +-- | @POST \/user\/createWithList@ +-- +-- Creates list of users with given input array +-- -- --- Delete user --- --- This can only be done by the logged in user. --- --- Note: Has 'Produces' instances, but no response schema --- -deleteUser - :: Username -- ^ "username" - The name that needs to be deleted - -> SwaggerPetstoreRequest DeleteUser MimeNoContent res -deleteUser (Username username) = - _mkRequest "DELETE" ["/user/",toPath username] +-- +-- Note: Has 'Produces' instances, but no response schema +-- +createUsersWithListInput + :: (Consumes CreateUsersWithListInput contentType, MimeRender contentType Body) + => contentType -- ^ request content-type ('MimeType') + -> Body -- ^ "body" - List of user object + -> SwaggerPetstoreRequest CreateUsersWithListInput contentType res +createUsersWithListInput _ body = + _mkRequest "POST" ["/user/createWithList"] + `setBodyParam` body -data DeleteUser --- | @application/xml@ -instance Produces DeleteUser MimeXML --- | @application/json@ -instance Produces DeleteUser MimeJSON - - --- *** getUserByName +data CreateUsersWithListInput + +-- | /Body Param/ "body" - List of user object +instance HasBodyParam CreateUsersWithListInput Body +-- | @application/xml@ +instance Produces CreateUsersWithListInput MimeXML +-- | @application/json@ +instance Produces CreateUsersWithListInput MimeJSON --- | @GET \/user\/{username}@ --- --- Get user by user name --- + +-- *** deleteUser + +-- | @DELETE \/user\/{username}@ -- --- -getUserByName - :: Username -- ^ "username" - The name that needs to be fetched. Use user1 for testing. - -> SwaggerPetstoreRequest GetUserByName MimeNoContent User -getUserByName (Username username) = - _mkRequest "GET" ["/user/",toPath username] - -data GetUserByName --- | @application/xml@ -instance Produces GetUserByName MimeXML --- | @application/json@ -instance Produces GetUserByName MimeJSON - - --- *** loginUser - --- | @GET \/user\/login@ --- --- Logs user into the system --- --- --- -loginUser - :: Username -- ^ "username" - The user name for login - -> Password -- ^ "password" - The password for login in clear text - -> SwaggerPetstoreRequest LoginUser MimeNoContent Text -loginUser (Username username) (Password password) = - _mkRequest "GET" ["/user/login"] - `setQuery` toQuery ("username", Just username) - `setQuery` toQuery ("password", Just password) - -data LoginUser --- | @application/xml@ -instance Produces LoginUser MimeXML --- | @application/json@ -instance Produces LoginUser MimeJSON - - --- *** logoutUser +-- Delete user +-- +-- This can only be done by the logged in user. +-- +-- Note: Has 'Produces' instances, but no response schema +-- +deleteUser + :: Username -- ^ "username" - The name that needs to be deleted + -> SwaggerPetstoreRequest DeleteUser MimeNoContent res +deleteUser (Username username) = + _mkRequest "DELETE" ["/user/",toPath username] + +data DeleteUser +-- | @application/xml@ +instance Produces DeleteUser MimeXML +-- | @application/json@ +instance Produces DeleteUser MimeJSON + + +-- *** getUserByName + +-- | @GET \/user\/{username}@ +-- +-- Get user by user name +-- +-- +-- +getUserByName + :: Username -- ^ "username" - The name that needs to be fetched. Use user1 for testing. + -> SwaggerPetstoreRequest GetUserByName MimeNoContent User +getUserByName (Username username) = + _mkRequest "GET" ["/user/",toPath username] + +data GetUserByName +-- | @application/xml@ +instance Produces GetUserByName MimeXML +-- | @application/json@ +instance Produces GetUserByName MimeJSON + --- | @GET \/user\/logout@ --- --- Logs out current logged in user session +-- *** loginUser + +-- | @GET \/user\/login@ -- --- +-- Logs user into the system -- --- Note: Has 'Produces' instances, but no response schema +-- -- -logoutUser - :: SwaggerPetstoreRequest LogoutUser MimeNoContent res -logoutUser = - _mkRequest "GET" ["/user/logout"] - -data LogoutUser --- | @application/xml@ -instance Produces LogoutUser MimeXML --- | @application/json@ -instance Produces LogoutUser MimeJSON - - --- *** updateUser - --- | @PUT \/user\/{username}@ --- --- Updated user --- --- This can only be done by the logged in user. +loginUser + :: Username -- ^ "username" - The user name for login + -> Password -- ^ "password" - The password for login in clear text + -> SwaggerPetstoreRequest LoginUser MimeNoContent Text +loginUser (Username username) (Password password) = + _mkRequest "GET" ["/user/login"] + `setQuery` toQuery ("username", Just username) + `setQuery` toQuery ("password", Just password) + +data LoginUser +-- | @application/xml@ +instance Produces LoginUser MimeXML +-- | @application/json@ +instance Produces LoginUser MimeJSON + + +-- *** logoutUser + +-- | @GET \/user\/logout@ -- --- Note: Has 'Produces' instances, but no response schema +-- Logs out current logged in user session -- -updateUser - :: (Consumes UpdateUser contentType, MimeRender contentType User) - => contentType -- ^ request content-type ('MimeType') - -> Username -- ^ "username" - name that need to be deleted - -> User -- ^ "body" - Updated user object - -> SwaggerPetstoreRequest UpdateUser contentType res -updateUser _ (Username username) body = - _mkRequest "PUT" ["/user/",toPath username] - `setBodyParam` body - -data UpdateUser - --- | /Body Param/ "body" - Updated user object -instance HasBodyParam UpdateUser User --- | @application/xml@ -instance Produces UpdateUser MimeXML --- | @application/json@ -instance Produces UpdateUser MimeJSON - - - --- * Parameter newtypes - -newtype AdditionalMetadata = AdditionalMetadata { unAdditionalMetadata :: Text } deriving (P.Eq, P.Show) -newtype ApiKey = ApiKey { unApiKey :: Text } deriving (P.Eq, P.Show) -newtype Body = Body { unBody :: [User] } deriving (P.Eq, P.Show, A.ToJSON) -newtype Byte = Byte { unByte :: ByteArray } deriving (P.Eq, P.Show) -newtype Callback = Callback { unCallback :: Text } deriving (P.Eq, P.Show) -newtype EnumFormString = EnumFormString { unEnumFormString :: Text } deriving (P.Eq, P.Show) -newtype EnumFormStringArray = EnumFormStringArray { unEnumFormStringArray :: [Text] } deriving (P.Eq, P.Show) -newtype EnumHeaderString = EnumHeaderString { unEnumHeaderString :: Text } deriving (P.Eq, P.Show) -newtype EnumHeaderStringArray = EnumHeaderStringArray { unEnumHeaderStringArray :: [Text] } deriving (P.Eq, P.Show) -newtype EnumQueryDouble = EnumQueryDouble { unEnumQueryDouble :: Double } deriving (P.Eq, P.Show) -newtype EnumQueryInteger = EnumQueryInteger { unEnumQueryInteger :: Int } deriving (P.Eq, P.Show) -newtype EnumQueryString = EnumQueryString { unEnumQueryString :: Text } deriving (P.Eq, P.Show) -newtype EnumQueryStringArray = EnumQueryStringArray { unEnumQueryStringArray :: [Text] } deriving (P.Eq, P.Show) -newtype File = File { unFile :: FilePath } deriving (P.Eq, P.Show) -newtype Int32 = Int32 { unInt32 :: Int } deriving (P.Eq, P.Show) -newtype Int64 = Int64 { unInt64 :: Integer } deriving (P.Eq, P.Show) -newtype Name2 = Name2 { unName2 :: Text } deriving (P.Eq, P.Show) -newtype Number = Number { unNumber :: Double } deriving (P.Eq, P.Show) -newtype OrderId = OrderId { unOrderId :: Integer } deriving (P.Eq, P.Show) -newtype OrderIdText = OrderIdText { unOrderIdText :: Text } deriving (P.Eq, P.Show) -newtype Param = Param { unParam :: Text } deriving (P.Eq, P.Show) -newtype Param2 = Param2 { unParam2 :: Text } deriving (P.Eq, P.Show) -newtype ParamBinary = ParamBinary { unParamBinary :: Binary } deriving (P.Eq, P.Show) -newtype ParamDate = ParamDate { unParamDate :: Date } deriving (P.Eq, P.Show) -newtype ParamDateTime = ParamDateTime { unParamDateTime :: DateTime } deriving (P.Eq, P.Show) -newtype ParamDouble = ParamDouble { unParamDouble :: Double } deriving (P.Eq, P.Show) -newtype ParamFloat = ParamFloat { unParamFloat :: Float } deriving (P.Eq, P.Show) -newtype ParamInteger = ParamInteger { unParamInteger :: Int } deriving (P.Eq, P.Show) -newtype ParamString = ParamString { unParamString :: Text } deriving (P.Eq, P.Show) -newtype Password = Password { unPassword :: Text } deriving (P.Eq, P.Show) -newtype PatternWithoutDelimiter = PatternWithoutDelimiter { unPatternWithoutDelimiter :: Text } deriving (P.Eq, P.Show) -newtype PetId = PetId { unPetId :: Integer } deriving (P.Eq, P.Show) -newtype Status = Status { unStatus :: [Text] } deriving (P.Eq, P.Show) -newtype StatusText = StatusText { unStatusText :: Text } deriving (P.Eq, P.Show) -newtype Tags = Tags { unTags :: [Text] } deriving (P.Eq, P.Show) -newtype Username = Username { unUsername :: Text } deriving (P.Eq, P.Show) - --- * Auth Methods - --- ** AuthApiKeyApiKey -data AuthApiKeyApiKey = - AuthApiKeyApiKey Text -- ^ secret - deriving (P.Eq, P.Show, P.Typeable) - -instance AuthMethod AuthApiKeyApiKey where - applyAuthMethod _ a@(AuthApiKeyApiKey secret) req = - P.pure $ - if (P.typeOf a `P.elem` rAuthTypes req) - then req `setHeader` toHeader ("api_key", secret) - & L.over rAuthTypesL (P.filter (/= P.typeOf a)) - else req - --- ** AuthApiKeyApiKeyQuery -data AuthApiKeyApiKeyQuery = - AuthApiKeyApiKeyQuery Text -- ^ secret - deriving (P.Eq, P.Show, P.Typeable) - -instance AuthMethod AuthApiKeyApiKeyQuery where - applyAuthMethod _ a@(AuthApiKeyApiKeyQuery secret) req = - P.pure $ - if (P.typeOf a `P.elem` rAuthTypes req) - then req `setQuery` toQuery ("api_key_query", Just secret) - & L.over rAuthTypesL (P.filter (/= P.typeOf a)) - else req +-- +-- +-- Note: Has 'Produces' instances, but no response schema +-- +logoutUser + :: SwaggerPetstoreRequest LogoutUser MimeNoContent res +logoutUser = + _mkRequest "GET" ["/user/logout"] + +data LogoutUser +-- | @application/xml@ +instance Produces LogoutUser MimeXML +-- | @application/json@ +instance Produces LogoutUser MimeJSON + + +-- *** updateUser + +-- | @PUT \/user\/{username}@ +-- +-- Updated user +-- +-- This can only be done by the logged in user. +-- +-- Note: Has 'Produces' instances, but no response schema +-- +updateUser + :: (Consumes UpdateUser contentType, MimeRender contentType User) + => contentType -- ^ request content-type ('MimeType') + -> Username -- ^ "username" - name that need to be deleted + -> User -- ^ "body" - Updated user object + -> SwaggerPetstoreRequest UpdateUser contentType res +updateUser _ (Username username) body = + _mkRequest "PUT" ["/user/",toPath username] + `setBodyParam` body + +data UpdateUser + +-- | /Body Param/ "body" - Updated user object +instance HasBodyParam UpdateUser User +-- | @application/xml@ +instance Produces UpdateUser MimeXML +-- | @application/json@ +instance Produces UpdateUser MimeJSON + + + +-- * Parameter newtypes + +newtype AdditionalMetadata = AdditionalMetadata { unAdditionalMetadata :: Text } deriving (P.Eq, P.Show) +newtype ApiKey = ApiKey { unApiKey :: Text } deriving (P.Eq, P.Show) +newtype Body = Body { unBody :: [User] } deriving (P.Eq, P.Show, A.ToJSON) +newtype Byte = Byte { unByte :: ByteArray } deriving (P.Eq, P.Show) +newtype Callback = Callback { unCallback :: Text } deriving (P.Eq, P.Show) +newtype EnumFormString = EnumFormString { unEnumFormString :: E'EnumFormString } deriving (P.Eq, P.Show) +newtype EnumFormStringArray = EnumFormStringArray { unEnumFormStringArray :: [E'Inner2] } deriving (P.Eq, P.Show) +newtype EnumHeaderString = EnumHeaderString { unEnumHeaderString :: E'EnumFormString } deriving (P.Eq, P.Show) +newtype EnumHeaderStringArray = EnumHeaderStringArray { unEnumHeaderStringArray :: [E'Inner2] } deriving (P.Eq, P.Show) +newtype EnumQueryDouble = EnumQueryDouble { unEnumQueryDouble :: E'EnumNumber } deriving (P.Eq, P.Show) +newtype EnumQueryInteger = EnumQueryInteger { unEnumQueryInteger :: E'EnumQueryInteger } deriving (P.Eq, P.Show) +newtype EnumQueryString = EnumQueryString { unEnumQueryString :: E'EnumFormString } deriving (P.Eq, P.Show) +newtype EnumQueryStringArray = EnumQueryStringArray { unEnumQueryStringArray :: [E'Inner2] } deriving (P.Eq, P.Show) +newtype File = File { unFile :: FilePath } deriving (P.Eq, P.Show) +newtype Int32 = Int32 { unInt32 :: Int } deriving (P.Eq, P.Show) +newtype Int64 = Int64 { unInt64 :: Integer } deriving (P.Eq, P.Show) +newtype Name2 = Name2 { unName2 :: Text } deriving (P.Eq, P.Show) +newtype Number = Number { unNumber :: Double } deriving (P.Eq, P.Show) +newtype OrderId = OrderId { unOrderId :: Integer } deriving (P.Eq, P.Show) +newtype OrderIdText = OrderIdText { unOrderIdText :: Text } deriving (P.Eq, P.Show) +newtype Param = Param { unParam :: Text } deriving (P.Eq, P.Show) +newtype Param2 = Param2 { unParam2 :: Text } deriving (P.Eq, P.Show) +newtype ParamBinary = ParamBinary { unParamBinary :: Binary } deriving (P.Eq, P.Show) +newtype ParamDate = ParamDate { unParamDate :: Date } deriving (P.Eq, P.Show) +newtype ParamDateTime = ParamDateTime { unParamDateTime :: DateTime } deriving (P.Eq, P.Show) +newtype ParamDouble = ParamDouble { unParamDouble :: Double } deriving (P.Eq, P.Show) +newtype ParamFloat = ParamFloat { unParamFloat :: Float } deriving (P.Eq, P.Show) +newtype ParamInteger = ParamInteger { unParamInteger :: Int } deriving (P.Eq, P.Show) +newtype ParamString = ParamString { unParamString :: Text } deriving (P.Eq, P.Show) +newtype Password = Password { unPassword :: Text } deriving (P.Eq, P.Show) +newtype PatternWithoutDelimiter = PatternWithoutDelimiter { unPatternWithoutDelimiter :: Text } deriving (P.Eq, P.Show) +newtype PetId = PetId { unPetId :: Integer } deriving (P.Eq, P.Show) +newtype Status = Status { unStatus :: [E'Status2] } deriving (P.Eq, P.Show) +newtype StatusText = StatusText { unStatusText :: Text } deriving (P.Eq, P.Show) +newtype Tags = Tags { unTags :: [Text] } deriving (P.Eq, P.Show) +newtype Username = Username { unUsername :: Text } deriving (P.Eq, P.Show) + +-- * Auth Methods --- ** AuthBasicHttpBasicTest -data AuthBasicHttpBasicTest = - AuthBasicHttpBasicTest B.ByteString B.ByteString -- ^ username password +-- ** AuthApiKeyApiKey +data AuthApiKeyApiKey = + AuthApiKeyApiKey Text -- ^ secret deriving (P.Eq, P.Show, P.Typeable) -instance AuthMethod AuthBasicHttpBasicTest where - applyAuthMethod _ a@(AuthBasicHttpBasicTest user pw) req = +instance AuthMethod AuthApiKeyApiKey where + applyAuthMethod _ a@(AuthApiKeyApiKey secret) req = P.pure $ - if (P.typeOf a `P.elem` rAuthTypes req) - then req `setHeader` toHeader ("Authorization", T.decodeUtf8 cred) - & L.over rAuthTypesL (P.filter (/= P.typeOf a)) - else req - where cred = BC.append "Basic " (B64.encode $ BC.concat [ user, ":", pw ]) - --- ** AuthOAuthPetstoreAuth -data AuthOAuthPetstoreAuth = - AuthOAuthPetstoreAuth Text -- ^ secret - deriving (P.Eq, P.Show, P.Typeable) - -instance AuthMethod AuthOAuthPetstoreAuth where - applyAuthMethod _ a@(AuthOAuthPetstoreAuth secret) req = - P.pure $ - if (P.typeOf a `P.elem` rAuthTypes req) - then req `setHeader` toHeader ("Authorization", "Bearer " <> secret) - & L.over rAuthTypesL (P.filter (/= P.typeOf a)) - else req - - - --- * Custom Mime Types + if (P.typeOf a `P.elem` rAuthTypes req) + then req `setHeader` toHeader ("api_key", secret) + & L.over rAuthTypesL (P.filter (/= P.typeOf a)) + else req + +-- ** AuthApiKeyApiKeyQuery +data AuthApiKeyApiKeyQuery = + AuthApiKeyApiKeyQuery Text -- ^ secret + deriving (P.Eq, P.Show, P.Typeable) + +instance AuthMethod AuthApiKeyApiKeyQuery where + applyAuthMethod _ a@(AuthApiKeyApiKeyQuery secret) req = + P.pure $ + if (P.typeOf a `P.elem` rAuthTypes req) + then req `setQuery` toQuery ("api_key_query", Just secret) + & L.over rAuthTypesL (P.filter (/= P.typeOf a)) + else req + +-- ** AuthBasicHttpBasicTest +data AuthBasicHttpBasicTest = + AuthBasicHttpBasicTest B.ByteString B.ByteString -- ^ username password + deriving (P.Eq, P.Show, P.Typeable) --- ** MimeJsonCharsetutf8 - -data MimeJsonCharsetutf8 = MimeJsonCharsetutf8 deriving (P.Typeable) - --- | @application/json; charset=utf-8@ -instance MimeType MimeJsonCharsetutf8 where - mimeType _ = Just $ P.fromString "application/json; charset=utf-8" -instance A.ToJSON a => MimeRender MimeJsonCharsetutf8 a where mimeRender _ = A.encode -instance A.FromJSON a => MimeUnrender MimeJsonCharsetutf8 a where mimeUnrender _ = A.eitherDecode --- instance MimeRender MimeJsonCharsetutf8 T.Text where mimeRender _ = undefined --- instance MimeUnrender MimeJsonCharsetutf8 T.Text where mimeUnrender _ = undefined - --- ** MimeXmlCharsetutf8 +instance AuthMethod AuthBasicHttpBasicTest where + applyAuthMethod _ a@(AuthBasicHttpBasicTest user pw) req = + P.pure $ + if (P.typeOf a `P.elem` rAuthTypes req) + then req `setHeader` toHeader ("Authorization", T.decodeUtf8 cred) + & L.over rAuthTypesL (P.filter (/= P.typeOf a)) + else req + where cred = BC.append "Basic " (B64.encode $ BC.concat [ user, ":", pw ]) + +-- ** AuthOAuthPetstoreAuth +data AuthOAuthPetstoreAuth = + AuthOAuthPetstoreAuth Text -- ^ secret + deriving (P.Eq, P.Show, P.Typeable) -data MimeXmlCharsetutf8 = MimeXmlCharsetutf8 deriving (P.Typeable) - --- | @application/xml; charset=utf-8@ -instance MimeType MimeXmlCharsetutf8 where - mimeType _ = Just $ P.fromString "application/xml; charset=utf-8" --- instance MimeRender MimeXmlCharsetutf8 T.Text where mimeRender _ = undefined --- instance MimeUnrender MimeXmlCharsetutf8 T.Text where mimeUnrender _ = undefined +instance AuthMethod AuthOAuthPetstoreAuth where + applyAuthMethod _ a@(AuthOAuthPetstoreAuth secret) req = + P.pure $ + if (P.typeOf a `P.elem` rAuthTypes req) + then req `setHeader` toHeader ("Authorization", "Bearer " <> secret) + & L.over rAuthTypesL (P.filter (/= P.typeOf a)) + else req - \ No newline at end of file + +-- * Custom Mime Types + +-- ** MimeJsonCharsetutf8 + +data MimeJsonCharsetutf8 = MimeJsonCharsetutf8 deriving (P.Typeable) + +-- | @application/json; charset=utf-8@ +instance MimeType MimeJsonCharsetutf8 where + mimeType _ = Just $ P.fromString "application/json; charset=utf-8" +instance A.ToJSON a => MimeRender MimeJsonCharsetutf8 a where mimeRender _ = A.encode +instance A.FromJSON a => MimeUnrender MimeJsonCharsetutf8 a where mimeUnrender _ = A.eitherDecode +-- instance MimeRender MimeJsonCharsetutf8 T.Text where mimeRender _ = undefined +-- instance MimeUnrender MimeJsonCharsetutf8 T.Text where mimeUnrender _ = undefined + +-- ** MimeXmlCharsetutf8 + +data MimeXmlCharsetutf8 = MimeXmlCharsetutf8 deriving (P.Typeable) + +-- | @application/xml; charset=utf-8@ +instance MimeType MimeXmlCharsetutf8 where + mimeType _ = Just $ P.fromString "application/xml; charset=utf-8" +-- instance MimeRender MimeXmlCharsetutf8 T.Text where mimeRender _ = undefined +-- instance MimeUnrender MimeXmlCharsetutf8 T.Text where mimeUnrender _ = undefined + + + \ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Client.html b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Client.html index 2c876b81d8a..210231032aa 100644 --- a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Client.html +++ b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Client.html @@ -56,21 +56,21 @@ Module : SwaggerPetstore.Client -- | send a request returning the raw http response dispatchLbs - :: (Produces req accept, MimeType contentType) + :: (Produces req accept, MimeType contentType) => NH.Manager -- ^ http-client Connection manager -> SwaggerPetstoreConfig -- ^ config - -> SwaggerPetstoreRequest req contentType res -- ^ request - -> accept -- ^ "accept" 'MimeType' + -> SwaggerPetstoreRequest req contentType res -- ^ request + -> accept -- ^ "accept" 'MimeType' -> IO (NH.Response BCL.ByteString) -- ^ response -dispatchLbs manager config request accept = do - initReq <- _toInitRequest config request accept - dispatchInitUnsafe manager config initReq +dispatchLbs manager config request accept = do + initReq <- _toInitRequest config request accept + dispatchInitUnsafe manager config initReq -- ** Mime -- | pair of decoded http body and http response -data MimeResult res = - MimeResult { mimeResult :: Either MimeError res -- ^ decoded http body +data MimeResult res = + MimeResult { mimeResult :: Either MimeError res -- ^ decoded http body , mimeResultResponse :: NH.Response BCL.ByteString -- ^ http response } deriving (Show, Functor, Foldable, Traversable) @@ -84,135 +84,135 @@ Module : SwaggerPetstore.Client -- | send a request returning the 'MimeResult' dispatchMime - :: (Produces req accept, MimeUnrender accept res, MimeType contentType) + :: (Produces req accept, MimeUnrender accept res, MimeType contentType) => NH.Manager -- ^ http-client Connection manager -> SwaggerPetstoreConfig -- ^ config - -> SwaggerPetstoreRequest req contentType res -- ^ request - -> accept -- ^ "accept" 'MimeType' - -> IO (MimeResult res) -- ^ response -dispatchMime manager config request accept = do - httpResponse <- dispatchLbs manager config request accept - parsedResult <- - runConfigLogWithExceptions "Client" config $ - do case mimeUnrender' accept (NH.responseBody httpResponse) of - Left s -> do - _log "Client" levelError (T.pack s) - pure (Left (MimeError s httpResponse)) - Right r -> pure (Right r) - return (MimeResult parsedResult httpResponse) + -> SwaggerPetstoreRequest req contentType res -- ^ request + -> accept -- ^ "accept" 'MimeType' + -> IO (MimeResult res) -- ^ response +dispatchMime manager config request accept = do + httpResponse <- dispatchLbs manager config request accept + parsedResult <- + runConfigLogWithExceptions "Client" config $ + do case mimeUnrender' accept (NH.responseBody httpResponse) of + Left s -> do + _log "Client" levelError (T.pack s) + pure (Left (MimeError s httpResponse)) + Right r -> pure (Right r) + return (MimeResult parsedResult httpResponse) -- | like 'dispatchMime', but only returns the decoded http body dispatchMime' - :: (Produces req accept, MimeUnrender accept res, MimeType contentType) + :: (Produces req accept, MimeUnrender accept res, MimeType contentType) => NH.Manager -- ^ http-client Connection manager -> SwaggerPetstoreConfig -- ^ config - -> SwaggerPetstoreRequest req contentType res -- ^ request - -> accept -- ^ "accept" 'MimeType' - -> IO (Either MimeError res) -- ^ response -dispatchMime' manager config request accept = do - MimeResult parsedResult _ <- dispatchMime manager config request accept - return parsedResult + -> SwaggerPetstoreRequest req contentType res -- ^ request + -> accept -- ^ "accept" 'MimeType' + -> IO (Either MimeError res) -- ^ response +dispatchMime' manager config request accept = do + MimeResult parsedResult _ <- dispatchMime manager config request accept + return parsedResult -- ** Unsafe -- | like 'dispatchReqLbs', but does not validate the operation is a 'Producer' of the "accept" 'MimeType'. (Useful if the server's response is undocumented) dispatchLbsUnsafe - :: (MimeType accept, MimeType contentType) + :: (MimeType accept, MimeType contentType) => NH.Manager -- ^ http-client Connection manager -> SwaggerPetstoreConfig -- ^ config - -> SwaggerPetstoreRequest req contentType res -- ^ request - -> accept -- ^ "accept" 'MimeType' + -> SwaggerPetstoreRequest req contentType res -- ^ request + -> accept -- ^ "accept" 'MimeType' -> IO (NH.Response BCL.ByteString) -- ^ response -dispatchLbsUnsafe manager config request accept = do - initReq <- _toInitRequest config request accept - dispatchInitUnsafe manager config initReq +dispatchLbsUnsafe manager config request accept = do + initReq <- _toInitRequest config request accept + dispatchInitUnsafe manager config initReq -- | dispatch an InitRequest dispatchInitUnsafe :: NH.Manager -- ^ http-client Connection manager -> SwaggerPetstoreConfig -- ^ config - -> InitRequest req contentType res accept -- ^ init request + -> InitRequest req contentType res accept -- ^ init request -> IO (NH.Response BCL.ByteString) -- ^ response -dispatchInitUnsafe manager config (InitRequest req) = do - runConfigLogWithExceptions src config $ - do _log src levelInfo requestLogMsg - _log src levelDebug requestDbgLogMsg - res <- P.liftIO $ NH.httpLbs req manager - _log src levelInfo (responseLogMsg res) - _log src levelDebug ((T.pack . show) res) - return res +dispatchInitUnsafe manager config (InitRequest req) = do + runConfigLogWithExceptions src config $ + do _log src levelInfo requestLogMsg + _log src levelDebug requestDbgLogMsg + res <- P.liftIO $ NH.httpLbs req manager + _log src levelInfo (responseLogMsg res) + _log src levelDebug ((T.pack . show) res) + return res where - src = "Client" - endpoint = + src = "Client" + endpoint = T.pack $ BC.unpack $ - NH.method req <> " " <> NH.host req <> NH.path req <> NH.queryString req - requestLogMsg = "REQ:" <> endpoint - requestDbgLogMsg = - "Headers=" <> (T.pack . show) (NH.requestHeaders req) <> " Body=" <> - (case NH.requestBody req of - NH.RequestBodyLBS xs -> T.decodeUtf8 (BL.toStrict xs) + NH.method req <> " " <> NH.host req <> NH.path req <> NH.queryString req + requestLogMsg = "REQ:" <> endpoint + requestDbgLogMsg = + "Headers=" <> (T.pack . show) (NH.requestHeaders req) <> " Body=" <> + (case NH.requestBody req of + NH.RequestBodyLBS xs -> T.decodeUtf8 (BL.toStrict xs) _ -> "<RequestBody>") - responseStatusCode = (T.pack . show) . NH.statusCode . NH.responseStatus - responseLogMsg res = - "RES:statusCode=" <> responseStatusCode res <> " (" <> endpoint <> ")" + responseStatusCode = (T.pack . show) . NH.statusCode . NH.responseStatus + responseLogMsg res = + "RES:statusCode=" <> responseStatusCode res <> " (" <> endpoint <> ")" -- * InitRequest -- | wraps an http-client 'Request' with request/response type parameters -newtype InitRequest req contentType res accept = InitRequest +newtype InitRequest req contentType res accept = InitRequest { unInitRequest :: NH.Request } deriving (Show) -- | Build an http-client 'Request' record from the supplied config and request _toInitRequest - :: (MimeType accept, MimeType contentType) + :: (MimeType accept, MimeType contentType) => SwaggerPetstoreConfig -- ^ config - -> SwaggerPetstoreRequest req contentType res -- ^ request - -> accept -- ^ "accept" 'MimeType' - -> IO (InitRequest req contentType res accept) -- ^ initialized request -_toInitRequest config req0 accept = - runConfigLogWithExceptions "Client" config $ do - parsedReq <- P.liftIO $ NH.parseRequest $ BCL.unpack $ BCL.append (configHost config) (BCL.concat (rUrlPath req0)) - req1 <- P.liftIO $ _applyAuthMethods req0 config + -> SwaggerPetstoreRequest req contentType res -- ^ request + -> accept -- ^ "accept" 'MimeType' + -> IO (InitRequest req contentType res accept) -- ^ initialized request +_toInitRequest config req0 accept = + runConfigLogWithExceptions "Client" config $ do + parsedReq <- P.liftIO $ NH.parseRequest $ BCL.unpack $ BCL.append (configHost config) (BCL.concat (rUrlPath req0)) + req1 <- P.liftIO $ _applyAuthMethods req0 config P.when - (configValidateAuthMethods config && (not . null . rAuthTypes) req1) - (E.throwString $ "AuthMethod not configured: " <> (show . head . rAuthTypes) req1) - let req2 = req1 & _setContentTypeHeader & flip _setAcceptHeader accept - reqHeaders = ("User-Agent", WH.toHeader (configUserAgent config)) : paramsHeaders (rParams req2) - reqQuery = NH.renderQuery True (paramsQuery (rParams req2)) - pReq = parsedReq { NH.method = (rMethod req2) - , NH.requestHeaders = reqHeaders - , NH.queryString = reqQuery + (configValidateAuthMethods config && (not . null . rAuthTypes) req1) + (E.throwString $ "AuthMethod not configured: " <> (show . head . rAuthTypes) req1) + let req2 = req1 & _setContentTypeHeader & flip _setAcceptHeader accept + reqHeaders = ("User-Agent", WH.toHeader (configUserAgent config)) : paramsHeaders (rParams req2) + reqQuery = NH.renderQuery True (paramsQuery (rParams req2)) + pReq = parsedReq { NH.method = (rMethod req2) + , NH.requestHeaders = reqHeaders + , NH.queryString = reqQuery } - outReq <- case paramsBody (rParams req2) of - ParamBodyNone -> pure (pReq { NH.requestBody = mempty }) - ParamBodyB bs -> pure (pReq { NH.requestBody = NH.RequestBodyBS bs }) - ParamBodyBL bl -> pure (pReq { NH.requestBody = NH.RequestBodyLBS bl }) - ParamBodyFormUrlEncoded form -> pure (pReq { NH.requestBody = NH.RequestBodyLBS (WH.urlEncodeForm form) }) - ParamBodyMultipartFormData parts -> NH.formDataBody parts pReq + outReq <- case paramsBody (rParams req2) of + ParamBodyNone -> pure (pReq { NH.requestBody = mempty }) + ParamBodyB bs -> pure (pReq { NH.requestBody = NH.RequestBodyBS bs }) + ParamBodyBL bl -> pure (pReq { NH.requestBody = NH.RequestBodyLBS bl }) + ParamBodyFormUrlEncoded form -> pure (pReq { NH.requestBody = NH.RequestBodyLBS (WH.urlEncodeForm form) }) + ParamBodyMultipartFormData parts -> NH.formDataBody parts pReq - pure (InitRequest outReq) + pure (InitRequest outReq) -- | modify the underlying Request -modifyInitRequest :: InitRequest req contentType res accept -> (NH.Request -> NH.Request) -> InitRequest req contentType res accept -modifyInitRequest (InitRequest req) f = InitRequest (f req) +modifyInitRequest :: InitRequest req contentType res accept -> (NH.Request -> NH.Request) -> InitRequest req contentType res accept +modifyInitRequest (InitRequest req) f = InitRequest (f req) -- | modify the underlying Request (monadic) -modifyInitRequestM :: Monad m => InitRequest req contentType res accept -> (NH.Request -> m NH.Request) -> m (InitRequest req contentType res accept) -modifyInitRequestM (InitRequest req) f = fmap InitRequest (f req) +modifyInitRequestM :: Monad m => InitRequest req contentType res accept -> (NH.Request -> m NH.Request) -> m (InitRequest req contentType res accept) +modifyInitRequestM (InitRequest req) f = fmap InitRequest (f req) -- ** Logging -- | Run a block using the configured logger instance runConfigLog - :: P.MonadIO m - => SwaggerPetstoreConfig -> LogExec m -runConfigLog config = configLogExecWithContext config (configLogContext config) + :: P.MonadIO m + => SwaggerPetstoreConfig -> LogExec m +runConfigLog config = configLogExecWithContext config (configLogContext config) -- | Run a block using the configured logger instance (logs exceptions) runConfigLogWithExceptions - :: (E.MonadCatch m, P.MonadIO m) - => T.Text -> SwaggerPetstoreConfig -> LogExec m -runConfigLogWithExceptions src config = runConfigLog config . logExceptions src + :: (E.MonadCatch m, P.MonadIO m) + => T.Text -> SwaggerPetstoreConfig -> LogExec m +runConfigLogWithExceptions src config = runConfigLog config . logExceptions src \ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Core.html b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Core.html index c170e868212..fc5e3493bbf 100644 --- a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Core.html +++ b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Core.html @@ -81,11 +81,11 @@ Module : SwaggerPetstore.Core -- | display the config instance P.Show SwaggerPetstoreConfig where - show c = + show c = T.printf "{ configHost = %v, configUserAgent = %v, ..}" - (show (configHost c)) - (show (configUserAgent c)) + (show (configHost c)) + (show (configUserAgent c)) -- | constructs a default SwaggerPetstoreConfig -- @@ -99,41 +99,41 @@ Module : SwaggerPetstore.Core -- newConfig :: IO SwaggerPetstoreConfig newConfig = do - logCxt <- initLogContext + logCxt <- initLogContext return $ SwaggerPetstoreConfig { configHost = "http://petstore.swagger.io:80/v2" , configUserAgent = "swagger-haskell-http-client/1.0.0" , configLogExecWithContext = runDefaultLogExecWithContext - , configLogContext = logCxt + , configLogContext = logCxt , configAuthMethods = [] , configValidateAuthMethods = True } -- | updates config use AuthMethod on matching requests -addAuthMethod :: AuthMethod auth => SwaggerPetstoreConfig -> auth -> SwaggerPetstoreConfig -addAuthMethod config@SwaggerPetstoreConfig {configAuthMethods = as} a = - config { configAuthMethods = AnyAuthMethod a : as} +addAuthMethod :: AuthMethod auth => SwaggerPetstoreConfig -> auth -> SwaggerPetstoreConfig +addAuthMethod config@SwaggerPetstoreConfig {configAuthMethods = as} a = + config { configAuthMethods = AnyAuthMethod a : as} -- | updates the config to use stdout logging withStdoutLogging :: SwaggerPetstoreConfig -> IO SwaggerPetstoreConfig -withStdoutLogging p = do - logCxt <- stdoutLoggingContext (configLogContext p) - return $ p { configLogExecWithContext = stdoutLoggingExec, configLogContext = logCxt } +withStdoutLogging p = do + logCxt <- stdoutLoggingContext (configLogContext p) + return $ p { configLogExecWithContext = stdoutLoggingExec, configLogContext = logCxt } -- | updates the config to use stderr logging withStderrLogging :: SwaggerPetstoreConfig -> IO SwaggerPetstoreConfig -withStderrLogging p = do - logCxt <- stderrLoggingContext (configLogContext p) - return $ p { configLogExecWithContext = stderrLoggingExec, configLogContext = logCxt } +withStderrLogging p = do + logCxt <- stderrLoggingContext (configLogContext p) + return $ p { configLogExecWithContext = stderrLoggingExec, configLogContext = logCxt } -- | updates the config to disable logging withNoLogging :: SwaggerPetstoreConfig -> SwaggerPetstoreConfig -withNoLogging p = p { configLogExecWithContext = runNullLogExec} +withNoLogging p = p { configLogExecWithContext = runNullLogExec} -- * SwaggerPetstoreRequest -- | Represents a request. The "req" type variable is the request type. The "res" type variable is the response type. -data SwaggerPetstoreRequest req contentType res = SwaggerPetstoreRequest +data SwaggerPetstoreRequest req contentType res = SwaggerPetstoreRequest { rMethod :: NH.Method -- ^ Method of SwaggerPetstoreRequest , rUrlPath :: [BCL.ByteString] -- ^ Endpoint of SwaggerPetstoreRequest , rParams :: Params -- ^ params of SwaggerPetstoreRequest @@ -142,47 +142,47 @@ Module : SwaggerPetstore.Core deriving (P.Show) -- | 'rMethod' Lens -rMethodL :: Lens_' (SwaggerPetstoreRequest req contentType res) NH.Method -rMethodL f SwaggerPetstoreRequest{..} = (\rMethod -> SwaggerPetstoreRequest { rMethod, ..} ) <$> f rMethod +rMethodL :: Lens_' (SwaggerPetstoreRequest req contentType res) NH.Method +rMethodL f SwaggerPetstoreRequest{..} = (\rMethod -> SwaggerPetstoreRequest { rMethod, ..} ) <$> f rMethod {-# INLINE rMethodL #-} -- | 'rUrlPath' Lens -rUrlPathL :: Lens_' (SwaggerPetstoreRequest req contentType res) [BCL.ByteString] -rUrlPathL f SwaggerPetstoreRequest{..} = (\rUrlPath -> SwaggerPetstoreRequest { rUrlPath, ..} ) <$> f rUrlPath +rUrlPathL :: Lens_' (SwaggerPetstoreRequest req contentType res) [BCL.ByteString] +rUrlPathL f SwaggerPetstoreRequest{..} = (\rUrlPath -> SwaggerPetstoreRequest { rUrlPath, ..} ) <$> f rUrlPath {-# INLINE rUrlPathL #-} -- | 'rParams' Lens -rParamsL :: Lens_' (SwaggerPetstoreRequest req contentType res) Params -rParamsL f SwaggerPetstoreRequest{..} = (\rParams -> SwaggerPetstoreRequest { rParams, ..} ) <$> f rParams +rParamsL :: Lens_' (SwaggerPetstoreRequest req contentType res) Params +rParamsL f SwaggerPetstoreRequest{..} = (\rParams -> SwaggerPetstoreRequest { rParams, ..} ) <$> f rParams {-# INLINE rParamsL #-} -- | 'rParams' Lens -rAuthTypesL :: Lens_' (SwaggerPetstoreRequest req contentType res) [P.TypeRep] -rAuthTypesL f SwaggerPetstoreRequest{..} = (\rAuthTypes -> SwaggerPetstoreRequest { rAuthTypes, ..} ) <$> f rAuthTypes +rAuthTypesL :: Lens_' (SwaggerPetstoreRequest req contentType res) [P.TypeRep] +rAuthTypesL f SwaggerPetstoreRequest{..} = (\rAuthTypes -> SwaggerPetstoreRequest { rAuthTypes, ..} ) <$> f rAuthTypes {-# INLINE rAuthTypesL #-} -- * HasBodyParam -- | Designates the body parameter of a request -class HasBodyParam req param where - setBodyParam :: forall contentType res. (Consumes req contentType, MimeRender contentType param) => SwaggerPetstoreRequest req contentType res -> param -> SwaggerPetstoreRequest req contentType res - setBodyParam req xs = - req `_setBodyLBS` mimeRender (P.Proxy :: P.Proxy contentType) xs & _setContentTypeHeader +class HasBodyParam req param where + setBodyParam :: forall contentType res. (Consumes req contentType, MimeRender contentType param) => SwaggerPetstoreRequest req contentType res -> param -> SwaggerPetstoreRequest req contentType res + setBodyParam req xs = + req `_setBodyLBS` mimeRender (P.Proxy :: P.Proxy contentType) xs & _setContentTypeHeader -- * HasOptionalParam -- | Designates the optional parameters of a request -class HasOptionalParam req param where +class HasOptionalParam req param where {-# MINIMAL applyOptionalParam | (-&-) #-} -- | Apply an optional parameter to a request - applyOptionalParam :: SwaggerPetstoreRequest req contentType res -> param -> SwaggerPetstoreRequest req contentType res - applyOptionalParam = (-&-) + applyOptionalParam :: SwaggerPetstoreRequest req contentType res -> param -> SwaggerPetstoreRequest req contentType res + applyOptionalParam = (-&-) {-# INLINE applyOptionalParam #-} -- | infix operator \/ alias for 'addOptionalParam' - (-&-) :: SwaggerPetstoreRequest req contentType res -> param -> SwaggerPetstoreRequest req contentType res - (-&-) = applyOptionalParam + (-&-) :: SwaggerPetstoreRequest req contentType res -> param -> SwaggerPetstoreRequest req contentType res + (-&-) = applyOptionalParam {-# INLINE (-&-) #-} infixl 2 -&- @@ -197,17 +197,17 @@ Module : SwaggerPetstore.Core -- | 'paramsQuery' Lens paramsQueryL :: Lens_' Params NH.Query -paramsQueryL f Params{..} = (\paramsQuery -> Params { paramsQuery, ..} ) <$> f paramsQuery +paramsQueryL f Params{..} = (\paramsQuery -> Params { paramsQuery, ..} ) <$> f paramsQuery {-# INLINE paramsQueryL #-} -- | 'paramsHeaders' Lens paramsHeadersL :: Lens_' Params NH.RequestHeaders -paramsHeadersL f Params{..} = (\paramsHeaders -> Params { paramsHeaders, ..} ) <$> f paramsHeaders +paramsHeadersL f Params{..} = (\paramsHeaders -> Params { paramsHeaders, ..} ) <$> f paramsHeaders {-# INLINE paramsHeadersL #-} -- | 'paramsBody' Lens paramsBodyL :: Lens_' Params ParamBody -paramsBodyL f Params{..} = (\paramsBody -> Params { paramsBody, ..} ) <$> f paramsBody +paramsBodyL f Params{..} = (\paramsBody -> Params { paramsBody, ..} ) <$> f paramsBody {-# INLINE paramsBodyL #-} -- | Request Body @@ -223,90 +223,90 @@ Module : SwaggerPetstore.Core _mkRequest :: NH.Method -- ^ Method -> [BCL.ByteString] -- ^ Endpoint - -> SwaggerPetstoreRequest req contentType res -- ^ req: Request Type, res: Response Type -_mkRequest m u = SwaggerPetstoreRequest m u _mkParams [] + -> SwaggerPetstoreRequest req contentType res -- ^ req: Request Type, res: Response Type +_mkRequest m u = SwaggerPetstoreRequest m u _mkParams [] _mkParams :: Params _mkParams = Params [] [] ParamBodyNone -setHeader :: SwaggerPetstoreRequest req contentType res -> [NH.Header] -> SwaggerPetstoreRequest req contentType res -setHeader req header = - req `removeHeader` P.fmap P.fst header & - L.over (rParamsL . paramsHeadersL) (header P.++) +setHeader :: SwaggerPetstoreRequest req contentType res -> [NH.Header] -> SwaggerPetstoreRequest req contentType res +setHeader req header = + req `removeHeader` P.fmap P.fst header & + L.over (rParamsL . paramsHeadersL) (header P.++) -removeHeader :: SwaggerPetstoreRequest req contentType res -> [NH.HeaderName] -> SwaggerPetstoreRequest req contentType res -removeHeader req header = - req & +removeHeader :: SwaggerPetstoreRequest req contentType res -> [NH.HeaderName] -> SwaggerPetstoreRequest req contentType res +removeHeader req header = + req & L.over (rParamsL . paramsHeadersL) - (P.filter (\h -> cifst h `P.notElem` P.fmap CI.mk header)) + (P.filter (\h -> cifst h `P.notElem` P.fmap CI.mk header)) where - cifst = CI.mk . P.fst + cifst = CI.mk . P.fst -_setContentTypeHeader :: forall req contentType res. MimeType contentType => SwaggerPetstoreRequest req contentType res -> SwaggerPetstoreRequest req contentType res -_setContentTypeHeader req = - case mimeType (P.Proxy :: P.Proxy contentType) of - Just m -> req `setHeader` [("content-type", BC.pack $ P.show m)] - Nothing -> req `removeHeader` ["content-type"] +_setContentTypeHeader :: forall req contentType res. MimeType contentType => SwaggerPetstoreRequest req contentType res -> SwaggerPetstoreRequest req contentType res +_setContentTypeHeader req = + case mimeType (P.Proxy :: P.Proxy contentType) of + Just m -> req `setHeader` [("content-type", BC.pack $ P.show m)] + Nothing -> req `removeHeader` ["content-type"] -_setAcceptHeader :: forall req contentType res accept. MimeType accept => SwaggerPetstoreRequest req contentType res -> accept -> SwaggerPetstoreRequest req contentType res -_setAcceptHeader req accept = - case mimeType' accept of - Just m -> req `setHeader` [("accept", BC.pack $ P.show m)] - Nothing -> req `removeHeader` ["accept"] +_setAcceptHeader :: forall req contentType res accept. MimeType accept => SwaggerPetstoreRequest req contentType res -> accept -> SwaggerPetstoreRequest req contentType res +_setAcceptHeader req accept = + case mimeType' accept of + Just m -> req `setHeader` [("accept", BC.pack $ P.show m)] + Nothing -> req `removeHeader` ["accept"] -setQuery :: SwaggerPetstoreRequest req contentType res -> [NH.QueryItem] -> SwaggerPetstoreRequest req contentType res -setQuery req query = - req & +setQuery :: SwaggerPetstoreRequest req contentType res -> [NH.QueryItem] -> SwaggerPetstoreRequest req contentType res +setQuery req query = + req & L.over (rParamsL . paramsQueryL) - ((query P.++) . P.filter (\q -> cifst q `P.notElem` P.fmap cifst query)) + ((query P.++) . P.filter (\q -> cifst q `P.notElem` P.fmap cifst query)) where - cifst = CI.mk . P.fst + cifst = CI.mk . P.fst -addForm :: SwaggerPetstoreRequest req contentType res -> WH.Form -> SwaggerPetstoreRequest req contentType res -addForm req newform = - let form = case paramsBody (rParams req) of - ParamBodyFormUrlEncoded _form -> _form +addForm :: SwaggerPetstoreRequest req contentType res -> WH.Form -> SwaggerPetstoreRequest req contentType res +addForm req newform = + let form = case paramsBody (rParams req) of + ParamBodyFormUrlEncoded _form -> _form _ -> mempty - in req & L.set (rParamsL . paramsBodyL) (ParamBodyFormUrlEncoded (newform <> form)) + in req & L.set (rParamsL . paramsBodyL) (ParamBodyFormUrlEncoded (newform <> form)) -_addMultiFormPart :: SwaggerPetstoreRequest req contentType res -> NH.Part -> SwaggerPetstoreRequest req contentType res -_addMultiFormPart req newpart = - let parts = case paramsBody (rParams req) of - ParamBodyMultipartFormData _parts -> _parts +_addMultiFormPart :: SwaggerPetstoreRequest req contentType res -> NH.Part -> SwaggerPetstoreRequest req contentType res +_addMultiFormPart req newpart = + let parts = case paramsBody (rParams req) of + ParamBodyMultipartFormData _parts -> _parts _ -> [] - in req & L.set (rParamsL . paramsBodyL) (ParamBodyMultipartFormData (newpart : parts)) + in req & L.set (rParamsL . paramsBodyL) (ParamBodyMultipartFormData (newpart : parts)) -_setBodyBS :: SwaggerPetstoreRequest req contentType res -> B.ByteString -> SwaggerPetstoreRequest req contentType res -_setBodyBS req body = - req & L.set (rParamsL . paramsBodyL) (ParamBodyB body) +_setBodyBS :: SwaggerPetstoreRequest req contentType res -> B.ByteString -> SwaggerPetstoreRequest req contentType res +_setBodyBS req body = + req & L.set (rParamsL . paramsBodyL) (ParamBodyB body) -_setBodyLBS :: SwaggerPetstoreRequest req contentType res -> BL.ByteString -> SwaggerPetstoreRequest req contentType res -_setBodyLBS req body = - req & L.set (rParamsL . paramsBodyL) (ParamBodyBL body) +_setBodyLBS :: SwaggerPetstoreRequest req contentType res -> BL.ByteString -> SwaggerPetstoreRequest req contentType res +_setBodyLBS req body = + req & L.set (rParamsL . paramsBodyL) (ParamBodyBL body) -_hasAuthType :: AuthMethod authMethod => SwaggerPetstoreRequest req contentType res -> P.Proxy authMethod -> SwaggerPetstoreRequest req contentType res -_hasAuthType req proxy = - req & L.over rAuthTypesL (P.typeRep proxy :) +_hasAuthType :: AuthMethod authMethod => SwaggerPetstoreRequest req contentType res -> P.Proxy authMethod -> SwaggerPetstoreRequest req contentType res +_hasAuthType req proxy = + req & L.over rAuthTypesL (P.typeRep proxy :) -- ** Params Utils toPath - :: WH.ToHttpApiData a - => a -> BCL.ByteString + :: WH.ToHttpApiData a + => a -> BCL.ByteString toPath = BB.toLazyByteString . WH.toEncodedUrlPiece -toHeader :: WH.ToHttpApiData a => (NH.HeaderName, a) -> [NH.Header] -toHeader x = [fmap WH.toHeader x] +toHeader :: WH.ToHttpApiData a => (NH.HeaderName, a) -> [NH.Header] +toHeader x = [fmap WH.toHeader x] -toForm :: WH.ToHttpApiData v => (BC.ByteString, v) -> WH.Form -toForm (k,v) = WH.toForm [(BC.unpack k,v)] +toForm :: WH.ToHttpApiData v => (BC.ByteString, v) -> WH.Form +toForm (k,v) = WH.toForm [(BC.unpack k,v)] -toQuery :: WH.ToHttpApiData a => (BC.ByteString, Maybe a) -> [NH.QueryItem] -toQuery x = [(fmap . fmap) toQueryParam x] - where toQueryParam = T.encodeUtf8 . WH.toQueryParam +toQuery :: WH.ToHttpApiData a => (BC.ByteString, Maybe a) -> [NH.QueryItem] +toQuery x = [(fmap . fmap) toQueryParam x] + where toQueryParam = T.encodeUtf8 . WH.toQueryParam -- *** Swagger `CollectionFormat` Utils @@ -318,38 +318,38 @@ Module : SwaggerPetstore.Core | PipeSeparated -- ^ `value1|value2|value2` | MultiParamArray -- ^ Using multiple GET parameters, e.g. `foo=bar&foo=baz`. This is valid only for parameters in "query" ('NH.Query') or "formData" ('WH.Form') -toHeaderColl :: WH.ToHttpApiData a => CollectionFormat -> (NH.HeaderName, [a]) -> [NH.Header] -toHeaderColl c xs = _toColl c toHeader xs +toHeaderColl :: WH.ToHttpApiData a => CollectionFormat -> (NH.HeaderName, [a]) -> [NH.Header] +toHeaderColl c xs = _toColl c toHeader xs -toFormColl :: WH.ToHttpApiData v => CollectionFormat -> (BC.ByteString, [v]) -> WH.Form -toFormColl c xs = WH.toForm $ fmap unpack $ _toColl c toHeader $ pack xs +toFormColl :: WH.ToHttpApiData v => CollectionFormat -> (BC.ByteString, [v]) -> WH.Form +toFormColl c xs = WH.toForm $ fmap unpack $ _toColl c toHeader $ pack xs where - pack (k,v) = (CI.mk k, v) - unpack (k,v) = (BC.unpack (CI.original k), BC.unpack v) + pack (k,v) = (CI.mk k, v) + unpack (k,v) = (BC.unpack (CI.original k), BC.unpack v) -toQueryColl :: WH.ToHttpApiData a => CollectionFormat -> (BC.ByteString, Maybe [a]) -> NH.Query -toQueryColl c xs = _toCollA c toQuery xs +toQueryColl :: WH.ToHttpApiData a => CollectionFormat -> (BC.ByteString, Maybe [a]) -> NH.Query +toQueryColl c xs = _toCollA c toQuery xs -_toColl :: P.Traversable f => CollectionFormat -> (f a -> [(b, BC.ByteString)]) -> f [a] -> [(b, BC.ByteString)] -_toColl c encode xs = fmap (fmap P.fromJust) (_toCollA' c fencode BC.singleton (fmap Just xs)) - where fencode = fmap (fmap Just) . encode . fmap P.fromJust +_toColl :: P.Traversable f => CollectionFormat -> (f a -> [(b, BC.ByteString)]) -> f [a] -> [(b, BC.ByteString)] +_toColl c encode xs = fmap (fmap P.fromJust) (_toCollA' c fencode BC.singleton (fmap Just xs)) + where fencode = fmap (fmap Just) . encode . fmap P.fromJust {-# INLINE fencode #-} -_toCollA :: (P.Traversable f, P.Traversable t, P.Alternative t) => CollectionFormat -> (f (t a) -> [(b, t BC.ByteString)]) -> f (t [a]) -> [(b, t BC.ByteString)] -_toCollA c encode xs = _toCollA' c encode BC.singleton xs +_toCollA :: (P.Traversable f, P.Traversable t, P.Alternative t) => CollectionFormat -> (f (t a) -> [(b, t BC.ByteString)]) -> f (t [a]) -> [(b, t BC.ByteString)] +_toCollA c encode xs = _toCollA' c encode BC.singleton xs -_toCollA' :: (P.Monoid c, P.Traversable f, P.Traversable t, P.Alternative t) => CollectionFormat -> (f (t a) -> [(b, t c)]) -> (Char -> c) -> f (t [a]) -> [(b, t c)] -_toCollA' c encode one xs = case c of - CommaSeparated -> go (one ',') - SpaceSeparated -> go (one ' ') - TabSeparated -> go (one '\t') - PipeSeparated -> go (one '|') - MultiParamArray -> expandList +_toCollA' :: (P.Monoid c, P.Traversable f, P.Traversable t, P.Alternative t) => CollectionFormat -> (f (t a) -> [(b, t c)]) -> (Char -> c) -> f (t [a]) -> [(b, t c)] +_toCollA' c encode one xs = case c of + CommaSeparated -> go (one ',') + SpaceSeparated -> go (one ' ') + TabSeparated -> go (one '\t') + PipeSeparated -> go (one '|') + MultiParamArray -> expandList where - go sep = - [P.foldl1 (\(sk, sv) (_, v) -> (sk, (combine sep <$> sv <*> v) <|> sv <|> v)) expandList] - combine sep x y = x <> sep <> y - expandList = (P.concatMap encode . (P.traverse . P.traverse) P.toList) xs + go sep = + [P.foldl1 (\(sk, sv) (_, v) -> (sk, (combine sep <$> sv <*> v) <|> sv <|> v)) expandList] + combine sep x y = x <> sep <> y + expandList = (P.concatMap encode . (P.traverse . P.traverse) P.toList) xs {-# INLINE go #-} {-# INLINE expandList #-} {-# INLINE combine #-} @@ -357,52 +357,52 @@ Module : SwaggerPetstore.Core -- * AuthMethods -- | Provides a method to apply auth methods to requests -class P.Typeable a => - AuthMethod a where +class P.Typeable a => + AuthMethod a where applyAuthMethod :: SwaggerPetstoreConfig - -> a - -> SwaggerPetstoreRequest req contentType res - -> IO (SwaggerPetstoreRequest req contentType res) + -> a + -> SwaggerPetstoreRequest req contentType res + -> IO (SwaggerPetstoreRequest req contentType res) -- | An existential wrapper for any AuthMethod -data AnyAuthMethod = forall a. AuthMethod a => AnyAuthMethod a deriving (P.Typeable) +data AnyAuthMethod = forall a. AuthMethod a => AnyAuthMethod a deriving (P.Typeable) -instance AuthMethod AnyAuthMethod where applyAuthMethod config (AnyAuthMethod a) req = applyAuthMethod config a req +instance AuthMethod AnyAuthMethod where applyAuthMethod config (AnyAuthMethod a) req = applyAuthMethod config a req -- | apply all matching AuthMethods in config to request _applyAuthMethods - :: SwaggerPetstoreRequest req contentType res + :: SwaggerPetstoreRequest req contentType res -> SwaggerPetstoreConfig - -> IO (SwaggerPetstoreRequest req contentType res) -_applyAuthMethods req config@(SwaggerPetstoreConfig {configAuthMethods = as}) = - foldlM go req as + -> IO (SwaggerPetstoreRequest req contentType res) +_applyAuthMethods req config@(SwaggerPetstoreConfig {configAuthMethods = as}) = + foldlM go req as where - go r (AnyAuthMethod a) = applyAuthMethod config a r + go r (AnyAuthMethod a) = applyAuthMethod config a r -- * Utils -- | Removes Null fields. (OpenAPI-Specification 2.0 does not allow Null in JSON) _omitNulls :: [(Text, A.Value)] -> A.Value -_omitNulls = A.object . P.filter notNull +_omitNulls = A.object . P.filter notNull where - notNull (_, A.Null) = False + notNull (_, A.Null) = False notNull _ = True -- | Encodes fields using WH.toQueryParam -_toFormItem :: (WH.ToHttpApiData a, Functor f) => t -> f a -> f (t, [Text]) -_toFormItem name x = (name,) . (:[]) . WH.toQueryParam <$> x +_toFormItem :: (WH.ToHttpApiData a, Functor f) => t -> f a -> f (t, [Text]) +_toFormItem name x = (name,) . (:[]) . WH.toQueryParam <$> x -- | Collapse (Just "") to Nothing _emptyToNothing :: Maybe String -> Maybe String _emptyToNothing (Just "") = Nothing -_emptyToNothing x = x +_emptyToNothing x = x {-# INLINE _emptyToNothing #-} -- | Collapse (Just mempty) to Nothing -_memptyToNothing :: (P.Monoid a, P.Eq a) => Maybe a -> Maybe a -_memptyToNothing (Just x) | x P.== P.mempty = Nothing -_memptyToNothing x = x +_memptyToNothing :: (P.Monoid a, P.Eq a) => Maybe a -> Maybe a +_memptyToNothing (Just x) | x P.== P.mempty = Nothing +_memptyToNothing x = x {-# INLINE _memptyToNothing #-} -- * DateTime Formatting @@ -412,33 +412,33 @@ Module : SwaggerPetstore.Core instance A.FromJSON DateTime where parseJSON = A.withText "DateTime" (_readDateTime . T.unpack) instance A.ToJSON DateTime where - toJSON (DateTime t) = A.toJSON (_showDateTime t) + toJSON (DateTime t) = A.toJSON (_showDateTime t) instance WH.FromHttpApiData DateTime where - parseUrlPiece = P.left T.pack . _readDateTime . T.unpack + parseUrlPiece = P.left T.pack . _readDateTime . T.unpack instance WH.ToHttpApiData DateTime where - toUrlPiece (DateTime t) = T.pack (_showDateTime t) + toUrlPiece (DateTime t) = T.pack (_showDateTime t) instance P.Show DateTime where - show (DateTime t) = _showDateTime t + show (DateTime t) = _showDateTime t instance MimeRender MimeMultipartFormData DateTime where - mimeRender _ = mimeRenderDefaultMultipartFormData + mimeRender _ = mimeRenderDefaultMultipartFormData -- | @_parseISO8601@ -_readDateTime :: (TI.ParseTime t, Monad m, Alternative m) => String -> m t +_readDateTime :: (TI.ParseTime t, Monad m, Alternative m) => String -> m t _readDateTime = _parseISO8601 {-# INLINE _readDateTime #-} -- | @TI.formatISO8601Millis@ -_showDateTime :: (t ~ TI.UTCTime, TI.FormatTime t) => t -> String +_showDateTime :: (t ~ TI.UTCTime, TI.FormatTime t) => t -> String _showDateTime = TI.formatISO8601Millis {-# INLINE _showDateTime #-} -- | parse an ISO8601 date-time string -_parseISO8601 :: (TI.ParseTime t, Monad m, Alternative m) => String -> m t -_parseISO8601 t = +_parseISO8601 :: (TI.ParseTime t, Monad m, Alternative m) => String -> m t +_parseISO8601 t = P.asum $ - P.flip (TI.parseTimeM True TI.defaultTimeLocale) t <$> + P.flip (TI.parseTimeM True TI.defaultTimeLocale) t <$> ["%FT%T%QZ", "%FT%T%Q%z", "%FT%T%Q%Z"] {-# INLINE _parseISO8601 #-} @@ -449,24 +449,24 @@ Module : SwaggerPetstore.Core instance A.FromJSON Date where parseJSON = A.withText "Date" (_readDate . T.unpack) instance A.ToJSON Date where - toJSON (Date t) = A.toJSON (_showDate t) + toJSON (Date t) = A.toJSON (_showDate t) instance WH.FromHttpApiData Date where - parseUrlPiece = P.left T.pack . _readDate . T.unpack + parseUrlPiece = P.left T.pack . _readDate . T.unpack instance WH.ToHttpApiData Date where - toUrlPiece (Date t) = T.pack (_showDate t) + toUrlPiece (Date t) = T.pack (_showDate t) instance P.Show Date where - show (Date t) = _showDate t + show (Date t) = _showDate t instance MimeRender MimeMultipartFormData Date where - mimeRender _ = mimeRenderDefaultMultipartFormData + mimeRender _ = mimeRenderDefaultMultipartFormData -- | @TI.parseTimeM True TI.defaultTimeLocale "%Y-%m-%d"@ -_readDate :: (TI.ParseTime t, Monad m) => String -> m t +_readDate :: (TI.ParseTime t, Monad m) => String -> m t _readDate = TI.parseTimeM True TI.defaultTimeLocale "%Y-%m-%d" {-# INLINE _readDate #-} -- | @TI.formatTime TI.defaultTimeLocale "%Y-%m-%d"@ -_showDate :: TI.FormatTime t => t -> String +_showDate :: TI.FormatTime t => t -> String _showDate = TI.formatTime TI.defaultTimeLocale "%Y-%m-%d" {-# INLINE _showDate #-} @@ -483,16 +483,16 @@ Module : SwaggerPetstore.Core instance A.ToJSON ByteArray where toJSON = A.toJSON . _showByteArray instance WH.FromHttpApiData ByteArray where - parseUrlPiece = P.left T.pack . _readByteArray + parseUrlPiece = P.left T.pack . _readByteArray instance WH.ToHttpApiData ByteArray where - toUrlPiece = _showByteArray + toUrlPiece = _showByteArray instance P.Show ByteArray where show = T.unpack . _showByteArray instance MimeRender MimeMultipartFormData ByteArray where - mimeRender _ = mimeRenderDefaultMultipartFormData + mimeRender _ = mimeRenderDefaultMultipartFormData -- | read base64 encoded characters -_readByteArray :: Monad m => Text -> m ByteArray +_readByteArray :: Monad m => Text -> m ByteArray _readByteArray = P.either P.fail (pure . ByteArray) . BL64.decode . BL.fromStrict . T.encodeUtf8 {-# INLINE _readByteArray #-} @@ -510,15 +510,15 @@ Module : SwaggerPetstore.Core instance A.ToJSON Binary where toJSON = A.toJSON . _showBinaryBase64 instance WH.FromHttpApiData Binary where - parseUrlPiece = P.left T.pack . _readBinaryBase64 + parseUrlPiece = P.left T.pack . _readBinaryBase64 instance WH.ToHttpApiData Binary where - toUrlPiece = _showBinaryBase64 + toUrlPiece = _showBinaryBase64 instance P.Show Binary where show = T.unpack . _showBinaryBase64 instance MimeRender MimeMultipartFormData Binary where - mimeRender _ = unBinary + mimeRender _ = unBinary -_readBinaryBase64 :: Monad m => Text -> m Binary +_readBinaryBase64 :: Monad m => Text -> m Binary _readBinaryBase64 = P.either P.fail (pure . Binary) . BL64.decode . BL.fromStrict . T.encodeUtf8 {-# INLINE _readBinaryBase64 #-} @@ -528,6 +528,6 @@ Module : SwaggerPetstore.Core -- * Lens Type Aliases -type Lens_' s a = Lens_ s s a a -type Lens_ s t a b = forall (f :: * -> *). Functor f => (a -> f b) -> s -> f t +type Lens_' s a = Lens_ s s a a +type Lens_ s t a b = forall (f :: * -> *). Functor f => (a -> f b) -> s -> f t \ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Logging.html b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Logging.html index 3db61663db1..f06402dbc99 100644 --- a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Logging.html +++ b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Logging.html @@ -35,11 +35,11 @@ Katip Logging functions -- * Type Aliases (for compatability) -- | Runs a Katip logging block with the Log environment -type LogExecWithContext = forall m. P.MonadIO m => - LogContext -> LogExec m +type LogExecWithContext = forall m. P.MonadIO m => + LogContext -> LogExec m -- | A Katip logging block -type LogExec m = forall a. LG.KatipT m a -> m a +type LogExec m = forall a. LG.KatipT m a -> m a -- | A Katip Log environment type LogContext = LG.LogEnv @@ -65,9 +65,9 @@ Katip Logging functions -- | A Katip Log environment which targets stdout stdoutLoggingContext :: LogContext -> IO LogContext -stdoutLoggingContext cxt = do - handleScribe <- LG.mkHandleScribe LG.ColorIfTerminal IO.stdout LG.InfoS LG.V2 - LG.registerScribe "stdout" handleScribe LG.defaultScribeSettings cxt +stdoutLoggingContext cxt = do + handleScribe <- LG.mkHandleScribe LG.ColorIfTerminal IO.stdout LG.InfoS LG.V2 + LG.registerScribe "stdout" handleScribe LG.defaultScribeSettings cxt -- * stderr logger @@ -77,34 +77,34 @@ Katip Logging functions -- | A Katip Log environment which targets stderr stderrLoggingContext :: LogContext -> IO LogContext -stderrLoggingContext cxt = do - handleScribe <- LG.mkHandleScribe LG.ColorIfTerminal IO.stderr LG.InfoS LG.V2 - LG.registerScribe "stderr" handleScribe LG.defaultScribeSettings cxt +stderrLoggingContext cxt = do + handleScribe <- LG.mkHandleScribe LG.ColorIfTerminal IO.stderr LG.InfoS LG.V2 + LG.registerScribe "stderr" handleScribe LG.defaultScribeSettings cxt -- * Null logger -- | Disables Katip logging runNullLogExec :: LogExecWithContext -runNullLogExec le (LG.KatipT f) = P.runReaderT f (L.set LG.logEnvScribes mempty le) +runNullLogExec le (LG.KatipT f) = P.runReaderT f (L.set LG.logEnvScribes mempty le) -- * Log Msg -- | Log a katip message -_log :: (Applicative m, LG.Katip m) => Text -> LogLevel -> Text -> m () -_log src level msg = do - LG.logMsg (fromString $ T.unpack src) level (LG.logStr msg) +_log :: (Applicative m, LG.Katip m) => Text -> LogLevel -> Text -> m () +_log src level msg = do + LG.logMsg (fromString $ T.unpack src) level (LG.logStr msg) -- * Log Exceptions -- | re-throws exceptions after logging them logExceptions - :: (LG.Katip m, E.MonadCatch m, Applicative m) - => Text -> m a -> m a -logExceptions src = + :: (LG.Katip m, E.MonadCatch m, Applicative m) + => Text -> m a -> m a +logExceptions src = E.handle - (\(e :: E.SomeException) -> do - _log src LG.ErrorS ((T.pack . show) e) - E.throw e) + (\(e :: E.SomeException) -> do + _log src LG.ErrorS ((T.pack . show) e) + E.throw e) -- * Log Level diff --git a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.MimeTypes.html b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.MimeTypes.html index 99e0a171a3c..8c1f5b813b8 100644 --- a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.MimeTypes.html +++ b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.MimeTypes.html @@ -45,11 +45,11 @@ Module : SwaggerPetstore.MimeTypes -- * Consumes Class -class MimeType mtype => Consumes req mtype where +class MimeType mtype => Consumes req mtype where -- * Produces Class -class MimeType mtype => Produces req mtype where +class MimeType mtype => Produces req mtype where -- * Default Mime Types @@ -69,126 +69,126 @@ Module : SwaggerPetstore.MimeTypes -- * MimeType Class -class P.Typeable mtype => MimeType mtype where +class P.Typeable mtype => MimeType mtype where {-# MINIMAL mimeType | mimeTypes #-} - mimeTypes :: P.Proxy mtype -> [ME.MediaType] - mimeTypes p = - case mimeType p of - Just x -> [x] + mimeTypes :: P.Proxy mtype -> [ME.MediaType] + mimeTypes p = + case mimeType p of + Just x -> [x] Nothing -> [] - mimeType :: P.Proxy mtype -> Maybe ME.MediaType - mimeType p = - case mimeTypes p of + mimeType :: P.Proxy mtype -> Maybe ME.MediaType + mimeType p = + case mimeTypes p of [] -> Nothing - (x:_) -> Just x + (x:_) -> Just x - mimeType' :: mtype -> Maybe ME.MediaType - mimeType' _ = mimeType (P.Proxy :: P.Proxy mtype) - mimeTypes' :: mtype -> [ME.MediaType] - mimeTypes' _ = mimeTypes (P.Proxy :: P.Proxy mtype) + mimeType' :: mtype -> Maybe ME.MediaType + mimeType' _ = mimeType (P.Proxy :: P.Proxy mtype) + mimeTypes' :: mtype -> [ME.MediaType] + mimeTypes' _ = mimeTypes (P.Proxy :: P.Proxy mtype) -- Default MimeType Instances -- | @application/json; charset=utf-8@ instance MimeType MimeJSON where - mimeType _ = Just $ P.fromString "application/json" + mimeType _ = Just $ P.fromString "application/json" -- | @application/xml; charset=utf-8@ instance MimeType MimeXML where - mimeType _ = Just $ P.fromString "application/xml" + mimeType _ = Just $ P.fromString "application/xml" -- | @application/x-www-form-urlencoded@ instance MimeType MimeFormUrlEncoded where - mimeType _ = Just $ P.fromString "application/x-www-form-urlencoded" + mimeType _ = Just $ P.fromString "application/x-www-form-urlencoded" -- | @multipart/form-data@ instance MimeType MimeMultipartFormData where - mimeType _ = Just $ P.fromString "multipart/form-data" + mimeType _ = Just $ P.fromString "multipart/form-data" -- | @text/plain; charset=utf-8@ instance MimeType MimePlainText where - mimeType _ = Just $ P.fromString "text/plain" + mimeType _ = Just $ P.fromString "text/plain" -- | @application/octet-stream@ instance MimeType MimeOctetStream where - mimeType _ = Just $ P.fromString "application/octet-stream" + mimeType _ = Just $ P.fromString "application/octet-stream" -- | @"*/*"@ instance MimeType MimeAny where - mimeType _ = Just $ P.fromString "*/*" + mimeType _ = Just $ P.fromString "*/*" instance MimeType MimeNoContent where - mimeType _ = Nothing + mimeType _ = Nothing -- * MimeRender Class -class MimeType mtype => MimeRender mtype x where - mimeRender :: P.Proxy mtype -> x -> BL.ByteString - mimeRender' :: mtype -> x -> BL.ByteString - mimeRender' _ x = mimeRender (P.Proxy :: P.Proxy mtype) x +class MimeType mtype => MimeRender mtype x where + mimeRender :: P.Proxy mtype -> x -> BL.ByteString + mimeRender' :: mtype -> x -> BL.ByteString + mimeRender' _ x = mimeRender (P.Proxy :: P.Proxy mtype) x -mimeRenderDefaultMultipartFormData :: WH.ToHttpApiData a => a -> BL.ByteString +mimeRenderDefaultMultipartFormData :: WH.ToHttpApiData a => a -> BL.ByteString mimeRenderDefaultMultipartFormData = BL.fromStrict . T.encodeUtf8 . WH.toQueryParam -- Default MimeRender Instances -- | `A.encode` -instance A.ToJSON a => MimeRender MimeJSON a where mimeRender _ = A.encode +instance A.ToJSON a => MimeRender MimeJSON a where mimeRender _ = A.encode -- | @WH.urlEncodeAsForm@ -instance WH.ToForm a => MimeRender MimeFormUrlEncoded a where mimeRender _ = WH.urlEncodeAsForm +instance WH.ToForm a => MimeRender MimeFormUrlEncoded a where mimeRender _ = WH.urlEncodeAsForm -- | @P.id@ -instance MimeRender MimePlainText BL.ByteString where mimeRender _ = P.id +instance MimeRender MimePlainText BL.ByteString where mimeRender _ = P.id -- | @BL.fromStrict . T.encodeUtf8@ -instance MimeRender MimePlainText T.Text where mimeRender _ = BL.fromStrict . T.encodeUtf8 +instance MimeRender MimePlainText T.Text where mimeRender _ = BL.fromStrict . T.encodeUtf8 -- | @BCL.pack@ -instance MimeRender MimePlainText String where mimeRender _ = BCL.pack +instance MimeRender MimePlainText String where mimeRender _ = BCL.pack -- | @P.id@ -instance MimeRender MimeOctetStream BL.ByteString where mimeRender _ = P.id +instance MimeRender MimeOctetStream BL.ByteString where mimeRender _ = P.id -- | @BL.fromStrict . T.encodeUtf8@ -instance MimeRender MimeOctetStream T.Text where mimeRender _ = BL.fromStrict . T.encodeUtf8 +instance MimeRender MimeOctetStream T.Text where mimeRender _ = BL.fromStrict . T.encodeUtf8 -- | @BCL.pack@ -instance MimeRender MimeOctetStream String where mimeRender _ = BCL.pack +instance MimeRender MimeOctetStream String where mimeRender _ = BCL.pack -instance MimeRender MimeMultipartFormData BL.ByteString where mimeRender _ = P.id +instance MimeRender MimeMultipartFormData BL.ByteString where mimeRender _ = P.id -instance MimeRender MimeMultipartFormData Bool where mimeRender _ = mimeRenderDefaultMultipartFormData -instance MimeRender MimeMultipartFormData Char where mimeRender _ = mimeRenderDefaultMultipartFormData -instance MimeRender MimeMultipartFormData Double where mimeRender _ = mimeRenderDefaultMultipartFormData -instance MimeRender MimeMultipartFormData Float where mimeRender _ = mimeRenderDefaultMultipartFormData -instance MimeRender MimeMultipartFormData Int where mimeRender _ = mimeRenderDefaultMultipartFormData -instance MimeRender MimeMultipartFormData Integer where mimeRender _ = mimeRenderDefaultMultipartFormData -instance MimeRender MimeMultipartFormData String where mimeRender _ = mimeRenderDefaultMultipartFormData -instance MimeRender MimeMultipartFormData T.Text where mimeRender _ = mimeRenderDefaultMultipartFormData +instance MimeRender MimeMultipartFormData Bool where mimeRender _ = mimeRenderDefaultMultipartFormData +instance MimeRender MimeMultipartFormData Char where mimeRender _ = mimeRenderDefaultMultipartFormData +instance MimeRender MimeMultipartFormData Double where mimeRender _ = mimeRenderDefaultMultipartFormData +instance MimeRender MimeMultipartFormData Float where mimeRender _ = mimeRenderDefaultMultipartFormData +instance MimeRender MimeMultipartFormData Int where mimeRender _ = mimeRenderDefaultMultipartFormData +instance MimeRender MimeMultipartFormData Integer where mimeRender _ = mimeRenderDefaultMultipartFormData +instance MimeRender MimeMultipartFormData String where mimeRender _ = mimeRenderDefaultMultipartFormData +instance MimeRender MimeMultipartFormData T.Text where mimeRender _ = mimeRenderDefaultMultipartFormData -- | @P.Right . P.const NoContent@ -instance MimeRender MimeNoContent NoContent where mimeRender _ = P.const BCL.empty +instance MimeRender MimeNoContent NoContent where mimeRender _ = P.const BCL.empty -- * MimeUnrender Class -class MimeType mtype => MimeUnrender mtype o where - mimeUnrender :: P.Proxy mtype -> BL.ByteString -> P.Either String o - mimeUnrender' :: mtype -> BL.ByteString -> P.Either String o - mimeUnrender' _ x = mimeUnrender (P.Proxy :: P.Proxy mtype) x +class MimeType mtype => MimeUnrender mtype o where + mimeUnrender :: P.Proxy mtype -> BL.ByteString -> P.Either String o + mimeUnrender' :: mtype -> BL.ByteString -> P.Either String o + mimeUnrender' _ x = mimeUnrender (P.Proxy :: P.Proxy mtype) x -- Default MimeUnrender Instances -- | @A.eitherDecode@ -instance A.FromJSON a => MimeUnrender MimeJSON a where mimeUnrender _ = A.eitherDecode +instance A.FromJSON a => MimeUnrender MimeJSON a where mimeUnrender _ = A.eitherDecode -- | @P.left T.unpack . WH.urlDecodeAsForm@ -instance WH.FromForm a => MimeUnrender MimeFormUrlEncoded a where mimeUnrender _ = P.left T.unpack . WH.urlDecodeAsForm +instance WH.FromForm a => MimeUnrender MimeFormUrlEncoded a where mimeUnrender _ = P.left T.unpack . WH.urlDecodeAsForm -- | @P.Right . P.id@ -instance MimeUnrender MimePlainText BL.ByteString where mimeUnrender _ = P.Right . P.id +instance MimeUnrender MimePlainText BL.ByteString where mimeUnrender _ = P.Right . P.id -- | @P.left P.show . TL.decodeUtf8'@ -instance MimeUnrender MimePlainText T.Text where mimeUnrender _ = P.left P.show . T.decodeUtf8' . BL.toStrict +instance MimeUnrender MimePlainText T.Text where mimeUnrender _ = P.left P.show . T.decodeUtf8' . BL.toStrict -- | @P.Right . BCL.unpack@ -instance MimeUnrender MimePlainText String where mimeUnrender _ = P.Right . BCL.unpack +instance MimeUnrender MimePlainText String where mimeUnrender _ = P.Right . BCL.unpack -- | @P.Right . P.id@ -instance MimeUnrender MimeOctetStream BL.ByteString where mimeUnrender _ = P.Right . P.id +instance MimeUnrender MimeOctetStream BL.ByteString where mimeUnrender _ = P.Right . P.id -- | @P.left P.show . T.decodeUtf8' . BL.toStrict@ -instance MimeUnrender MimeOctetStream T.Text where mimeUnrender _ = P.left P.show . T.decodeUtf8' . BL.toStrict +instance MimeUnrender MimeOctetStream T.Text where mimeUnrender _ = P.left P.show . T.decodeUtf8' . BL.toStrict -- | @P.Right . BCL.unpack@ -instance MimeUnrender MimeOctetStream String where mimeUnrender _ = P.Right . BCL.unpack +instance MimeUnrender MimeOctetStream String where mimeUnrender _ = P.Right . BCL.unpack -- | @P.Right . P.const NoContent@ -instance MimeUnrender MimeNoContent NoContent where mimeUnrender _ = P.Right . P.const NoContent \ No newline at end of file +instance MimeUnrender MimeNoContent NoContent where mimeUnrender _ = P.Right . P.const NoContent \ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Model.html b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Model.html index 8701470671b..ec96aa46fb5 100644 --- a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Model.html +++ b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Model.html @@ -18,178 +18,178 @@ Module : SwaggerPetstore.Model {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE TupleSections #-} -{-# LANGUAGE TypeFamilies #-} -{-# OPTIONS_GHC -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-} - -module SwaggerPetstore.Model where +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeFamilies #-} +{-# OPTIONS_GHC -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-} -import SwaggerPetstore.Core +module SwaggerPetstore.Model where -import Data.Aeson ((.:),(.:!),(.:?),(.=)) - -import qualified Data.Aeson as A -import qualified Data.ByteString as B -import qualified Data.ByteString.Lazy as BL -import qualified Data.Data as P (Data, Typeable) -import qualified Data.Foldable as P -import qualified Data.HashMap.Lazy as HM -import qualified Data.Map as Map -import qualified Data.Maybe as P -import qualified Data.Set as Set -import qualified Data.Text as T -import qualified Data.Text.Encoding as T -import qualified Data.Time as TI -import qualified Web.FormUrlEncoded as WH -import qualified Web.HttpApiData as WH - -import Control.Applicative ((<|>)) -import Control.Applicative (Alternative) -import Data.Text (Text) -import Prelude (($), (.),(<$>),(<*>),(>>=),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor) - -import qualified Prelude as P - - +import SwaggerPetstore.Core +import SwaggerPetstore.MimeTypes + +import Data.Aeson ((.:),(.:!),(.:?),(.=)) + +import qualified Control.Arrow as P (left) +import qualified Data.Aeson as A +import qualified Data.ByteString as B +import qualified Data.ByteString.Lazy as BL +import qualified Data.Data as P (Data, Typeable) +import qualified Data.Foldable as P +import qualified Data.HashMap.Lazy as HM +import qualified Data.Map as Map +import qualified Data.Maybe as P +import qualified Data.Set as Set +import qualified Data.Text as T +import qualified Data.Text.Encoding as T +import qualified Data.Time as TI +import qualified Web.FormUrlEncoded as WH +import qualified Web.HttpApiData as WH + +import Control.Applicative ((<|>)) +import Control.Applicative (Alternative) +import Data.Text (Text) +import Prelude (($), (.),(<$>),(<*>),(>>=),(=<<),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor) --- * Models +import qualified Prelude as P --- ** AdditionalPropertiesClass --- | AdditionalPropertiesClass -data AdditionalPropertiesClass = AdditionalPropertiesClass - { additionalPropertiesClassMapProperty :: !(Maybe (Map.Map String Text)) -- ^ "map_property" - , additionalPropertiesClassMapOfMapProperty :: !(Maybe (Map.Map String (Map.Map String Text))) -- ^ "map_of_map_property" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON AdditionalPropertiesClass -instance A.FromJSON AdditionalPropertiesClass where - parseJSON = A.withObject "AdditionalPropertiesClass" $ \o -> - AdditionalPropertiesClass - <$> (o .:? "map_property") - <*> (o .:? "map_of_map_property") - --- | ToJSON AdditionalPropertiesClass -instance A.ToJSON AdditionalPropertiesClass where - toJSON AdditionalPropertiesClass {..} = - _omitNulls - [ "map_property" .= additionalPropertiesClassMapProperty - , "map_of_map_property" .= additionalPropertiesClassMapOfMapProperty - ] - - --- | Construct a value of type 'AdditionalPropertiesClass' (by applying it's required fields, if any) -mkAdditionalPropertiesClass - :: AdditionalPropertiesClass -mkAdditionalPropertiesClass = - AdditionalPropertiesClass - { additionalPropertiesClassMapProperty = Nothing - , additionalPropertiesClassMapOfMapProperty = Nothing - } - - --- ** Animal --- | Animal -data Animal = Animal - { animalClassName :: !(Text) -- ^ /Required/ "className" - , animalColor :: !(Maybe Text) -- ^ "color" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Animal -instance A.FromJSON Animal where - parseJSON = A.withObject "Animal" $ \o -> - Animal - <$> (o .: "className") - <*> (o .:? "color") - --- | ToJSON Animal -instance A.ToJSON Animal where - toJSON Animal {..} = - _omitNulls - [ "className" .= animalClassName - , "color" .= animalColor - ] - - --- | Construct a value of type 'Animal' (by applying it's required fields, if any) -mkAnimal - :: Text -- ^ 'animalClassName' - -> Animal -mkAnimal animalClassName = - Animal - { animalClassName - , animalColor = Nothing - } - - --- ** AnimalFarm --- | AnimalFarm -data AnimalFarm = AnimalFarm - { - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON AnimalFarm -instance A.FromJSON AnimalFarm where - parseJSON = A.withObject "AnimalFarm" $ \o -> - pure AnimalFarm - - --- | ToJSON AnimalFarm -instance A.ToJSON AnimalFarm where - toJSON AnimalFarm = - _omitNulls - [ - ] - - --- | Construct a value of type 'AnimalFarm' (by applying it's required fields, if any) -mkAnimalFarm - :: AnimalFarm -mkAnimalFarm = - AnimalFarm - { - } - - --- ** ApiResponse --- | ApiResponse -data ApiResponse = ApiResponse - { apiResponseCode :: !(Maybe Int) -- ^ "code" - , apiResponseType :: !(Maybe Text) -- ^ "type" - , apiResponseMessage :: !(Maybe Text) -- ^ "message" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON ApiResponse -instance A.FromJSON ApiResponse where - parseJSON = A.withObject "ApiResponse" $ \o -> - ApiResponse - <$> (o .:? "code") - <*> (o .:? "type") - <*> (o .:? "message") - --- | ToJSON ApiResponse -instance A.ToJSON ApiResponse where - toJSON ApiResponse {..} = - _omitNulls - [ "code" .= apiResponseCode - , "type" .= apiResponseType - , "message" .= apiResponseMessage - ] - + +-- * Models + + +-- ** AdditionalPropertiesClass +-- | AdditionalPropertiesClass +data AdditionalPropertiesClass = AdditionalPropertiesClass + { additionalPropertiesClassMapProperty :: !(Maybe (Map.Map String Text)) -- ^ "map_property" + , additionalPropertiesClassMapOfMapProperty :: !(Maybe (Map.Map String (Map.Map String Text))) -- ^ "map_of_map_property" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON AdditionalPropertiesClass +instance A.FromJSON AdditionalPropertiesClass where + parseJSON = A.withObject "AdditionalPropertiesClass" $ \o -> + AdditionalPropertiesClass + <$> (o .:? "map_property") + <*> (o .:? "map_of_map_property") + +-- | ToJSON AdditionalPropertiesClass +instance A.ToJSON AdditionalPropertiesClass where + toJSON AdditionalPropertiesClass {..} = + _omitNulls + [ "map_property" .= additionalPropertiesClassMapProperty + , "map_of_map_property" .= additionalPropertiesClassMapOfMapProperty + ] + + +-- | Construct a value of type 'AdditionalPropertiesClass' (by applying it's required fields, if any) +mkAdditionalPropertiesClass + :: AdditionalPropertiesClass +mkAdditionalPropertiesClass = + AdditionalPropertiesClass + { additionalPropertiesClassMapProperty = Nothing + , additionalPropertiesClassMapOfMapProperty = Nothing + } + +-- ** Animal +-- | Animal +data Animal = Animal + { animalClassName :: !(Text) -- ^ /Required/ "className" + , animalColor :: !(Maybe Text) -- ^ "color" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Animal +instance A.FromJSON Animal where + parseJSON = A.withObject "Animal" $ \o -> + Animal + <$> (o .: "className") + <*> (o .:? "color") + +-- | ToJSON Animal +instance A.ToJSON Animal where + toJSON Animal {..} = + _omitNulls + [ "className" .= animalClassName + , "color" .= animalColor + ] + + +-- | Construct a value of type 'Animal' (by applying it's required fields, if any) +mkAnimal + :: Text -- ^ 'animalClassName' + -> Animal +mkAnimal animalClassName = + Animal + { animalClassName + , animalColor = Nothing + } + +-- ** AnimalFarm +-- | AnimalFarm +data AnimalFarm = AnimalFarm + { + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON AnimalFarm +instance A.FromJSON AnimalFarm where + parseJSON = A.withObject "AnimalFarm" $ \o -> + pure AnimalFarm + + +-- | ToJSON AnimalFarm +instance A.ToJSON AnimalFarm where + toJSON AnimalFarm = + _omitNulls + [ + ] + + +-- | Construct a value of type 'AnimalFarm' (by applying it's required fields, if any) +mkAnimalFarm + :: AnimalFarm +mkAnimalFarm = + AnimalFarm + { + } + +-- ** ApiResponse +-- | ApiResponse +data ApiResponse = ApiResponse + { apiResponseCode :: !(Maybe Int) -- ^ "code" + , apiResponseType :: !(Maybe Text) -- ^ "type" + , apiResponseMessage :: !(Maybe Text) -- ^ "message" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON ApiResponse +instance A.FromJSON ApiResponse where + parseJSON = A.withObject "ApiResponse" $ \o -> + ApiResponse + <$> (o .:? "code") + <*> (o .:? "type") + <*> (o .:? "message") + +-- | ToJSON ApiResponse +instance A.ToJSON ApiResponse where + toJSON ApiResponse {..} = + _omitNulls + [ "code" .= apiResponseCode + , "type" .= apiResponseType + , "message" .= apiResponseMessage + ] --- | Construct a value of type 'ApiResponse' (by applying it's required fields, if any) -mkApiResponse - :: ApiResponse -mkApiResponse = - ApiResponse - { apiResponseCode = Nothing - , apiResponseType = Nothing - , apiResponseMessage = Nothing - } - + +-- | Construct a value of type 'ApiResponse' (by applying it's required fields, if any) +mkApiResponse + :: ApiResponse +mkApiResponse = + ApiResponse + { apiResponseCode = Nothing + , apiResponseType = Nothing + , apiResponseMessage = Nothing + } -- ** ArrayOfArrayOfNumberOnly -- | ArrayOfArrayOfNumberOnly @@ -199,15 +199,15 @@ Module : SwaggerPetstore.Model -- | FromJSON ArrayOfArrayOfNumberOnly instance A.FromJSON ArrayOfArrayOfNumberOnly where - parseJSON = A.withObject "ArrayOfArrayOfNumberOnly" $ \o -> + parseJSON = A.withObject "ArrayOfArrayOfNumberOnly" $ \o -> ArrayOfArrayOfNumberOnly - <$> (o .:? "ArrayArrayNumber") + <$> (o .:? "ArrayArrayNumber") -- | ToJSON ArrayOfArrayOfNumberOnly instance A.ToJSON ArrayOfArrayOfNumberOnly where toJSON ArrayOfArrayOfNumberOnly {..} = _omitNulls - [ "ArrayArrayNumber" .= arrayOfArrayOfNumberOnlyArrayArrayNumber + [ "ArrayArrayNumber" .= arrayOfArrayOfNumberOnlyArrayArrayNumber ] @@ -219,1083 +219,1380 @@ Module : SwaggerPetstore.Model { arrayOfArrayOfNumberOnlyArrayArrayNumber = Nothing } - --- ** ArrayOfNumberOnly --- | ArrayOfNumberOnly -data ArrayOfNumberOnly = ArrayOfNumberOnly - { arrayOfNumberOnlyArrayNumber :: !(Maybe [Double]) -- ^ "ArrayNumber" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON ArrayOfNumberOnly -instance A.FromJSON ArrayOfNumberOnly where - parseJSON = A.withObject "ArrayOfNumberOnly" $ \o -> - ArrayOfNumberOnly - <$> (o .:? "ArrayNumber") - --- | ToJSON ArrayOfNumberOnly -instance A.ToJSON ArrayOfNumberOnly where - toJSON ArrayOfNumberOnly {..} = - _omitNulls - [ "ArrayNumber" .= arrayOfNumberOnlyArrayNumber - ] +-- ** ArrayOfNumberOnly +-- | ArrayOfNumberOnly +data ArrayOfNumberOnly = ArrayOfNumberOnly + { arrayOfNumberOnlyArrayNumber :: !(Maybe [Double]) -- ^ "ArrayNumber" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON ArrayOfNumberOnly +instance A.FromJSON ArrayOfNumberOnly where + parseJSON = A.withObject "ArrayOfNumberOnly" $ \o -> + ArrayOfNumberOnly + <$> (o .:? "ArrayNumber") + +-- | ToJSON ArrayOfNumberOnly +instance A.ToJSON ArrayOfNumberOnly where + toJSON ArrayOfNumberOnly {..} = + _omitNulls + [ "ArrayNumber" .= arrayOfNumberOnlyArrayNumber + ] + - --- | Construct a value of type 'ArrayOfNumberOnly' (by applying it's required fields, if any) -mkArrayOfNumberOnly - :: ArrayOfNumberOnly -mkArrayOfNumberOnly = - ArrayOfNumberOnly - { arrayOfNumberOnlyArrayNumber = Nothing - } - - --- ** ArrayTest --- | ArrayTest -data ArrayTest = ArrayTest - { arrayTestArrayOfString :: !(Maybe [Text]) -- ^ "array_of_string" - , arrayTestArrayArrayOfInteger :: !(Maybe [[Integer]]) -- ^ "array_array_of_integer" - , arrayTestArrayArrayOfModel :: !(Maybe [[ReadOnlyFirst]]) -- ^ "array_array_of_model" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON ArrayTest -instance A.FromJSON ArrayTest where - parseJSON = A.withObject "ArrayTest" $ \o -> - ArrayTest - <$> (o .:? "array_of_string") - <*> (o .:? "array_array_of_integer") - <*> (o .:? "array_array_of_model") - --- | ToJSON ArrayTest -instance A.ToJSON ArrayTest where - toJSON ArrayTest {..} = - _omitNulls - [ "array_of_string" .= arrayTestArrayOfString - , "array_array_of_integer" .= arrayTestArrayArrayOfInteger - , "array_array_of_model" .= arrayTestArrayArrayOfModel - ] - - --- | Construct a value of type 'ArrayTest' (by applying it's required fields, if any) -mkArrayTest - :: ArrayTest -mkArrayTest = - ArrayTest - { arrayTestArrayOfString = Nothing - , arrayTestArrayArrayOfInteger = Nothing - , arrayTestArrayArrayOfModel = Nothing - } - - --- ** Capitalization --- | Capitalization -data Capitalization = Capitalization - { capitalizationSmallCamel :: !(Maybe Text) -- ^ "smallCamel" - , capitalizationCapitalCamel :: !(Maybe Text) -- ^ "CapitalCamel" - , capitalizationSmallSnake :: !(Maybe Text) -- ^ "small_Snake" - , capitalizationCapitalSnake :: !(Maybe Text) -- ^ "Capital_Snake" - , capitalizationScaEthFlowPoints :: !(Maybe Text) -- ^ "SCA_ETH_Flow_Points" - , capitalizationAttName :: !(Maybe Text) -- ^ "ATT_NAME" - Name of the pet - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Capitalization -instance A.FromJSON Capitalization where - parseJSON = A.withObject "Capitalization" $ \o -> - Capitalization - <$> (o .:? "smallCamel") - <*> (o .:? "CapitalCamel") - <*> (o .:? "small_Snake") - <*> (o .:? "Capital_Snake") - <*> (o .:? "SCA_ETH_Flow_Points") - <*> (o .:? "ATT_NAME") - --- | ToJSON Capitalization -instance A.ToJSON Capitalization where - toJSON Capitalization {..} = - _omitNulls - [ "smallCamel" .= capitalizationSmallCamel - , "CapitalCamel" .= capitalizationCapitalCamel - , "small_Snake" .= capitalizationSmallSnake - , "Capital_Snake" .= capitalizationCapitalSnake - , "SCA_ETH_Flow_Points" .= capitalizationScaEthFlowPoints - , "ATT_NAME" .= capitalizationAttName - ] - - --- | Construct a value of type 'Capitalization' (by applying it's required fields, if any) -mkCapitalization - :: Capitalization -mkCapitalization = - Capitalization - { capitalizationSmallCamel = Nothing - , capitalizationCapitalCamel = Nothing - , capitalizationSmallSnake = Nothing - , capitalizationCapitalSnake = Nothing - , capitalizationScaEthFlowPoints = Nothing - , capitalizationAttName = Nothing - } - - --- ** Category --- | Category -data Category = Category - { categoryId :: !(Maybe Integer) -- ^ "id" - , categoryName :: !(Maybe Text) -- ^ "name" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Category -instance A.FromJSON Category where - parseJSON = A.withObject "Category" $ \o -> - Category - <$> (o .:? "id") - <*> (o .:? "name") - --- | ToJSON Category -instance A.ToJSON Category where - toJSON Category {..} = - _omitNulls - [ "id" .= categoryId - , "name" .= categoryName - ] - - --- | Construct a value of type 'Category' (by applying it's required fields, if any) -mkCategory - :: Category -mkCategory = - Category - { categoryId = Nothing - , categoryName = Nothing - } - - --- ** ClassModel --- | ClassModel --- Model for testing model with \"_class\" property -data ClassModel = ClassModel - { classModelClass :: !(Maybe Text) -- ^ "_class" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON ClassModel -instance A.FromJSON ClassModel where - parseJSON = A.withObject "ClassModel" $ \o -> - ClassModel - <$> (o .:? "_class") - --- | ToJSON ClassModel -instance A.ToJSON ClassModel where - toJSON ClassModel {..} = - _omitNulls - [ "_class" .= classModelClass - ] - - --- | Construct a value of type 'ClassModel' (by applying it's required fields, if any) -mkClassModel - :: ClassModel -mkClassModel = - ClassModel - { classModelClass = Nothing - } - +-- | Construct a value of type 'ArrayOfNumberOnly' (by applying it's required fields, if any) +mkArrayOfNumberOnly + :: ArrayOfNumberOnly +mkArrayOfNumberOnly = + ArrayOfNumberOnly + { arrayOfNumberOnlyArrayNumber = Nothing + } + +-- ** ArrayTest +-- | ArrayTest +data ArrayTest = ArrayTest + { arrayTestArrayOfString :: !(Maybe [Text]) -- ^ "array_of_string" + , arrayTestArrayArrayOfInteger :: !(Maybe [[Integer]]) -- ^ "array_array_of_integer" + , arrayTestArrayArrayOfModel :: !(Maybe [[ReadOnlyFirst]]) -- ^ "array_array_of_model" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON ArrayTest +instance A.FromJSON ArrayTest where + parseJSON = A.withObject "ArrayTest" $ \o -> + ArrayTest + <$> (o .:? "array_of_string") + <*> (o .:? "array_array_of_integer") + <*> (o .:? "array_array_of_model") + +-- | ToJSON ArrayTest +instance A.ToJSON ArrayTest where + toJSON ArrayTest {..} = + _omitNulls + [ "array_of_string" .= arrayTestArrayOfString + , "array_array_of_integer" .= arrayTestArrayArrayOfInteger + , "array_array_of_model" .= arrayTestArrayArrayOfModel + ] + + +-- | Construct a value of type 'ArrayTest' (by applying it's required fields, if any) +mkArrayTest + :: ArrayTest +mkArrayTest = + ArrayTest + { arrayTestArrayOfString = Nothing + , arrayTestArrayArrayOfInteger = Nothing + , arrayTestArrayArrayOfModel = Nothing + } + +-- ** Capitalization +-- | Capitalization +data Capitalization = Capitalization + { capitalizationSmallCamel :: !(Maybe Text) -- ^ "smallCamel" + , capitalizationCapitalCamel :: !(Maybe Text) -- ^ "CapitalCamel" + , capitalizationSmallSnake :: !(Maybe Text) -- ^ "small_Snake" + , capitalizationCapitalSnake :: !(Maybe Text) -- ^ "Capital_Snake" + , capitalizationScaEthFlowPoints :: !(Maybe Text) -- ^ "SCA_ETH_Flow_Points" + , capitalizationAttName :: !(Maybe Text) -- ^ "ATT_NAME" - Name of the pet + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Capitalization +instance A.FromJSON Capitalization where + parseJSON = A.withObject "Capitalization" $ \o -> + Capitalization + <$> (o .:? "smallCamel") + <*> (o .:? "CapitalCamel") + <*> (o .:? "small_Snake") + <*> (o .:? "Capital_Snake") + <*> (o .:? "SCA_ETH_Flow_Points") + <*> (o .:? "ATT_NAME") + +-- | ToJSON Capitalization +instance A.ToJSON Capitalization where + toJSON Capitalization {..} = + _omitNulls + [ "smallCamel" .= capitalizationSmallCamel + , "CapitalCamel" .= capitalizationCapitalCamel + , "small_Snake" .= capitalizationSmallSnake + , "Capital_Snake" .= capitalizationCapitalSnake + , "SCA_ETH_Flow_Points" .= capitalizationScaEthFlowPoints + , "ATT_NAME" .= capitalizationAttName + ] + + +-- | Construct a value of type 'Capitalization' (by applying it's required fields, if any) +mkCapitalization + :: Capitalization +mkCapitalization = + Capitalization + { capitalizationSmallCamel = Nothing + , capitalizationCapitalCamel = Nothing + , capitalizationSmallSnake = Nothing + , capitalizationCapitalSnake = Nothing + , capitalizationScaEthFlowPoints = Nothing + , capitalizationAttName = Nothing + } + +-- ** Category +-- | Category +data Category = Category + { categoryId :: !(Maybe Integer) -- ^ "id" + , categoryName :: !(Maybe Text) -- ^ "name" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Category +instance A.FromJSON Category where + parseJSON = A.withObject "Category" $ \o -> + Category + <$> (o .:? "id") + <*> (o .:? "name") + +-- | ToJSON Category +instance A.ToJSON Category where + toJSON Category {..} = + _omitNulls + [ "id" .= categoryId + , "name" .= categoryName + ] + + +-- | Construct a value of type 'Category' (by applying it's required fields, if any) +mkCategory + :: Category +mkCategory = + Category + { categoryId = Nothing + , categoryName = Nothing + } + +-- ** ClassModel +-- | ClassModel +-- Model for testing model with \"_class\" property +data ClassModel = ClassModel + { classModelClass :: !(Maybe Text) -- ^ "_class" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON ClassModel +instance A.FromJSON ClassModel where + parseJSON = A.withObject "ClassModel" $ \o -> + ClassModel + <$> (o .:? "_class") + +-- | ToJSON ClassModel +instance A.ToJSON ClassModel where + toJSON ClassModel {..} = + _omitNulls + [ "_class" .= classModelClass + ] + + +-- | Construct a value of type 'ClassModel' (by applying it's required fields, if any) +mkClassModel + :: ClassModel +mkClassModel = + ClassModel + { classModelClass = Nothing + } + +-- ** Client +-- | Client +data Client = Client + { clientClient :: !(Maybe Text) -- ^ "client" + } deriving (P.Show, P.Eq, P.Typeable) --- ** Client --- | Client -data Client = Client - { clientClient :: !(Maybe Text) -- ^ "client" - } deriving (P.Show, P.Eq, P.Typeable) +-- | FromJSON Client +instance A.FromJSON Client where + parseJSON = A.withObject "Client" $ \o -> + Client + <$> (o .:? "client") --- | FromJSON Client -instance A.FromJSON Client where - parseJSON = A.withObject "Client" $ \o -> - Client - <$> (o .:? "client") - --- | ToJSON Client -instance A.ToJSON Client where - toJSON Client {..} = - _omitNulls - [ "client" .= clientClient - ] - - --- | Construct a value of type 'Client' (by applying it's required fields, if any) -mkClient - :: Client -mkClient = - Client - { clientClient = Nothing - } - +-- | ToJSON Client +instance A.ToJSON Client where + toJSON Client {..} = + _omitNulls + [ "client" .= clientClient + ] + + +-- | Construct a value of type 'Client' (by applying it's required fields, if any) +mkClient + :: Client +mkClient = + Client + { clientClient = Nothing + } + +-- ** EnumArrays +-- | EnumArrays +data EnumArrays = EnumArrays + { enumArraysJustSymbol :: !(Maybe E'JustSymbol) -- ^ "just_symbol" + , enumArraysArrayEnum :: !(Maybe [E'ArrayEnum]) -- ^ "array_enum" + } deriving (P.Show, P.Eq, P.Typeable) --- ** EnumArrays --- | EnumArrays -data EnumArrays = EnumArrays - { enumArraysJustSymbol :: !(Maybe Text) -- ^ "just_symbol" - , enumArraysArrayEnum :: !(Maybe [Text]) -- ^ "array_enum" - } deriving (P.Show, P.Eq, P.Typeable) +-- | FromJSON EnumArrays +instance A.FromJSON EnumArrays where + parseJSON = A.withObject "EnumArrays" $ \o -> + EnumArrays + <$> (o .:? "just_symbol") + <*> (o .:? "array_enum") --- | FromJSON EnumArrays -instance A.FromJSON EnumArrays where - parseJSON = A.withObject "EnumArrays" $ \o -> - EnumArrays - <$> (o .:? "just_symbol") - <*> (o .:? "array_enum") - --- | ToJSON EnumArrays -instance A.ToJSON EnumArrays where - toJSON EnumArrays {..} = - _omitNulls - [ "just_symbol" .= enumArraysJustSymbol - , "array_enum" .= enumArraysArrayEnum - ] - - --- | Construct a value of type 'EnumArrays' (by applying it's required fields, if any) -mkEnumArrays - :: EnumArrays -mkEnumArrays = - EnumArrays - { enumArraysJustSymbol = Nothing - , enumArraysArrayEnum = Nothing - } - - --- ** EnumClass --- | EnumClass -data EnumClass = EnumClass - { - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON EnumClass -instance A.FromJSON EnumClass where - parseJSON = A.withObject "EnumClass" $ \o -> - pure EnumClass - - --- | ToJSON EnumClass -instance A.ToJSON EnumClass where - toJSON EnumClass = - _omitNulls - [ - ] - +-- | ToJSON EnumArrays +instance A.ToJSON EnumArrays where + toJSON EnumArrays {..} = + _omitNulls + [ "just_symbol" .= enumArraysJustSymbol + , "array_enum" .= enumArraysArrayEnum + ] + + +-- | Construct a value of type 'EnumArrays' (by applying it's required fields, if any) +mkEnumArrays + :: EnumArrays +mkEnumArrays = + EnumArrays + { enumArraysJustSymbol = Nothing + , enumArraysArrayEnum = Nothing + } + +-- ** EnumTest +-- | EnumTest +data EnumTest = EnumTest + { enumTestEnumString :: !(Maybe E'EnumString) -- ^ "enum_string" + , enumTestEnumInteger :: !(Maybe E'EnumInteger) -- ^ "enum_integer" + , enumTestEnumNumber :: !(Maybe E'EnumNumber) -- ^ "enum_number" + , enumTestOuterEnum :: !(Maybe OuterEnum) -- ^ "outerEnum" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON EnumTest +instance A.FromJSON EnumTest where + parseJSON = A.withObject "EnumTest" $ \o -> + EnumTest + <$> (o .:? "enum_string") + <*> (o .:? "enum_integer") + <*> (o .:? "enum_number") + <*> (o .:? "outerEnum") + +-- | ToJSON EnumTest +instance A.ToJSON EnumTest where + toJSON EnumTest {..} = + _omitNulls + [ "enum_string" .= enumTestEnumString + , "enum_integer" .= enumTestEnumInteger + , "enum_number" .= enumTestEnumNumber + , "outerEnum" .= enumTestOuterEnum + ] --- | Construct a value of type 'EnumClass' (by applying it's required fields, if any) -mkEnumClass - :: EnumClass -mkEnumClass = - EnumClass - { - } - - --- ** EnumTest --- | EnumTest -data EnumTest = EnumTest - { enumTestEnumString :: !(Maybe Text) -- ^ "enum_string" - , enumTestEnumInteger :: !(Maybe Int) -- ^ "enum_integer" - , enumTestEnumNumber :: !(Maybe Double) -- ^ "enum_number" - , enumTestOuterEnum :: !(Maybe OuterEnum) -- ^ "outerEnum" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON EnumTest -instance A.FromJSON EnumTest where - parseJSON = A.withObject "EnumTest" $ \o -> - EnumTest - <$> (o .:? "enum_string") - <*> (o .:? "enum_integer") - <*> (o .:? "enum_number") - <*> (o .:? "outerEnum") - --- | ToJSON EnumTest -instance A.ToJSON EnumTest where - toJSON EnumTest {..} = - _omitNulls - [ "enum_string" .= enumTestEnumString - , "enum_integer" .= enumTestEnumInteger - , "enum_number" .= enumTestEnumNumber - , "outerEnum" .= enumTestOuterEnum - ] - - --- | Construct a value of type 'EnumTest' (by applying it's required fields, if any) -mkEnumTest - :: EnumTest -mkEnumTest = - EnumTest - { enumTestEnumString = Nothing - , enumTestEnumInteger = Nothing - , enumTestEnumNumber = Nothing - , enumTestOuterEnum = Nothing - } - - --- ** FormatTest --- | FormatTest -data FormatTest = FormatTest - { formatTestInteger :: !(Maybe Int) -- ^ "integer" - , formatTestInt32 :: !(Maybe Int) -- ^ "int32" - , formatTestInt64 :: !(Maybe Integer) -- ^ "int64" - , formatTestNumber :: !(Double) -- ^ /Required/ "number" - , formatTestFloat :: !(Maybe Float) -- ^ "float" - , formatTestDouble :: !(Maybe Double) -- ^ "double" - , formatTestString :: !(Maybe Text) -- ^ "string" - , formatTestByte :: !(ByteArray) -- ^ /Required/ "byte" - , formatTestBinary :: !(Maybe Binary) -- ^ "binary" - , formatTestDate :: !(Date) -- ^ /Required/ "date" - , formatTestDateTime :: !(Maybe DateTime) -- ^ "dateTime" - , formatTestUuid :: !(Maybe Text) -- ^ "uuid" - , formatTestPassword :: !(Text) -- ^ /Required/ "password" - } deriving (P.Show, P.Eq, P.Typeable) + +-- | Construct a value of type 'EnumTest' (by applying it's required fields, if any) +mkEnumTest + :: EnumTest +mkEnumTest = + EnumTest + { enumTestEnumString = Nothing + , enumTestEnumInteger = Nothing + , enumTestEnumNumber = Nothing + , enumTestOuterEnum = Nothing + } + +-- ** FormatTest +-- | FormatTest +data FormatTest = FormatTest + { formatTestInteger :: !(Maybe Int) -- ^ "integer" + , formatTestInt32 :: !(Maybe Int) -- ^ "int32" + , formatTestInt64 :: !(Maybe Integer) -- ^ "int64" + , formatTestNumber :: !(Double) -- ^ /Required/ "number" + , formatTestFloat :: !(Maybe Float) -- ^ "float" + , formatTestDouble :: !(Maybe Double) -- ^ "double" + , formatTestString :: !(Maybe Text) -- ^ "string" + , formatTestByte :: !(ByteArray) -- ^ /Required/ "byte" + , formatTestBinary :: !(Maybe Binary) -- ^ "binary" + , formatTestDate :: !(Date) -- ^ /Required/ "date" + , formatTestDateTime :: !(Maybe DateTime) -- ^ "dateTime" + , formatTestUuid :: !(Maybe Text) -- ^ "uuid" + , formatTestPassword :: !(Text) -- ^ /Required/ "password" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON FormatTest +instance A.FromJSON FormatTest where + parseJSON = A.withObject "FormatTest" $ \o -> + FormatTest + <$> (o .:? "integer") + <*> (o .:? "int32") + <*> (o .:? "int64") + <*> (o .: "number") + <*> (o .:? "float") + <*> (o .:? "double") + <*> (o .:? "string") + <*> (o .: "byte") + <*> (o .:? "binary") + <*> (o .: "date") + <*> (o .:? "dateTime") + <*> (o .:? "uuid") + <*> (o .: "password") + +-- | ToJSON FormatTest +instance A.ToJSON FormatTest where + toJSON FormatTest {..} = + _omitNulls + [ "integer" .= formatTestInteger + , "int32" .= formatTestInt32 + , "int64" .= formatTestInt64 + , "number" .= formatTestNumber + , "float" .= formatTestFloat + , "double" .= formatTestDouble + , "string" .= formatTestString + , "byte" .= formatTestByte + , "binary" .= formatTestBinary + , "date" .= formatTestDate + , "dateTime" .= formatTestDateTime + , "uuid" .= formatTestUuid + , "password" .= formatTestPassword + ] + --- | FromJSON FormatTest -instance A.FromJSON FormatTest where - parseJSON = A.withObject "FormatTest" $ \o -> - FormatTest - <$> (o .:? "integer") - <*> (o .:? "int32") - <*> (o .:? "int64") - <*> (o .: "number") - <*> (o .:? "float") - <*> (o .:? "double") - <*> (o .:? "string") - <*> (o .: "byte") - <*> (o .:? "binary") - <*> (o .: "date") - <*> (o .:? "dateTime") - <*> (o .:? "uuid") - <*> (o .: "password") - --- | ToJSON FormatTest -instance A.ToJSON FormatTest where - toJSON FormatTest {..} = - _omitNulls - [ "integer" .= formatTestInteger - , "int32" .= formatTestInt32 - , "int64" .= formatTestInt64 - , "number" .= formatTestNumber - , "float" .= formatTestFloat - , "double" .= formatTestDouble - , "string" .= formatTestString - , "byte" .= formatTestByte - , "binary" .= formatTestBinary - , "date" .= formatTestDate - , "dateTime" .= formatTestDateTime - , "uuid" .= formatTestUuid - , "password" .= formatTestPassword - ] - +-- | Construct a value of type 'FormatTest' (by applying it's required fields, if any) +mkFormatTest + :: Double -- ^ 'formatTestNumber' + -> ByteArray -- ^ 'formatTestByte' + -> Date -- ^ 'formatTestDate' + -> Text -- ^ 'formatTestPassword' + -> FormatTest +mkFormatTest formatTestNumber formatTestByte formatTestDate formatTestPassword = + FormatTest + { formatTestInteger = Nothing + , formatTestInt32 = Nothing + , formatTestInt64 = Nothing + , formatTestNumber + , formatTestFloat = Nothing + , formatTestDouble = Nothing + , formatTestString = Nothing + , formatTestByte + , formatTestBinary = Nothing + , formatTestDate + , formatTestDateTime = Nothing + , formatTestUuid = Nothing + , formatTestPassword + } + +-- ** HasOnlyReadOnly +-- | HasOnlyReadOnly +data HasOnlyReadOnly = HasOnlyReadOnly + { hasOnlyReadOnlyBar :: !(Maybe Text) -- ^ "bar" + , hasOnlyReadOnlyFoo :: !(Maybe Text) -- ^ "foo" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON HasOnlyReadOnly +instance A.FromJSON HasOnlyReadOnly where + parseJSON = A.withObject "HasOnlyReadOnly" $ \o -> + HasOnlyReadOnly + <$> (o .:? "bar") + <*> (o .:? "foo") --- | Construct a value of type 'FormatTest' (by applying it's required fields, if any) -mkFormatTest - :: Double -- ^ 'formatTestNumber' - -> ByteArray -- ^ 'formatTestByte' - -> Date -- ^ 'formatTestDate' - -> Text -- ^ 'formatTestPassword' - -> FormatTest -mkFormatTest formatTestNumber formatTestByte formatTestDate formatTestPassword = - FormatTest - { formatTestInteger = Nothing - , formatTestInt32 = Nothing - , formatTestInt64 = Nothing - , formatTestNumber - , formatTestFloat = Nothing - , formatTestDouble = Nothing - , formatTestString = Nothing - , formatTestByte - , formatTestBinary = Nothing - , formatTestDate - , formatTestDateTime = Nothing - , formatTestUuid = Nothing - , formatTestPassword - } - +-- | ToJSON HasOnlyReadOnly +instance A.ToJSON HasOnlyReadOnly where + toJSON HasOnlyReadOnly {..} = + _omitNulls + [ "bar" .= hasOnlyReadOnlyBar + , "foo" .= hasOnlyReadOnlyFoo + ] + + +-- | Construct a value of type 'HasOnlyReadOnly' (by applying it's required fields, if any) +mkHasOnlyReadOnly + :: HasOnlyReadOnly +mkHasOnlyReadOnly = + HasOnlyReadOnly + { hasOnlyReadOnlyBar = Nothing + , hasOnlyReadOnlyFoo = Nothing + } + +-- ** MapTest +-- | MapTest +data MapTest = MapTest + { mapTestMapMapOfString :: !(Maybe (Map.Map String (Map.Map String Text))) -- ^ "map_map_of_string" + , mapTestMapOfEnumString :: !(Maybe (Map.Map String E'Inner)) -- ^ "map_of_enum_string" + } deriving (P.Show, P.Eq, P.Typeable) --- ** HasOnlyReadOnly --- | HasOnlyReadOnly -data HasOnlyReadOnly = HasOnlyReadOnly - { hasOnlyReadOnlyBar :: !(Maybe Text) -- ^ "bar" - , hasOnlyReadOnlyFoo :: !(Maybe Text) -- ^ "foo" - } deriving (P.Show, P.Eq, P.Typeable) +-- | FromJSON MapTest +instance A.FromJSON MapTest where + parseJSON = A.withObject "MapTest" $ \o -> + MapTest + <$> (o .:? "map_map_of_string") + <*> (o .:? "map_of_enum_string") --- | FromJSON HasOnlyReadOnly -instance A.FromJSON HasOnlyReadOnly where - parseJSON = A.withObject "HasOnlyReadOnly" $ \o -> - HasOnlyReadOnly - <$> (o .:? "bar") - <*> (o .:? "foo") - --- | ToJSON HasOnlyReadOnly -instance A.ToJSON HasOnlyReadOnly where - toJSON HasOnlyReadOnly {..} = - _omitNulls - [ "bar" .= hasOnlyReadOnlyBar - , "foo" .= hasOnlyReadOnlyFoo - ] - - --- | Construct a value of type 'HasOnlyReadOnly' (by applying it's required fields, if any) -mkHasOnlyReadOnly - :: HasOnlyReadOnly -mkHasOnlyReadOnly = - HasOnlyReadOnly - { hasOnlyReadOnlyBar = Nothing - , hasOnlyReadOnlyFoo = Nothing - } - +-- | ToJSON MapTest +instance A.ToJSON MapTest where + toJSON MapTest {..} = + _omitNulls + [ "map_map_of_string" .= mapTestMapMapOfString + , "map_of_enum_string" .= mapTestMapOfEnumString + ] + + +-- | Construct a value of type 'MapTest' (by applying it's required fields, if any) +mkMapTest + :: MapTest +mkMapTest = + MapTest + { mapTestMapMapOfString = Nothing + , mapTestMapOfEnumString = Nothing + } + +-- ** MixedPropertiesAndAdditionalPropertiesClass +-- | MixedPropertiesAndAdditionalPropertiesClass +data MixedPropertiesAndAdditionalPropertiesClass = MixedPropertiesAndAdditionalPropertiesClass + { mixedPropertiesAndAdditionalPropertiesClassUuid :: !(Maybe Text) -- ^ "uuid" + , mixedPropertiesAndAdditionalPropertiesClassDateTime :: !(Maybe DateTime) -- ^ "dateTime" + , mixedPropertiesAndAdditionalPropertiesClassMap :: !(Maybe (Map.Map String Animal)) -- ^ "map" + } deriving (P.Show, P.Eq, P.Typeable) --- ** MapTest --- | MapTest -data MapTest = MapTest - { mapTestMapMapOfString :: !(Maybe (Map.Map String (Map.Map String Text))) -- ^ "map_map_of_string" - , mapTestMapOfEnumString :: !(Maybe (Map.Map String Text)) -- ^ "map_of_enum_string" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON MapTest -instance A.FromJSON MapTest where - parseJSON = A.withObject "MapTest" $ \o -> - MapTest - <$> (o .:? "map_map_of_string") - <*> (o .:? "map_of_enum_string") - --- | ToJSON MapTest -instance A.ToJSON MapTest where - toJSON MapTest {..} = - _omitNulls - [ "map_map_of_string" .= mapTestMapMapOfString - , "map_of_enum_string" .= mapTestMapOfEnumString - ] - - --- | Construct a value of type 'MapTest' (by applying it's required fields, if any) -mkMapTest - :: MapTest -mkMapTest = - MapTest - { mapTestMapMapOfString = Nothing - , mapTestMapOfEnumString = Nothing - } - - --- ** MixedPropertiesAndAdditionalPropertiesClass --- | MixedPropertiesAndAdditionalPropertiesClass -data MixedPropertiesAndAdditionalPropertiesClass = MixedPropertiesAndAdditionalPropertiesClass - { mixedPropertiesAndAdditionalPropertiesClassUuid :: !(Maybe Text) -- ^ "uuid" - , mixedPropertiesAndAdditionalPropertiesClassDateTime :: !(Maybe DateTime) -- ^ "dateTime" - , mixedPropertiesAndAdditionalPropertiesClassMap :: !(Maybe (Map.Map String Animal)) -- ^ "map" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON MixedPropertiesAndAdditionalPropertiesClass -instance A.FromJSON MixedPropertiesAndAdditionalPropertiesClass where - parseJSON = A.withObject "MixedPropertiesAndAdditionalPropertiesClass" $ \o -> - MixedPropertiesAndAdditionalPropertiesClass - <$> (o .:? "uuid") - <*> (o .:? "dateTime") - <*> (o .:? "map") - --- | ToJSON MixedPropertiesAndAdditionalPropertiesClass -instance A.ToJSON MixedPropertiesAndAdditionalPropertiesClass where - toJSON MixedPropertiesAndAdditionalPropertiesClass {..} = - _omitNulls - [ "uuid" .= mixedPropertiesAndAdditionalPropertiesClassUuid - , "dateTime" .= mixedPropertiesAndAdditionalPropertiesClassDateTime - , "map" .= mixedPropertiesAndAdditionalPropertiesClassMap - ] - - --- | Construct a value of type 'MixedPropertiesAndAdditionalPropertiesClass' (by applying it's required fields, if any) -mkMixedPropertiesAndAdditionalPropertiesClass - :: MixedPropertiesAndAdditionalPropertiesClass -mkMixedPropertiesAndAdditionalPropertiesClass = - MixedPropertiesAndAdditionalPropertiesClass - { mixedPropertiesAndAdditionalPropertiesClassUuid = Nothing - , mixedPropertiesAndAdditionalPropertiesClassDateTime = Nothing - , mixedPropertiesAndAdditionalPropertiesClassMap = Nothing - } - - --- ** Model200Response --- | Model200Response --- Model for testing model name starting with number -data Model200Response = Model200Response - { model200ResponseName :: !(Maybe Int) -- ^ "name" - , model200ResponseClass :: !(Maybe Text) -- ^ "class" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Model200Response -instance A.FromJSON Model200Response where - parseJSON = A.withObject "Model200Response" $ \o -> - Model200Response - <$> (o .:? "name") - <*> (o .:? "class") - --- | ToJSON Model200Response -instance A.ToJSON Model200Response where - toJSON Model200Response {..} = - _omitNulls - [ "name" .= model200ResponseName - , "class" .= model200ResponseClass - ] - - --- | Construct a value of type 'Model200Response' (by applying it's required fields, if any) -mkModel200Response - :: Model200Response -mkModel200Response = - Model200Response - { model200ResponseName = Nothing - , model200ResponseClass = Nothing - } - - --- ** ModelList --- | ModelList -data ModelList = ModelList - { modelList123List :: !(Maybe Text) -- ^ "123-list" - } deriving (P.Show, P.Eq, P.Typeable) +-- | FromJSON MixedPropertiesAndAdditionalPropertiesClass +instance A.FromJSON MixedPropertiesAndAdditionalPropertiesClass where + parseJSON = A.withObject "MixedPropertiesAndAdditionalPropertiesClass" $ \o -> + MixedPropertiesAndAdditionalPropertiesClass + <$> (o .:? "uuid") + <*> (o .:? "dateTime") + <*> (o .:? "map") + +-- | ToJSON MixedPropertiesAndAdditionalPropertiesClass +instance A.ToJSON MixedPropertiesAndAdditionalPropertiesClass where + toJSON MixedPropertiesAndAdditionalPropertiesClass {..} = + _omitNulls + [ "uuid" .= mixedPropertiesAndAdditionalPropertiesClassUuid + , "dateTime" .= mixedPropertiesAndAdditionalPropertiesClassDateTime + , "map" .= mixedPropertiesAndAdditionalPropertiesClassMap + ] + + +-- | Construct a value of type 'MixedPropertiesAndAdditionalPropertiesClass' (by applying it's required fields, if any) +mkMixedPropertiesAndAdditionalPropertiesClass + :: MixedPropertiesAndAdditionalPropertiesClass +mkMixedPropertiesAndAdditionalPropertiesClass = + MixedPropertiesAndAdditionalPropertiesClass + { mixedPropertiesAndAdditionalPropertiesClassUuid = Nothing + , mixedPropertiesAndAdditionalPropertiesClassDateTime = Nothing + , mixedPropertiesAndAdditionalPropertiesClassMap = Nothing + } + +-- ** Model200Response +-- | Model200Response +-- Model for testing model name starting with number +data Model200Response = Model200Response + { model200ResponseName :: !(Maybe Int) -- ^ "name" + , model200ResponseClass :: !(Maybe Text) -- ^ "class" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Model200Response +instance A.FromJSON Model200Response where + parseJSON = A.withObject "Model200Response" $ \o -> + Model200Response + <$> (o .:? "name") + <*> (o .:? "class") + +-- | ToJSON Model200Response +instance A.ToJSON Model200Response where + toJSON Model200Response {..} = + _omitNulls + [ "name" .= model200ResponseName + , "class" .= model200ResponseClass + ] + + +-- | Construct a value of type 'Model200Response' (by applying it's required fields, if any) +mkModel200Response + :: Model200Response +mkModel200Response = + Model200Response + { model200ResponseName = Nothing + , model200ResponseClass = Nothing + } + +-- ** ModelList +-- | ModelList +data ModelList = ModelList + { modelList123List :: !(Maybe Text) -- ^ "123-list" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON ModelList +instance A.FromJSON ModelList where + parseJSON = A.withObject "ModelList" $ \o -> + ModelList + <$> (o .:? "123-list") + +-- | ToJSON ModelList +instance A.ToJSON ModelList where + toJSON ModelList {..} = + _omitNulls + [ "123-list" .= modelList123List + ] + + +-- | Construct a value of type 'ModelList' (by applying it's required fields, if any) +mkModelList + :: ModelList +mkModelList = + ModelList + { modelList123List = Nothing + } + +-- ** ModelReturn +-- | ModelReturn +-- Model for testing reserved words +data ModelReturn = ModelReturn + { modelReturnReturn :: !(Maybe Int) -- ^ "return" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON ModelReturn +instance A.FromJSON ModelReturn where + parseJSON = A.withObject "ModelReturn" $ \o -> + ModelReturn + <$> (o .:? "return") + +-- | ToJSON ModelReturn +instance A.ToJSON ModelReturn where + toJSON ModelReturn {..} = + _omitNulls + [ "return" .= modelReturnReturn + ] + --- | FromJSON ModelList -instance A.FromJSON ModelList where - parseJSON = A.withObject "ModelList" $ \o -> - ModelList - <$> (o .:? "123-list") - --- | ToJSON ModelList -instance A.ToJSON ModelList where - toJSON ModelList {..} = - _omitNulls - [ "123-list" .= modelList123List - ] - - --- | Construct a value of type 'ModelList' (by applying it's required fields, if any) -mkModelList - :: ModelList -mkModelList = - ModelList - { modelList123List = Nothing - } - - --- ** ModelReturn --- | ModelReturn --- Model for testing reserved words -data ModelReturn = ModelReturn - { modelReturnReturn :: !(Maybe Int) -- ^ "return" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON ModelReturn -instance A.FromJSON ModelReturn where - parseJSON = A.withObject "ModelReturn" $ \o -> - ModelReturn - <$> (o .:? "return") - --- | ToJSON ModelReturn -instance A.ToJSON ModelReturn where - toJSON ModelReturn {..} = - _omitNulls - [ "return" .= modelReturnReturn - ] - - --- | Construct a value of type 'ModelReturn' (by applying it's required fields, if any) -mkModelReturn - :: ModelReturn -mkModelReturn = - ModelReturn - { modelReturnReturn = Nothing - } - - --- ** Name --- | Name --- Model for testing model name same as property name -data Name = Name - { nameName :: !(Int) -- ^ /Required/ "name" - , nameSnakeCase :: !(Maybe Int) -- ^ "snake_case" - , nameProperty :: !(Maybe Text) -- ^ "property" - , name123Number :: !(Maybe Int) -- ^ "123Number" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Name -instance A.FromJSON Name where - parseJSON = A.withObject "Name" $ \o -> - Name - <$> (o .: "name") - <*> (o .:? "snake_case") - <*> (o .:? "property") - <*> (o .:? "123Number") - --- | ToJSON Name -instance A.ToJSON Name where - toJSON Name {..} = - _omitNulls - [ "name" .= nameName - , "snake_case" .= nameSnakeCase - , "property" .= nameProperty - , "123Number" .= name123Number - ] - - --- | Construct a value of type 'Name' (by applying it's required fields, if any) -mkName - :: Int -- ^ 'nameName' - -> Name -mkName nameName = - Name - { nameName - , nameSnakeCase = Nothing - , nameProperty = Nothing - , name123Number = Nothing - } - - --- ** NumberOnly --- | NumberOnly -data NumberOnly = NumberOnly - { numberOnlyJustNumber :: !(Maybe Double) -- ^ "JustNumber" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON NumberOnly -instance A.FromJSON NumberOnly where - parseJSON = A.withObject "NumberOnly" $ \o -> - NumberOnly - <$> (o .:? "JustNumber") - --- | ToJSON NumberOnly -instance A.ToJSON NumberOnly where - toJSON NumberOnly {..} = - _omitNulls - [ "JustNumber" .= numberOnlyJustNumber - ] - - --- | Construct a value of type 'NumberOnly' (by applying it's required fields, if any) -mkNumberOnly - :: NumberOnly -mkNumberOnly = - NumberOnly - { numberOnlyJustNumber = Nothing - } - - --- ** Order --- | Order -data Order = Order - { orderId :: !(Maybe Integer) -- ^ "id" - , orderPetId :: !(Maybe Integer) -- ^ "petId" - , orderQuantity :: !(Maybe Int) -- ^ "quantity" - , orderShipDate :: !(Maybe DateTime) -- ^ "shipDate" - , orderStatus :: !(Maybe Text) -- ^ "status" - Order Status - , orderComplete :: !(Maybe Bool) -- ^ "complete" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Order -instance A.FromJSON Order where - parseJSON = A.withObject "Order" $ \o -> - Order - <$> (o .:? "id") - <*> (o .:? "petId") - <*> (o .:? "quantity") - <*> (o .:? "shipDate") - <*> (o .:? "status") - <*> (o .:? "complete") - --- | ToJSON Order -instance A.ToJSON Order where - toJSON Order {..} = - _omitNulls - [ "id" .= orderId - , "petId" .= orderPetId - , "quantity" .= orderQuantity - , "shipDate" .= orderShipDate - , "status" .= orderStatus - , "complete" .= orderComplete - ] +-- | Construct a value of type 'ModelReturn' (by applying it's required fields, if any) +mkModelReturn + :: ModelReturn +mkModelReturn = + ModelReturn + { modelReturnReturn = Nothing + } + +-- ** Name +-- | Name +-- Model for testing model name same as property name +data Name = Name + { nameName :: !(Int) -- ^ /Required/ "name" + , nameSnakeCase :: !(Maybe Int) -- ^ "snake_case" + , nameProperty :: !(Maybe Text) -- ^ "property" + , name123Number :: !(Maybe Int) -- ^ "123Number" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Name +instance A.FromJSON Name where + parseJSON = A.withObject "Name" $ \o -> + Name + <$> (o .: "name") + <*> (o .:? "snake_case") + <*> (o .:? "property") + <*> (o .:? "123Number") + +-- | ToJSON Name +instance A.ToJSON Name where + toJSON Name {..} = + _omitNulls + [ "name" .= nameName + , "snake_case" .= nameSnakeCase + , "property" .= nameProperty + , "123Number" .= name123Number + ] + + +-- | Construct a value of type 'Name' (by applying it's required fields, if any) +mkName + :: Int -- ^ 'nameName' + -> Name +mkName nameName = + Name + { nameName + , nameSnakeCase = Nothing + , nameProperty = Nothing + , name123Number = Nothing + } + +-- ** NumberOnly +-- | NumberOnly +data NumberOnly = NumberOnly + { numberOnlyJustNumber :: !(Maybe Double) -- ^ "JustNumber" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON NumberOnly +instance A.FromJSON NumberOnly where + parseJSON = A.withObject "NumberOnly" $ \o -> + NumberOnly + <$> (o .:? "JustNumber") + +-- | ToJSON NumberOnly +instance A.ToJSON NumberOnly where + toJSON NumberOnly {..} = + _omitNulls + [ "JustNumber" .= numberOnlyJustNumber + ] + + +-- | Construct a value of type 'NumberOnly' (by applying it's required fields, if any) +mkNumberOnly + :: NumberOnly +mkNumberOnly = + NumberOnly + { numberOnlyJustNumber = Nothing + } + +-- ** Order +-- | Order +data Order = Order + { orderId :: !(Maybe Integer) -- ^ "id" + , orderPetId :: !(Maybe Integer) -- ^ "petId" + , orderQuantity :: !(Maybe Int) -- ^ "quantity" + , orderShipDate :: !(Maybe DateTime) -- ^ "shipDate" + , orderStatus :: !(Maybe E'Status) -- ^ "status" - Order Status + , orderComplete :: !(Maybe Bool) -- ^ "complete" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Order +instance A.FromJSON Order where + parseJSON = A.withObject "Order" $ \o -> + Order + <$> (o .:? "id") + <*> (o .:? "petId") + <*> (o .:? "quantity") + <*> (o .:? "shipDate") + <*> (o .:? "status") + <*> (o .:? "complete") + +-- | ToJSON Order +instance A.ToJSON Order where + toJSON Order {..} = + _omitNulls + [ "id" .= orderId + , "petId" .= orderPetId + , "quantity" .= orderQuantity + , "shipDate" .= orderShipDate + , "status" .= orderStatus + , "complete" .= orderComplete + ] + + +-- | Construct a value of type 'Order' (by applying it's required fields, if any) +mkOrder + :: Order +mkOrder = + Order + { orderId = Nothing + , orderPetId = Nothing + , orderQuantity = Nothing + , orderShipDate = Nothing + , orderStatus = Nothing + , orderComplete = Nothing + } + +-- ** OuterBoolean +-- | OuterBoolean +newtype OuterBoolean = OuterBoolean + { unOuterBoolean :: Bool + } deriving (P.Eq, P.Show, P.Typeable, A.ToJSON, A.FromJSON, WH.ToHttpApiData, WH.FromHttpApiData) + + +-- ** OuterComposite +-- | OuterComposite +data OuterComposite = OuterComposite + { outerCompositeMyNumber :: !(Maybe OuterNumber) -- ^ "my_number" + , outerCompositeMyString :: !(Maybe OuterString) -- ^ "my_string" + , outerCompositeMyBoolean :: !(Maybe OuterBoolean) -- ^ "my_boolean" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON OuterComposite +instance A.FromJSON OuterComposite where + parseJSON = A.withObject "OuterComposite" $ \o -> + OuterComposite + <$> (o .:? "my_number") + <*> (o .:? "my_string") + <*> (o .:? "my_boolean") + +-- | ToJSON OuterComposite +instance A.ToJSON OuterComposite where + toJSON OuterComposite {..} = + _omitNulls + [ "my_number" .= outerCompositeMyNumber + , "my_string" .= outerCompositeMyString + , "my_boolean" .= outerCompositeMyBoolean + ] + - --- | Construct a value of type 'Order' (by applying it's required fields, if any) -mkOrder - :: Order -mkOrder = - Order - { orderId = Nothing - , orderPetId = Nothing - , orderQuantity = Nothing - , orderShipDate = Nothing - , orderStatus = Nothing - , orderComplete = Nothing - } - - --- ** OuterBoolean --- | OuterBoolean -newtype OuterBoolean = OuterBoolean - { unOuterBoolean :: Bool - } deriving (P.Eq, P.Show, P.Typeable, A.ToJSON, A.FromJSON, WH.ToHttpApiData, WH.FromHttpApiData) - - +-- | Construct a value of type 'OuterComposite' (by applying it's required fields, if any) +mkOuterComposite + :: OuterComposite +mkOuterComposite = + OuterComposite + { outerCompositeMyNumber = Nothing + , outerCompositeMyString = Nothing + , outerCompositeMyBoolean = Nothing + } + +-- ** OuterNumber +-- | OuterNumber +newtype OuterNumber = OuterNumber + { unOuterNumber :: Double + } deriving (P.Eq, P.Show, P.Typeable, A.ToJSON, A.FromJSON, WH.ToHttpApiData, WH.FromHttpApiData) + + +-- ** OuterString +-- | OuterString +newtype OuterString = OuterString + { unOuterString :: Text + } deriving (P.Eq, P.Show, P.Typeable, A.ToJSON, A.FromJSON, WH.ToHttpApiData, WH.FromHttpApiData) --- ** OuterComposite --- | OuterComposite -data OuterComposite = OuterComposite - { outerCompositeMyNumber :: !(Maybe OuterNumber) -- ^ "my_number" - , outerCompositeMyString :: !(Maybe OuterString) -- ^ "my_string" - , outerCompositeMyBoolean :: !(Maybe OuterBoolean) -- ^ "my_boolean" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON OuterComposite -instance A.FromJSON OuterComposite where - parseJSON = A.withObject "OuterComposite" $ \o -> - OuterComposite - <$> (o .:? "my_number") - <*> (o .:? "my_string") - <*> (o .:? "my_boolean") - --- | ToJSON OuterComposite -instance A.ToJSON OuterComposite where - toJSON OuterComposite {..} = - _omitNulls - [ "my_number" .= outerCompositeMyNumber - , "my_string" .= outerCompositeMyString - , "my_boolean" .= outerCompositeMyBoolean - ] - - --- | Construct a value of type 'OuterComposite' (by applying it's required fields, if any) -mkOuterComposite - :: OuterComposite -mkOuterComposite = - OuterComposite - { outerCompositeMyNumber = Nothing - , outerCompositeMyString = Nothing - , outerCompositeMyBoolean = Nothing - } + +-- ** Pet +-- | Pet +data Pet = Pet + { petId :: !(Maybe Integer) -- ^ "id" + , petCategory :: !(Maybe Category) -- ^ "category" + , petName :: !(Text) -- ^ /Required/ "name" + , petPhotoUrls :: !([Text]) -- ^ /Required/ "photoUrls" + , petTags :: !(Maybe [Tag]) -- ^ "tags" + , petStatus :: !(Maybe E'Status2) -- ^ "status" - pet status in the store + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Pet +instance A.FromJSON Pet where + parseJSON = A.withObject "Pet" $ \o -> + Pet + <$> (o .:? "id") + <*> (o .:? "category") + <*> (o .: "name") + <*> (o .: "photoUrls") + <*> (o .:? "tags") + <*> (o .:? "status") + +-- | ToJSON Pet +instance A.ToJSON Pet where + toJSON Pet {..} = + _omitNulls + [ "id" .= petId + , "category" .= petCategory + , "name" .= petName + , "photoUrls" .= petPhotoUrls + , "tags" .= petTags + , "status" .= petStatus + ] + - --- ** OuterEnum --- | OuterEnum -data OuterEnum = OuterEnum - { - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON OuterEnum -instance A.FromJSON OuterEnum where - parseJSON = A.withObject "OuterEnum" $ \o -> - pure OuterEnum - - --- | ToJSON OuterEnum -instance A.ToJSON OuterEnum where - toJSON OuterEnum = - _omitNulls - [ - ] - - --- | Construct a value of type 'OuterEnum' (by applying it's required fields, if any) -mkOuterEnum - :: OuterEnum -mkOuterEnum = - OuterEnum - { - } +-- | Construct a value of type 'Pet' (by applying it's required fields, if any) +mkPet + :: Text -- ^ 'petName' + -> [Text] -- ^ 'petPhotoUrls' + -> Pet +mkPet petName petPhotoUrls = + Pet + { petId = Nothing + , petCategory = Nothing + , petName + , petPhotoUrls + , petTags = Nothing + , petStatus = Nothing + } + +-- ** ReadOnlyFirst +-- | ReadOnlyFirst +data ReadOnlyFirst = ReadOnlyFirst + { readOnlyFirstBar :: !(Maybe Text) -- ^ "bar" + , readOnlyFirstBaz :: !(Maybe Text) -- ^ "baz" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON ReadOnlyFirst +instance A.FromJSON ReadOnlyFirst where + parseJSON = A.withObject "ReadOnlyFirst" $ \o -> + ReadOnlyFirst + <$> (o .:? "bar") + <*> (o .:? "baz") - --- ** OuterNumber --- | OuterNumber -newtype OuterNumber = OuterNumber - { unOuterNumber :: Double - } deriving (P.Eq, P.Show, P.Typeable, A.ToJSON, A.FromJSON, WH.ToHttpApiData, WH.FromHttpApiData) - +-- | ToJSON ReadOnlyFirst +instance A.ToJSON ReadOnlyFirst where + toJSON ReadOnlyFirst {..} = + _omitNulls + [ "bar" .= readOnlyFirstBar + , "baz" .= readOnlyFirstBaz + ] --- ** OuterString --- | OuterString -newtype OuterString = OuterString - { unOuterString :: Text - } deriving (P.Eq, P.Show, P.Typeable, A.ToJSON, A.FromJSON, WH.ToHttpApiData, WH.FromHttpApiData) - - - --- ** Pet --- | Pet -data Pet = Pet - { petId :: !(Maybe Integer) -- ^ "id" - , petCategory :: !(Maybe Category) -- ^ "category" - , petName :: !(Text) -- ^ /Required/ "name" - , petPhotoUrls :: !([Text]) -- ^ /Required/ "photoUrls" - , petTags :: !(Maybe [Tag]) -- ^ "tags" - , petStatus :: !(Maybe Text) -- ^ "status" - pet status in the store - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Pet -instance A.FromJSON Pet where - parseJSON = A.withObject "Pet" $ \o -> - Pet - <$> (o .:? "id") - <*> (o .:? "category") - <*> (o .: "name") - <*> (o .: "photoUrls") - <*> (o .:? "tags") - <*> (o .:? "status") - --- | ToJSON Pet -instance A.ToJSON Pet where - toJSON Pet {..} = - _omitNulls - [ "id" .= petId - , "category" .= petCategory - , "name" .= petName - , "photoUrls" .= petPhotoUrls - , "tags" .= petTags - , "status" .= petStatus - ] - - --- | Construct a value of type 'Pet' (by applying it's required fields, if any) -mkPet - :: Text -- ^ 'petName' - -> [Text] -- ^ 'petPhotoUrls' - -> Pet -mkPet petName petPhotoUrls = - Pet - { petId = Nothing - , petCategory = Nothing - , petName - , petPhotoUrls - , petTags = Nothing - , petStatus = Nothing - } - +-- | Construct a value of type 'ReadOnlyFirst' (by applying it's required fields, if any) +mkReadOnlyFirst + :: ReadOnlyFirst +mkReadOnlyFirst = + ReadOnlyFirst + { readOnlyFirstBar = Nothing + , readOnlyFirstBaz = Nothing + } + +-- ** SpecialModelName +-- | SpecialModelName +data SpecialModelName = SpecialModelName + { specialModelNameSpecialPropertyName :: !(Maybe Integer) -- ^ "$special[property.name]" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON SpecialModelName +instance A.FromJSON SpecialModelName where + parseJSON = A.withObject "SpecialModelName" $ \o -> + SpecialModelName + <$> (o .:? "$special[property.name]") + +-- | ToJSON SpecialModelName +instance A.ToJSON SpecialModelName where + toJSON SpecialModelName {..} = + _omitNulls + [ "$special[property.name]" .= specialModelNameSpecialPropertyName + ] + + +-- | Construct a value of type 'SpecialModelName' (by applying it's required fields, if any) +mkSpecialModelName + :: SpecialModelName +mkSpecialModelName = + SpecialModelName + { specialModelNameSpecialPropertyName = Nothing + } + +-- ** Tag +-- | Tag +data Tag = Tag + { tagId :: !(Maybe Integer) -- ^ "id" + , tagName :: !(Maybe Text) -- ^ "name" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Tag +instance A.FromJSON Tag where + parseJSON = A.withObject "Tag" $ \o -> + Tag + <$> (o .:? "id") + <*> (o .:? "name") + +-- | ToJSON Tag +instance A.ToJSON Tag where + toJSON Tag {..} = + _omitNulls + [ "id" .= tagId + , "name" .= tagName + ] --- ** ReadOnlyFirst --- | ReadOnlyFirst -data ReadOnlyFirst = ReadOnlyFirst - { readOnlyFirstBar :: !(Maybe Text) -- ^ "bar" - , readOnlyFirstBaz :: !(Maybe Text) -- ^ "baz" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON ReadOnlyFirst -instance A.FromJSON ReadOnlyFirst where - parseJSON = A.withObject "ReadOnlyFirst" $ \o -> - ReadOnlyFirst - <$> (o .:? "bar") - <*> (o .:? "baz") - --- | ToJSON ReadOnlyFirst -instance A.ToJSON ReadOnlyFirst where - toJSON ReadOnlyFirst {..} = - _omitNulls - [ "bar" .= readOnlyFirstBar - , "baz" .= readOnlyFirstBaz - ] - + +-- | Construct a value of type 'Tag' (by applying it's required fields, if any) +mkTag + :: Tag +mkTag = + Tag + { tagId = Nothing + , tagName = Nothing + } + +-- ** User +-- | User +data User = User + { userId :: !(Maybe Integer) -- ^ "id" + , userUsername :: !(Maybe Text) -- ^ "username" + , userFirstName :: !(Maybe Text) -- ^ "firstName" + , userLastName :: !(Maybe Text) -- ^ "lastName" + , userEmail :: !(Maybe Text) -- ^ "email" + , userPassword :: !(Maybe Text) -- ^ "password" + , userPhone :: !(Maybe Text) -- ^ "phone" + , userUserStatus :: !(Maybe Int) -- ^ "userStatus" - User Status + } deriving (P.Show, P.Eq, P.Typeable) --- | Construct a value of type 'ReadOnlyFirst' (by applying it's required fields, if any) -mkReadOnlyFirst - :: ReadOnlyFirst -mkReadOnlyFirst = - ReadOnlyFirst - { readOnlyFirstBar = Nothing - , readOnlyFirstBaz = Nothing - } - - --- ** SpecialModelName --- | SpecialModelName -data SpecialModelName = SpecialModelName - { specialModelNameSpecialPropertyName :: !(Maybe Integer) -- ^ "$special[property.name]" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON SpecialModelName -instance A.FromJSON SpecialModelName where - parseJSON = A.withObject "SpecialModelName" $ \o -> - SpecialModelName - <$> (o .:? "$special[property.name]") - --- | ToJSON SpecialModelName -instance A.ToJSON SpecialModelName where - toJSON SpecialModelName {..} = - _omitNulls - [ "$special[property.name]" .= specialModelNameSpecialPropertyName - ] - - --- | Construct a value of type 'SpecialModelName' (by applying it's required fields, if any) -mkSpecialModelName - :: SpecialModelName -mkSpecialModelName = - SpecialModelName - { specialModelNameSpecialPropertyName = Nothing - } - - --- ** Tag --- | Tag -data Tag = Tag - { tagId :: !(Maybe Integer) -- ^ "id" - , tagName :: !(Maybe Text) -- ^ "name" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Tag -instance A.FromJSON Tag where - parseJSON = A.withObject "Tag" $ \o -> - Tag - <$> (o .:? "id") - <*> (o .:? "name") - --- | ToJSON Tag -instance A.ToJSON Tag where - toJSON Tag {..} = - _omitNulls - [ "id" .= tagId - , "name" .= tagName - ] - - --- | Construct a value of type 'Tag' (by applying it's required fields, if any) -mkTag - :: Tag -mkTag = - Tag - { tagId = Nothing - , tagName = Nothing - } - - --- ** User --- | User -data User = User - { userId :: !(Maybe Integer) -- ^ "id" - , userUsername :: !(Maybe Text) -- ^ "username" - , userFirstName :: !(Maybe Text) -- ^ "firstName" - , userLastName :: !(Maybe Text) -- ^ "lastName" - , userEmail :: !(Maybe Text) -- ^ "email" - , userPassword :: !(Maybe Text) -- ^ "password" - , userPhone :: !(Maybe Text) -- ^ "phone" - , userUserStatus :: !(Maybe Int) -- ^ "userStatus" - User Status - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON User -instance A.FromJSON User where - parseJSON = A.withObject "User" $ \o -> - User - <$> (o .:? "id") - <*> (o .:? "username") - <*> (o .:? "firstName") - <*> (o .:? "lastName") - <*> (o .:? "email") - <*> (o .:? "password") - <*> (o .:? "phone") - <*> (o .:? "userStatus") - --- | ToJSON User -instance A.ToJSON User where - toJSON User {..} = - _omitNulls - [ "id" .= userId - , "username" .= userUsername - , "firstName" .= userFirstName - , "lastName" .= userLastName - , "email" .= userEmail - , "password" .= userPassword - , "phone" .= userPhone - , "userStatus" .= userUserStatus - ] - - --- | Construct a value of type 'User' (by applying it's required fields, if any) -mkUser - :: User -mkUser = - User - { userId = Nothing - , userUsername = Nothing - , userFirstName = Nothing - , userLastName = Nothing - , userEmail = Nothing - , userPassword = Nothing - , userPhone = Nothing - , userUserStatus = Nothing - } - +-- | FromJSON User +instance A.FromJSON User where + parseJSON = A.withObject "User" $ \o -> + User + <$> (o .:? "id") + <*> (o .:? "username") + <*> (o .:? "firstName") + <*> (o .:? "lastName") + <*> (o .:? "email") + <*> (o .:? "password") + <*> (o .:? "phone") + <*> (o .:? "userStatus") + +-- | ToJSON User +instance A.ToJSON User where + toJSON User {..} = + _omitNulls + [ "id" .= userId + , "username" .= userUsername + , "firstName" .= userFirstName + , "lastName" .= userLastName + , "email" .= userEmail + , "password" .= userPassword + , "phone" .= userPhone + , "userStatus" .= userUserStatus + ] + + +-- | Construct a value of type 'User' (by applying it's required fields, if any) +mkUser + :: User +mkUser = + User + { userId = Nothing + , userUsername = Nothing + , userFirstName = Nothing + , userLastName = Nothing + , userEmail = Nothing + , userPassword = Nothing + , userPhone = Nothing + , userUserStatus = Nothing + } + +-- ** Cat +-- | Cat +data Cat = Cat + { catClassName :: !(Text) -- ^ /Required/ "className" + , catColor :: !(Maybe Text) -- ^ "color" + , catDeclawed :: !(Maybe Bool) -- ^ "declawed" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Cat +instance A.FromJSON Cat where + parseJSON = A.withObject "Cat" $ \o -> + Cat + <$> (o .: "className") + <*> (o .:? "color") + <*> (o .:? "declawed") + +-- | ToJSON Cat +instance A.ToJSON Cat where + toJSON Cat {..} = + _omitNulls + [ "className" .= catClassName + , "color" .= catColor + , "declawed" .= catDeclawed + ] + + +-- | Construct a value of type 'Cat' (by applying it's required fields, if any) +mkCat + :: Text -- ^ 'catClassName' + -> Cat +mkCat catClassName = + Cat + { catClassName + , catColor = Nothing + , catDeclawed = Nothing + } + +-- ** Dog +-- | Dog +data Dog = Dog + { dogClassName :: !(Text) -- ^ /Required/ "className" + , dogColor :: !(Maybe Text) -- ^ "color" + , dogBreed :: !(Maybe Text) -- ^ "breed" + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Dog +instance A.FromJSON Dog where + parseJSON = A.withObject "Dog" $ \o -> + Dog + <$> (o .: "className") + <*> (o .:? "color") + <*> (o .:? "breed") + +-- | ToJSON Dog +instance A.ToJSON Dog where + toJSON Dog {..} = + _omitNulls + [ "className" .= dogClassName + , "color" .= dogColor + , "breed" .= dogBreed + ] + + +-- | Construct a value of type 'Dog' (by applying it's required fields, if any) +mkDog + :: Text -- ^ 'dogClassName' + -> Dog +mkDog dogClassName = + Dog + { dogClassName + , dogColor = Nothing + , dogBreed = Nothing + } + + +-- * Enums + + +-- ** E'ArrayEnum + +-- | Enum of 'Text' +data E'ArrayEnum + = E'ArrayEnum'Fish -- ^ @"fish"@ + | E'ArrayEnum'Crab -- ^ @"crab"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) --- ** Cat --- | Cat -data Cat = Cat - { catClassName :: !(Text) -- ^ /Required/ "className" - , catColor :: !(Maybe Text) -- ^ "color" - , catDeclawed :: !(Maybe Bool) -- ^ "declawed" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Cat -instance A.FromJSON Cat where - parseJSON = A.withObject "Cat" $ \o -> - Cat - <$> (o .: "className") - <*> (o .:? "color") - <*> (o .:? "declawed") - --- | ToJSON Cat -instance A.ToJSON Cat where - toJSON Cat {..} = - _omitNulls - [ "className" .= catClassName - , "color" .= catColor - , "declawed" .= catDeclawed - ] - - --- | Construct a value of type 'Cat' (by applying it's required fields, if any) -mkCat - :: Text -- ^ 'catClassName' - -> Cat -mkCat catClassName = - Cat - { catClassName - , catColor = Nothing - , catDeclawed = Nothing - } - - --- ** Dog --- | Dog -data Dog = Dog - { dogClassName :: !(Text) -- ^ /Required/ "className" - , dogColor :: !(Maybe Text) -- ^ "color" - , dogBreed :: !(Maybe Text) -- ^ "breed" - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Dog -instance A.FromJSON Dog where - parseJSON = A.withObject "Dog" $ \o -> - Dog - <$> (o .: "className") - <*> (o .:? "color") - <*> (o .:? "breed") - --- | ToJSON Dog -instance A.ToJSON Dog where - toJSON Dog {..} = - _omitNulls - [ "className" .= dogClassName - , "color" .= dogColor - , "breed" .= dogBreed - ] - - --- | Construct a value of type 'Dog' (by applying it's required fields, if any) -mkDog - :: Text -- ^ 'dogClassName' - -> Dog -mkDog dogClassName = - Dog - { dogClassName - , dogColor = Nothing - , dogBreed = Nothing - } - - - - \ No newline at end of file +instance A.ToJSON E'ArrayEnum where toJSON = A.toJSON . fromE'ArrayEnum +instance A.FromJSON E'ArrayEnum where parseJSON o = P.either P.fail (pure . P.id) . toE'ArrayEnum =<< A.parseJSON o +instance WH.ToHttpApiData E'ArrayEnum where toQueryParam = WH.toQueryParam . fromE'ArrayEnum +instance WH.FromHttpApiData E'ArrayEnum where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'ArrayEnum +instance MimeRender MimeMultipartFormData E'ArrayEnum where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'ArrayEnum' enum +fromE'ArrayEnum :: E'ArrayEnum -> Text +fromE'ArrayEnum = \case + E'ArrayEnum'Fish -> "fish" + E'ArrayEnum'Crab -> "crab" + +-- | parse 'E'ArrayEnum' enum +toE'ArrayEnum :: Text -> P.Either String E'ArrayEnum +toE'ArrayEnum = \case + "fish" -> P.Right E'ArrayEnum'Fish + "crab" -> P.Right E'ArrayEnum'Crab + s -> P.Left $ "toE'ArrayEnum: enum parse failure: " P.++ P.show s + + +-- ** E'EnumFormString + +-- | Enum of 'Text' +data E'EnumFormString + = E'EnumFormString'_abc -- ^ @"_abc"@ + | E'EnumFormString'_efg -- ^ @"-efg"@ + | E'EnumFormString'_xyz -- ^ @"(xyz)"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'EnumFormString where toJSON = A.toJSON . fromE'EnumFormString +instance A.FromJSON E'EnumFormString where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumFormString =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumFormString where toQueryParam = WH.toQueryParam . fromE'EnumFormString +instance WH.FromHttpApiData E'EnumFormString where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumFormString +instance MimeRender MimeMultipartFormData E'EnumFormString where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'EnumFormString' enum +fromE'EnumFormString :: E'EnumFormString -> Text +fromE'EnumFormString = \case + E'EnumFormString'_abc -> "_abc" + E'EnumFormString'_efg -> "-efg" + E'EnumFormString'_xyz -> "(xyz)" + +-- | parse 'E'EnumFormString' enum +toE'EnumFormString :: Text -> P.Either String E'EnumFormString +toE'EnumFormString = \case + "_abc" -> P.Right E'EnumFormString'_abc + "-efg" -> P.Right E'EnumFormString'_efg + "(xyz)" -> P.Right E'EnumFormString'_xyz + s -> P.Left $ "toE'EnumFormString: enum parse failure: " P.++ P.show s + + +-- ** E'EnumInteger + +-- | Enum of 'Int' +data E'EnumInteger + = E'EnumInteger'Num1 -- ^ @1@ + | E'EnumInteger'NumMinus_1 -- ^ @-1@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'EnumInteger where toJSON = A.toJSON . fromE'EnumInteger +instance A.FromJSON E'EnumInteger where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumInteger =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumInteger where toQueryParam = WH.toQueryParam . fromE'EnumInteger +instance WH.FromHttpApiData E'EnumInteger where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumInteger +instance MimeRender MimeMultipartFormData E'EnumInteger where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'EnumInteger' enum +fromE'EnumInteger :: E'EnumInteger -> Int +fromE'EnumInteger = \case + E'EnumInteger'Num1 -> 1 + E'EnumInteger'NumMinus_1 -> -1 + +-- | parse 'E'EnumInteger' enum +toE'EnumInteger :: Int -> P.Either String E'EnumInteger +toE'EnumInteger = \case + 1 -> P.Right E'EnumInteger'Num1 + -1 -> P.Right E'EnumInteger'NumMinus_1 + s -> P.Left $ "toE'EnumInteger: enum parse failure: " P.++ P.show s + + +-- ** E'EnumNumber + +-- | Enum of 'Double' +data E'EnumNumber + = E'EnumNumber'Num1_Dot_1 -- ^ @1.1@ + | E'EnumNumber'NumMinus_1_Dot_2 -- ^ @-1.2@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'EnumNumber where toJSON = A.toJSON . fromE'EnumNumber +instance A.FromJSON E'EnumNumber where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumNumber =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumNumber where toQueryParam = WH.toQueryParam . fromE'EnumNumber +instance WH.FromHttpApiData E'EnumNumber where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumNumber +instance MimeRender MimeMultipartFormData E'EnumNumber where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'EnumNumber' enum +fromE'EnumNumber :: E'EnumNumber -> Double +fromE'EnumNumber = \case + E'EnumNumber'Num1_Dot_1 -> 1.1 + E'EnumNumber'NumMinus_1_Dot_2 -> -1.2 + +-- | parse 'E'EnumNumber' enum +toE'EnumNumber :: Double -> P.Either String E'EnumNumber +toE'EnumNumber = \case + 1.1 -> P.Right E'EnumNumber'Num1_Dot_1 + -1.2 -> P.Right E'EnumNumber'NumMinus_1_Dot_2 + s -> P.Left $ "toE'EnumNumber: enum parse failure: " P.++ P.show s + + +-- ** E'EnumQueryInteger + +-- | Enum of 'Int' +data E'EnumQueryInteger + = E'EnumQueryInteger'Num1 -- ^ @1@ + | E'EnumQueryInteger'NumMinus_2 -- ^ @-2@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'EnumQueryInteger where toJSON = A.toJSON . fromE'EnumQueryInteger +instance A.FromJSON E'EnumQueryInteger where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumQueryInteger =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumQueryInteger where toQueryParam = WH.toQueryParam . fromE'EnumQueryInteger +instance WH.FromHttpApiData E'EnumQueryInteger where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumQueryInteger +instance MimeRender MimeMultipartFormData E'EnumQueryInteger where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'EnumQueryInteger' enum +fromE'EnumQueryInteger :: E'EnumQueryInteger -> Int +fromE'EnumQueryInteger = \case + E'EnumQueryInteger'Num1 -> 1 + E'EnumQueryInteger'NumMinus_2 -> -2 + +-- | parse 'E'EnumQueryInteger' enum +toE'EnumQueryInteger :: Int -> P.Either String E'EnumQueryInteger +toE'EnumQueryInteger = \case + 1 -> P.Right E'EnumQueryInteger'Num1 + -2 -> P.Right E'EnumQueryInteger'NumMinus_2 + s -> P.Left $ "toE'EnumQueryInteger: enum parse failure: " P.++ P.show s + + +-- ** E'EnumString + +-- | Enum of 'Text' +data E'EnumString + = E'EnumString'UPPER -- ^ @"UPPER"@ + | E'EnumString'Lower -- ^ @"lower"@ + | E'EnumString'Empty -- ^ @""@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'EnumString where toJSON = A.toJSON . fromE'EnumString +instance A.FromJSON E'EnumString where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumString =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumString where toQueryParam = WH.toQueryParam . fromE'EnumString +instance WH.FromHttpApiData E'EnumString where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumString +instance MimeRender MimeMultipartFormData E'EnumString where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'EnumString' enum +fromE'EnumString :: E'EnumString -> Text +fromE'EnumString = \case + E'EnumString'UPPER -> "UPPER" + E'EnumString'Lower -> "lower" + E'EnumString'Empty -> "" + +-- | parse 'E'EnumString' enum +toE'EnumString :: Text -> P.Either String E'EnumString +toE'EnumString = \case + "UPPER" -> P.Right E'EnumString'UPPER + "lower" -> P.Right E'EnumString'Lower + "" -> P.Right E'EnumString'Empty + s -> P.Left $ "toE'EnumString: enum parse failure: " P.++ P.show s + + +-- ** E'Inner + +-- | Enum of 'Text' +data E'Inner + = E'Inner'UPPER -- ^ @"UPPER"@ + | E'Inner'Lower -- ^ @"lower"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'Inner where toJSON = A.toJSON . fromE'Inner +instance A.FromJSON E'Inner where parseJSON o = P.either P.fail (pure . P.id) . toE'Inner =<< A.parseJSON o +instance WH.ToHttpApiData E'Inner where toQueryParam = WH.toQueryParam . fromE'Inner +instance WH.FromHttpApiData E'Inner where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Inner +instance MimeRender MimeMultipartFormData E'Inner where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'Inner' enum +fromE'Inner :: E'Inner -> Text +fromE'Inner = \case + E'Inner'UPPER -> "UPPER" + E'Inner'Lower -> "lower" + +-- | parse 'E'Inner' enum +toE'Inner :: Text -> P.Either String E'Inner +toE'Inner = \case + "UPPER" -> P.Right E'Inner'UPPER + "lower" -> P.Right E'Inner'Lower + s -> P.Left $ "toE'Inner: enum parse failure: " P.++ P.show s + + +-- ** E'Inner2 + +-- | Enum of 'Text' +data E'Inner2 + = E'Inner2'GreaterThan -- ^ @">"@ + | E'Inner2'Dollar -- ^ @"$"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'Inner2 where toJSON = A.toJSON . fromE'Inner2 +instance A.FromJSON E'Inner2 where parseJSON o = P.either P.fail (pure . P.id) . toE'Inner2 =<< A.parseJSON o +instance WH.ToHttpApiData E'Inner2 where toQueryParam = WH.toQueryParam . fromE'Inner2 +instance WH.FromHttpApiData E'Inner2 where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Inner2 +instance MimeRender MimeMultipartFormData E'Inner2 where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'Inner2' enum +fromE'Inner2 :: E'Inner2 -> Text +fromE'Inner2 = \case + E'Inner2'GreaterThan -> ">" + E'Inner2'Dollar -> "$" + +-- | parse 'E'Inner2' enum +toE'Inner2 :: Text -> P.Either String E'Inner2 +toE'Inner2 = \case + ">" -> P.Right E'Inner2'GreaterThan + "$" -> P.Right E'Inner2'Dollar + s -> P.Left $ "toE'Inner2: enum parse failure: " P.++ P.show s + + +-- ** E'JustSymbol + +-- | Enum of 'Text' +data E'JustSymbol + = E'JustSymbol'Greater_Than_Or_Equal_To -- ^ @">="@ + | E'JustSymbol'Dollar -- ^ @"$"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'JustSymbol where toJSON = A.toJSON . fromE'JustSymbol +instance A.FromJSON E'JustSymbol where parseJSON o = P.either P.fail (pure . P.id) . toE'JustSymbol =<< A.parseJSON o +instance WH.ToHttpApiData E'JustSymbol where toQueryParam = WH.toQueryParam . fromE'JustSymbol +instance WH.FromHttpApiData E'JustSymbol where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'JustSymbol +instance MimeRender MimeMultipartFormData E'JustSymbol where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'JustSymbol' enum +fromE'JustSymbol :: E'JustSymbol -> Text +fromE'JustSymbol = \case + E'JustSymbol'Greater_Than_Or_Equal_To -> ">=" + E'JustSymbol'Dollar -> "$" + +-- | parse 'E'JustSymbol' enum +toE'JustSymbol :: Text -> P.Either String E'JustSymbol +toE'JustSymbol = \case + ">=" -> P.Right E'JustSymbol'Greater_Than_Or_Equal_To + "$" -> P.Right E'JustSymbol'Dollar + s -> P.Left $ "toE'JustSymbol: enum parse failure: " P.++ P.show s + + +-- ** E'Status + +-- | Enum of 'Text' . +-- Order Status +data E'Status + = E'Status'Placed -- ^ @"placed"@ + | E'Status'Approved -- ^ @"approved"@ + | E'Status'Delivered -- ^ @"delivered"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'Status where toJSON = A.toJSON . fromE'Status +instance A.FromJSON E'Status where parseJSON o = P.either P.fail (pure . P.id) . toE'Status =<< A.parseJSON o +instance WH.ToHttpApiData E'Status where toQueryParam = WH.toQueryParam . fromE'Status +instance WH.FromHttpApiData E'Status where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Status +instance MimeRender MimeMultipartFormData E'Status where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'Status' enum +fromE'Status :: E'Status -> Text +fromE'Status = \case + E'Status'Placed -> "placed" + E'Status'Approved -> "approved" + E'Status'Delivered -> "delivered" + +-- | parse 'E'Status' enum +toE'Status :: Text -> P.Either String E'Status +toE'Status = \case + "placed" -> P.Right E'Status'Placed + "approved" -> P.Right E'Status'Approved + "delivered" -> P.Right E'Status'Delivered + s -> P.Left $ "toE'Status: enum parse failure: " P.++ P.show s + + +-- ** E'Status2 + +-- | Enum of 'Text' . +-- pet status in the store +data E'Status2 + = E'Status2'Available -- ^ @"available"@ + | E'Status2'Pending -- ^ @"pending"@ + | E'Status2'Sold -- ^ @"sold"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'Status2 where toJSON = A.toJSON . fromE'Status2 +instance A.FromJSON E'Status2 where parseJSON o = P.either P.fail (pure . P.id) . toE'Status2 =<< A.parseJSON o +instance WH.ToHttpApiData E'Status2 where toQueryParam = WH.toQueryParam . fromE'Status2 +instance WH.FromHttpApiData E'Status2 where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Status2 +instance MimeRender MimeMultipartFormData E'Status2 where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'Status2' enum +fromE'Status2 :: E'Status2 -> Text +fromE'Status2 = \case + E'Status2'Available -> "available" + E'Status2'Pending -> "pending" + E'Status2'Sold -> "sold" + +-- | parse 'E'Status2' enum +toE'Status2 :: Text -> P.Either String E'Status2 +toE'Status2 = \case + "available" -> P.Right E'Status2'Available + "pending" -> P.Right E'Status2'Pending + "sold" -> P.Right E'Status2'Sold + s -> P.Left $ "toE'Status2: enum parse failure: " P.++ P.show s + + +-- ** EnumClass + +-- | Enum of 'Text' +data EnumClass + = EnumClass'_abc -- ^ @"_abc"@ + | EnumClass'_efg -- ^ @"-efg"@ + | EnumClass'_xyz -- ^ @"(xyz)"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON EnumClass where toJSON = A.toJSON . fromEnumClass +instance A.FromJSON EnumClass where parseJSON o = P.either P.fail (pure . P.id) . toEnumClass =<< A.parseJSON o +instance WH.ToHttpApiData EnumClass where toQueryParam = WH.toQueryParam . fromEnumClass +instance WH.FromHttpApiData EnumClass where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toEnumClass +instance MimeRender MimeMultipartFormData EnumClass where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'EnumClass' enum +fromEnumClass :: EnumClass -> Text +fromEnumClass = \case + EnumClass'_abc -> "_abc" + EnumClass'_efg -> "-efg" + EnumClass'_xyz -> "(xyz)" + +-- | parse 'EnumClass' enum +toEnumClass :: Text -> P.Either String EnumClass +toEnumClass = \case + "_abc" -> P.Right EnumClass'_abc + "-efg" -> P.Right EnumClass'_efg + "(xyz)" -> P.Right EnumClass'_xyz + s -> P.Left $ "toEnumClass: enum parse failure: " P.++ P.show s + + +-- ** OuterEnum + +-- | Enum of 'Text' +data OuterEnum + = OuterEnum'Placed -- ^ @"placed"@ + | OuterEnum'Approved -- ^ @"approved"@ + | OuterEnum'Delivered -- ^ @"delivered"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON OuterEnum where toJSON = A.toJSON . fromOuterEnum +instance A.FromJSON OuterEnum where parseJSON o = P.either P.fail (pure . P.id) . toOuterEnum =<< A.parseJSON o +instance WH.ToHttpApiData OuterEnum where toQueryParam = WH.toQueryParam . fromOuterEnum +instance WH.FromHttpApiData OuterEnum where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toOuterEnum +instance MimeRender MimeMultipartFormData OuterEnum where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'OuterEnum' enum +fromOuterEnum :: OuterEnum -> Text +fromOuterEnum = \case + OuterEnum'Placed -> "placed" + OuterEnum'Approved -> "approved" + OuterEnum'Delivered -> "delivered" + +-- | parse 'OuterEnum' enum +toOuterEnum :: Text -> P.Either String OuterEnum +toOuterEnum = \case + "placed" -> P.Right OuterEnum'Placed + "approved" -> P.Right OuterEnum'Approved + "delivered" -> P.Right OuterEnum'Delivered + s -> P.Left $ "toOuterEnum: enum parse failure: " P.++ P.show s + \ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.ModelLens.html b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.ModelLens.html index 79957636daf..29073bebe35 100644 --- a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.ModelLens.html +++ b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.ModelLens.html @@ -41,12 +41,12 @@ Module : SwaggerPetstore.Lens -- | 'additionalPropertiesClassMapProperty' Lens additionalPropertiesClassMapPropertyL :: Lens_' AdditionalPropertiesClass (Maybe (Map.Map String Text)) -additionalPropertiesClassMapPropertyL f AdditionalPropertiesClass{..} = (\additionalPropertiesClassMapProperty -> AdditionalPropertiesClass { additionalPropertiesClassMapProperty, ..} ) <$> f additionalPropertiesClassMapProperty +additionalPropertiesClassMapPropertyL f AdditionalPropertiesClass{..} = (\additionalPropertiesClassMapProperty -> AdditionalPropertiesClass { additionalPropertiesClassMapProperty, ..} ) <$> f additionalPropertiesClassMapProperty {-# INLINE additionalPropertiesClassMapPropertyL #-} -- | 'additionalPropertiesClassMapOfMapProperty' Lens additionalPropertiesClassMapOfMapPropertyL :: Lens_' AdditionalPropertiesClass (Maybe (Map.Map String (Map.Map String Text))) -additionalPropertiesClassMapOfMapPropertyL f AdditionalPropertiesClass{..} = (\additionalPropertiesClassMapOfMapProperty -> AdditionalPropertiesClass { additionalPropertiesClassMapOfMapProperty, ..} ) <$> f additionalPropertiesClassMapOfMapProperty +additionalPropertiesClassMapOfMapPropertyL f AdditionalPropertiesClass{..} = (\additionalPropertiesClassMapOfMapProperty -> AdditionalPropertiesClass { additionalPropertiesClassMapOfMapProperty, ..} ) <$> f additionalPropertiesClassMapOfMapProperty {-# INLINE additionalPropertiesClassMapOfMapPropertyL #-} @@ -55,12 +55,12 @@ Module : SwaggerPetstore.Lens -- | 'animalClassName' Lens animalClassNameL :: Lens_' Animal (Text) -animalClassNameL f Animal{..} = (\animalClassName -> Animal { animalClassName, ..} ) <$> f animalClassName +animalClassNameL f Animal{..} = (\animalClassName -> Animal { animalClassName, ..} ) <$> f animalClassName {-# INLINE animalClassNameL #-} -- | 'animalColor' Lens animalColorL :: Lens_' Animal (Maybe Text) -animalColorL f Animal{..} = (\animalColor -> Animal { animalColor, ..} ) <$> f animalColor +animalColorL f Animal{..} = (\animalColor -> Animal { animalColor, ..} ) <$> f animalColor {-# INLINE animalColorL #-} @@ -73,17 +73,17 @@ Module : SwaggerPetstore.Lens -- | 'apiResponseCode' Lens apiResponseCodeL :: Lens_' ApiResponse (Maybe Int) -apiResponseCodeL f ApiResponse{..} = (\apiResponseCode -> ApiResponse { apiResponseCode, ..} ) <$> f apiResponseCode +apiResponseCodeL f ApiResponse{..} = (\apiResponseCode -> ApiResponse { apiResponseCode, ..} ) <$> f apiResponseCode {-# INLINE apiResponseCodeL #-} -- | 'apiResponseType' Lens apiResponseTypeL :: Lens_' ApiResponse (Maybe Text) -apiResponseTypeL f ApiResponse{..} = (\apiResponseType -> ApiResponse { apiResponseType, ..} ) <$> f apiResponseType +apiResponseTypeL f ApiResponse{..} = (\apiResponseType -> ApiResponse { apiResponseType, ..} ) <$> f apiResponseType {-# INLINE apiResponseTypeL #-} -- | 'apiResponseMessage' Lens apiResponseMessageL :: Lens_' ApiResponse (Maybe Text) -apiResponseMessageL f ApiResponse{..} = (\apiResponseMessage -> ApiResponse { apiResponseMessage, ..} ) <$> f apiResponseMessage +apiResponseMessageL f ApiResponse{..} = (\apiResponseMessage -> ApiResponse { apiResponseMessage, ..} ) <$> f apiResponseMessage {-# INLINE apiResponseMessageL #-} @@ -92,7 +92,7 @@ Module : SwaggerPetstore.Lens -- | 'arrayOfArrayOfNumberOnlyArrayArrayNumber' Lens arrayOfArrayOfNumberOnlyArrayArrayNumberL :: Lens_' ArrayOfArrayOfNumberOnly (Maybe [[Double]]) -arrayOfArrayOfNumberOnlyArrayArrayNumberL f ArrayOfArrayOfNumberOnly{..} = (\arrayOfArrayOfNumberOnlyArrayArrayNumber -> ArrayOfArrayOfNumberOnly { arrayOfArrayOfNumberOnlyArrayArrayNumber, ..} ) <$> f arrayOfArrayOfNumberOnlyArrayArrayNumber +arrayOfArrayOfNumberOnlyArrayArrayNumberL f ArrayOfArrayOfNumberOnly{..} = (\arrayOfArrayOfNumberOnlyArrayArrayNumber -> ArrayOfArrayOfNumberOnly { arrayOfArrayOfNumberOnlyArrayArrayNumber, ..} ) <$> f arrayOfArrayOfNumberOnlyArrayArrayNumber {-# INLINE arrayOfArrayOfNumberOnlyArrayArrayNumberL #-} @@ -101,7 +101,7 @@ Module : SwaggerPetstore.Lens -- | 'arrayOfNumberOnlyArrayNumber' Lens arrayOfNumberOnlyArrayNumberL :: Lens_' ArrayOfNumberOnly (Maybe [Double]) -arrayOfNumberOnlyArrayNumberL f ArrayOfNumberOnly{..} = (\arrayOfNumberOnlyArrayNumber -> ArrayOfNumberOnly { arrayOfNumberOnlyArrayNumber, ..} ) <$> f arrayOfNumberOnlyArrayNumber +arrayOfNumberOnlyArrayNumberL f ArrayOfNumberOnly{..} = (\arrayOfNumberOnlyArrayNumber -> ArrayOfNumberOnly { arrayOfNumberOnlyArrayNumber, ..} ) <$> f arrayOfNumberOnlyArrayNumber {-# INLINE arrayOfNumberOnlyArrayNumberL #-} @@ -110,17 +110,17 @@ Module : SwaggerPetstore.Lens -- | 'arrayTestArrayOfString' Lens arrayTestArrayOfStringL :: Lens_' ArrayTest (Maybe [Text]) -arrayTestArrayOfStringL f ArrayTest{..} = (\arrayTestArrayOfString -> ArrayTest { arrayTestArrayOfString, ..} ) <$> f arrayTestArrayOfString +arrayTestArrayOfStringL f ArrayTest{..} = (\arrayTestArrayOfString -> ArrayTest { arrayTestArrayOfString, ..} ) <$> f arrayTestArrayOfString {-# INLINE arrayTestArrayOfStringL #-} -- | 'arrayTestArrayArrayOfInteger' Lens arrayTestArrayArrayOfIntegerL :: Lens_' ArrayTest (Maybe [[Integer]]) -arrayTestArrayArrayOfIntegerL f ArrayTest{..} = (\arrayTestArrayArrayOfInteger -> ArrayTest { arrayTestArrayArrayOfInteger, ..} ) <$> f arrayTestArrayArrayOfInteger +arrayTestArrayArrayOfIntegerL f ArrayTest{..} = (\arrayTestArrayArrayOfInteger -> ArrayTest { arrayTestArrayArrayOfInteger, ..} ) <$> f arrayTestArrayArrayOfInteger {-# INLINE arrayTestArrayArrayOfIntegerL #-} -- | 'arrayTestArrayArrayOfModel' Lens arrayTestArrayArrayOfModelL :: Lens_' ArrayTest (Maybe [[ReadOnlyFirst]]) -arrayTestArrayArrayOfModelL f ArrayTest{..} = (\arrayTestArrayArrayOfModel -> ArrayTest { arrayTestArrayArrayOfModel, ..} ) <$> f arrayTestArrayArrayOfModel +arrayTestArrayArrayOfModelL f ArrayTest{..} = (\arrayTestArrayArrayOfModel -> ArrayTest { arrayTestArrayArrayOfModel, ..} ) <$> f arrayTestArrayArrayOfModel {-# INLINE arrayTestArrayArrayOfModelL #-} @@ -129,32 +129,32 @@ Module : SwaggerPetstore.Lens -- | 'capitalizationSmallCamel' Lens capitalizationSmallCamelL :: Lens_' Capitalization (Maybe Text) -capitalizationSmallCamelL f Capitalization{..} = (\capitalizationSmallCamel -> Capitalization { capitalizationSmallCamel, ..} ) <$> f capitalizationSmallCamel +capitalizationSmallCamelL f Capitalization{..} = (\capitalizationSmallCamel -> Capitalization { capitalizationSmallCamel, ..} ) <$> f capitalizationSmallCamel {-# INLINE capitalizationSmallCamelL #-} -- | 'capitalizationCapitalCamel' Lens capitalizationCapitalCamelL :: Lens_' Capitalization (Maybe Text) -capitalizationCapitalCamelL f Capitalization{..} = (\capitalizationCapitalCamel -> Capitalization { capitalizationCapitalCamel, ..} ) <$> f capitalizationCapitalCamel +capitalizationCapitalCamelL f Capitalization{..} = (\capitalizationCapitalCamel -> Capitalization { capitalizationCapitalCamel, ..} ) <$> f capitalizationCapitalCamel {-# INLINE capitalizationCapitalCamelL #-} -- | 'capitalizationSmallSnake' Lens capitalizationSmallSnakeL :: Lens_' Capitalization (Maybe Text) -capitalizationSmallSnakeL f Capitalization{..} = (\capitalizationSmallSnake -> Capitalization { capitalizationSmallSnake, ..} ) <$> f capitalizationSmallSnake +capitalizationSmallSnakeL f Capitalization{..} = (\capitalizationSmallSnake -> Capitalization { capitalizationSmallSnake, ..} ) <$> f capitalizationSmallSnake {-# INLINE capitalizationSmallSnakeL #-} -- | 'capitalizationCapitalSnake' Lens capitalizationCapitalSnakeL :: Lens_' Capitalization (Maybe Text) -capitalizationCapitalSnakeL f Capitalization{..} = (\capitalizationCapitalSnake -> Capitalization { capitalizationCapitalSnake, ..} ) <$> f capitalizationCapitalSnake +capitalizationCapitalSnakeL f Capitalization{..} = (\capitalizationCapitalSnake -> Capitalization { capitalizationCapitalSnake, ..} ) <$> f capitalizationCapitalSnake {-# INLINE capitalizationCapitalSnakeL #-} -- | 'capitalizationScaEthFlowPoints' Lens capitalizationScaEthFlowPointsL :: Lens_' Capitalization (Maybe Text) -capitalizationScaEthFlowPointsL f Capitalization{..} = (\capitalizationScaEthFlowPoints -> Capitalization { capitalizationScaEthFlowPoints, ..} ) <$> f capitalizationScaEthFlowPoints +capitalizationScaEthFlowPointsL f Capitalization{..} = (\capitalizationScaEthFlowPoints -> Capitalization { capitalizationScaEthFlowPoints, ..} ) <$> f capitalizationScaEthFlowPoints {-# INLINE capitalizationScaEthFlowPointsL #-} -- | 'capitalizationAttName' Lens capitalizationAttNameL :: Lens_' Capitalization (Maybe Text) -capitalizationAttNameL f Capitalization{..} = (\capitalizationAttName -> Capitalization { capitalizationAttName, ..} ) <$> f capitalizationAttName +capitalizationAttNameL f Capitalization{..} = (\capitalizationAttName -> Capitalization { capitalizationAttName, ..} ) <$> f capitalizationAttName {-# INLINE capitalizationAttNameL #-} @@ -163,12 +163,12 @@ Module : SwaggerPetstore.Lens -- | 'categoryId' Lens categoryIdL :: Lens_' Category (Maybe Integer) -categoryIdL f Category{..} = (\categoryId -> Category { categoryId, ..} ) <$> f categoryId +categoryIdL f Category{..} = (\categoryId -> Category { categoryId, ..} ) <$> f categoryId {-# INLINE categoryIdL #-} -- | 'categoryName' Lens categoryNameL :: Lens_' Category (Maybe Text) -categoryNameL f Category{..} = (\categoryName -> Category { categoryName, ..} ) <$> f categoryName +categoryNameL f Category{..} = (\categoryName -> Category { categoryName, ..} ) <$> f categoryName {-# INLINE categoryNameL #-} @@ -177,7 +177,7 @@ Module : SwaggerPetstore.Lens -- | 'classModelClass' Lens classModelClassL :: Lens_' ClassModel (Maybe Text) -classModelClassL f ClassModel{..} = (\classModelClass -> ClassModel { classModelClass, ..} ) <$> f classModelClass +classModelClassL f ClassModel{..} = (\classModelClass -> ClassModel { classModelClass, ..} ) <$> f classModelClass {-# INLINE classModelClassL #-} @@ -186,7 +186,7 @@ Module : SwaggerPetstore.Lens -- | 'clientClient' Lens clientClientL :: Lens_' Client (Maybe Text) -clientClientL f Client{..} = (\clientClient -> Client { clientClient, ..} ) <$> f clientClient +clientClientL f Client{..} = (\clientClient -> Client { clientClient, ..} ) <$> f clientClient {-# INLINE clientClientL #-} @@ -194,13 +194,13 @@ Module : SwaggerPetstore.Lens -- * EnumArrays -- | 'enumArraysJustSymbol' Lens -enumArraysJustSymbolL :: Lens_' EnumArrays (Maybe Text) -enumArraysJustSymbolL f EnumArrays{..} = (\enumArraysJustSymbol -> EnumArrays { enumArraysJustSymbol, ..} ) <$> f enumArraysJustSymbol +enumArraysJustSymbolL :: Lens_' EnumArrays (Maybe E'JustSymbol) +enumArraysJustSymbolL f EnumArrays{..} = (\enumArraysJustSymbol -> EnumArrays { enumArraysJustSymbol, ..} ) <$> f enumArraysJustSymbol {-# INLINE enumArraysJustSymbolL #-} -- | 'enumArraysArrayEnum' Lens -enumArraysArrayEnumL :: Lens_' EnumArrays (Maybe [Text]) -enumArraysArrayEnumL f EnumArrays{..} = (\enumArraysArrayEnum -> EnumArrays { enumArraysArrayEnum, ..} ) <$> f enumArraysArrayEnum +enumArraysArrayEnumL :: Lens_' EnumArrays (Maybe [E'ArrayEnum]) +enumArraysArrayEnumL f EnumArrays{..} = (\enumArraysArrayEnum -> EnumArrays { enumArraysArrayEnum, ..} ) <$> f enumArraysArrayEnum {-# INLINE enumArraysArrayEnumL #-} @@ -212,23 +212,23 @@ Module : SwaggerPetstore.Lens -- * EnumTest -- | 'enumTestEnumString' Lens -enumTestEnumStringL :: Lens_' EnumTest (Maybe Text) -enumTestEnumStringL f EnumTest{..} = (\enumTestEnumString -> EnumTest { enumTestEnumString, ..} ) <$> f enumTestEnumString +enumTestEnumStringL :: Lens_' EnumTest (Maybe E'EnumString) +enumTestEnumStringL f EnumTest{..} = (\enumTestEnumString -> EnumTest { enumTestEnumString, ..} ) <$> f enumTestEnumString {-# INLINE enumTestEnumStringL #-} -- | 'enumTestEnumInteger' Lens -enumTestEnumIntegerL :: Lens_' EnumTest (Maybe Int) -enumTestEnumIntegerL f EnumTest{..} = (\enumTestEnumInteger -> EnumTest { enumTestEnumInteger, ..} ) <$> f enumTestEnumInteger +enumTestEnumIntegerL :: Lens_' EnumTest (Maybe E'EnumInteger) +enumTestEnumIntegerL f EnumTest{..} = (\enumTestEnumInteger -> EnumTest { enumTestEnumInteger, ..} ) <$> f enumTestEnumInteger {-# INLINE enumTestEnumIntegerL #-} -- | 'enumTestEnumNumber' Lens -enumTestEnumNumberL :: Lens_' EnumTest (Maybe Double) -enumTestEnumNumberL f EnumTest{..} = (\enumTestEnumNumber -> EnumTest { enumTestEnumNumber, ..} ) <$> f enumTestEnumNumber +enumTestEnumNumberL :: Lens_' EnumTest (Maybe E'EnumNumber) +enumTestEnumNumberL f EnumTest{..} = (\enumTestEnumNumber -> EnumTest { enumTestEnumNumber, ..} ) <$> f enumTestEnumNumber {-# INLINE enumTestEnumNumberL #-} -- | 'enumTestOuterEnum' Lens enumTestOuterEnumL :: Lens_' EnumTest (Maybe OuterEnum) -enumTestOuterEnumL f EnumTest{..} = (\enumTestOuterEnum -> EnumTest { enumTestOuterEnum, ..} ) <$> f enumTestOuterEnum +enumTestOuterEnumL f EnumTest{..} = (\enumTestOuterEnum -> EnumTest { enumTestOuterEnum, ..} ) <$> f enumTestOuterEnum {-# INLINE enumTestOuterEnumL #-} @@ -237,67 +237,67 @@ Module : SwaggerPetstore.Lens -- | 'formatTestInteger' Lens formatTestIntegerL :: Lens_' FormatTest (Maybe Int) -formatTestIntegerL f FormatTest{..} = (\formatTestInteger -> FormatTest { formatTestInteger, ..} ) <$> f formatTestInteger +formatTestIntegerL f FormatTest{..} = (\formatTestInteger -> FormatTest { formatTestInteger, ..} ) <$> f formatTestInteger {-# INLINE formatTestIntegerL #-} -- | 'formatTestInt32' Lens formatTestInt32L :: Lens_' FormatTest (Maybe Int) -formatTestInt32L f FormatTest{..} = (\formatTestInt32 -> FormatTest { formatTestInt32, ..} ) <$> f formatTestInt32 +formatTestInt32L f FormatTest{..} = (\formatTestInt32 -> FormatTest { formatTestInt32, ..} ) <$> f formatTestInt32 {-# INLINE formatTestInt32L #-} -- | 'formatTestInt64' Lens formatTestInt64L :: Lens_' FormatTest (Maybe Integer) -formatTestInt64L f FormatTest{..} = (\formatTestInt64 -> FormatTest { formatTestInt64, ..} ) <$> f formatTestInt64 +formatTestInt64L f FormatTest{..} = (\formatTestInt64 -> FormatTest { formatTestInt64, ..} ) <$> f formatTestInt64 {-# INLINE formatTestInt64L #-} -- | 'formatTestNumber' Lens formatTestNumberL :: Lens_' FormatTest (Double) -formatTestNumberL f FormatTest{..} = (\formatTestNumber -> FormatTest { formatTestNumber, ..} ) <$> f formatTestNumber +formatTestNumberL f FormatTest{..} = (\formatTestNumber -> FormatTest { formatTestNumber, ..} ) <$> f formatTestNumber {-# INLINE formatTestNumberL #-} -- | 'formatTestFloat' Lens formatTestFloatL :: Lens_' FormatTest (Maybe Float) -formatTestFloatL f FormatTest{..} = (\formatTestFloat -> FormatTest { formatTestFloat, ..} ) <$> f formatTestFloat +formatTestFloatL f FormatTest{..} = (\formatTestFloat -> FormatTest { formatTestFloat, ..} ) <$> f formatTestFloat {-# INLINE formatTestFloatL #-} -- | 'formatTestDouble' Lens formatTestDoubleL :: Lens_' FormatTest (Maybe Double) -formatTestDoubleL f FormatTest{..} = (\formatTestDouble -> FormatTest { formatTestDouble, ..} ) <$> f formatTestDouble +formatTestDoubleL f FormatTest{..} = (\formatTestDouble -> FormatTest { formatTestDouble, ..} ) <$> f formatTestDouble {-# INLINE formatTestDoubleL #-} -- | 'formatTestString' Lens formatTestStringL :: Lens_' FormatTest (Maybe Text) -formatTestStringL f FormatTest{..} = (\formatTestString -> FormatTest { formatTestString, ..} ) <$> f formatTestString +formatTestStringL f FormatTest{..} = (\formatTestString -> FormatTest { formatTestString, ..} ) <$> f formatTestString {-# INLINE formatTestStringL #-} -- | 'formatTestByte' Lens formatTestByteL :: Lens_' FormatTest (ByteArray) -formatTestByteL f FormatTest{..} = (\formatTestByte -> FormatTest { formatTestByte, ..} ) <$> f formatTestByte +formatTestByteL f FormatTest{..} = (\formatTestByte -> FormatTest { formatTestByte, ..} ) <$> f formatTestByte {-# INLINE formatTestByteL #-} -- | 'formatTestBinary' Lens formatTestBinaryL :: Lens_' FormatTest (Maybe Binary) -formatTestBinaryL f FormatTest{..} = (\formatTestBinary -> FormatTest { formatTestBinary, ..} ) <$> f formatTestBinary +formatTestBinaryL f FormatTest{..} = (\formatTestBinary -> FormatTest { formatTestBinary, ..} ) <$> f formatTestBinary {-# INLINE formatTestBinaryL #-} -- | 'formatTestDate' Lens formatTestDateL :: Lens_' FormatTest (Date) -formatTestDateL f FormatTest{..} = (\formatTestDate -> FormatTest { formatTestDate, ..} ) <$> f formatTestDate +formatTestDateL f FormatTest{..} = (\formatTestDate -> FormatTest { formatTestDate, ..} ) <$> f formatTestDate {-# INLINE formatTestDateL #-} -- | 'formatTestDateTime' Lens formatTestDateTimeL :: Lens_' FormatTest (Maybe DateTime) -formatTestDateTimeL f FormatTest{..} = (\formatTestDateTime -> FormatTest { formatTestDateTime, ..} ) <$> f formatTestDateTime +formatTestDateTimeL f FormatTest{..} = (\formatTestDateTime -> FormatTest { formatTestDateTime, ..} ) <$> f formatTestDateTime {-# INLINE formatTestDateTimeL #-} -- | 'formatTestUuid' Lens formatTestUuidL :: Lens_' FormatTest (Maybe Text) -formatTestUuidL f FormatTest{..} = (\formatTestUuid -> FormatTest { formatTestUuid, ..} ) <$> f formatTestUuid +formatTestUuidL f FormatTest{..} = (\formatTestUuid -> FormatTest { formatTestUuid, ..} ) <$> f formatTestUuid {-# INLINE formatTestUuidL #-} -- | 'formatTestPassword' Lens formatTestPasswordL :: Lens_' FormatTest (Text) -formatTestPasswordL f FormatTest{..} = (\formatTestPassword -> FormatTest { formatTestPassword, ..} ) <$> f formatTestPassword +formatTestPasswordL f FormatTest{..} = (\formatTestPassword -> FormatTest { formatTestPassword, ..} ) <$> f formatTestPassword {-# INLINE formatTestPasswordL #-} @@ -306,12 +306,12 @@ Module : SwaggerPetstore.Lens -- | 'hasOnlyReadOnlyBar' Lens hasOnlyReadOnlyBarL :: Lens_' HasOnlyReadOnly (Maybe Text) -hasOnlyReadOnlyBarL f HasOnlyReadOnly{..} = (\hasOnlyReadOnlyBar -> HasOnlyReadOnly { hasOnlyReadOnlyBar, ..} ) <$> f hasOnlyReadOnlyBar +hasOnlyReadOnlyBarL f HasOnlyReadOnly{..} = (\hasOnlyReadOnlyBar -> HasOnlyReadOnly { hasOnlyReadOnlyBar, ..} ) <$> f hasOnlyReadOnlyBar {-# INLINE hasOnlyReadOnlyBarL #-} -- | 'hasOnlyReadOnlyFoo' Lens hasOnlyReadOnlyFooL :: Lens_' HasOnlyReadOnly (Maybe Text) -hasOnlyReadOnlyFooL f HasOnlyReadOnly{..} = (\hasOnlyReadOnlyFoo -> HasOnlyReadOnly { hasOnlyReadOnlyFoo, ..} ) <$> f hasOnlyReadOnlyFoo +hasOnlyReadOnlyFooL f HasOnlyReadOnly{..} = (\hasOnlyReadOnlyFoo -> HasOnlyReadOnly { hasOnlyReadOnlyFoo, ..} ) <$> f hasOnlyReadOnlyFoo {-# INLINE hasOnlyReadOnlyFooL #-} @@ -320,12 +320,12 @@ Module : SwaggerPetstore.Lens -- | 'mapTestMapMapOfString' Lens mapTestMapMapOfStringL :: Lens_' MapTest (Maybe (Map.Map String (Map.Map String Text))) -mapTestMapMapOfStringL f MapTest{..} = (\mapTestMapMapOfString -> MapTest { mapTestMapMapOfString, ..} ) <$> f mapTestMapMapOfString +mapTestMapMapOfStringL f MapTest{..} = (\mapTestMapMapOfString -> MapTest { mapTestMapMapOfString, ..} ) <$> f mapTestMapMapOfString {-# INLINE mapTestMapMapOfStringL #-} -- | 'mapTestMapOfEnumString' Lens -mapTestMapOfEnumStringL :: Lens_' MapTest (Maybe (Map.Map String Text)) -mapTestMapOfEnumStringL f MapTest{..} = (\mapTestMapOfEnumString -> MapTest { mapTestMapOfEnumString, ..} ) <$> f mapTestMapOfEnumString +mapTestMapOfEnumStringL :: Lens_' MapTest (Maybe (Map.Map String E'Inner)) +mapTestMapOfEnumStringL f MapTest{..} = (\mapTestMapOfEnumString -> MapTest { mapTestMapOfEnumString, ..} ) <$> f mapTestMapOfEnumString {-# INLINE mapTestMapOfEnumStringL #-} @@ -334,17 +334,17 @@ Module : SwaggerPetstore.Lens -- | 'mixedPropertiesAndAdditionalPropertiesClassUuid' Lens mixedPropertiesAndAdditionalPropertiesClassUuidL :: Lens_' MixedPropertiesAndAdditionalPropertiesClass (Maybe Text) -mixedPropertiesAndAdditionalPropertiesClassUuidL f MixedPropertiesAndAdditionalPropertiesClass{..} = (\mixedPropertiesAndAdditionalPropertiesClassUuid -> MixedPropertiesAndAdditionalPropertiesClass { mixedPropertiesAndAdditionalPropertiesClassUuid, ..} ) <$> f mixedPropertiesAndAdditionalPropertiesClassUuid +mixedPropertiesAndAdditionalPropertiesClassUuidL f MixedPropertiesAndAdditionalPropertiesClass{..} = (\mixedPropertiesAndAdditionalPropertiesClassUuid -> MixedPropertiesAndAdditionalPropertiesClass { mixedPropertiesAndAdditionalPropertiesClassUuid, ..} ) <$> f mixedPropertiesAndAdditionalPropertiesClassUuid {-# INLINE mixedPropertiesAndAdditionalPropertiesClassUuidL #-} -- | 'mixedPropertiesAndAdditionalPropertiesClassDateTime' Lens mixedPropertiesAndAdditionalPropertiesClassDateTimeL :: Lens_' MixedPropertiesAndAdditionalPropertiesClass (Maybe DateTime) -mixedPropertiesAndAdditionalPropertiesClassDateTimeL f MixedPropertiesAndAdditionalPropertiesClass{..} = (\mixedPropertiesAndAdditionalPropertiesClassDateTime -> MixedPropertiesAndAdditionalPropertiesClass { mixedPropertiesAndAdditionalPropertiesClassDateTime, ..} ) <$> f mixedPropertiesAndAdditionalPropertiesClassDateTime +mixedPropertiesAndAdditionalPropertiesClassDateTimeL f MixedPropertiesAndAdditionalPropertiesClass{..} = (\mixedPropertiesAndAdditionalPropertiesClassDateTime -> MixedPropertiesAndAdditionalPropertiesClass { mixedPropertiesAndAdditionalPropertiesClassDateTime, ..} ) <$> f mixedPropertiesAndAdditionalPropertiesClassDateTime {-# INLINE mixedPropertiesAndAdditionalPropertiesClassDateTimeL #-} -- | 'mixedPropertiesAndAdditionalPropertiesClassMap' Lens mixedPropertiesAndAdditionalPropertiesClassMapL :: Lens_' MixedPropertiesAndAdditionalPropertiesClass (Maybe (Map.Map String Animal)) -mixedPropertiesAndAdditionalPropertiesClassMapL f MixedPropertiesAndAdditionalPropertiesClass{..} = (\mixedPropertiesAndAdditionalPropertiesClassMap -> MixedPropertiesAndAdditionalPropertiesClass { mixedPropertiesAndAdditionalPropertiesClassMap, ..} ) <$> f mixedPropertiesAndAdditionalPropertiesClassMap +mixedPropertiesAndAdditionalPropertiesClassMapL f MixedPropertiesAndAdditionalPropertiesClass{..} = (\mixedPropertiesAndAdditionalPropertiesClassMap -> MixedPropertiesAndAdditionalPropertiesClass { mixedPropertiesAndAdditionalPropertiesClassMap, ..} ) <$> f mixedPropertiesAndAdditionalPropertiesClassMap {-# INLINE mixedPropertiesAndAdditionalPropertiesClassMapL #-} @@ -353,12 +353,12 @@ Module : SwaggerPetstore.Lens -- | 'model200ResponseName' Lens model200ResponseNameL :: Lens_' Model200Response (Maybe Int) -model200ResponseNameL f Model200Response{..} = (\model200ResponseName -> Model200Response { model200ResponseName, ..} ) <$> f model200ResponseName +model200ResponseNameL f Model200Response{..} = (\model200ResponseName -> Model200Response { model200ResponseName, ..} ) <$> f model200ResponseName {-# INLINE model200ResponseNameL #-} -- | 'model200ResponseClass' Lens model200ResponseClassL :: Lens_' Model200Response (Maybe Text) -model200ResponseClassL f Model200Response{..} = (\model200ResponseClass -> Model200Response { model200ResponseClass, ..} ) <$> f model200ResponseClass +model200ResponseClassL f Model200Response{..} = (\model200ResponseClass -> Model200Response { model200ResponseClass, ..} ) <$> f model200ResponseClass {-# INLINE model200ResponseClassL #-} @@ -367,7 +367,7 @@ Module : SwaggerPetstore.Lens -- | 'modelList123List' Lens modelList123ListL :: Lens_' ModelList (Maybe Text) -modelList123ListL f ModelList{..} = (\modelList123List -> ModelList { modelList123List, ..} ) <$> f modelList123List +modelList123ListL f ModelList{..} = (\modelList123List -> ModelList { modelList123List, ..} ) <$> f modelList123List {-# INLINE modelList123ListL #-} @@ -376,7 +376,7 @@ Module : SwaggerPetstore.Lens -- | 'modelReturnReturn' Lens modelReturnReturnL :: Lens_' ModelReturn (Maybe Int) -modelReturnReturnL f ModelReturn{..} = (\modelReturnReturn -> ModelReturn { modelReturnReturn, ..} ) <$> f modelReturnReturn +modelReturnReturnL f ModelReturn{..} = (\modelReturnReturn -> ModelReturn { modelReturnReturn, ..} ) <$> f modelReturnReturn {-# INLINE modelReturnReturnL #-} @@ -385,22 +385,22 @@ Module : SwaggerPetstore.Lens -- | 'nameName' Lens nameNameL :: Lens_' Name (Int) -nameNameL f Name{..} = (\nameName -> Name { nameName, ..} ) <$> f nameName +nameNameL f Name{..} = (\nameName -> Name { nameName, ..} ) <$> f nameName {-# INLINE nameNameL #-} -- | 'nameSnakeCase' Lens nameSnakeCaseL :: Lens_' Name (Maybe Int) -nameSnakeCaseL f Name{..} = (\nameSnakeCase -> Name { nameSnakeCase, ..} ) <$> f nameSnakeCase +nameSnakeCaseL f Name{..} = (\nameSnakeCase -> Name { nameSnakeCase, ..} ) <$> f nameSnakeCase {-# INLINE nameSnakeCaseL #-} -- | 'nameProperty' Lens namePropertyL :: Lens_' Name (Maybe Text) -namePropertyL f Name{..} = (\nameProperty -> Name { nameProperty, ..} ) <$> f nameProperty +namePropertyL f Name{..} = (\nameProperty -> Name { nameProperty, ..} ) <$> f nameProperty {-# INLINE namePropertyL #-} -- | 'name123Number' Lens name123NumberL :: Lens_' Name (Maybe Int) -name123NumberL f Name{..} = (\name123Number -> Name { name123Number, ..} ) <$> f name123Number +name123NumberL f Name{..} = (\name123Number -> Name { name123Number, ..} ) <$> f name123Number {-# INLINE name123NumberL #-} @@ -409,7 +409,7 @@ Module : SwaggerPetstore.Lens -- | 'numberOnlyJustNumber' Lens numberOnlyJustNumberL :: Lens_' NumberOnly (Maybe Double) -numberOnlyJustNumberL f NumberOnly{..} = (\numberOnlyJustNumber -> NumberOnly { numberOnlyJustNumber, ..} ) <$> f numberOnlyJustNumber +numberOnlyJustNumberL f NumberOnly{..} = (\numberOnlyJustNumber -> NumberOnly { numberOnlyJustNumber, ..} ) <$> f numberOnlyJustNumber {-# INLINE numberOnlyJustNumberL #-} @@ -418,32 +418,32 @@ Module : SwaggerPetstore.Lens -- | 'orderId' Lens orderIdL :: Lens_' Order (Maybe Integer) -orderIdL f Order{..} = (\orderId -> Order { orderId, ..} ) <$> f orderId +orderIdL f Order{..} = (\orderId -> Order { orderId, ..} ) <$> f orderId {-# INLINE orderIdL #-} -- | 'orderPetId' Lens orderPetIdL :: Lens_' Order (Maybe Integer) -orderPetIdL f Order{..} = (\orderPetId -> Order { orderPetId, ..} ) <$> f orderPetId +orderPetIdL f Order{..} = (\orderPetId -> Order { orderPetId, ..} ) <$> f orderPetId {-# INLINE orderPetIdL #-} -- | 'orderQuantity' Lens orderQuantityL :: Lens_' Order (Maybe Int) -orderQuantityL f Order{..} = (\orderQuantity -> Order { orderQuantity, ..} ) <$> f orderQuantity +orderQuantityL f Order{..} = (\orderQuantity -> Order { orderQuantity, ..} ) <$> f orderQuantity {-# INLINE orderQuantityL #-} -- | 'orderShipDate' Lens orderShipDateL :: Lens_' Order (Maybe DateTime) -orderShipDateL f Order{..} = (\orderShipDate -> Order { orderShipDate, ..} ) <$> f orderShipDate +orderShipDateL f Order{..} = (\orderShipDate -> Order { orderShipDate, ..} ) <$> f orderShipDate {-# INLINE orderShipDateL #-} -- | 'orderStatus' Lens -orderStatusL :: Lens_' Order (Maybe Text) -orderStatusL f Order{..} = (\orderStatus -> Order { orderStatus, ..} ) <$> f orderStatus +orderStatusL :: Lens_' Order (Maybe E'Status) +orderStatusL f Order{..} = (\orderStatus -> Order { orderStatus, ..} ) <$> f orderStatus {-# INLINE orderStatusL #-} -- | 'orderComplete' Lens orderCompleteL :: Lens_' Order (Maybe Bool) -orderCompleteL f Order{..} = (\orderComplete -> Order { orderComplete, ..} ) <$> f orderComplete +orderCompleteL f Order{..} = (\orderComplete -> Order { orderComplete, ..} ) <$> f orderComplete {-# INLINE orderCompleteL #-} @@ -456,17 +456,17 @@ Module : SwaggerPetstore.Lens -- | 'outerCompositeMyNumber' Lens outerCompositeMyNumberL :: Lens_' OuterComposite (Maybe OuterNumber) -outerCompositeMyNumberL f OuterComposite{..} = (\outerCompositeMyNumber -> OuterComposite { outerCompositeMyNumber, ..} ) <$> f outerCompositeMyNumber +outerCompositeMyNumberL f OuterComposite{..} = (\outerCompositeMyNumber -> OuterComposite { outerCompositeMyNumber, ..} ) <$> f outerCompositeMyNumber {-# INLINE outerCompositeMyNumberL #-} -- | 'outerCompositeMyString' Lens outerCompositeMyStringL :: Lens_' OuterComposite (Maybe OuterString) -outerCompositeMyStringL f OuterComposite{..} = (\outerCompositeMyString -> OuterComposite { outerCompositeMyString, ..} ) <$> f outerCompositeMyString +outerCompositeMyStringL f OuterComposite{..} = (\outerCompositeMyString -> OuterComposite { outerCompositeMyString, ..} ) <$> f outerCompositeMyString {-# INLINE outerCompositeMyStringL #-} -- | 'outerCompositeMyBoolean' Lens outerCompositeMyBooleanL :: Lens_' OuterComposite (Maybe OuterBoolean) -outerCompositeMyBooleanL f OuterComposite{..} = (\outerCompositeMyBoolean -> OuterComposite { outerCompositeMyBoolean, ..} ) <$> f outerCompositeMyBoolean +outerCompositeMyBooleanL f OuterComposite{..} = (\outerCompositeMyBoolean -> OuterComposite { outerCompositeMyBoolean, ..} ) <$> f outerCompositeMyBoolean {-# INLINE outerCompositeMyBooleanL #-} @@ -487,32 +487,32 @@ Module : SwaggerPetstore.Lens -- | 'petId' Lens petIdL :: Lens_' Pet (Maybe Integer) -petIdL f Pet{..} = (\petId -> Pet { petId, ..} ) <$> f petId +petIdL f Pet{..} = (\petId -> Pet { petId, ..} ) <$> f petId {-# INLINE petIdL #-} -- | 'petCategory' Lens petCategoryL :: Lens_' Pet (Maybe Category) -petCategoryL f Pet{..} = (\petCategory -> Pet { petCategory, ..} ) <$> f petCategory +petCategoryL f Pet{..} = (\petCategory -> Pet { petCategory, ..} ) <$> f petCategory {-# INLINE petCategoryL #-} -- | 'petName' Lens petNameL :: Lens_' Pet (Text) -petNameL f Pet{..} = (\petName -> Pet { petName, ..} ) <$> f petName +petNameL f Pet{..} = (\petName -> Pet { petName, ..} ) <$> f petName {-# INLINE petNameL #-} -- | 'petPhotoUrls' Lens petPhotoUrlsL :: Lens_' Pet ([Text]) -petPhotoUrlsL f Pet{..} = (\petPhotoUrls -> Pet { petPhotoUrls, ..} ) <$> f petPhotoUrls +petPhotoUrlsL f Pet{..} = (\petPhotoUrls -> Pet { petPhotoUrls, ..} ) <$> f petPhotoUrls {-# INLINE petPhotoUrlsL #-} -- | 'petTags' Lens petTagsL :: Lens_' Pet (Maybe [Tag]) -petTagsL f Pet{..} = (\petTags -> Pet { petTags, ..} ) <$> f petTags +petTagsL f Pet{..} = (\petTags -> Pet { petTags, ..} ) <$> f petTags {-# INLINE petTagsL #-} -- | 'petStatus' Lens -petStatusL :: Lens_' Pet (Maybe Text) -petStatusL f Pet{..} = (\petStatus -> Pet { petStatus, ..} ) <$> f petStatus +petStatusL :: Lens_' Pet (Maybe E'Status2) +petStatusL f Pet{..} = (\petStatus -> Pet { petStatus, ..} ) <$> f petStatus {-# INLINE petStatusL #-} @@ -521,12 +521,12 @@ Module : SwaggerPetstore.Lens -- | 'readOnlyFirstBar' Lens readOnlyFirstBarL :: Lens_' ReadOnlyFirst (Maybe Text) -readOnlyFirstBarL f ReadOnlyFirst{..} = (\readOnlyFirstBar -> ReadOnlyFirst { readOnlyFirstBar, ..} ) <$> f readOnlyFirstBar +readOnlyFirstBarL f ReadOnlyFirst{..} = (\readOnlyFirstBar -> ReadOnlyFirst { readOnlyFirstBar, ..} ) <$> f readOnlyFirstBar {-# INLINE readOnlyFirstBarL #-} -- | 'readOnlyFirstBaz' Lens readOnlyFirstBazL :: Lens_' ReadOnlyFirst (Maybe Text) -readOnlyFirstBazL f ReadOnlyFirst{..} = (\readOnlyFirstBaz -> ReadOnlyFirst { readOnlyFirstBaz, ..} ) <$> f readOnlyFirstBaz +readOnlyFirstBazL f ReadOnlyFirst{..} = (\readOnlyFirstBaz -> ReadOnlyFirst { readOnlyFirstBaz, ..} ) <$> f readOnlyFirstBaz {-# INLINE readOnlyFirstBazL #-} @@ -535,7 +535,7 @@ Module : SwaggerPetstore.Lens -- | 'specialModelNameSpecialPropertyName' Lens specialModelNameSpecialPropertyNameL :: Lens_' SpecialModelName (Maybe Integer) -specialModelNameSpecialPropertyNameL f SpecialModelName{..} = (\specialModelNameSpecialPropertyName -> SpecialModelName { specialModelNameSpecialPropertyName, ..} ) <$> f specialModelNameSpecialPropertyName +specialModelNameSpecialPropertyNameL f SpecialModelName{..} = (\specialModelNameSpecialPropertyName -> SpecialModelName { specialModelNameSpecialPropertyName, ..} ) <$> f specialModelNameSpecialPropertyName {-# INLINE specialModelNameSpecialPropertyNameL #-} @@ -544,12 +544,12 @@ Module : SwaggerPetstore.Lens -- | 'tagId' Lens tagIdL :: Lens_' Tag (Maybe Integer) -tagIdL f Tag{..} = (\tagId -> Tag { tagId, ..} ) <$> f tagId +tagIdL f Tag{..} = (\tagId -> Tag { tagId, ..} ) <$> f tagId {-# INLINE tagIdL #-} -- | 'tagName' Lens tagNameL :: Lens_' Tag (Maybe Text) -tagNameL f Tag{..} = (\tagName -> Tag { tagName, ..} ) <$> f tagName +tagNameL f Tag{..} = (\tagName -> Tag { tagName, ..} ) <$> f tagName {-# INLINE tagNameL #-} @@ -558,42 +558,42 @@ Module : SwaggerPetstore.Lens -- | 'userId' Lens userIdL :: Lens_' User (Maybe Integer) -userIdL f User{..} = (\userId -> User { userId, ..} ) <$> f userId +userIdL f User{..} = (\userId -> User { userId, ..} ) <$> f userId {-# INLINE userIdL #-} -- | 'userUsername' Lens userUsernameL :: Lens_' User (Maybe Text) -userUsernameL f User{..} = (\userUsername -> User { userUsername, ..} ) <$> f userUsername +userUsernameL f User{..} = (\userUsername -> User { userUsername, ..} ) <$> f userUsername {-# INLINE userUsernameL #-} -- | 'userFirstName' Lens userFirstNameL :: Lens_' User (Maybe Text) -userFirstNameL f User{..} = (\userFirstName -> User { userFirstName, ..} ) <$> f userFirstName +userFirstNameL f User{..} = (\userFirstName -> User { userFirstName, ..} ) <$> f userFirstName {-# INLINE userFirstNameL #-} -- | 'userLastName' Lens userLastNameL :: Lens_' User (Maybe Text) -userLastNameL f User{..} = (\userLastName -> User { userLastName, ..} ) <$> f userLastName +userLastNameL f User{..} = (\userLastName -> User { userLastName, ..} ) <$> f userLastName {-# INLINE userLastNameL #-} -- | 'userEmail' Lens userEmailL :: Lens_' User (Maybe Text) -userEmailL f User{..} = (\userEmail -> User { userEmail, ..} ) <$> f userEmail +userEmailL f User{..} = (\userEmail -> User { userEmail, ..} ) <$> f userEmail {-# INLINE userEmailL #-} -- | 'userPassword' Lens userPasswordL :: Lens_' User (Maybe Text) -userPasswordL f User{..} = (\userPassword -> User { userPassword, ..} ) <$> f userPassword +userPasswordL f User{..} = (\userPassword -> User { userPassword, ..} ) <$> f userPassword {-# INLINE userPasswordL #-} -- | 'userPhone' Lens userPhoneL :: Lens_' User (Maybe Text) -userPhoneL f User{..} = (\userPhone -> User { userPhone, ..} ) <$> f userPhone +userPhoneL f User{..} = (\userPhone -> User { userPhone, ..} ) <$> f userPhone {-# INLINE userPhoneL #-} -- | 'userUserStatus' Lens userUserStatusL :: Lens_' User (Maybe Int) -userUserStatusL f User{..} = (\userUserStatus -> User { userUserStatus, ..} ) <$> f userUserStatus +userUserStatusL f User{..} = (\userUserStatus -> User { userUserStatus, ..} ) <$> f userUserStatus {-# INLINE userUserStatusL #-} @@ -602,17 +602,17 @@ Module : SwaggerPetstore.Lens -- | 'catClassName' Lens catClassNameL :: Lens_' Cat (Text) -catClassNameL f Cat{..} = (\catClassName -> Cat { catClassName, ..} ) <$> f catClassName +catClassNameL f Cat{..} = (\catClassName -> Cat { catClassName, ..} ) <$> f catClassName {-# INLINE catClassNameL #-} -- | 'catColor' Lens catColorL :: Lens_' Cat (Maybe Text) -catColorL f Cat{..} = (\catColor -> Cat { catColor, ..} ) <$> f catColor +catColorL f Cat{..} = (\catColor -> Cat { catColor, ..} ) <$> f catColor {-# INLINE catColorL #-} -- | 'catDeclawed' Lens catDeclawedL :: Lens_' Cat (Maybe Bool) -catDeclawedL f Cat{..} = (\catDeclawed -> Cat { catDeclawed, ..} ) <$> f catDeclawed +catDeclawedL f Cat{..} = (\catDeclawed -> Cat { catDeclawed, ..} ) <$> f catDeclawed {-# INLINE catDeclawedL #-} @@ -621,17 +621,17 @@ Module : SwaggerPetstore.Lens -- | 'dogClassName' Lens dogClassNameL :: Lens_' Dog (Text) -dogClassNameL f Dog{..} = (\dogClassName -> Dog { dogClassName, ..} ) <$> f dogClassName +dogClassNameL f Dog{..} = (\dogClassName -> Dog { dogClassName, ..} ) <$> f dogClassName {-# INLINE dogClassNameL #-} -- | 'dogColor' Lens dogColorL :: Lens_' Dog (Maybe Text) -dogColorL f Dog{..} = (\dogColor -> Dog { dogColor, ..} ) <$> f dogColor +dogColorL f Dog{..} = (\dogColor -> Dog { dogColor, ..} ) <$> f dogColor {-# INLINE dogColorL #-} -- | 'dogBreed' Lens dogBreedL :: Lens_' Dog (Maybe Text) -dogBreedL f Dog{..} = (\dogBreed -> Dog { dogBreed, ..} ) <$> f dogBreed +dogBreedL f Dog{..} = (\dogBreed -> Dog { dogBreed, ..} ) <$> f dogBreed {-# INLINE dogBreedL #-} diff --git a/samples/client/petstore/haskell-http-client/example-app/Main.hs b/samples/client/petstore/haskell-http-client/example-app/Main.hs index cf703a572d6..a6a7917bb34 100644 --- a/samples/client/petstore/haskell-http-client/example-app/Main.hs +++ b/samples/client/petstore/haskell-http-client/example-app/Main.hs @@ -104,7 +104,9 @@ runPet mgr config = do Right r -> putStrLn $ "getPetById: found pet: " <> show r -- display 'Pet' model object, r -- findPetsByStatus - let findPetsByStatusRequest = S.findPetsByStatus (S.Status ["available","pending","sold"]) + let findPetsByStatusRequest = S.findPetsByStatus (S.Status [ S.E'Status2'Available + , S.E'Status2'Pending + , S.E'Status2'Sold]) findPetsByStatusResult <- S.dispatchMime mgr config findPetsByStatusRequest S.MimeJSON mapM_ (\r -> putStrLn $ "findPetsByStatus: found " <> (show . length) r <> " pets") findPetsByStatusResult @@ -115,7 +117,7 @@ runPet mgr config = do -- updatePet let updatePetRequest = S.updatePet S.MimeJSON $ pet - { S.petStatus = Just "available" + { S.petStatus = Just S.E'Status2'Available , S.petCategory = Just (S.Category (Just 3) (Just "catname")) } _ <- S.dispatchLbs mgr config updatePetRequest S.MimeXML diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API.hs index afce16b8084..997ba21abaa 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API.hs @@ -359,6 +359,32 @@ instance Consumes TestEnumParameters MimeAny instance Produces TestEnumParameters MimeAny +-- *** testInlineAdditionalProperties + +-- | @POST \/fake\/inline-additionalProperties@ +-- +-- test inline additionalProperties +-- +-- +-- +testInlineAdditionalProperties + :: (Consumes TestInlineAdditionalProperties contentType, MimeRender contentType A.Value) + => contentType -- ^ request content-type ('MimeType') + -> A.Value -- ^ "param" - request body + -> SwaggerPetstoreRequest TestInlineAdditionalProperties contentType NoContent +testInlineAdditionalProperties _ param = + _mkRequest "POST" ["/fake/inline-additionalProperties"] + `setBodyParam` param + +data TestInlineAdditionalProperties + +-- | /Body Param/ "param" - request body +instance HasBodyParam TestInlineAdditionalProperties A.Value + +-- | @application/json@ +instance Consumes TestInlineAdditionalProperties MimeJSON + + -- *** testJsonFormData -- | @GET \/fake\/jsonFormData@ @@ -990,14 +1016,14 @@ newtype ApiKey = ApiKey { unApiKey :: Text } deriving (P.Eq, P.Show) newtype Body = Body { unBody :: [User] } deriving (P.Eq, P.Show, A.ToJSON) newtype Byte = Byte { unByte :: ByteArray } deriving (P.Eq, P.Show) newtype Callback = Callback { unCallback :: Text } deriving (P.Eq, P.Show) -newtype EnumFormString = EnumFormString { unEnumFormString :: Text } deriving (P.Eq, P.Show) -newtype EnumFormStringArray = EnumFormStringArray { unEnumFormStringArray :: [Text] } deriving (P.Eq, P.Show) -newtype EnumHeaderString = EnumHeaderString { unEnumHeaderString :: Text } deriving (P.Eq, P.Show) -newtype EnumHeaderStringArray = EnumHeaderStringArray { unEnumHeaderStringArray :: [Text] } deriving (P.Eq, P.Show) -newtype EnumQueryDouble = EnumQueryDouble { unEnumQueryDouble :: Double } deriving (P.Eq, P.Show) -newtype EnumQueryInteger = EnumQueryInteger { unEnumQueryInteger :: Int } deriving (P.Eq, P.Show) -newtype EnumQueryString = EnumQueryString { unEnumQueryString :: Text } deriving (P.Eq, P.Show) -newtype EnumQueryStringArray = EnumQueryStringArray { unEnumQueryStringArray :: [Text] } deriving (P.Eq, P.Show) +newtype EnumFormString = EnumFormString { unEnumFormString :: E'EnumFormString } deriving (P.Eq, P.Show) +newtype EnumFormStringArray = EnumFormStringArray { unEnumFormStringArray :: [E'Inner2] } deriving (P.Eq, P.Show) +newtype EnumHeaderString = EnumHeaderString { unEnumHeaderString :: E'EnumFormString } deriving (P.Eq, P.Show) +newtype EnumHeaderStringArray = EnumHeaderStringArray { unEnumHeaderStringArray :: [E'Inner2] } deriving (P.Eq, P.Show) +newtype EnumQueryDouble = EnumQueryDouble { unEnumQueryDouble :: E'EnumNumber } deriving (P.Eq, P.Show) +newtype EnumQueryInteger = EnumQueryInteger { unEnumQueryInteger :: E'EnumQueryInteger } deriving (P.Eq, P.Show) +newtype EnumQueryString = EnumQueryString { unEnumQueryString :: E'EnumFormString } deriving (P.Eq, P.Show) +newtype EnumQueryStringArray = EnumQueryStringArray { unEnumQueryStringArray :: [E'Inner2] } deriving (P.Eq, P.Show) newtype File = File { unFile :: FilePath } deriving (P.Eq, P.Show) newtype Int32 = Int32 { unInt32 :: Int } deriving (P.Eq, P.Show) newtype Int64 = Int64 { unInt64 :: Integer } deriving (P.Eq, P.Show) @@ -1017,7 +1043,7 @@ newtype ParamString = ParamString { unParamString :: Text } deriving (P.Eq, P.Sh newtype Password = Password { unPassword :: Text } deriving (P.Eq, P.Show) newtype PatternWithoutDelimiter = PatternWithoutDelimiter { unPatternWithoutDelimiter :: Text } deriving (P.Eq, P.Show) newtype PetId = PetId { unPetId :: Integer } deriving (P.Eq, P.Show) -newtype Status = Status { unStatus :: [Text] } deriving (P.Eq, P.Show) +newtype Status = Status { unStatus :: [E'Status2] } deriving (P.Eq, P.Show) newtype StatusText = StatusText { unStatusText :: Text } deriving (P.Eq, P.Show) newtype Tags = Tags { unTags :: [Text] } deriving (P.Eq, P.Show) newtype Username = Username { unUsername :: Text } deriving (P.Eq, P.Show) diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Model.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Model.hs index 81208c6ce42..588f92a2390 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Model.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Model.hs @@ -18,6 +18,8 @@ Module : SwaggerPetstore.Model {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} @@ -28,9 +30,11 @@ Module : SwaggerPetstore.Model module SwaggerPetstore.Model where import SwaggerPetstore.Core +import SwaggerPetstore.MimeTypes import Data.Aeson ((.:),(.:!),(.:?),(.=)) +import qualified Control.Arrow as P (left) import qualified Data.Aeson as A import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL @@ -49,7 +53,7 @@ import qualified Web.HttpApiData as WH import Control.Applicative ((<|>)) import Control.Applicative (Alternative) import Data.Text (Text) -import Prelude (($), (.),(<$>),(<*>),(>>=),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor) +import Prelude (($), (.),(<$>),(<*>),(>>=),(=<<),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor) import qualified Prelude as P @@ -90,7 +94,6 @@ mkAdditionalPropertiesClass = , additionalPropertiesClassMapOfMapProperty = Nothing } - -- ** Animal -- | Animal data Animal = Animal @@ -124,7 +127,6 @@ mkAnimal animalClassName = , animalColor = Nothing } - -- ** AnimalFarm -- | AnimalFarm data AnimalFarm = AnimalFarm @@ -153,7 +155,6 @@ mkAnimalFarm = { } - -- ** ApiResponse -- | ApiResponse data ApiResponse = ApiResponse @@ -190,7 +191,6 @@ mkApiResponse = , apiResponseMessage = Nothing } - -- ** ArrayOfArrayOfNumberOnly -- | ArrayOfArrayOfNumberOnly data ArrayOfArrayOfNumberOnly = ArrayOfArrayOfNumberOnly @@ -219,7 +219,6 @@ mkArrayOfArrayOfNumberOnly = { arrayOfArrayOfNumberOnlyArrayArrayNumber = Nothing } - -- ** ArrayOfNumberOnly -- | ArrayOfNumberOnly data ArrayOfNumberOnly = ArrayOfNumberOnly @@ -248,7 +247,6 @@ mkArrayOfNumberOnly = { arrayOfNumberOnlyArrayNumber = Nothing } - -- ** ArrayTest -- | ArrayTest data ArrayTest = ArrayTest @@ -285,7 +283,6 @@ mkArrayTest = , arrayTestArrayArrayOfModel = Nothing } - -- ** Capitalization -- | Capitalization data Capitalization = Capitalization @@ -334,7 +331,6 @@ mkCapitalization = , capitalizationAttName = Nothing } - -- ** Category -- | Category data Category = Category @@ -367,7 +363,6 @@ mkCategory = , categoryName = Nothing } - -- ** ClassModel -- | ClassModel -- Model for testing model with \"_class\" property @@ -397,7 +392,6 @@ mkClassModel = { classModelClass = Nothing } - -- ** Client -- | Client data Client = Client @@ -426,12 +420,11 @@ mkClient = { clientClient = Nothing } - -- ** EnumArrays -- | EnumArrays data EnumArrays = EnumArrays - { enumArraysJustSymbol :: !(Maybe Text) -- ^ "just_symbol" - , enumArraysArrayEnum :: !(Maybe [Text]) -- ^ "array_enum" + { enumArraysJustSymbol :: !(Maybe E'JustSymbol) -- ^ "just_symbol" + , enumArraysArrayEnum :: !(Maybe [E'ArrayEnum]) -- ^ "array_enum" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON EnumArrays @@ -459,42 +452,12 @@ mkEnumArrays = , enumArraysArrayEnum = Nothing } - --- ** EnumClass --- | EnumClass -data EnumClass = EnumClass - { - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON EnumClass -instance A.FromJSON EnumClass where - parseJSON = A.withObject "EnumClass" $ \o -> - pure EnumClass - - --- | ToJSON EnumClass -instance A.ToJSON EnumClass where - toJSON EnumClass = - _omitNulls - [ - ] - - --- | Construct a value of type 'EnumClass' (by applying it's required fields, if any) -mkEnumClass - :: EnumClass -mkEnumClass = - EnumClass - { - } - - -- ** EnumTest -- | EnumTest data EnumTest = EnumTest - { enumTestEnumString :: !(Maybe Text) -- ^ "enum_string" - , enumTestEnumInteger :: !(Maybe Int) -- ^ "enum_integer" - , enumTestEnumNumber :: !(Maybe Double) -- ^ "enum_number" + { enumTestEnumString :: !(Maybe E'EnumString) -- ^ "enum_string" + , enumTestEnumInteger :: !(Maybe E'EnumInteger) -- ^ "enum_integer" + , enumTestEnumNumber :: !(Maybe E'EnumNumber) -- ^ "enum_number" , enumTestOuterEnum :: !(Maybe OuterEnum) -- ^ "outerEnum" } deriving (P.Show, P.Eq, P.Typeable) @@ -529,7 +492,6 @@ mkEnumTest = , enumTestOuterEnum = Nothing } - -- ** FormatTest -- | FormatTest data FormatTest = FormatTest @@ -610,7 +572,6 @@ mkFormatTest formatTestNumber formatTestByte formatTestDate formatTestPassword = , formatTestPassword } - -- ** HasOnlyReadOnly -- | HasOnlyReadOnly data HasOnlyReadOnly = HasOnlyReadOnly @@ -643,12 +604,11 @@ mkHasOnlyReadOnly = , hasOnlyReadOnlyFoo = Nothing } - -- ** MapTest -- | MapTest data MapTest = MapTest { mapTestMapMapOfString :: !(Maybe (Map.Map String (Map.Map String Text))) -- ^ "map_map_of_string" - , mapTestMapOfEnumString :: !(Maybe (Map.Map String Text)) -- ^ "map_of_enum_string" + , mapTestMapOfEnumString :: !(Maybe (Map.Map String E'Inner)) -- ^ "map_of_enum_string" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON MapTest @@ -676,7 +636,6 @@ mkMapTest = , mapTestMapOfEnumString = Nothing } - -- ** MixedPropertiesAndAdditionalPropertiesClass -- | MixedPropertiesAndAdditionalPropertiesClass data MixedPropertiesAndAdditionalPropertiesClass = MixedPropertiesAndAdditionalPropertiesClass @@ -713,7 +672,6 @@ mkMixedPropertiesAndAdditionalPropertiesClass = , mixedPropertiesAndAdditionalPropertiesClassMap = Nothing } - -- ** Model200Response -- | Model200Response -- Model for testing model name starting with number @@ -747,7 +705,6 @@ mkModel200Response = , model200ResponseClass = Nothing } - -- ** ModelList -- | ModelList data ModelList = ModelList @@ -776,7 +733,6 @@ mkModelList = { modelList123List = Nothing } - -- ** ModelReturn -- | ModelReturn -- Model for testing reserved words @@ -806,7 +762,6 @@ mkModelReturn = { modelReturnReturn = Nothing } - -- ** Name -- | Name -- Model for testing model name same as property name @@ -849,7 +804,6 @@ mkName nameName = , name123Number = Nothing } - -- ** NumberOnly -- | NumberOnly data NumberOnly = NumberOnly @@ -878,7 +832,6 @@ mkNumberOnly = { numberOnlyJustNumber = Nothing } - -- ** Order -- | Order data Order = Order @@ -886,7 +839,7 @@ data Order = Order , orderPetId :: !(Maybe Integer) -- ^ "petId" , orderQuantity :: !(Maybe Int) -- ^ "quantity" , orderShipDate :: !(Maybe DateTime) -- ^ "shipDate" - , orderStatus :: !(Maybe Text) -- ^ "status" - Order Status + , orderStatus :: !(Maybe E'Status) -- ^ "status" - Order Status , orderComplete :: !(Maybe Bool) -- ^ "complete" } deriving (P.Show, P.Eq, P.Typeable) @@ -927,7 +880,6 @@ mkOrder = , orderComplete = Nothing } - -- ** OuterBoolean -- | OuterBoolean newtype OuterBoolean = OuterBoolean @@ -935,7 +887,6 @@ newtype OuterBoolean = OuterBoolean } deriving (P.Eq, P.Show, P.Typeable, A.ToJSON, A.FromJSON, WH.ToHttpApiData, WH.FromHttpApiData) - -- ** OuterComposite -- | OuterComposite data OuterComposite = OuterComposite @@ -972,36 +923,6 @@ mkOuterComposite = , outerCompositeMyBoolean = Nothing } - --- ** OuterEnum --- | OuterEnum -data OuterEnum = OuterEnum - { - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON OuterEnum -instance A.FromJSON OuterEnum where - parseJSON = A.withObject "OuterEnum" $ \o -> - pure OuterEnum - - --- | ToJSON OuterEnum -instance A.ToJSON OuterEnum where - toJSON OuterEnum = - _omitNulls - [ - ] - - --- | Construct a value of type 'OuterEnum' (by applying it's required fields, if any) -mkOuterEnum - :: OuterEnum -mkOuterEnum = - OuterEnum - { - } - - -- ** OuterNumber -- | OuterNumber newtype OuterNumber = OuterNumber @@ -1009,7 +930,6 @@ newtype OuterNumber = OuterNumber } deriving (P.Eq, P.Show, P.Typeable, A.ToJSON, A.FromJSON, WH.ToHttpApiData, WH.FromHttpApiData) - -- ** OuterString -- | OuterString newtype OuterString = OuterString @@ -1017,7 +937,6 @@ newtype OuterString = OuterString } deriving (P.Eq, P.Show, P.Typeable, A.ToJSON, A.FromJSON, WH.ToHttpApiData, WH.FromHttpApiData) - -- ** Pet -- | Pet data Pet = Pet @@ -1026,7 +945,7 @@ data Pet = Pet , petName :: !(Text) -- ^ /Required/ "name" , petPhotoUrls :: !([Text]) -- ^ /Required/ "photoUrls" , petTags :: !(Maybe [Tag]) -- ^ "tags" - , petStatus :: !(Maybe Text) -- ^ "status" - pet status in the store + , petStatus :: !(Maybe E'Status2) -- ^ "status" - pet status in the store } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Pet @@ -1068,7 +987,6 @@ mkPet petName petPhotoUrls = , petStatus = Nothing } - -- ** ReadOnlyFirst -- | ReadOnlyFirst data ReadOnlyFirst = ReadOnlyFirst @@ -1101,7 +1019,6 @@ mkReadOnlyFirst = , readOnlyFirstBaz = Nothing } - -- ** SpecialModelName -- | SpecialModelName data SpecialModelName = SpecialModelName @@ -1130,7 +1047,6 @@ mkSpecialModelName = { specialModelNameSpecialPropertyName = Nothing } - -- ** Tag -- | Tag data Tag = Tag @@ -1163,7 +1079,6 @@ mkTag = , tagName = Nothing } - -- ** User -- | User data User = User @@ -1220,7 +1135,6 @@ mkUser = , userUserStatus = Nothing } - -- ** Cat -- | Cat data Cat = Cat @@ -1258,7 +1172,6 @@ mkCat catClassName = , catDeclawed = Nothing } - -- ** Dog -- | Dog data Dog = Dog @@ -1297,4 +1210,388 @@ mkDog dogClassName = } +-- * Enums + +-- ** E'ArrayEnum + +-- | Enum of 'Text' +data E'ArrayEnum + = E'ArrayEnum'Fish -- ^ @"fish"@ + | E'ArrayEnum'Crab -- ^ @"crab"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'ArrayEnum where toJSON = A.toJSON . fromE'ArrayEnum +instance A.FromJSON E'ArrayEnum where parseJSON o = P.either P.fail (pure . P.id) . toE'ArrayEnum =<< A.parseJSON o +instance WH.ToHttpApiData E'ArrayEnum where toQueryParam = WH.toQueryParam . fromE'ArrayEnum +instance WH.FromHttpApiData E'ArrayEnum where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'ArrayEnum +instance MimeRender MimeMultipartFormData E'ArrayEnum where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'ArrayEnum' enum +fromE'ArrayEnum :: E'ArrayEnum -> Text +fromE'ArrayEnum = \case + E'ArrayEnum'Fish -> "fish" + E'ArrayEnum'Crab -> "crab" + +-- | parse 'E'ArrayEnum' enum +toE'ArrayEnum :: Text -> P.Either String E'ArrayEnum +toE'ArrayEnum = \case + "fish" -> P.Right E'ArrayEnum'Fish + "crab" -> P.Right E'ArrayEnum'Crab + s -> P.Left $ "toE'ArrayEnum: enum parse failure: " P.++ P.show s + + +-- ** E'EnumFormString + +-- | Enum of 'Text' +data E'EnumFormString + = E'EnumFormString'_abc -- ^ @"_abc"@ + | E'EnumFormString'_efg -- ^ @"-efg"@ + | E'EnumFormString'_xyz -- ^ @"(xyz)"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'EnumFormString where toJSON = A.toJSON . fromE'EnumFormString +instance A.FromJSON E'EnumFormString where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumFormString =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumFormString where toQueryParam = WH.toQueryParam . fromE'EnumFormString +instance WH.FromHttpApiData E'EnumFormString where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumFormString +instance MimeRender MimeMultipartFormData E'EnumFormString where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'EnumFormString' enum +fromE'EnumFormString :: E'EnumFormString -> Text +fromE'EnumFormString = \case + E'EnumFormString'_abc -> "_abc" + E'EnumFormString'_efg -> "-efg" + E'EnumFormString'_xyz -> "(xyz)" + +-- | parse 'E'EnumFormString' enum +toE'EnumFormString :: Text -> P.Either String E'EnumFormString +toE'EnumFormString = \case + "_abc" -> P.Right E'EnumFormString'_abc + "-efg" -> P.Right E'EnumFormString'_efg + "(xyz)" -> P.Right E'EnumFormString'_xyz + s -> P.Left $ "toE'EnumFormString: enum parse failure: " P.++ P.show s + + +-- ** E'EnumInteger + +-- | Enum of 'Int' +data E'EnumInteger + = E'EnumInteger'Num1 -- ^ @1@ + | E'EnumInteger'NumMinus_1 -- ^ @-1@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'EnumInteger where toJSON = A.toJSON . fromE'EnumInteger +instance A.FromJSON E'EnumInteger where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumInteger =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumInteger where toQueryParam = WH.toQueryParam . fromE'EnumInteger +instance WH.FromHttpApiData E'EnumInteger where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumInteger +instance MimeRender MimeMultipartFormData E'EnumInteger where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'EnumInteger' enum +fromE'EnumInteger :: E'EnumInteger -> Int +fromE'EnumInteger = \case + E'EnumInteger'Num1 -> 1 + E'EnumInteger'NumMinus_1 -> -1 + +-- | parse 'E'EnumInteger' enum +toE'EnumInteger :: Int -> P.Either String E'EnumInteger +toE'EnumInteger = \case + 1 -> P.Right E'EnumInteger'Num1 + -1 -> P.Right E'EnumInteger'NumMinus_1 + s -> P.Left $ "toE'EnumInteger: enum parse failure: " P.++ P.show s + + +-- ** E'EnumNumber + +-- | Enum of 'Double' +data E'EnumNumber + = E'EnumNumber'Num1_Dot_1 -- ^ @1.1@ + | E'EnumNumber'NumMinus_1_Dot_2 -- ^ @-1.2@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'EnumNumber where toJSON = A.toJSON . fromE'EnumNumber +instance A.FromJSON E'EnumNumber where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumNumber =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumNumber where toQueryParam = WH.toQueryParam . fromE'EnumNumber +instance WH.FromHttpApiData E'EnumNumber where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumNumber +instance MimeRender MimeMultipartFormData E'EnumNumber where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'EnumNumber' enum +fromE'EnumNumber :: E'EnumNumber -> Double +fromE'EnumNumber = \case + E'EnumNumber'Num1_Dot_1 -> 1.1 + E'EnumNumber'NumMinus_1_Dot_2 -> -1.2 + +-- | parse 'E'EnumNumber' enum +toE'EnumNumber :: Double -> P.Either String E'EnumNumber +toE'EnumNumber = \case + 1.1 -> P.Right E'EnumNumber'Num1_Dot_1 + -1.2 -> P.Right E'EnumNumber'NumMinus_1_Dot_2 + s -> P.Left $ "toE'EnumNumber: enum parse failure: " P.++ P.show s + + +-- ** E'EnumQueryInteger + +-- | Enum of 'Int' +data E'EnumQueryInteger + = E'EnumQueryInteger'Num1 -- ^ @1@ + | E'EnumQueryInteger'NumMinus_2 -- ^ @-2@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'EnumQueryInteger where toJSON = A.toJSON . fromE'EnumQueryInteger +instance A.FromJSON E'EnumQueryInteger where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumQueryInteger =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumQueryInteger where toQueryParam = WH.toQueryParam . fromE'EnumQueryInteger +instance WH.FromHttpApiData E'EnumQueryInteger where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumQueryInteger +instance MimeRender MimeMultipartFormData E'EnumQueryInteger where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'EnumQueryInteger' enum +fromE'EnumQueryInteger :: E'EnumQueryInteger -> Int +fromE'EnumQueryInteger = \case + E'EnumQueryInteger'Num1 -> 1 + E'EnumQueryInteger'NumMinus_2 -> -2 + +-- | parse 'E'EnumQueryInteger' enum +toE'EnumQueryInteger :: Int -> P.Either String E'EnumQueryInteger +toE'EnumQueryInteger = \case + 1 -> P.Right E'EnumQueryInteger'Num1 + -2 -> P.Right E'EnumQueryInteger'NumMinus_2 + s -> P.Left $ "toE'EnumQueryInteger: enum parse failure: " P.++ P.show s + + +-- ** E'EnumString + +-- | Enum of 'Text' +data E'EnumString + = E'EnumString'UPPER -- ^ @"UPPER"@ + | E'EnumString'Lower -- ^ @"lower"@ + | E'EnumString'Empty -- ^ @""@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'EnumString where toJSON = A.toJSON . fromE'EnumString +instance A.FromJSON E'EnumString where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumString =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumString where toQueryParam = WH.toQueryParam . fromE'EnumString +instance WH.FromHttpApiData E'EnumString where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumString +instance MimeRender MimeMultipartFormData E'EnumString where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'EnumString' enum +fromE'EnumString :: E'EnumString -> Text +fromE'EnumString = \case + E'EnumString'UPPER -> "UPPER" + E'EnumString'Lower -> "lower" + E'EnumString'Empty -> "" + +-- | parse 'E'EnumString' enum +toE'EnumString :: Text -> P.Either String E'EnumString +toE'EnumString = \case + "UPPER" -> P.Right E'EnumString'UPPER + "lower" -> P.Right E'EnumString'Lower + "" -> P.Right E'EnumString'Empty + s -> P.Left $ "toE'EnumString: enum parse failure: " P.++ P.show s + + +-- ** E'Inner + +-- | Enum of 'Text' +data E'Inner + = E'Inner'UPPER -- ^ @"UPPER"@ + | E'Inner'Lower -- ^ @"lower"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'Inner where toJSON = A.toJSON . fromE'Inner +instance A.FromJSON E'Inner where parseJSON o = P.either P.fail (pure . P.id) . toE'Inner =<< A.parseJSON o +instance WH.ToHttpApiData E'Inner where toQueryParam = WH.toQueryParam . fromE'Inner +instance WH.FromHttpApiData E'Inner where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Inner +instance MimeRender MimeMultipartFormData E'Inner where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'Inner' enum +fromE'Inner :: E'Inner -> Text +fromE'Inner = \case + E'Inner'UPPER -> "UPPER" + E'Inner'Lower -> "lower" + +-- | parse 'E'Inner' enum +toE'Inner :: Text -> P.Either String E'Inner +toE'Inner = \case + "UPPER" -> P.Right E'Inner'UPPER + "lower" -> P.Right E'Inner'Lower + s -> P.Left $ "toE'Inner: enum parse failure: " P.++ P.show s + + +-- ** E'Inner2 + +-- | Enum of 'Text' +data E'Inner2 + = E'Inner2'GreaterThan -- ^ @">"@ + | E'Inner2'Dollar -- ^ @"$"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'Inner2 where toJSON = A.toJSON . fromE'Inner2 +instance A.FromJSON E'Inner2 where parseJSON o = P.either P.fail (pure . P.id) . toE'Inner2 =<< A.parseJSON o +instance WH.ToHttpApiData E'Inner2 where toQueryParam = WH.toQueryParam . fromE'Inner2 +instance WH.FromHttpApiData E'Inner2 where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Inner2 +instance MimeRender MimeMultipartFormData E'Inner2 where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'Inner2' enum +fromE'Inner2 :: E'Inner2 -> Text +fromE'Inner2 = \case + E'Inner2'GreaterThan -> ">" + E'Inner2'Dollar -> "$" + +-- | parse 'E'Inner2' enum +toE'Inner2 :: Text -> P.Either String E'Inner2 +toE'Inner2 = \case + ">" -> P.Right E'Inner2'GreaterThan + "$" -> P.Right E'Inner2'Dollar + s -> P.Left $ "toE'Inner2: enum parse failure: " P.++ P.show s + + +-- ** E'JustSymbol + +-- | Enum of 'Text' +data E'JustSymbol + = E'JustSymbol'Greater_Than_Or_Equal_To -- ^ @">="@ + | E'JustSymbol'Dollar -- ^ @"$"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'JustSymbol where toJSON = A.toJSON . fromE'JustSymbol +instance A.FromJSON E'JustSymbol where parseJSON o = P.either P.fail (pure . P.id) . toE'JustSymbol =<< A.parseJSON o +instance WH.ToHttpApiData E'JustSymbol where toQueryParam = WH.toQueryParam . fromE'JustSymbol +instance WH.FromHttpApiData E'JustSymbol where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'JustSymbol +instance MimeRender MimeMultipartFormData E'JustSymbol where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'JustSymbol' enum +fromE'JustSymbol :: E'JustSymbol -> Text +fromE'JustSymbol = \case + E'JustSymbol'Greater_Than_Or_Equal_To -> ">=" + E'JustSymbol'Dollar -> "$" + +-- | parse 'E'JustSymbol' enum +toE'JustSymbol :: Text -> P.Either String E'JustSymbol +toE'JustSymbol = \case + ">=" -> P.Right E'JustSymbol'Greater_Than_Or_Equal_To + "$" -> P.Right E'JustSymbol'Dollar + s -> P.Left $ "toE'JustSymbol: enum parse failure: " P.++ P.show s + + +-- ** E'Status + +-- | Enum of 'Text' . +-- Order Status +data E'Status + = E'Status'Placed -- ^ @"placed"@ + | E'Status'Approved -- ^ @"approved"@ + | E'Status'Delivered -- ^ @"delivered"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'Status where toJSON = A.toJSON . fromE'Status +instance A.FromJSON E'Status where parseJSON o = P.either P.fail (pure . P.id) . toE'Status =<< A.parseJSON o +instance WH.ToHttpApiData E'Status where toQueryParam = WH.toQueryParam . fromE'Status +instance WH.FromHttpApiData E'Status where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Status +instance MimeRender MimeMultipartFormData E'Status where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'Status' enum +fromE'Status :: E'Status -> Text +fromE'Status = \case + E'Status'Placed -> "placed" + E'Status'Approved -> "approved" + E'Status'Delivered -> "delivered" + +-- | parse 'E'Status' enum +toE'Status :: Text -> P.Either String E'Status +toE'Status = \case + "placed" -> P.Right E'Status'Placed + "approved" -> P.Right E'Status'Approved + "delivered" -> P.Right E'Status'Delivered + s -> P.Left $ "toE'Status: enum parse failure: " P.++ P.show s + + +-- ** E'Status2 + +-- | Enum of 'Text' . +-- pet status in the store +data E'Status2 + = E'Status2'Available -- ^ @"available"@ + | E'Status2'Pending -- ^ @"pending"@ + | E'Status2'Sold -- ^ @"sold"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON E'Status2 where toJSON = A.toJSON . fromE'Status2 +instance A.FromJSON E'Status2 where parseJSON o = P.either P.fail (pure . P.id) . toE'Status2 =<< A.parseJSON o +instance WH.ToHttpApiData E'Status2 where toQueryParam = WH.toQueryParam . fromE'Status2 +instance WH.FromHttpApiData E'Status2 where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Status2 +instance MimeRender MimeMultipartFormData E'Status2 where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'E'Status2' enum +fromE'Status2 :: E'Status2 -> Text +fromE'Status2 = \case + E'Status2'Available -> "available" + E'Status2'Pending -> "pending" + E'Status2'Sold -> "sold" + +-- | parse 'E'Status2' enum +toE'Status2 :: Text -> P.Either String E'Status2 +toE'Status2 = \case + "available" -> P.Right E'Status2'Available + "pending" -> P.Right E'Status2'Pending + "sold" -> P.Right E'Status2'Sold + s -> P.Left $ "toE'Status2: enum parse failure: " P.++ P.show s + + +-- ** EnumClass + +-- | Enum of 'Text' +data EnumClass + = EnumClass'_abc -- ^ @"_abc"@ + | EnumClass'_efg -- ^ @"-efg"@ + | EnumClass'_xyz -- ^ @"(xyz)"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON EnumClass where toJSON = A.toJSON . fromEnumClass +instance A.FromJSON EnumClass where parseJSON o = P.either P.fail (pure . P.id) . toEnumClass =<< A.parseJSON o +instance WH.ToHttpApiData EnumClass where toQueryParam = WH.toQueryParam . fromEnumClass +instance WH.FromHttpApiData EnumClass where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toEnumClass +instance MimeRender MimeMultipartFormData EnumClass where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'EnumClass' enum +fromEnumClass :: EnumClass -> Text +fromEnumClass = \case + EnumClass'_abc -> "_abc" + EnumClass'_efg -> "-efg" + EnumClass'_xyz -> "(xyz)" + +-- | parse 'EnumClass' enum +toEnumClass :: Text -> P.Either String EnumClass +toEnumClass = \case + "_abc" -> P.Right EnumClass'_abc + "-efg" -> P.Right EnumClass'_efg + "(xyz)" -> P.Right EnumClass'_xyz + s -> P.Left $ "toEnumClass: enum parse failure: " P.++ P.show s + + +-- ** OuterEnum + +-- | Enum of 'Text' +data OuterEnum + = OuterEnum'Placed -- ^ @"placed"@ + | OuterEnum'Approved -- ^ @"approved"@ + | OuterEnum'Delivered -- ^ @"delivered"@ + deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) + +instance A.ToJSON OuterEnum where toJSON = A.toJSON . fromOuterEnum +instance A.FromJSON OuterEnum where parseJSON o = P.either P.fail (pure . P.id) . toOuterEnum =<< A.parseJSON o +instance WH.ToHttpApiData OuterEnum where toQueryParam = WH.toQueryParam . fromOuterEnum +instance WH.FromHttpApiData OuterEnum where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toOuterEnum +instance MimeRender MimeMultipartFormData OuterEnum where mimeRender _ = mimeRenderDefaultMultipartFormData + +-- | unwrap 'OuterEnum' enum +fromOuterEnum :: OuterEnum -> Text +fromOuterEnum = \case + OuterEnum'Placed -> "placed" + OuterEnum'Approved -> "approved" + OuterEnum'Delivered -> "delivered" + +-- | parse 'OuterEnum' enum +toOuterEnum :: Text -> P.Either String OuterEnum +toOuterEnum = \case + "placed" -> P.Right OuterEnum'Placed + "approved" -> P.Right OuterEnum'Approved + "delivered" -> P.Right OuterEnum'Delivered + s -> P.Left $ "toOuterEnum: enum parse failure: " P.++ P.show s diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/ModelLens.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/ModelLens.hs index d9573a4c2c0..3193d0ac69c 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/ModelLens.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/ModelLens.hs @@ -194,12 +194,12 @@ clientClientL f Client{..} = (\clientClient -> Client { clientClient, ..} ) <$> -- * EnumArrays -- | 'enumArraysJustSymbol' Lens -enumArraysJustSymbolL :: Lens_' EnumArrays (Maybe Text) +enumArraysJustSymbolL :: Lens_' EnumArrays (Maybe E'JustSymbol) enumArraysJustSymbolL f EnumArrays{..} = (\enumArraysJustSymbol -> EnumArrays { enumArraysJustSymbol, ..} ) <$> f enumArraysJustSymbol {-# INLINE enumArraysJustSymbolL #-} -- | 'enumArraysArrayEnum' Lens -enumArraysArrayEnumL :: Lens_' EnumArrays (Maybe [Text]) +enumArraysArrayEnumL :: Lens_' EnumArrays (Maybe [E'ArrayEnum]) enumArraysArrayEnumL f EnumArrays{..} = (\enumArraysArrayEnum -> EnumArrays { enumArraysArrayEnum, ..} ) <$> f enumArraysArrayEnum {-# INLINE enumArraysArrayEnumL #-} @@ -212,17 +212,17 @@ enumArraysArrayEnumL f EnumArrays{..} = (\enumArraysArrayEnum -> EnumArrays { en -- * EnumTest -- | 'enumTestEnumString' Lens -enumTestEnumStringL :: Lens_' EnumTest (Maybe Text) +enumTestEnumStringL :: Lens_' EnumTest (Maybe E'EnumString) enumTestEnumStringL f EnumTest{..} = (\enumTestEnumString -> EnumTest { enumTestEnumString, ..} ) <$> f enumTestEnumString {-# INLINE enumTestEnumStringL #-} -- | 'enumTestEnumInteger' Lens -enumTestEnumIntegerL :: Lens_' EnumTest (Maybe Int) +enumTestEnumIntegerL :: Lens_' EnumTest (Maybe E'EnumInteger) enumTestEnumIntegerL f EnumTest{..} = (\enumTestEnumInteger -> EnumTest { enumTestEnumInteger, ..} ) <$> f enumTestEnumInteger {-# INLINE enumTestEnumIntegerL #-} -- | 'enumTestEnumNumber' Lens -enumTestEnumNumberL :: Lens_' EnumTest (Maybe Double) +enumTestEnumNumberL :: Lens_' EnumTest (Maybe E'EnumNumber) enumTestEnumNumberL f EnumTest{..} = (\enumTestEnumNumber -> EnumTest { enumTestEnumNumber, ..} ) <$> f enumTestEnumNumber {-# INLINE enumTestEnumNumberL #-} @@ -324,7 +324,7 @@ mapTestMapMapOfStringL f MapTest{..} = (\mapTestMapMapOfString -> MapTest { mapT {-# INLINE mapTestMapMapOfStringL #-} -- | 'mapTestMapOfEnumString' Lens -mapTestMapOfEnumStringL :: Lens_' MapTest (Maybe (Map.Map String Text)) +mapTestMapOfEnumStringL :: Lens_' MapTest (Maybe (Map.Map String E'Inner)) mapTestMapOfEnumStringL f MapTest{..} = (\mapTestMapOfEnumString -> MapTest { mapTestMapOfEnumString, ..} ) <$> f mapTestMapOfEnumString {-# INLINE mapTestMapOfEnumStringL #-} @@ -437,7 +437,7 @@ orderShipDateL f Order{..} = (\orderShipDate -> Order { orderShipDate, ..} ) <$> {-# INLINE orderShipDateL #-} -- | 'orderStatus' Lens -orderStatusL :: Lens_' Order (Maybe Text) +orderStatusL :: Lens_' Order (Maybe E'Status) orderStatusL f Order{..} = (\orderStatus -> Order { orderStatus, ..} ) <$> f orderStatus {-# INLINE orderStatusL #-} @@ -511,7 +511,7 @@ petTagsL f Pet{..} = (\petTags -> Pet { petTags, ..} ) <$> f petTags {-# INLINE petTagsL #-} -- | 'petStatus' Lens -petStatusL :: Lens_' Pet (Maybe Text) +petStatusL :: Lens_' Pet (Maybe E'Status2) petStatusL f Pet{..} = (\petStatus -> Pet { petStatus, ..} ) <$> f petStatus {-# INLINE petStatusL #-} diff --git a/samples/client/petstore/haskell-http-client/stack.yaml b/samples/client/petstore/haskell-http-client/stack.yaml index 174a76815bc..aa4a059faa5 100644 --- a/samples/client/petstore/haskell-http-client/stack.yaml +++ b/samples/client/petstore/haskell-http-client/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-9.0 +resolver: lts-9.10 build: haddock-arguments: haddock-args: diff --git a/samples/client/petstore/haskell-http-client/swagger-petstore.cabal b/samples/client/petstore/haskell-http-client/swagger-petstore.cabal index 36a8e7212c1..e5a712598f8 100644 --- a/samples/client/petstore/haskell-http-client/swagger-petstore.cabal +++ b/samples/client/petstore/haskell-http-client/swagger-petstore.cabal @@ -40,7 +40,7 @@ library , bytestring >=0.10.0 && <0.11 , base64-bytestring >1.0 && <2.0 , containers >=0.5.0.0 && <0.6 - , http-types >=0.8 && <0.10 + , http-types >=0.8 && <0.11 , http-client >=0.5 && <0.6 , http-client-tls , http-api-data >= 0.3.4 && <0.4 diff --git a/samples/client/petstore/haskell-http-client/swagger.yaml b/samples/client/petstore/haskell-http-client/swagger.yaml index 9a4097a9292..2721bfb19c9 100644 --- a/samples/client/petstore/haskell-http-client/swagger.yaml +++ b/samples/client/petstore/haskell-http-client/swagger.yaml @@ -918,6 +918,27 @@ paths: responses: 200: description: "successful operation" + /fake/inline-additionalProperties: + post: + tags: + - "fake" + summary: "test inline additionalProperties" + description: "" + operationId: "testInlineAdditionalProperties" + consumes: + - "application/json" + parameters: + - in: "body" + name: "param" + description: "request body" + required: true + schema: + type: "object" + additionalProperties: + type: "string" + responses: + 200: + description: "successful operation" /another-fake/dummy: patch: tags: @@ -966,15 +987,19 @@ definitions: id: type: "integer" format: "int64" + x-dataType: "Integer" petId: type: "integer" format: "int64" + x-dataType: "Integer" quantity: type: "integer" format: "int32" + x-dataType: "Int" shipDate: type: "string" format: "date-time" + x-dataType: "DateTime" status: type: "string" description: "Order Status" @@ -982,9 +1007,11 @@ definitions: - "placed" - "approved" - "delivered" + x-dataType: "E'Status" complete: type: "boolean" default: false + x-dataType: "Bool" example: petId: 6 quantity: 1 @@ -1003,8 +1030,10 @@ definitions: id: type: "integer" format: "int64" + x-dataType: "Integer" name: type: "string" + x-dataType: "Text" example: name: "name" id: 6 @@ -1017,22 +1046,30 @@ definitions: type: "integer" format: "int64" x-is-unique: true + x-dataType: "Integer" username: type: "string" + x-dataType: "Text" firstName: type: "string" + x-dataType: "Text" lastName: type: "string" + x-dataType: "Text" email: type: "string" + x-dataType: "Text" password: type: "string" + x-dataType: "Text" phone: type: "string" + x-dataType: "Text" userStatus: type: "integer" format: "int32" description: "User Status" + x-dataType: "Int" example: firstName: "firstName" lastName: "lastName" @@ -1053,8 +1090,10 @@ definitions: id: type: "integer" format: "int64" + x-dataType: "Integer" name: type: "string" + x-dataType: "Text" example: name: "name" id: 1 @@ -1070,11 +1109,14 @@ definitions: type: "integer" format: "int64" x-is-unique: true + x-dataType: "Integer" category: $ref: "#/definitions/Category" + x-dataType: "Category" name: type: "string" example: "doggie" + x-dataType: "Text" photoUrls: type: "array" xml: @@ -1082,6 +1124,7 @@ definitions: wrapped: true items: type: "string" + x-dataType: "[Text]" tags: type: "array" xml: @@ -1089,6 +1132,7 @@ definitions: wrapped: true items: $ref: "#/definitions/Tag" + x-dataType: "[Tag]" status: type: "string" description: "pet status in the store" @@ -1096,6 +1140,7 @@ definitions: - "available" - "pending" - "sold" + x-dataType: "E'Status2" example: photoUrls: - "photoUrls" @@ -1122,10 +1167,13 @@ definitions: code: type: "integer" format: "int32" + x-dataType: "Int" type: type: "string" + x-dataType: "Text" message: type: "string" + x-dataType: "Text" example: code: 0 type: "type" @@ -1135,6 +1183,7 @@ definitions: $special[property.name]: type: "integer" format: "int64" + x-dataType: "Integer" xml: name: "$special[model.name]" Return: @@ -1142,6 +1191,7 @@ definitions: return: type: "integer" format: "int32" + x-dataType: "Int" description: "Model for testing reserved words" xml: name: "Return" @@ -1152,15 +1202,19 @@ definitions: name: type: "integer" format: "int32" + x-dataType: "Int" snake_case: type: "integer" format: "int32" readOnly: true + x-dataType: "Int" property: type: "string" + x-dataType: "Text" 123Number: type: "integer" readOnly: true + x-dataType: "Int" description: "Model for testing model name same as property name" xml: name: "Name" @@ -1169,8 +1223,10 @@ definitions: name: type: "integer" format: "int32" + x-dataType: "Int" class: type: "string" + x-dataType: "Text" description: "Model for testing model name starting with number" xml: name: "Name" @@ -1178,6 +1234,7 @@ definitions: properties: _class: type: "string" + x-dataType: "Text" description: "Model for testing model with \"_class\" property" Dog: allOf: @@ -1186,6 +1243,7 @@ definitions: properties: breed: type: "string" + x-dataType: "Text" Cat: allOf: - $ref: "#/definitions/Animal" @@ -1193,6 +1251,7 @@ definitions: properties: declawed: type: "boolean" + x-dataType: "Bool" Animal: type: "object" required: @@ -1201,9 +1260,11 @@ definitions: properties: className: type: "string" + x-dataType: "Text" color: type: "string" default: "red" + x-dataType: "Text" AnimalFarm: type: "array" items: @@ -1220,52 +1281,65 @@ definitions: type: "integer" minimum: 10 maximum: 100 + x-dataType: "Int" int32: type: "integer" format: "int32" minimum: 20 maximum: 200 + x-dataType: "Int" int64: type: "integer" format: "int64" + x-dataType: "Integer" number: type: "number" minimum: 32.1 maximum: 543.2 + x-dataType: "Double" float: type: "number" format: "float" minimum: 54.3 maximum: 987.6 + x-dataType: "Float" double: type: "number" format: "double" minimum: 67.8 maximum: 123.4 + x-dataType: "Double" string: type: "string" pattern: "/[a-z]/i" + x-dataType: "Text" byte: type: "string" format: "byte" pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" + x-dataType: "ByteArray" binary: type: "string" format: "binary" + x-dataType: "Binary" date: type: "string" format: "date" + x-dataType: "Date" dateTime: type: "string" format: "date-time" + x-dataType: "DateTime" uuid: type: "string" format: "uuid" + x-dataType: "Text" password: type: "string" format: "password" minLength: 10 maxLength: 64 + x-dataType: "Text" EnumClass: type: "string" enum: @@ -1282,20 +1356,24 @@ definitions: - "UPPER" - "lower" - "" + x-dataType: "E'EnumString" enum_integer: type: "integer" format: "int32" enum: - 1 - -1 + x-dataType: "E'EnumInteger" enum_number: type: "number" format: "double" enum: - 1.1 - -1.2 + x-dataType: "E'EnumNumber" outerEnum: $ref: "#/definitions/OuterEnum" + x-dataType: "OuterEnum" AdditionalPropertiesClass: type: "object" properties: @@ -1303,35 +1381,42 @@ definitions: type: "object" additionalProperties: type: "string" + x-dataType: "(Map.Map String Text)" map_of_map_property: type: "object" additionalProperties: type: "object" additionalProperties: type: "string" + x-dataType: "(Map.Map String (Map.Map String Text))" MixedPropertiesAndAdditionalPropertiesClass: type: "object" properties: uuid: type: "string" format: "uuid" + x-dataType: "Text" dateTime: type: "string" format: "date-time" + x-dataType: "DateTime" map: type: "object" additionalProperties: $ref: "#/definitions/Animal" + x-dataType: "(Map.Map String Animal)" List: type: "object" properties: 123-list: type: "string" + x-dataType: "Text" Client: type: "object" properties: client: type: "string" + x-dataType: "Text" example: client: "client" x-mimeTypes: @@ -1342,33 +1427,43 @@ definitions: bar: type: "string" readOnly: true + x-dataType: "Text" baz: type: "string" + x-dataType: "Text" hasOnlyReadOnly: type: "object" properties: bar: type: "string" readOnly: true + x-dataType: "Text" foo: type: "string" readOnly: true + x-dataType: "Text" Capitalization: type: "object" properties: smallCamel: type: "string" + x-dataType: "Text" CapitalCamel: type: "string" + x-dataType: "Text" small_Snake: type: "string" + x-dataType: "Text" Capital_Snake: type: "string" + x-dataType: "Text" SCA_ETH_Flow_Points: type: "string" + x-dataType: "Text" ATT_NAME: type: "string" description: "Name of the pet\n" + x-dataType: "Text" MapTest: type: "object" properties: @@ -1378,6 +1473,7 @@ definitions: type: "object" additionalProperties: type: "string" + x-dataType: "(Map.Map String (Map.Map String Text))" map_of_enum_string: type: "object" additionalProperties: @@ -1385,6 +1481,7 @@ definitions: enum: - "UPPER" - "lower" + x-dataType: "(Map.Map String E'Inner)" ArrayTest: type: "object" properties: @@ -1392,6 +1489,7 @@ definitions: type: "array" items: type: "string" + x-dataType: "[Text]" array_array_of_integer: type: "array" items: @@ -1399,17 +1497,20 @@ definitions: items: type: "integer" format: "int64" + x-dataType: "[[Integer]]" array_array_of_model: type: "array" items: type: "array" items: $ref: "#/definitions/ReadOnlyFirst" + x-dataType: "[[ReadOnlyFirst]]" NumberOnly: type: "object" properties: JustNumber: type: "number" + x-dataType: "Double" ArrayOfNumberOnly: type: "object" properties: @@ -1417,6 +1518,7 @@ definitions: type: "array" items: type: "number" + x-dataType: "[Double]" ArrayOfArrayOfNumberOnly: type: "object" properties: @@ -1426,6 +1528,7 @@ definitions: type: "array" items: type: "number" + x-dataType: "[[Double]]" EnumArrays: type: "object" properties: @@ -1434,6 +1537,7 @@ definitions: enum: - ">=" - "$" + x-dataType: "E'JustSymbol" array_enum: type: "array" items: @@ -1441,6 +1545,7 @@ definitions: enum: - "fish" - "crab" + x-dataType: "[E'ArrayEnum]" OuterEnum: type: "string" enum: @@ -1452,20 +1557,26 @@ definitions: properties: my_number: $ref: "#/definitions/OuterNumber" + x-dataType: "OuterNumber" my_string: $ref: "#/definitions/OuterString" + x-dataType: "OuterString" my_boolean: $ref: "#/definitions/OuterBoolean" + x-dataType: "OuterBoolean" example: my_string: {} my_number: {} my_boolean: {} OuterNumber: type: "number" + x-dataType: "Double" OuterString: type: "string" + x-dataType: "Text" OuterBoolean: type: "boolean" + x-dataType: "Bool" externalDocs: description: "Find out more about Swagger" url: "http://swagger.io" diff --git a/samples/client/petstore/haskell-http-client/tests-integration/tests/Test.hs b/samples/client/petstore/haskell-http-client/tests-integration/tests/Test.hs index a6563639f82..c9d8c5f3406 100644 --- a/samples/client/petstore/haskell-http-client/tests-integration/tests/Test.hs +++ b/samples/client/petstore/haskell-http-client/tests-integration/tests/Test.hs @@ -106,7 +106,9 @@ testPetOps mgr config = Left (S.MimeError e _) -> assertFailure e it "findPetsByStatus" $ do - let findPetsByStatusRequest = S.findPetsByStatus (S.Status ["available","pending","sold"]) + let findPetsByStatusRequest = S.findPetsByStatus (S.Status [ S.E'Status2'Available + , S.E'Status2'Pending + , S.E'Status2'Sold]) findPetsByStatusResult <- S.dispatchMime mgr config findPetsByStatusRequest S.MimeJSON NH.responseStatus (S.mimeResultResponse findPetsByStatusResult) `shouldBe` NH.status200 case S.mimeResult findPetsByStatusResult of @@ -127,7 +129,7 @@ testPetOps mgr config = _ -> pendingWith "no pet") $ it "updatePet" $ \pet -> do let updatePetRequest = S.updatePet S.MimeJSON $ pet - { S.petStatus = Just "available" + { S.petStatus = Just S.E'Status2'Available , S.petCategory = Just (S.Category (Just 3) (Just "catname")) } updatePetResponse <- S.dispatchLbs mgr config updatePetRequest S.MimeXML diff --git a/samples/client/petstore/haskell-http-client/tests/Instances.hs b/samples/client/petstore/haskell-http-client/tests/Instances.hs index 43cc2d9e622..18349ade341 100644 --- a/samples/client/petstore/haskell-http-client/tests/Instances.hs +++ b/samples/client/petstore/haskell-http-client/tests/Instances.hs @@ -95,20 +95,17 @@ instance Arbitrary AdditionalPropertiesClass where <$> arbitrary -- additionalPropertiesClassMapProperty :: Maybe (Map.Map String Text) <*> arbitrary -- additionalPropertiesClassMapOfMapProperty :: Maybe (Map.Map String (Map.Map String Text)) - instance Arbitrary Animal where arbitrary = Animal <$> arbitrary -- animalClassName :: Text <*> arbitrary -- animalColor :: Maybe Text - instance Arbitrary AnimalFarm where arbitrary = pure AnimalFarm - instance Arbitrary ApiResponse where arbitrary = ApiResponse @@ -116,19 +113,16 @@ instance Arbitrary ApiResponse where <*> arbitrary -- apiResponseType :: Maybe Text <*> arbitrary -- apiResponseMessage :: Maybe Text - instance Arbitrary ArrayOfArrayOfNumberOnly where arbitrary = ArrayOfArrayOfNumberOnly <$> arbitrary -- arrayOfArrayOfNumberOnlyArrayArrayNumber :: Maybe [[Double]] - instance Arbitrary ArrayOfNumberOnly where arbitrary = ArrayOfNumberOnly <$> arbitrary -- arrayOfNumberOnlyArrayNumber :: Maybe [Double] - instance Arbitrary ArrayTest where arbitrary = ArrayTest @@ -136,7 +130,6 @@ instance Arbitrary ArrayTest where <*> arbitrary -- arrayTestArrayArrayOfInteger :: Maybe [[Integer]] <*> arbitrary -- arrayTestArrayArrayOfModel :: Maybe [[ReadOnlyFirst]] - instance Arbitrary Capitalization where arbitrary = Capitalization @@ -147,39 +140,28 @@ instance Arbitrary Capitalization where <*> arbitrary -- capitalizationScaEthFlowPoints :: Maybe Text <*> arbitrary -- capitalizationAttName :: Maybe Text - instance Arbitrary Category where arbitrary = Category <$> arbitrary -- categoryId :: Maybe Integer <*> arbitrary -- categoryName :: Maybe Text - instance Arbitrary ClassModel where arbitrary = ClassModel <$> arbitrary -- classModelClass :: Maybe Text - instance Arbitrary Client where arbitrary = Client <$> arbitrary -- clientClient :: Maybe Text - instance Arbitrary EnumArrays where arbitrary = EnumArrays <$> arbitrary -- enumArraysJustSymbol :: Maybe Text <*> arbitrary -- enumArraysArrayEnum :: Maybe [Text] - -instance Arbitrary EnumClass where - arbitrary = - - pure EnumClass - - instance Arbitrary EnumTest where arbitrary = EnumTest @@ -188,7 +170,6 @@ instance Arbitrary EnumTest where <*> arbitrary -- enumTestEnumNumber :: Maybe Double <*> arbitrary -- enumTestOuterEnum :: Maybe OuterEnum - instance Arbitrary FormatTest where arbitrary = FormatTest @@ -206,21 +187,18 @@ instance Arbitrary FormatTest where <*> arbitrary -- formatTestUuid :: Maybe Text <*> arbitrary -- formatTestPassword :: Text - instance Arbitrary HasOnlyReadOnly where arbitrary = HasOnlyReadOnly <$> arbitrary -- hasOnlyReadOnlyBar :: Maybe Text <*> arbitrary -- hasOnlyReadOnlyFoo :: Maybe Text - instance Arbitrary MapTest where arbitrary = MapTest <$> arbitrary -- mapTestMapMapOfString :: Maybe (Map.Map String (Map.Map String Text)) <*> arbitrary -- mapTestMapOfEnumString :: Maybe (Map.Map String Text) - instance Arbitrary MixedPropertiesAndAdditionalPropertiesClass where arbitrary = MixedPropertiesAndAdditionalPropertiesClass @@ -228,26 +206,22 @@ instance Arbitrary MixedPropertiesAndAdditionalPropertiesClass where <*> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassDateTime :: Maybe DateTime <*> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassMap :: Maybe (Map.Map String Animal) - instance Arbitrary Model200Response where arbitrary = Model200Response <$> arbitrary -- model200ResponseName :: Maybe Int <*> arbitrary -- model200ResponseClass :: Maybe Text - instance Arbitrary ModelList where arbitrary = ModelList <$> arbitrary -- modelList123List :: Maybe Text - instance Arbitrary ModelReturn where arbitrary = ModelReturn <$> arbitrary -- modelReturnReturn :: Maybe Int - instance Arbitrary Name where arbitrary = Name @@ -256,13 +230,11 @@ instance Arbitrary Name where <*> arbitrary -- nameProperty :: Maybe Text <*> arbitrary -- name123Number :: Maybe Int - instance Arbitrary NumberOnly where arbitrary = NumberOnly <$> arbitrary -- numberOnlyJustNumber :: Maybe Double - instance Arbitrary Order where arbitrary = Order @@ -273,11 +245,9 @@ instance Arbitrary Order where <*> arbitrary -- orderStatus :: Maybe Text <*> arbitrary -- orderComplete :: Maybe Bool - instance Arbitrary OuterBoolean where arbitrary = OuterBoolean <$> arbitrary - instance Arbitrary OuterComposite where arbitrary = OuterComposite @@ -285,21 +255,12 @@ instance Arbitrary OuterComposite where <*> arbitrary -- outerCompositeMyString :: Maybe OuterString <*> arbitrary -- outerCompositeMyBoolean :: Maybe OuterBoolean - -instance Arbitrary OuterEnum where - arbitrary = - - pure OuterEnum - - instance Arbitrary OuterNumber where arbitrary = OuterNumber <$> arbitrary - instance Arbitrary OuterString where arbitrary = OuterString <$> arbitrary - instance Arbitrary Pet where arbitrary = Pet @@ -310,27 +271,23 @@ instance Arbitrary Pet where <*> arbitrary -- petTags :: Maybe [Tag] <*> arbitrary -- petStatus :: Maybe Text - instance Arbitrary ReadOnlyFirst where arbitrary = ReadOnlyFirst <$> arbitrary -- readOnlyFirstBar :: Maybe Text <*> arbitrary -- readOnlyFirstBaz :: Maybe Text - instance Arbitrary SpecialModelName where arbitrary = SpecialModelName <$> arbitrary -- specialModelNameSpecialPropertyName :: Maybe Integer - instance Arbitrary Tag where arbitrary = Tag <$> arbitrary -- tagId :: Maybe Integer <*> arbitrary -- tagName :: Maybe Text - instance Arbitrary User where arbitrary = User @@ -343,7 +300,6 @@ instance Arbitrary User where <*> arbitrary -- userPhone :: Maybe Text <*> arbitrary -- userUserStatus :: Maybe Int - instance Arbitrary Cat where arbitrary = Cat @@ -351,7 +307,6 @@ instance Arbitrary Cat where <*> arbitrary -- catColor :: Maybe Text <*> arbitrary -- catDeclawed :: Maybe Bool - instance Arbitrary Dog where arbitrary = Dog @@ -361,3 +316,42 @@ instance Arbitrary Dog where + +instance Arbitrary E'ArrayEnum where + arbitrary = arbitraryBoundedEnum + +instance Arbitrary E'EnumFormString where + arbitrary = arbitraryBoundedEnum + +instance Arbitrary E'EnumInteger where + arbitrary = arbitraryBoundedEnum + +instance Arbitrary E'EnumNumber where + arbitrary = arbitraryBoundedEnum + +instance Arbitrary E'EnumQueryInteger where + arbitrary = arbitraryBoundedEnum + +instance Arbitrary E'EnumString where + arbitrary = arbitraryBoundedEnum + +instance Arbitrary E'Inner where + arbitrary = arbitraryBoundedEnum + +instance Arbitrary E'Inner2 where + arbitrary = arbitraryBoundedEnum + +instance Arbitrary E'JustSymbol where + arbitrary = arbitraryBoundedEnum + +instance Arbitrary E'Status where + arbitrary = arbitraryBoundedEnum + +instance Arbitrary E'Status2 where + arbitrary = arbitraryBoundedEnum + +instance Arbitrary EnumClass where + arbitrary = arbitraryBoundedEnum + +instance Arbitrary OuterEnum where + arbitrary = arbitraryBoundedEnum diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java index 657744b9266..ff7faf53bc3 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java @@ -8,9 +8,9 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -20,10 +20,9 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "Pet", description = "the Pet API") public interface PetApi { @@ -71,7 +70,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - com.netflix.hystrix.HystrixCommand>> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status); + com.netflix.hystrix.HystrixCommand>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status); @ApiOperation(value = "Finds Pets by tags", nickname = "findPetsByTags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -87,7 +86,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - com.netflix.hystrix.HystrixCommand>> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags); + com.netflix.hystrix.HystrixCommand>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags); @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java index 8c15c2c3d7b..bd412c2af3d 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -19,10 +19,9 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "Store", description = "the Store API") public interface StoreApi { @@ -59,7 +58,7 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - com.netflix.hystrix.HystrixCommand> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId); + com.netflix.hystrix.HystrixCommand> getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId); @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java index 2fb94582c14..1d1169ec13d 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -19,10 +19,9 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "User", description = "the User API") public interface UserApi { @@ -88,7 +87,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - com.netflix.hystrix.HystrixCommand> loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password); + com.netflix.hystrix.HystrixCommand> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password); @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) diff --git a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java index 05183069351..a4a3768817c 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java @@ -8,9 +8,9 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -19,12 +19,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "pet", description = "the pet API") public interface PetApi { @@ -41,7 +39,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.POST) - ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = { @@ -56,7 +54,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -72,7 +70,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status); @ApiOperation(value = "Finds Pets by tags", nickname = "findPetsByTags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -88,7 +86,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags); @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -102,7 +100,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -119,7 +117,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.PUT) - ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = { @@ -134,7 +132,7 @@ public interface PetApi { produces = "application/json", consumes = "application/x-www-form-urlencoded", method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status); @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -149,6 +147,6 @@ public interface PetApi { produces = "application/json", consumes = "multipart/form-data", method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file); } diff --git a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/StoreApi.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/StoreApi.java index 86121d67f36..7ccfa191a07 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/StoreApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,12 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "store", description = "the store API") public interface StoreApi { @@ -36,7 +34,7 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("orderId") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("orderId") String orderId); @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -48,7 +46,7 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> getInventory(); @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) @@ -60,7 +58,7 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId); @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) @@ -71,6 +69,6 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.POST) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); } diff --git a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/UserApi.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/UserApi.java index 9a01e79fa0e..9482597b5da 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/UserApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/UserApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,12 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "user", description = "the user API") public interface UserApi { @@ -35,7 +33,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.POST) - ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @@ -45,7 +43,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.POST) - ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @@ -55,7 +53,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.POST) - ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @@ -66,7 +64,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -78,7 +76,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username); @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -89,7 +87,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password); @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @@ -99,7 +97,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity logoutUser(); @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @@ -110,6 +108,6 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Category.java b/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Category.java index fb9207f4b5d..9f0206575f5 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Category.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Category.java @@ -92,21 +92,5 @@ public class Category { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/apimodels/ModelApiResponse.java b/samples/server/petstore/java-play-framework-controller-only/app/apimodels/ModelApiResponse.java index 05911012313..07493e84825 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/apimodels/ModelApiResponse.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/apimodels/ModelApiResponse.java @@ -114,21 +114,5 @@ public class ModelApiResponse { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Order.java b/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Order.java index 987ef07d460..cdc21f722c9 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Order.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Order.java @@ -215,21 +215,5 @@ public class Order { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Pet.java b/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Pet.java index 430bbe805ce..5e5ff376294 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Pet.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Pet.java @@ -234,21 +234,5 @@ public class Pet { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Tag.java b/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Tag.java index 709fef2cf11..15a8774252a 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Tag.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/apimodels/Tag.java @@ -92,21 +92,5 @@ public class Tag { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/apimodels/User.java b/samples/server/petstore/java-play-framework-controller-only/app/apimodels/User.java index ba41fb76f80..689de768893 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/apimodels/User.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/apimodels/User.java @@ -224,21 +224,5 @@ public class User { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java index 74f975466b1..4ccf6a2aea9 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java @@ -18,6 +18,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -25,10 +26,12 @@ import swagger.SwaggerUtils.ApiAction; public class PetApiController extends Controller { private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private PetApiController() { + private PetApiController(Configuration configuration) { mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -38,7 +41,9 @@ public class PetApiController extends Controller { Pet body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Pet.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -98,7 +103,9 @@ public class PetApiController extends Controller { Pet body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Pet.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java index a0cc3e27d57..3482251783b 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java @@ -17,6 +17,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -24,10 +25,12 @@ import swagger.SwaggerUtils.ApiAction; public class StoreApiController extends Controller { private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private StoreApiController() { + private StoreApiController(Configuration configuration) { mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -52,7 +55,9 @@ public class StoreApiController extends Controller { Order body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Order.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java index ec0b0d53ef0..862e317a341 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java @@ -17,6 +17,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -24,10 +25,12 @@ import swagger.SwaggerUtils.ApiAction; public class UserApiController extends Controller { private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private UserApiController() { + private UserApiController(Configuration configuration) { mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -37,7 +40,9 @@ public class UserApiController extends Controller { User body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), User.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -50,8 +55,10 @@ public class UserApiController extends Controller { List body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), new TypeReference>(){}); - for (User curItem : body) { - curItem.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + for (User curItem : body) { + SwaggerUtils.validate(curItem); + } } } else { throw new IllegalArgumentException("'body' parameter is required"); @@ -65,8 +72,10 @@ public class UserApiController extends Controller { List body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), new TypeReference>(){}); - for (User curItem : body) { - curItem.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + for (User curItem : body) { + SwaggerUtils.validate(curItem); + } } } else { throw new IllegalArgumentException("'body' parameter is required"); @@ -114,7 +123,9 @@ public class UserApiController extends Controller { User body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), User.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-controller-only/app/swagger/SwaggerUtils.java index c7d8bd3de9e..d4900e02167 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/swagger/SwaggerUtils.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/swagger/SwaggerUtils.java @@ -9,6 +9,11 @@ import java.lang.annotation.Target; import java.text.SimpleDateFormat; import java.util.*; +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + public class SwaggerUtils { @With(ApiCall.class) @@ -17,6 +22,22 @@ public class SwaggerUtils { public @interface ApiAction { } + public static void validate(T obj) { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + Validator validator = factory.getValidator(); + Set> constraintViolations = validator.validate(obj); + if (constraintViolations.size() > 0) { + StringBuilder errors = new StringBuilder(); + for (ConstraintViolation contraintes : constraintViolations) { + errors.append(String.format("%s.%s %s\n", + contraintes.getRootBeanClass().getSimpleName(), + contraintes.getPropertyPath(), + contraintes.getMessage())); + } + throw new RuntimeException("Bean validation : " + errors); + } + } + public static List parametersToList(String collectionFormat, String[] values){ List params = new ArrayList<>(); diff --git a/samples/server/petstore/java-play-framework-controller-only/conf/application.conf b/samples/server/petstore/java-play-framework-controller-only/conf/application.conf index 514ce684a77..c147af52f25 100644 --- a/samples/server/petstore/java-play-framework-controller-only/conf/application.conf +++ b/samples/server/petstore/java-play-framework-controller-only/conf/application.conf @@ -17,6 +17,15 @@ play.filters.headers.contentSecurityPolicy=null +# When using bean validation with the swagger api, the validator will check that every constraint is respected +# This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have +# shown that the time it takes to validate is exponential. +# If this is a concern in your application, or if you don't want to validate the output coming from your API for +# respecting its contract, set the "output" property below to "false". Since there is not a lot of data as input for +# an endpoint, I highly suggest you let the "input" property set to true. +useInputBeanValidation=true +useOutputBeanValidation=true + play.http.errorHandler="swagger.ErrorHandler" ## Akka diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/AdditionalPropertiesClass.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/AdditionalPropertiesClass.java index 7ad3b29d780..0d1d7a1fd98 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/AdditionalPropertiesClass.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/AdditionalPropertiesClass.java @@ -112,21 +112,5 @@ public class AdditionalPropertiesClass { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Animal.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Animal.java index 0b52bbf6382..2202fe1078e 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Animal.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Animal.java @@ -95,21 +95,5 @@ public class Animal { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/AnimalFarm.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/AnimalFarm.java index 44f4227ba5d..13a90b97be2 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/AnimalFarm.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/AnimalFarm.java @@ -51,21 +51,5 @@ public class AnimalFarm extends ArrayList { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ArrayOfArrayOfNumberOnly.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ArrayOfArrayOfNumberOnly.java index 19f3a4841b4..ebeb622cd16 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ArrayOfArrayOfNumberOnly.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ArrayOfArrayOfNumberOnly.java @@ -82,21 +82,5 @@ public class ArrayOfArrayOfNumberOnly { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ArrayOfNumberOnly.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ArrayOfNumberOnly.java index 4d232db89ef..193c2f77177 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ArrayOfNumberOnly.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ArrayOfNumberOnly.java @@ -82,21 +82,5 @@ public class ArrayOfNumberOnly { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ArrayTest.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ArrayTest.java index 3fc13073c1a..80cefa109d6 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ArrayTest.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ArrayTest.java @@ -143,21 +143,5 @@ public class ArrayTest { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Capitalization.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Capitalization.java index 1469630f874..f78ceeb9d0b 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Capitalization.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Capitalization.java @@ -180,21 +180,5 @@ public class Capitalization { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Cat.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Cat.java index ad587a0540e..a87f399d687 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Cat.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Cat.java @@ -72,21 +72,5 @@ public class Cat extends Animal { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Category.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Category.java index 572cd6ef3d2..c2a4222a8aa 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Category.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Category.java @@ -92,21 +92,5 @@ public class Category { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ClassModel.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ClassModel.java index 37313d2860b..ee8cd40ca40 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ClassModel.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ClassModel.java @@ -70,21 +70,5 @@ public class ClassModel { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Client.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Client.java index 8e4618db6b6..f14be52cf46 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Client.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Client.java @@ -70,21 +70,5 @@ public class Client { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Dog.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Dog.java index bd7ad700daa..27e3f5fdb25 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Dog.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Dog.java @@ -72,21 +72,5 @@ public class Dog extends Animal { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/EnumArrays.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/EnumArrays.java index a8f126b5124..a82c9ee422d 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/EnumArrays.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/EnumArrays.java @@ -164,21 +164,5 @@ public class EnumArrays { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/EnumTest.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/EnumTest.java index 165a4b02a0e..8b202da4f10 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/EnumTest.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/EnumTest.java @@ -233,21 +233,5 @@ public class EnumTest { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/FormatTest.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/FormatTest.java index b3293abc73b..5e70176abc7 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/FormatTest.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/FormatTest.java @@ -369,21 +369,5 @@ public class FormatTest { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/HasOnlyReadOnly.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/HasOnlyReadOnly.java index bc1644d165c..17d09b40692 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/HasOnlyReadOnly.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/HasOnlyReadOnly.java @@ -92,21 +92,5 @@ public class HasOnlyReadOnly { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/MapTest.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/MapTest.java index 3d8ced1fc41..7cd05af295f 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/MapTest.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/MapTest.java @@ -143,21 +143,5 @@ public class MapTest { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/MixedPropertiesAndAdditionalPropertiesClass.java index 3d8314f1e1c..e52678fa5c4 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/MixedPropertiesAndAdditionalPropertiesClass.java @@ -131,21 +131,5 @@ public class MixedPropertiesAndAdditionalPropertiesClass { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Model200Response.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Model200Response.java index 7e63d2a2ab9..1e0db95e010 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Model200Response.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Model200Response.java @@ -92,21 +92,5 @@ public class Model200Response { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ModelApiResponse.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ModelApiResponse.java index bdb4c3b1a35..a5505482e08 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ModelApiResponse.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ModelApiResponse.java @@ -114,21 +114,5 @@ public class ModelApiResponse { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ModelReturn.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ModelReturn.java index cab65161aae..89d3a0e25ff 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ModelReturn.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ModelReturn.java @@ -70,21 +70,5 @@ public class ModelReturn { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Name.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Name.java index 94466b89fbf..b17faa3cc5c 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Name.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Name.java @@ -137,21 +137,5 @@ public class Name { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/NumberOnly.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/NumberOnly.java index 4c56adea5c6..a54fece6268 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/NumberOnly.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/NumberOnly.java @@ -72,21 +72,5 @@ public class NumberOnly { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Order.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Order.java index ba0144ec429..50990892750 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Order.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Order.java @@ -215,21 +215,5 @@ public class Order { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/OuterComposite.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/OuterComposite.java index 78288a15e3b..92a8ca4c95a 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/OuterComposite.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/OuterComposite.java @@ -116,21 +116,5 @@ public class OuterComposite { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Pet.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Pet.java index d1abd7c48aa..aaa139c566d 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Pet.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Pet.java @@ -234,21 +234,5 @@ public class Pet { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ReadOnlyFirst.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ReadOnlyFirst.java index 1a3e4e7fcc2..693aa7eba34 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ReadOnlyFirst.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/ReadOnlyFirst.java @@ -92,21 +92,5 @@ public class ReadOnlyFirst { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/SpecialModelName.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/SpecialModelName.java index fa827dbd77f..ff398610850 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/SpecialModelName.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/SpecialModelName.java @@ -70,21 +70,5 @@ public class SpecialModelName { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Tag.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Tag.java index 033f9d61bd7..5426c883569 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Tag.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/Tag.java @@ -92,21 +92,5 @@ public class Tag { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/User.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/User.java index a479bb5e5f0..0308cc92681 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/User.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/apimodels/User.java @@ -224,21 +224,5 @@ public class User { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java index 6164019070f..a81d96a90a7 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java @@ -16,6 +16,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -24,11 +25,13 @@ public class AnotherFakeApiController extends Controller { private final AnotherFakeApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private AnotherFakeApiController(AnotherFakeApiControllerImpInterface imp) { + private AnotherFakeApiController(Configuration configuration, AnotherFakeApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -38,12 +41,16 @@ public class AnotherFakeApiController extends Controller { Client body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Client.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } Client obj = imp.testSpecialTags(body); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java index d9bcaed20a5..0fcefacfa3b 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java @@ -20,6 +20,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -28,11 +29,13 @@ public class FakeApiController extends Controller { private final FakeApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private FakeApiController(FakeApiControllerImpInterface imp) { + private FakeApiController(Configuration configuration, FakeApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -42,7 +45,9 @@ public class FakeApiController extends Controller { Boolean body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Boolean.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { body = null; } @@ -57,12 +62,16 @@ public class FakeApiController extends Controller { OuterComposite body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), OuterComposite.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { body = null; } OuterComposite obj = imp.fakeOuterCompositeSerialize(body); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -73,12 +82,16 @@ public class FakeApiController extends Controller { BigDecimal body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), BigDecimal.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { body = null; } BigDecimal obj = imp.fakeOuterNumberSerialize(body); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -89,7 +102,9 @@ public class FakeApiController extends Controller { String body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), String.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { body = null; } @@ -104,12 +119,16 @@ public class FakeApiController extends Controller { Client body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Client.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } Client obj = imp.testClientModel(body); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -182,14 +201,14 @@ public class FakeApiController extends Controller { String valuebinary = (request().body().asMultipartFormData().asFormUrlEncoded().get("binary"))[0]; byte[] binary; if (valuebinary != null) { - binary = valuebinary; + binary = valuebinary.getBytes(); } else { binary = null; } String valuedate = (request().body().asMultipartFormData().asFormUrlEncoded().get("date"))[0]; LocalDate date; if (valuedate != null) { - date = valuedate; + date = LocalDate.parse(valuedate); } else { date = null; } @@ -280,6 +299,22 @@ public class FakeApiController extends Controller { return ok(); } + @ApiAction + public Result testInlineAdditionalProperties() throws Exception { + JsonNode nodeparam = request().body().asJson(); + Object param; + if (nodeparam != null) { + param = mapper.readValue(nodeparam.toString(), Object.class); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(param); + } + } else { + throw new IllegalArgumentException("'param' parameter is required"); + } + imp.testInlineAdditionalProperties(param); + return ok(); + } + @ApiAction public Result testJsonFormData() throws Exception { String valueparam = (request().body().asMultipartFormData().asFormUrlEncoded().get("param"))[0]; diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImp.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImp.java index 36a6affba94..8756c4226c3 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImp.java @@ -56,6 +56,12 @@ public class FakeApiControllerImp implements FakeApiControllerImpInterface { } + @Override + public void testInlineAdditionalProperties(Object param) throws Exception { + //Do your magic!!! + + } + @Override public void testJsonFormData(String param, String param2) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java index 210755319d2..48828746e09 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java @@ -29,6 +29,8 @@ public interface FakeApiControllerImpInterface { void testEnumParameters(List enumFormStringArray, String enumFormString, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble) throws Exception; + void testInlineAdditionalProperties(Object param) throws Exception; + void testJsonFormData(String param, String param2) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java index 785c5da877f..89c227fa5db 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java @@ -16,6 +16,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -24,11 +25,13 @@ public class FakeClassnameTags123ApiController extends Controller { private final FakeClassnameTags123ApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private FakeClassnameTags123ApiController(FakeClassnameTags123ApiControllerImpInterface imp) { + private FakeClassnameTags123ApiController(Configuration configuration, FakeClassnameTags123ApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -38,12 +41,16 @@ public class FakeClassnameTags123ApiController extends Controller { Client body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Client.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } Client obj = imp.testClassname(body); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java index 2ecdbcbdc0b..cab362abda5 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java @@ -18,6 +18,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -26,11 +27,13 @@ public class PetApiController extends Controller { private final PetApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private PetApiController(PetApiControllerImpInterface imp) { + private PetApiController(Configuration configuration, PetApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -40,7 +43,9 @@ public class PetApiController extends Controller { Pet body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Pet.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -74,8 +79,10 @@ public class PetApiController extends Controller { status.add(curParam); } List obj = imp.findPetsByStatus(status); - for (Pet curItem : obj) { - curItem.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + SwaggerUtils.validate(curItem); + } } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -94,8 +101,10 @@ public class PetApiController extends Controller { tags.add(curParam); } List obj = imp.findPetsByTags(tags); - for (Pet curItem : obj) { - curItem.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + SwaggerUtils.validate(curItem); + } } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -104,7 +113,9 @@ public class PetApiController extends Controller { @ApiAction public Result getPetById(Long petId) throws Exception { Pet obj = imp.getPetById(petId); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -115,7 +126,9 @@ public class PetApiController extends Controller { Pet body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Pet.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -154,7 +167,9 @@ public class PetApiController extends Controller { } Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java index 8254d1f992e..c94c5aa111a 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java @@ -17,6 +17,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -25,11 +26,13 @@ public class StoreApiController extends Controller { private final StoreApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private StoreApiController(StoreApiControllerImpInterface imp) { + private StoreApiController(Configuration configuration, StoreApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -49,7 +52,9 @@ public class StoreApiController extends Controller { @ApiAction public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception { Order obj = imp.getOrderById(orderId); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -60,12 +65,16 @@ public class StoreApiController extends Controller { Order body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Order.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } Order obj = imp.placeOrder(body); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java index b0676d8e3d5..245d076858a 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java @@ -17,6 +17,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -25,11 +26,13 @@ public class UserApiController extends Controller { private final UserApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private UserApiController(UserApiControllerImpInterface imp) { + private UserApiController(Configuration configuration, UserApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -39,7 +42,9 @@ public class UserApiController extends Controller { User body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), User.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -53,8 +58,10 @@ public class UserApiController extends Controller { List body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), new TypeReference>(){}); - for (User curItem : body) { - curItem.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + for (User curItem : body) { + SwaggerUtils.validate(curItem); + } } } else { throw new IllegalArgumentException("'body' parameter is required"); @@ -69,8 +76,10 @@ public class UserApiController extends Controller { List body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), new TypeReference>(){}); - for (User curItem : body) { - curItem.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + for (User curItem : body) { + SwaggerUtils.validate(curItem); + } } } else { throw new IllegalArgumentException("'body' parameter is required"); @@ -88,7 +97,9 @@ public class UserApiController extends Controller { @ApiAction public Result getUserByName(String username) throws Exception { User obj = imp.getUserByName(username); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -126,7 +137,9 @@ public class UserApiController extends Controller { User body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), User.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/swagger/SwaggerUtils.java index c7d8bd3de9e..d4900e02167 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/swagger/SwaggerUtils.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/swagger/SwaggerUtils.java @@ -9,6 +9,11 @@ import java.lang.annotation.Target; import java.text.SimpleDateFormat; import java.util.*; +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + public class SwaggerUtils { @With(ApiCall.class) @@ -17,6 +22,22 @@ public class SwaggerUtils { public @interface ApiAction { } + public static void validate(T obj) { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + Validator validator = factory.getValidator(); + Set> constraintViolations = validator.validate(obj); + if (constraintViolations.size() > 0) { + StringBuilder errors = new StringBuilder(); + for (ConstraintViolation contraintes : constraintViolations) { + errors.append(String.format("%s.%s %s\n", + contraintes.getRootBeanClass().getSimpleName(), + contraintes.getPropertyPath(), + contraintes.getMessage())); + } + throw new RuntimeException("Bean validation : " + errors); + } + } + public static List parametersToList(String collectionFormat, String[] values){ List params = new ArrayList<>(); diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/conf/application.conf b/samples/server/petstore/java-play-framework-fake-endpoints/conf/application.conf index a361b74d38e..46ce4312dd3 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/conf/application.conf +++ b/samples/server/petstore/java-play-framework-fake-endpoints/conf/application.conf @@ -17,6 +17,15 @@ play.filters.headers.contentSecurityPolicy=null +# When using bean validation with the swagger api, the validator will check that every constraint is respected +# This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have +# shown that the time it takes to validate is exponential. +# If this is a concern in your application, or if you don't want to validate the output coming from your API for +# respecting its contract, set the "output" property below to "false". Since there is not a lot of data as input for +# an endpoint, I highly suggest you let the "input" property set to true. +useInputBeanValidation=true +useOutputBeanValidation=true + play.http.errorHandler="swagger.ErrorHandler" ## Akka diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/conf/routes b/samples/server/petstore/java-play-framework-fake-endpoints/conf/routes index d3094cd2441..6a342645b5d 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/conf/routes +++ b/samples/server/petstore/java-play-framework-fake-endpoints/conf/routes @@ -16,6 +16,7 @@ POST /v2/fake/outer/string controllers.FakeApiController PATCH /v2/fake controllers.FakeApiController.testClientModel() POST /v2/fake controllers.FakeApiController.testEndpointParameters() GET /v2/fake controllers.FakeApiController.testEnumParameters() +POST /v2/fake/inline-additionalProperties controllers.FakeApiController.testInlineAdditionalProperties() GET /v2/fake/jsonFormData controllers.FakeApiController.testJsonFormData() #Functions for FakeClassnameTags123 API diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/public/swagger.json b/samples/server/petstore/java-play-framework-fake-endpoints/public/swagger.json index 52a10430087..368be2e2b4d 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/public/swagger.json +++ b/samples/server/petstore/java-play-framework-fake-endpoints/public/swagger.json @@ -1088,6 +1088,34 @@ "x-accepts" : "application/json" } }, + "/fake/inline-additionalProperties" : { + "post" : { + "tags" : [ "fake" ], + "summary" : "test inline additionalProperties", + "description" : "", + "operationId" : "testInlineAdditionalProperties", + "consumes" : [ "application/json" ], + "parameters" : [ { + "in" : "body", + "name" : "param", + "description" : "request body", + "required" : true, + "schema" : { + "type" : "object", + "additionalProperties" : { + "type" : "string" + } + } + } ], + "responses" : { + "200" : { + "description" : "successful operation" + } + }, + "x-contentType" : "application/json", + "x-accepts" : "application/json" + } + }, "/another-fake/dummy" : { "patch" : { "tags" : [ "$another-fake?" ], diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Category.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Category.java index 399a6f2646a..44eb3a6bf7a 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Category.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Category.java @@ -91,6 +91,5 @@ public class Category { } return o.toString().replace("\n", "\n "); } - } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/ModelApiResponse.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/ModelApiResponse.java index 9b3b2fc7e92..81a2333008b 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/ModelApiResponse.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/ModelApiResponse.java @@ -113,6 +113,5 @@ public class ModelApiResponse { } return o.toString().replace("\n", "\n "); } - } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Order.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Order.java index 873a6aebd25..2290a967e4b 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Order.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Order.java @@ -213,6 +213,5 @@ public class Order { } return o.toString().replace("\n", "\n "); } - } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Pet.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Pet.java index e6adacc5d5c..ec14d76b41f 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Pet.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Pet.java @@ -229,6 +229,5 @@ public class Pet { } return o.toString().replace("\n", "\n "); } - } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Tag.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Tag.java index cc8a86828f0..80b1d783b33 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Tag.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/Tag.java @@ -91,6 +91,5 @@ public class Tag { } return o.toString().replace("\n", "\n "); } - } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/User.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/User.java index 5fc613edfbe..221a9f30591 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/User.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/apimodels/User.java @@ -223,6 +223,5 @@ public class User { } return o.toString().replace("\n", "\n "); } - } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/swagger/SwaggerUtils.java index c7d8bd3de9e..831a59d70be 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/swagger/SwaggerUtils.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/swagger/SwaggerUtils.java @@ -9,6 +9,7 @@ import java.lang.annotation.Target; import java.text.SimpleDateFormat; import java.util.*; + public class SwaggerUtils { @With(ApiCall.class) @@ -17,6 +18,7 @@ public class SwaggerUtils { public @interface ApiAction { } + public static List parametersToList(String collectionFormat, String[] values){ List params = new ArrayList<>(); diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/conf/application.conf b/samples/server/petstore/java-play-framework-no-bean-validation/conf/application.conf index a361b74d38e..21e3331bf27 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/conf/application.conf +++ b/samples/server/petstore/java-play-framework-no-bean-validation/conf/application.conf @@ -17,6 +17,7 @@ play.filters.headers.contentSecurityPolicy=null + play.http.errorHandler="swagger.ErrorHandler" ## Akka diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Category.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Category.java index fb9207f4b5d..9f0206575f5 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Category.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Category.java @@ -92,21 +92,5 @@ public class Category { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/ModelApiResponse.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/ModelApiResponse.java index 05911012313..07493e84825 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/ModelApiResponse.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/ModelApiResponse.java @@ -114,21 +114,5 @@ public class ModelApiResponse { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Order.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Order.java index 987ef07d460..cdc21f722c9 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Order.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Order.java @@ -215,21 +215,5 @@ public class Order { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Pet.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Pet.java index 430bbe805ce..5e5ff376294 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Pet.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Pet.java @@ -234,21 +234,5 @@ public class Pet { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Tag.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Tag.java index 709fef2cf11..15a8774252a 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Tag.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/Tag.java @@ -92,21 +92,5 @@ public class Tag { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/User.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/User.java index ba41fb76f80..689de768893 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/User.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/apimodels/User.java @@ -224,21 +224,5 @@ public class User { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java index c5fc05efb60..9422ed10ca0 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java @@ -19,6 +19,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -27,11 +28,13 @@ public class PetApiController extends Controller { private final PetApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private PetApiController(PetApiControllerImpInterface imp) { + private PetApiController(Configuration configuration, PetApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -41,7 +44,9 @@ public class PetApiController extends Controller { Pet body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Pet.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -75,8 +80,10 @@ public class PetApiController extends Controller { status.add(curParam); } List obj = imp.findPetsByStatus(status); - for (Pet curItem : obj) { - curItem.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + SwaggerUtils.validate(curItem); + } } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -95,8 +102,10 @@ public class PetApiController extends Controller { tags.add(curParam); } List obj = imp.findPetsByTags(tags); - for (Pet curItem : obj) { - curItem.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + SwaggerUtils.validate(curItem); + } } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -105,7 +114,9 @@ public class PetApiController extends Controller { @ApiAction public Result getPetById(Long petId) { Pet obj = imp.getPetById(petId); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -116,7 +127,9 @@ public class PetApiController extends Controller { Pet body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Pet.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -155,7 +168,9 @@ public class PetApiController extends Controller { } Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java index 147561498ea..e98dea01e40 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java @@ -18,6 +18,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -26,11 +27,13 @@ public class StoreApiController extends Controller { private final StoreApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private StoreApiController(StoreApiControllerImpInterface imp) { + private StoreApiController(Configuration configuration, StoreApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -50,7 +53,9 @@ public class StoreApiController extends Controller { @ApiAction public Result getOrderById( @Min(1) @Max(5)Long orderId) { Order obj = imp.getOrderById(orderId); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -61,12 +66,16 @@ public class StoreApiController extends Controller { Order body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Order.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } Order obj = imp.placeOrder(body); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java index a0e94c65233..2afd562c7c8 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java @@ -18,6 +18,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -26,11 +27,13 @@ public class UserApiController extends Controller { private final UserApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private UserApiController(UserApiControllerImpInterface imp) { + private UserApiController(Configuration configuration, UserApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -40,7 +43,9 @@ public class UserApiController extends Controller { User body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), User.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -54,8 +59,10 @@ public class UserApiController extends Controller { List body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), new TypeReference>(){}); - for (User curItem : body) { - curItem.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + for (User curItem : body) { + SwaggerUtils.validate(curItem); + } } } else { throw new IllegalArgumentException("'body' parameter is required"); @@ -70,8 +77,10 @@ public class UserApiController extends Controller { List body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), new TypeReference>(){}); - for (User curItem : body) { - curItem.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + for (User curItem : body) { + SwaggerUtils.validate(curItem); + } } } else { throw new IllegalArgumentException("'body' parameter is required"); @@ -89,7 +98,9 @@ public class UserApiController extends Controller { @ApiAction public Result getUserByName(String username) { User obj = imp.getUserByName(username); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -127,7 +138,9 @@ public class UserApiController extends Controller { User body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), User.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/swagger/SwaggerUtils.java index c7d8bd3de9e..d4900e02167 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/swagger/SwaggerUtils.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/swagger/SwaggerUtils.java @@ -9,6 +9,11 @@ import java.lang.annotation.Target; import java.text.SimpleDateFormat; import java.util.*; +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + public class SwaggerUtils { @With(ApiCall.class) @@ -17,6 +22,22 @@ public class SwaggerUtils { public @interface ApiAction { } + public static void validate(T obj) { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + Validator validator = factory.getValidator(); + Set> constraintViolations = validator.validate(obj); + if (constraintViolations.size() > 0) { + StringBuilder errors = new StringBuilder(); + for (ConstraintViolation contraintes : constraintViolations) { + errors.append(String.format("%s.%s %s\n", + contraintes.getRootBeanClass().getSimpleName(), + contraintes.getPropertyPath(), + contraintes.getMessage())); + } + throw new RuntimeException("Bean validation : " + errors); + } + } + public static List parametersToList(String collectionFormat, String[] values){ List params = new ArrayList<>(); diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/conf/application.conf b/samples/server/petstore/java-play-framework-no-exception-handling/conf/application.conf index 9b6a9566c96..2b8e956dae5 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/conf/application.conf +++ b/samples/server/petstore/java-play-framework-no-exception-handling/conf/application.conf @@ -17,6 +17,15 @@ play.filters.headers.contentSecurityPolicy=null +# When using bean validation with the swagger api, the validator will check that every constraint is respected +# This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have +# shown that the time it takes to validate is exponential. +# If this is a concern in your application, or if you don't want to validate the output coming from your API for +# respecting its contract, set the "output" property below to "false". Since there is not a lot of data as input for +# an endpoint, I highly suggest you let the "input" property set to true. +useInputBeanValidation=true +useOutputBeanValidation=true + ## Akka # https://www.playframework.com/documentation/latest/ScalaAkka#Configuration diff --git a/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Category.java b/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Category.java index fb9207f4b5d..9f0206575f5 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Category.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Category.java @@ -92,21 +92,5 @@ public class Category { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/apimodels/ModelApiResponse.java b/samples/server/petstore/java-play-framework-no-interface/app/apimodels/ModelApiResponse.java index 05911012313..07493e84825 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/apimodels/ModelApiResponse.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/apimodels/ModelApiResponse.java @@ -114,21 +114,5 @@ public class ModelApiResponse { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Order.java b/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Order.java index 987ef07d460..cdc21f722c9 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Order.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Order.java @@ -215,21 +215,5 @@ public class Order { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Pet.java b/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Pet.java index 430bbe805ce..5e5ff376294 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Pet.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Pet.java @@ -234,21 +234,5 @@ public class Pet { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Tag.java b/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Tag.java index 709fef2cf11..15a8774252a 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Tag.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/apimodels/Tag.java @@ -92,21 +92,5 @@ public class Tag { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/apimodels/User.java b/samples/server/petstore/java-play-framework-no-interface/app/apimodels/User.java index ba41fb76f80..689de768893 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/apimodels/User.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/apimodels/User.java @@ -224,21 +224,5 @@ public class User { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java index e1f3f0b0a21..eb522b1f8f5 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java @@ -18,6 +18,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -26,11 +27,13 @@ public class PetApiController extends Controller { private final PetApiControllerImp imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private PetApiController(PetApiControllerImp imp) { + private PetApiController(Configuration configuration, PetApiControllerImp imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -40,7 +43,9 @@ public class PetApiController extends Controller { Pet body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Pet.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -74,8 +79,10 @@ public class PetApiController extends Controller { status.add(curParam); } List obj = imp.findPetsByStatus(status); - for (Pet curItem : obj) { - curItem.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + SwaggerUtils.validate(curItem); + } } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -94,8 +101,10 @@ public class PetApiController extends Controller { tags.add(curParam); } List obj = imp.findPetsByTags(tags); - for (Pet curItem : obj) { - curItem.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + SwaggerUtils.validate(curItem); + } } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -104,7 +113,9 @@ public class PetApiController extends Controller { @ApiAction public Result getPetById(Long petId) throws Exception { Pet obj = imp.getPetById(petId); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -115,7 +126,9 @@ public class PetApiController extends Controller { Pet body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Pet.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -154,7 +167,9 @@ public class PetApiController extends Controller { } Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java index 2c0b41176ce..e5829bb4d81 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java @@ -17,6 +17,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -25,11 +26,13 @@ public class StoreApiController extends Controller { private final StoreApiControllerImp imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private StoreApiController(StoreApiControllerImp imp) { + private StoreApiController(Configuration configuration, StoreApiControllerImp imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -49,7 +52,9 @@ public class StoreApiController extends Controller { @ApiAction public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception { Order obj = imp.getOrderById(orderId); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -60,12 +65,16 @@ public class StoreApiController extends Controller { Order body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Order.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } Order obj = imp.placeOrder(body); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java index 05f0a4eefed..8bb48133af9 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java @@ -17,6 +17,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -25,11 +26,13 @@ public class UserApiController extends Controller { private final UserApiControllerImp imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private UserApiController(UserApiControllerImp imp) { + private UserApiController(Configuration configuration, UserApiControllerImp imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -39,7 +42,9 @@ public class UserApiController extends Controller { User body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), User.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -53,8 +58,10 @@ public class UserApiController extends Controller { List body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), new TypeReference>(){}); - for (User curItem : body) { - curItem.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + for (User curItem : body) { + SwaggerUtils.validate(curItem); + } } } else { throw new IllegalArgumentException("'body' parameter is required"); @@ -69,8 +76,10 @@ public class UserApiController extends Controller { List body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), new TypeReference>(){}); - for (User curItem : body) { - curItem.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + for (User curItem : body) { + SwaggerUtils.validate(curItem); + } } } else { throw new IllegalArgumentException("'body' parameter is required"); @@ -88,7 +97,9 @@ public class UserApiController extends Controller { @ApiAction public Result getUserByName(String username) throws Exception { User obj = imp.getUserByName(username); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -126,7 +137,9 @@ public class UserApiController extends Controller { User body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), User.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-no-interface/app/swagger/SwaggerUtils.java index c7d8bd3de9e..d4900e02167 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/swagger/SwaggerUtils.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/swagger/SwaggerUtils.java @@ -9,6 +9,11 @@ import java.lang.annotation.Target; import java.text.SimpleDateFormat; import java.util.*; +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + public class SwaggerUtils { @With(ApiCall.class) @@ -17,6 +22,22 @@ public class SwaggerUtils { public @interface ApiAction { } + public static void validate(T obj) { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + Validator validator = factory.getValidator(); + Set> constraintViolations = validator.validate(obj); + if (constraintViolations.size() > 0) { + StringBuilder errors = new StringBuilder(); + for (ConstraintViolation contraintes : constraintViolations) { + errors.append(String.format("%s.%s %s\n", + contraintes.getRootBeanClass().getSimpleName(), + contraintes.getPropertyPath(), + contraintes.getMessage())); + } + throw new RuntimeException("Bean validation : " + errors); + } + } + public static List parametersToList(String collectionFormat, String[] values){ List params = new ArrayList<>(); diff --git a/samples/server/petstore/java-play-framework-no-interface/conf/application.conf b/samples/server/petstore/java-play-framework-no-interface/conf/application.conf index 514ce684a77..c147af52f25 100644 --- a/samples/server/petstore/java-play-framework-no-interface/conf/application.conf +++ b/samples/server/petstore/java-play-framework-no-interface/conf/application.conf @@ -17,6 +17,15 @@ play.filters.headers.contentSecurityPolicy=null +# When using bean validation with the swagger api, the validator will check that every constraint is respected +# This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have +# shown that the time it takes to validate is exponential. +# If this is a concern in your application, or if you don't want to validate the output coming from your API for +# respecting its contract, set the "output" property below to "false". Since there is not a lot of data as input for +# an endpoint, I highly suggest you let the "input" property set to true. +useInputBeanValidation=true +useOutputBeanValidation=true + play.http.errorHandler="swagger.ErrorHandler" ## Akka diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Category.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Category.java index fb9207f4b5d..9f0206575f5 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Category.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Category.java @@ -92,21 +92,5 @@ public class Category { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/ModelApiResponse.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/ModelApiResponse.java index 05911012313..07493e84825 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/ModelApiResponse.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/ModelApiResponse.java @@ -114,21 +114,5 @@ public class ModelApiResponse { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Order.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Order.java index 987ef07d460..cdc21f722c9 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Order.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Order.java @@ -215,21 +215,5 @@ public class Order { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Pet.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Pet.java index 430bbe805ce..5e5ff376294 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Pet.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Pet.java @@ -234,21 +234,5 @@ public class Pet { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Tag.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Tag.java index 709fef2cf11..15a8774252a 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Tag.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/Tag.java @@ -92,21 +92,5 @@ public class Tag { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/User.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/User.java index ba41fb76f80..689de768893 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/User.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/apimodels/User.java @@ -224,21 +224,5 @@ public class User { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java index 2ecdbcbdc0b..cab362abda5 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java @@ -18,6 +18,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -26,11 +27,13 @@ public class PetApiController extends Controller { private final PetApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private PetApiController(PetApiControllerImpInterface imp) { + private PetApiController(Configuration configuration, PetApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -40,7 +43,9 @@ public class PetApiController extends Controller { Pet body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Pet.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -74,8 +79,10 @@ public class PetApiController extends Controller { status.add(curParam); } List obj = imp.findPetsByStatus(status); - for (Pet curItem : obj) { - curItem.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + SwaggerUtils.validate(curItem); + } } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -94,8 +101,10 @@ public class PetApiController extends Controller { tags.add(curParam); } List obj = imp.findPetsByTags(tags); - for (Pet curItem : obj) { - curItem.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + SwaggerUtils.validate(curItem); + } } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -104,7 +113,9 @@ public class PetApiController extends Controller { @ApiAction public Result getPetById(Long petId) throws Exception { Pet obj = imp.getPetById(petId); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -115,7 +126,9 @@ public class PetApiController extends Controller { Pet body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Pet.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -154,7 +167,9 @@ public class PetApiController extends Controller { } Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java index 8254d1f992e..c94c5aa111a 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java @@ -17,6 +17,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -25,11 +26,13 @@ public class StoreApiController extends Controller { private final StoreApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private StoreApiController(StoreApiControllerImpInterface imp) { + private StoreApiController(Configuration configuration, StoreApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -49,7 +52,9 @@ public class StoreApiController extends Controller { @ApiAction public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception { Order obj = imp.getOrderById(orderId); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -60,12 +65,16 @@ public class StoreApiController extends Controller { Order body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Order.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } Order obj = imp.placeOrder(body); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java index b0676d8e3d5..245d076858a 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java @@ -17,6 +17,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -25,11 +26,13 @@ public class UserApiController extends Controller { private final UserApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private UserApiController(UserApiControllerImpInterface imp) { + private UserApiController(Configuration configuration, UserApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -39,7 +42,9 @@ public class UserApiController extends Controller { User body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), User.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -53,8 +58,10 @@ public class UserApiController extends Controller { List body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), new TypeReference>(){}); - for (User curItem : body) { - curItem.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + for (User curItem : body) { + SwaggerUtils.validate(curItem); + } } } else { throw new IllegalArgumentException("'body' parameter is required"); @@ -69,8 +76,10 @@ public class UserApiController extends Controller { List body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), new TypeReference>(){}); - for (User curItem : body) { - curItem.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + for (User curItem : body) { + SwaggerUtils.validate(curItem); + } } } else { throw new IllegalArgumentException("'body' parameter is required"); @@ -88,7 +97,9 @@ public class UserApiController extends Controller { @ApiAction public Result getUserByName(String username) throws Exception { User obj = imp.getUserByName(username); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -126,7 +137,9 @@ public class UserApiController extends Controller { User body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), User.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/swagger/SwaggerUtils.java index c7d8bd3de9e..d4900e02167 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/swagger/SwaggerUtils.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/swagger/SwaggerUtils.java @@ -9,6 +9,11 @@ import java.lang.annotation.Target; import java.text.SimpleDateFormat; import java.util.*; +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + public class SwaggerUtils { @With(ApiCall.class) @@ -17,6 +22,22 @@ public class SwaggerUtils { public @interface ApiAction { } + public static void validate(T obj) { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + Validator validator = factory.getValidator(); + Set> constraintViolations = validator.validate(obj); + if (constraintViolations.size() > 0) { + StringBuilder errors = new StringBuilder(); + for (ConstraintViolation contraintes : constraintViolations) { + errors.append(String.format("%s.%s %s\n", + contraintes.getRootBeanClass().getSimpleName(), + contraintes.getPropertyPath(), + contraintes.getMessage())); + } + throw new RuntimeException("Bean validation : " + errors); + } + } + public static List parametersToList(String collectionFormat, String[] values){ List params = new ArrayList<>(); diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/conf/application.conf b/samples/server/petstore/java-play-framework-no-swagger-ui/conf/application.conf index a361b74d38e..46ce4312dd3 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/conf/application.conf +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/conf/application.conf @@ -17,6 +17,15 @@ play.filters.headers.contentSecurityPolicy=null +# When using bean validation with the swagger api, the validator will check that every constraint is respected +# This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have +# shown that the time it takes to validate is exponential. +# If this is a concern in your application, or if you don't want to validate the output coming from your API for +# respecting its contract, set the "output" property below to "false". Since there is not a lot of data as input for +# an endpoint, I highly suggest you let the "input" property set to true. +useInputBeanValidation=true +useOutputBeanValidation=true + play.http.errorHandler="swagger.ErrorHandler" ## Akka diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Category.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Category.java index fb9207f4b5d..9f0206575f5 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Category.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Category.java @@ -92,21 +92,5 @@ public class Category { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/ModelApiResponse.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/ModelApiResponse.java index 05911012313..07493e84825 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/ModelApiResponse.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/ModelApiResponse.java @@ -114,21 +114,5 @@ public class ModelApiResponse { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Order.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Order.java index 987ef07d460..cdc21f722c9 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Order.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Order.java @@ -215,21 +215,5 @@ public class Order { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Pet.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Pet.java index 430bbe805ce..5e5ff376294 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Pet.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Pet.java @@ -234,21 +234,5 @@ public class Pet { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Tag.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Tag.java index 709fef2cf11..15a8774252a 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Tag.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/Tag.java @@ -92,21 +92,5 @@ public class Tag { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/User.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/User.java index ba41fb76f80..689de768893 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/User.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/apimodels/User.java @@ -224,21 +224,5 @@ public class User { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java index 7b393595452..ef0030703c6 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java @@ -18,6 +18,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; @@ -25,11 +26,13 @@ public class PetApiController extends Controller { private final PetApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private PetApiController(PetApiControllerImpInterface imp) { + private PetApiController(Configuration configuration, PetApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -39,7 +42,9 @@ public class PetApiController extends Controller { Pet body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Pet.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -73,8 +78,10 @@ public class PetApiController extends Controller { status.add(curParam); } List obj = imp.findPetsByStatus(status); - for (Pet curItem : obj) { - curItem.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + SwaggerUtils.validate(curItem); + } } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -93,8 +100,10 @@ public class PetApiController extends Controller { tags.add(curParam); } List obj = imp.findPetsByTags(tags); - for (Pet curItem : obj) { - curItem.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + SwaggerUtils.validate(curItem); + } } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -103,7 +112,9 @@ public class PetApiController extends Controller { public Result getPetById(Long petId) throws Exception { Pet obj = imp.getPetById(petId); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -114,7 +125,9 @@ public class PetApiController extends Controller { Pet body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Pet.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -153,7 +166,9 @@ public class PetApiController extends Controller { } Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java index 964e48e91a0..16a3e3c8efa 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java @@ -17,6 +17,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; @@ -24,11 +25,13 @@ public class StoreApiController extends Controller { private final StoreApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private StoreApiController(StoreApiControllerImpInterface imp) { + private StoreApiController(Configuration configuration, StoreApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -48,7 +51,9 @@ public class StoreApiController extends Controller { public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception { Order obj = imp.getOrderById(orderId); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -59,12 +64,16 @@ public class StoreApiController extends Controller { Order body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Order.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } Order obj = imp.placeOrder(body); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java index 06b4ef13b65..596ce528fff 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java @@ -17,6 +17,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; @@ -24,11 +25,13 @@ public class UserApiController extends Controller { private final UserApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private UserApiController(UserApiControllerImpInterface imp) { + private UserApiController(Configuration configuration, UserApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -38,7 +41,9 @@ public class UserApiController extends Controller { User body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), User.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -52,8 +57,10 @@ public class UserApiController extends Controller { List body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), new TypeReference>(){}); - for (User curItem : body) { - curItem.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + for (User curItem : body) { + SwaggerUtils.validate(curItem); + } } } else { throw new IllegalArgumentException("'body' parameter is required"); @@ -68,8 +75,10 @@ public class UserApiController extends Controller { List body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), new TypeReference>(){}); - for (User curItem : body) { - curItem.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + for (User curItem : body) { + SwaggerUtils.validate(curItem); + } } } else { throw new IllegalArgumentException("'body' parameter is required"); @@ -87,7 +96,9 @@ public class UserApiController extends Controller { public Result getUserByName(String username) throws Exception { User obj = imp.getUserByName(username); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -125,7 +136,9 @@ public class UserApiController extends Controller { User body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), User.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/swagger/SwaggerUtils.java index b00dd30e7e5..4c5ee51c67f 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/swagger/SwaggerUtils.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/swagger/SwaggerUtils.java @@ -9,9 +9,30 @@ import java.lang.annotation.Target; import java.text.SimpleDateFormat; import java.util.*; +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + public class SwaggerUtils { + public static void validate(T obj) { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + Validator validator = factory.getValidator(); + Set> constraintViolations = validator.validate(obj); + if (constraintViolations.size() > 0) { + StringBuilder errors = new StringBuilder(); + for (ConstraintViolation contraintes : constraintViolations) { + errors.append(String.format("%s.%s %s\n", + contraintes.getRootBeanClass().getSimpleName(), + contraintes.getPropertyPath(), + contraintes.getMessage())); + } + throw new RuntimeException("Bean validation : " + errors); + } + } + public static List parametersToList(String collectionFormat, String[] values){ List params = new ArrayList<>(); diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/conf/application.conf b/samples/server/petstore/java-play-framework-no-wrap-calls/conf/application.conf index a361b74d38e..46ce4312dd3 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/conf/application.conf +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/conf/application.conf @@ -17,6 +17,15 @@ play.filters.headers.contentSecurityPolicy=null +# When using bean validation with the swagger api, the validator will check that every constraint is respected +# This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have +# shown that the time it takes to validate is exponential. +# If this is a concern in your application, or if you don't want to validate the output coming from your API for +# respecting its contract, set the "output" property below to "false". Since there is not a lot of data as input for +# an endpoint, I highly suggest you let the "input" property set to true. +useInputBeanValidation=true +useOutputBeanValidation=true + play.http.errorHandler="swagger.ErrorHandler" ## Akka diff --git a/samples/server/petstore/java-play-framework/app/apimodels/Category.java b/samples/server/petstore/java-play-framework/app/apimodels/Category.java index fb9207f4b5d..9f0206575f5 100644 --- a/samples/server/petstore/java-play-framework/app/apimodels/Category.java +++ b/samples/server/petstore/java-play-framework/app/apimodels/Category.java @@ -92,21 +92,5 @@ public class Category { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework/app/apimodels/ModelApiResponse.java b/samples/server/petstore/java-play-framework/app/apimodels/ModelApiResponse.java index 05911012313..07493e84825 100644 --- a/samples/server/petstore/java-play-framework/app/apimodels/ModelApiResponse.java +++ b/samples/server/petstore/java-play-framework/app/apimodels/ModelApiResponse.java @@ -114,21 +114,5 @@ public class ModelApiResponse { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework/app/apimodels/Order.java b/samples/server/petstore/java-play-framework/app/apimodels/Order.java index 987ef07d460..cdc21f722c9 100644 --- a/samples/server/petstore/java-play-framework/app/apimodels/Order.java +++ b/samples/server/petstore/java-play-framework/app/apimodels/Order.java @@ -215,21 +215,5 @@ public class Order { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework/app/apimodels/Pet.java b/samples/server/petstore/java-play-framework/app/apimodels/Pet.java index 430bbe805ce..5e5ff376294 100644 --- a/samples/server/petstore/java-play-framework/app/apimodels/Pet.java +++ b/samples/server/petstore/java-play-framework/app/apimodels/Pet.java @@ -234,21 +234,5 @@ public class Pet { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework/app/apimodels/Tag.java b/samples/server/petstore/java-play-framework/app/apimodels/Tag.java index 709fef2cf11..15a8774252a 100644 --- a/samples/server/petstore/java-play-framework/app/apimodels/Tag.java +++ b/samples/server/petstore/java-play-framework/app/apimodels/Tag.java @@ -92,21 +92,5 @@ public class Tag { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework/app/apimodels/User.java b/samples/server/petstore/java-play-framework/app/apimodels/User.java index ba41fb76f80..689de768893 100644 --- a/samples/server/petstore/java-play-framework/app/apimodels/User.java +++ b/samples/server/petstore/java-play-framework/app/apimodels/User.java @@ -224,21 +224,5 @@ public class User { } return o.toString().replace("\n", "\n "); } - - public void validate() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(this); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } } diff --git a/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java index 2ecdbcbdc0b..cab362abda5 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java @@ -18,6 +18,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -26,11 +27,13 @@ public class PetApiController extends Controller { private final PetApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private PetApiController(PetApiControllerImpInterface imp) { + private PetApiController(Configuration configuration, PetApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -40,7 +43,9 @@ public class PetApiController extends Controller { Pet body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Pet.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -74,8 +79,10 @@ public class PetApiController extends Controller { status.add(curParam); } List obj = imp.findPetsByStatus(status); - for (Pet curItem : obj) { - curItem.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + SwaggerUtils.validate(curItem); + } } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -94,8 +101,10 @@ public class PetApiController extends Controller { tags.add(curParam); } List obj = imp.findPetsByTags(tags); - for (Pet curItem : obj) { - curItem.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + SwaggerUtils.validate(curItem); + } } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -104,7 +113,9 @@ public class PetApiController extends Controller { @ApiAction public Result getPetById(Long petId) throws Exception { Pet obj = imp.getPetById(petId); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -115,7 +126,9 @@ public class PetApiController extends Controller { Pet body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Pet.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -154,7 +167,9 @@ public class PetApiController extends Controller { } Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } diff --git a/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java index 8254d1f992e..c94c5aa111a 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java @@ -17,6 +17,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -25,11 +26,13 @@ public class StoreApiController extends Controller { private final StoreApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private StoreApiController(StoreApiControllerImpInterface imp) { + private StoreApiController(Configuration configuration, StoreApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -49,7 +52,9 @@ public class StoreApiController extends Controller { @ApiAction public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception { Order obj = imp.getOrderById(orderId); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -60,12 +65,16 @@ public class StoreApiController extends Controller { Order body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Order.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } Order obj = imp.placeOrder(body); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } diff --git a/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java index b0676d8e3d5..245d076858a 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java @@ -17,6 +17,7 @@ import swagger.SwaggerUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; +import play.Configuration; import swagger.SwaggerUtils.ApiAction; @@ -25,11 +26,13 @@ public class UserApiController extends Controller { private final UserApiControllerImpInterface imp; private final ObjectMapper mapper; + private final Configuration configuration; @Inject - private UserApiController(UserApiControllerImpInterface imp) { + private UserApiController(Configuration configuration, UserApiControllerImpInterface imp) { this.imp = imp; mapper = new ObjectMapper(); + this.configuration = configuration; } @@ -39,7 +42,9 @@ public class UserApiController extends Controller { User body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), User.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } @@ -53,8 +58,10 @@ public class UserApiController extends Controller { List body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), new TypeReference>(){}); - for (User curItem : body) { - curItem.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + for (User curItem : body) { + SwaggerUtils.validate(curItem); + } } } else { throw new IllegalArgumentException("'body' parameter is required"); @@ -69,8 +76,10 @@ public class UserApiController extends Controller { List body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), new TypeReference>(){}); - for (User curItem : body) { - curItem.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + for (User curItem : body) { + SwaggerUtils.validate(curItem); + } } } else { throw new IllegalArgumentException("'body' parameter is required"); @@ -88,7 +97,9 @@ public class UserApiController extends Controller { @ApiAction public Result getUserByName(String username) throws Exception { User obj = imp.getUserByName(username); - obj.validate(); + if (configuration.getBoolean("useOutputBeanValidation")) { + SwaggerUtils.validate(obj); + } JsonNode result = mapper.valueToTree(obj); return ok(result); } @@ -126,7 +137,9 @@ public class UserApiController extends Controller { User body; if (nodebody != null) { body = mapper.readValue(nodebody.toString(), User.class); - body.validate(); + if (configuration.getBoolean("useInputBeanValidation")) { + SwaggerUtils.validate(body); + } } else { throw new IllegalArgumentException("'body' parameter is required"); } diff --git a/samples/server/petstore/java-play-framework/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework/app/swagger/SwaggerUtils.java index c7d8bd3de9e..d4900e02167 100644 --- a/samples/server/petstore/java-play-framework/app/swagger/SwaggerUtils.java +++ b/samples/server/petstore/java-play-framework/app/swagger/SwaggerUtils.java @@ -9,6 +9,11 @@ import java.lang.annotation.Target; import java.text.SimpleDateFormat; import java.util.*; +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + public class SwaggerUtils { @With(ApiCall.class) @@ -17,6 +22,22 @@ public class SwaggerUtils { public @interface ApiAction { } + public static void validate(T obj) { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + Validator validator = factory.getValidator(); + Set> constraintViolations = validator.validate(obj); + if (constraintViolations.size() > 0) { + StringBuilder errors = new StringBuilder(); + for (ConstraintViolation contraintes : constraintViolations) { + errors.append(String.format("%s.%s %s\n", + contraintes.getRootBeanClass().getSimpleName(), + contraintes.getPropertyPath(), + contraintes.getMessage())); + } + throw new RuntimeException("Bean validation : " + errors); + } + } + public static List parametersToList(String collectionFormat, String[] values){ List params = new ArrayList<>(); diff --git a/samples/server/petstore/java-play-framework/conf/application.conf b/samples/server/petstore/java-play-framework/conf/application.conf index a361b74d38e..46ce4312dd3 100644 --- a/samples/server/petstore/java-play-framework/conf/application.conf +++ b/samples/server/petstore/java-play-framework/conf/application.conf @@ -17,6 +17,15 @@ play.filters.headers.contentSecurityPolicy=null +# When using bean validation with the swagger api, the validator will check that every constraint is respected +# This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have +# shown that the time it takes to validate is exponential. +# If this is a concern in your application, or if you don't want to validate the output coming from your API for +# respecting its contract, set the "output" property below to "false". Since there is not a lot of data as input for +# an endpoint, I highly suggest you let the "input" property set to true. +useInputBeanValidation=true +useOutputBeanValidation=true + play.http.errorHandler="swagger.ErrorHandler" ## Akka diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/AnotherFakeApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/AnotherFakeApi.java index 8ad023f68d0..c2e845dce90 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/AnotherFakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/AnotherFakeApi.java @@ -6,10 +6,13 @@ package io.swagger.api; import io.swagger.model.Client; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,17 +21,32 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; +import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; @Api(value = "another-fake", description = "the another-fake API") public interface AnotherFakeApi { + Logger log = LoggerFactory.getLogger(AnotherFakeApi.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + @ApiOperation(value = "To test special tags", nickname = "testSpecialTags", notes = "To test special tags", response = Client.class, tags={ "$another-fake?", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) @@ -36,9 +54,20 @@ public interface AnotherFakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - default CompletableFuture> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default AnotherFakeApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/AnotherFakeApiController.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/AnotherFakeApiController.java index 82f8a98cfee..c57e8ee5a06 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/AnotherFakeApiController.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/AnotherFakeApiController.java @@ -1,17 +1,31 @@ package io.swagger.api; -import org.springframework.stereotype.Controller; import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import javax.validation.constraints.*; -import javax.validation.Valid; +import org.springframework.stereotype.Controller; +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; @Controller public class AnotherFakeApiController implements AnotherFakeApi { + private final ObjectMapper objectMapper; - public AnotherFakeApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public AnotherFakeApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); } } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java index b2693211907..5c946bfb707 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java @@ -10,10 +10,13 @@ import io.swagger.model.Client; import java.time.LocalDate; import java.time.OffsetDateTime; import io.swagger.model.OuterComposite; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -22,25 +25,51 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; +import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; @Api(value = "fake", description = "the fake API") public interface FakeApi { + Logger log = LoggerFactory.getLogger(FakeApi.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) @RequestMapping(value = "/fake/outer/boolean", method = RequestMethod.POST) - default CompletableFuture> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ }", Boolean.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -49,9 +78,20 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) @RequestMapping(value = "/fake/outer/composite", method = RequestMethod.POST) - default CompletableFuture> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -60,9 +100,20 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) @RequestMapping(value = "/fake/outer/number", method = RequestMethod.POST) - default CompletableFuture> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ }", BigDecimal.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -71,9 +122,20 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output string", response = String.class) }) @RequestMapping(value = "/fake/outer/string", method = RequestMethod.POST) - default CompletableFuture> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ }", String.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -84,9 +146,20 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - default CompletableFuture> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -100,9 +173,12 @@ public interface FakeApi { produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, method = RequestMethod.POST) - default CompletableFuture> testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -114,9 +190,12 @@ public interface FakeApi { produces = { "*/*" }, consumes = { "*/*" }, method = RequestMethod.GET) - default CompletableFuture> testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -126,9 +205,12 @@ public interface FakeApi { @RequestMapping(value = "/fake/inline-additionalProperties", consumes = { "application/json" }, method = RequestMethod.POST) - default CompletableFuture> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -138,9 +220,12 @@ public interface FakeApi { @RequestMapping(value = "/fake/jsonFormData", consumes = { "application/json" }, method = RequestMethod.GET) - default CompletableFuture> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApiController.java index c9bf94efe6a..caf13795605 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApiController.java @@ -1,17 +1,31 @@ package io.swagger.api; -import org.springframework.stereotype.Controller; import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import javax.validation.constraints.*; -import javax.validation.Valid; +import org.springframework.stereotype.Controller; +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; @Controller public class FakeApiController implements FakeApi { + private final ObjectMapper objectMapper; - public FakeApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); } } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeClassnameTestApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeClassnameTestApi.java index bee88691e39..1382f6a44f9 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeClassnameTestApi.java @@ -6,10 +6,13 @@ package io.swagger.api; import io.swagger.model.Client; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,17 +21,32 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; +import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; @Api(value = "fake_classname_test", description = "the fake_classname_test API") public interface FakeClassnameTestApi { + Logger log = LoggerFactory.getLogger(FakeClassnameTestApi.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "", response = Client.class, authorizations = { @Authorization(value = "api_key_query") }, tags={ "fake_classname_tags 123#$%^", }) @@ -38,9 +56,20 @@ public interface FakeClassnameTestApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - default CompletableFuture> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeClassnameTestApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeClassnameTestApiController.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeClassnameTestApiController.java index 3957401c9b2..692712ad25e 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeClassnameTestApiController.java @@ -1,17 +1,31 @@ package io.swagger.api; -import org.springframework.stereotype.Controller; import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import javax.validation.constraints.*; -import javax.validation.Valid; +import org.springframework.stereotype.Controller; +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; @Controller public class FakeClassnameTestApiController implements FakeClassnameTestApi { + private final ObjectMapper objectMapper; - public FakeClassnameTestApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeClassnameTestApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); } } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java index ee21db44fa8..4681a226115 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java @@ -8,10 +8,13 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -20,17 +23,32 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; +import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; @Api(value = "pet", description = "the pet API") public interface PetApi { + Logger log = LoggerFactory.getLogger(PetApi.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", notes = "", authorizations = { @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @@ -43,9 +61,12 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.POST) - default CompletableFuture> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -60,9 +81,12 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default CompletableFuture> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -78,9 +102,28 @@ public interface PetApi { @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture>> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity>(HttpStatus.OK)); + default CompletableFuture>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/xml")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -96,9 +139,28 @@ public interface PetApi { @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture>> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity>(HttpStatus.OK)); + default CompletableFuture>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/xml")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -112,9 +174,28 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/xml")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue(" 123456789 doggie aeiou aeiou", Pet.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -132,9 +213,12 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.PUT) - default CompletableFuture> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -150,9 +234,12 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - default CompletableFuture> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -168,9 +255,20 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - default CompletableFuture> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApiController.java index 5dd78a0e768..d90808e4ae4 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApiController.java @@ -1,17 +1,31 @@ package io.swagger.api; -import org.springframework.stereotype.Controller; import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import javax.validation.constraints.*; -import javax.validation.Valid; +import org.springframework.stereotype.Controller; +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; @Controller public class PetApiController implements PetApi { + private final ObjectMapper objectMapper; - public PetApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public PetApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); } } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java index c19e7c48733..e77f2de7f70 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java @@ -7,10 +7,13 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -19,17 +22,32 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; +import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; @Api(value = "store", description = "the store API") public interface StoreApi { + Logger log = LoggerFactory.getLogger(StoreApi.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + @ApiOperation(value = "Delete purchase order by ID", nickname = "deleteOrder", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @@ -37,9 +55,12 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default CompletableFuture> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -51,9 +72,20 @@ public interface StoreApi { @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - default CompletableFuture>> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity>(HttpStatus.OK)); + default CompletableFuture>> getInventory() { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"key\" : 0}", Map.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -65,9 +97,28 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/xml")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -78,9 +129,28 @@ public interface StoreApi { @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - default CompletableFuture> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/xml")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApiController.java index 652923c800b..93cb65b21aa 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApiController.java @@ -1,17 +1,31 @@ package io.swagger.api; -import org.springframework.stereotype.Controller; import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import javax.validation.constraints.*; -import javax.validation.Valid; +import org.springframework.stereotype.Controller; +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; @Controller public class StoreApiController implements StoreApi { + private final ObjectMapper objectMapper; - public StoreApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public StoreApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); } } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java index 1a8a82de5c6..4e755a2a73d 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java @@ -7,10 +7,13 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -19,26 +22,44 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; +import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; @Api(value = "user", description = "the user API") public interface UserApi { + Logger log = LoggerFactory.getLogger(UserApi.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) @RequestMapping(value = "/user", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - default CompletableFuture> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -48,9 +69,12 @@ public interface UserApi { @RequestMapping(value = "/user/createWithArray", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - default CompletableFuture> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -60,9 +84,12 @@ public interface UserApi { @RequestMapping(value = "/user/createWithList", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - default CompletableFuture> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -73,9 +100,12 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default CompletableFuture> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -87,9 +117,28 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/xml")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123", User.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -100,9 +149,28 @@ public interface UserApi { @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/xml")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("aeiou", String.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + if (getAcceptHeader().get().contains("application/json")) { + try { + return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED)); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -112,9 +180,12 @@ public interface UserApi { @RequestMapping(value = "/user/logout", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> logoutUser() { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -125,9 +196,12 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - default CompletableFuture> updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + default CompletableFuture> updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApiController.java index 5afeac776dd..319d98d4deb 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApiController.java @@ -1,17 +1,31 @@ package io.swagger.api; -import org.springframework.stereotype.Controller; import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import javax.validation.constraints.*; -import javax.validation.Valid; +import org.springframework.stereotype.Controller; +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; @Controller public class UserApiController implements UserApi { + private final ObjectMapper objectMapper; - public UserApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public UserApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); } } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/FormatTest.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/FormatTest.java index e809ba3ca62..c73949ecf4f 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/FormatTest.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/FormatTest.java @@ -71,7 +71,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(10) @Max(100) +@Min(10) @Max(100) public Integer getInteger() { return integer; } @@ -93,7 +93,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(20) @Max(200) +@Min(20) @Max(200) public Integer getInt32() { return int32; } @@ -137,7 +137,7 @@ public class FormatTest { @NotNull @Valid - @DecimalMin("32.1") @DecimalMax("543.2") +@DecimalMin("32.1") @DecimalMax("543.2") public BigDecimal getNumber() { return number; } @@ -159,7 +159,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("54.3") @DecimalMax("987.6") +@DecimalMin("54.3") @DecimalMax("987.6") public Float getFloat() { return _float; } @@ -181,7 +181,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("67.8") @DecimalMax("123.4") +@DecimalMin("67.8") @DecimalMax("123.4") public Double getDouble() { return _double; } @@ -201,7 +201,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Pattern(regexp="/[a-z]/i") +@Pattern(regexp="/[a-z]/i") public String getString() { return string; } @@ -222,7 +222,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") +@Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") public byte[] getByte() { return _byte; } @@ -327,7 +327,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Size(min=10,max=64) +@Size(min=10,max=64) public String getPassword() { return password; } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/AnotherFakeApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/AnotherFakeApi.java index a3fcfabaf12..6f6dd920913 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/AnotherFakeApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/AnotherFakeApi.java @@ -6,9 +6,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -17,12 +17,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "another-fake", description = "the another-fake API") public interface AnotherFakeApi { @@ -34,6 +32,6 @@ public interface AnotherFakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/AnotherFakeApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/AnotherFakeApiController.java index 02fe84a126e..1f969f15713 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/AnotherFakeApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/AnotherFakeApiController.java @@ -1,9 +1,10 @@ package io.swagger.api; import io.swagger.model.Client; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -14,29 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class AnotherFakeApiController implements AnotherFakeApi { + + private static final Logger log = LoggerFactory.getLogger(AnotherFakeApiController.class); + private final ObjectMapper objectMapper; - public AnotherFakeApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public AnotherFakeApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java index 814003e2086..92b47fb2a37 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java @@ -10,9 +10,9 @@ import io.swagger.model.Client; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import io.swagger.model.OuterComposite; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -21,12 +21,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "fake", description = "the fake API") public interface FakeApi { @@ -36,7 +34,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) @RequestMapping(value = "/fake/outer/boolean", method = RequestMethod.POST) - ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body); @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @@ -44,7 +42,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) @RequestMapping(value = "/fake/outer/composite", method = RequestMethod.POST) - ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body); @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @@ -52,7 +50,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) @RequestMapping(value = "/fake/outer/number", method = RequestMethod.POST) - ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body); @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @@ -60,7 +58,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output string", response = String.class) }) @RequestMapping(value = "/fake/outer/string", method = RequestMethod.POST) - ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body); @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @@ -70,7 +68,7 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = { @@ -83,7 +81,7 @@ public interface FakeApi { produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, method = RequestMethod.POST) - ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback); @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) @@ -94,7 +92,7 @@ public interface FakeApi { produces = { "*/*" }, consumes = { "*/*" }, method = RequestMethod.GET) - ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble); @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @@ -103,7 +101,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/inline-additionalProperties", consumes = { "application/json" }, method = RequestMethod.POST) - ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param); @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @@ -112,6 +110,6 @@ public interface FakeApi { @RequestMapping(value = "/fake/jsonFormData", consumes = { "application/json" }, method = RequestMethod.GET) - ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java index e3eebeca3b2..360e1d910d7 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java @@ -5,9 +5,10 @@ import io.swagger.model.Client; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import io.swagger.model.OuterComposite; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -18,118 +19,115 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class FakeApiController implements FakeApi { + + private static final Logger log = LoggerFactory.getLogger(FakeApiController.class); + private final ObjectMapper objectMapper; - public FakeApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", Boolean.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", Boolean.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number, - @ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double, - @ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, - @ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte, - @ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer, - @ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32, - @ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64, - @ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float, - @ApiParam(value = "None") @RequestPart(value="string", required=false) String string, - @ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary, - @ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date, - @ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime, - @ApiParam(value = "None") @RequestPart(value="password", required=false) String password, - @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray, - @ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString, - @ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray, - @ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, - @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, - @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, - @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, - @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param, - @ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeClassnameTestApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeClassnameTestApi.java index 00fffe8a123..8316190673c 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeClassnameTestApi.java @@ -6,9 +6,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -17,12 +17,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "fake_classname_test", description = "the fake_classname_test API") public interface FakeClassnameTestApi { @@ -36,6 +34,6 @@ public interface FakeClassnameTestApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeClassnameTestApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeClassnameTestApiController.java index ea2c0016470..37288b4c860 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeClassnameTestApiController.java @@ -1,9 +1,10 @@ package io.swagger.api; import io.swagger.model.Client; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -14,29 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class FakeClassnameTestApiController implements FakeClassnameTestApi { + + private static final Logger log = LoggerFactory.getLogger(FakeClassnameTestApiController.class); + private final ObjectMapper objectMapper; - public FakeClassnameTestApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeClassnameTestApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java index 247fa4dec59..d4604e9380e 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java @@ -8,9 +8,9 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -19,12 +19,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "pet", description = "the pet API") public interface PetApi { @@ -41,7 +39,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.POST) - ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = { @@ -55,7 +53,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -70,7 +68,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status); @ApiOperation(value = "Finds Pets by tags", nickname = "findPetsByTags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -85,7 +83,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags); @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -98,7 +96,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -115,7 +113,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.PUT) - ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = { @@ -130,7 +128,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status); @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -145,6 +143,6 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java index 5a6f5dc2808..a3890cf787d 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java @@ -3,9 +3,10 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -16,106 +17,128 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class PetApiController implements PetApi { + + private static final Logger log = LoggerFactory.getLogger(PetApiController.class); + private final ObjectMapper objectMapper; - public PetApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public PetApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 doggie aeiou aeiou", Pet.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 doggie aeiou aeiou", Pet.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, - @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java index f0dd4e2d631..f23d712511f 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,12 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "store", description = "the store API") public interface StoreApi { @@ -35,7 +33,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId); @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -46,7 +44,7 @@ public interface StoreApi { @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - ResponseEntity> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> getInventory(); @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) @@ -57,7 +55,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId); @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) @@ -67,6 +65,6 @@ public interface StoreApi { @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java index 8d84a45d949..6e463e1307f 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java @@ -2,9 +2,10 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -15,66 +16,90 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class StoreApiController implements StoreApi { + + private static final Logger log = LoggerFactory.getLogger(StoreApiController.class); + private final ObjectMapper objectMapper; - public StoreApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public StoreApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> getInventory(@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> getInventory() { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java index 0f8609bc6ac..3dbcf7293cd 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,12 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "user", description = "the user API") public interface UserApi { @@ -34,7 +32,7 @@ public interface UserApi { @RequestMapping(value = "/user", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @@ -43,7 +41,7 @@ public interface UserApi { @RequestMapping(value = "/user/createWithArray", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @@ -52,7 +50,7 @@ public interface UserApi { @RequestMapping(value = "/user/createWithList", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @@ -62,7 +60,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -73,7 +71,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username); @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -83,7 +81,7 @@ public interface UserApi { @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password); @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @@ -92,7 +90,7 @@ public interface UserApi { @RequestMapping(value = "/user/logout", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity logoutUser(); @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @@ -102,6 +100,6 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java index b0bf6f65380..e96dfe648b4 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java @@ -2,9 +2,10 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -15,87 +16,101 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class UserApiController implements UserApi { + + private static final Logger log = LoggerFactory.getLogger(UserApiController.class); + private final ObjectMapper objectMapper; - public UserApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public UserApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123", User.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123", User.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, - @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue("aeiou", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("aeiou", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("\"\"", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity logoutUser(@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity logoutUser() { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username, - @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/FormatTest.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/FormatTest.java index 9d47a2e4245..9a7f3ff8be1 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/FormatTest.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/FormatTest.java @@ -71,7 +71,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(10) @Max(100) +@Min(10) @Max(100) public Integer getInteger() { return integer; } @@ -93,7 +93,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(20) @Max(200) +@Min(20) @Max(200) public Integer getInt32() { return int32; } @@ -137,7 +137,7 @@ public class FormatTest { @NotNull @Valid - @DecimalMin("32.1") @DecimalMax("543.2") +@DecimalMin("32.1") @DecimalMax("543.2") public BigDecimal getNumber() { return number; } @@ -159,7 +159,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("54.3") @DecimalMax("987.6") +@DecimalMin("54.3") @DecimalMax("987.6") public Float getFloat() { return _float; } @@ -181,7 +181,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("67.8") @DecimalMax("123.4") +@DecimalMin("67.8") @DecimalMax("123.4") public Double getDouble() { return _double; } @@ -201,7 +201,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Pattern(regexp="/[a-z]/i") +@Pattern(regexp="/[a-z]/i") public String getString() { return string; } @@ -222,7 +222,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") +@Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") public byte[] getByte() { return _byte; } @@ -327,7 +327,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Size(min=10,max=64) +@Size(min=10,max=64) public String getPassword() { return password; } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/AnotherFakeApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/AnotherFakeApi.java index a3fcfabaf12..6f6dd920913 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/AnotherFakeApi.java @@ -6,9 +6,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -17,12 +17,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "another-fake", description = "the another-fake API") public interface AnotherFakeApi { @@ -34,6 +32,6 @@ public interface AnotherFakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/AnotherFakeApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/AnotherFakeApiController.java index 02fe84a126e..1f969f15713 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/AnotherFakeApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/AnotherFakeApiController.java @@ -1,9 +1,10 @@ package io.swagger.api; import io.swagger.model.Client; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -14,29 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class AnotherFakeApiController implements AnotherFakeApi { + + private static final Logger log = LoggerFactory.getLogger(AnotherFakeApiController.class); + private final ObjectMapper objectMapper; - public AnotherFakeApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public AnotherFakeApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java index 814003e2086..92b47fb2a37 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java @@ -10,9 +10,9 @@ import io.swagger.model.Client; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import io.swagger.model.OuterComposite; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -21,12 +21,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "fake", description = "the fake API") public interface FakeApi { @@ -36,7 +34,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) @RequestMapping(value = "/fake/outer/boolean", method = RequestMethod.POST) - ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body); @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @@ -44,7 +42,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) @RequestMapping(value = "/fake/outer/composite", method = RequestMethod.POST) - ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body); @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @@ -52,7 +50,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) @RequestMapping(value = "/fake/outer/number", method = RequestMethod.POST) - ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body); @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @@ -60,7 +58,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output string", response = String.class) }) @RequestMapping(value = "/fake/outer/string", method = RequestMethod.POST) - ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body); @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @@ -70,7 +68,7 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = { @@ -83,7 +81,7 @@ public interface FakeApi { produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, method = RequestMethod.POST) - ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback); @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) @@ -94,7 +92,7 @@ public interface FakeApi { produces = { "*/*" }, consumes = { "*/*" }, method = RequestMethod.GET) - ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble); @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @@ -103,7 +101,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/inline-additionalProperties", consumes = { "application/json" }, method = RequestMethod.POST) - ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param); @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @@ -112,6 +110,6 @@ public interface FakeApi { @RequestMapping(value = "/fake/jsonFormData", consumes = { "application/json" }, method = RequestMethod.GET) - ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2); } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java index e3eebeca3b2..360e1d910d7 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java @@ -5,9 +5,10 @@ import io.swagger.model.Client; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import io.swagger.model.OuterComposite; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -18,118 +19,115 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class FakeApiController implements FakeApi { + + private static final Logger log = LoggerFactory.getLogger(FakeApiController.class); + private final ObjectMapper objectMapper; - public FakeApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", Boolean.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", Boolean.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number, - @ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double, - @ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, - @ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte, - @ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer, - @ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32, - @ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64, - @ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float, - @ApiParam(value = "None") @RequestPart(value="string", required=false) String string, - @ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary, - @ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date, - @ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime, - @ApiParam(value = "None") @RequestPart(value="password", required=false) String password, - @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray, - @ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString, - @ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray, - @ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, - @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, - @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, - @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, - @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param, - @ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeClassnameTestApi.java index 00fffe8a123..8316190673c 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeClassnameTestApi.java @@ -6,9 +6,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -17,12 +17,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "fake_classname_test", description = "the fake_classname_test API") public interface FakeClassnameTestApi { @@ -36,6 +34,6 @@ public interface FakeClassnameTestApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeClassnameTestApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeClassnameTestApiController.java index ea2c0016470..37288b4c860 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeClassnameTestApiController.java @@ -1,9 +1,10 @@ package io.swagger.api; import io.swagger.model.Client; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -14,29 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class FakeClassnameTestApiController implements FakeClassnameTestApi { + + private static final Logger log = LoggerFactory.getLogger(FakeClassnameTestApiController.class); + private final ObjectMapper objectMapper; - public FakeClassnameTestApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeClassnameTestApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java index 247fa4dec59..d4604e9380e 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java @@ -8,9 +8,9 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -19,12 +19,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "pet", description = "the pet API") public interface PetApi { @@ -41,7 +39,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.POST) - ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = { @@ -55,7 +53,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -70,7 +68,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status); @ApiOperation(value = "Finds Pets by tags", nickname = "findPetsByTags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -85,7 +83,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags); @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -98,7 +96,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -115,7 +113,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.PUT) - ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = { @@ -130,7 +128,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status); @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -145,6 +143,6 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file); } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java index 5a6f5dc2808..a3890cf787d 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java @@ -3,9 +3,10 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -16,106 +17,128 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class PetApiController implements PetApi { + + private static final Logger log = LoggerFactory.getLogger(PetApiController.class); + private final ObjectMapper objectMapper; - public PetApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public PetApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 doggie aeiou aeiou", Pet.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 doggie aeiou aeiou", Pet.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, - @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java index f0dd4e2d631..f23d712511f 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,12 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "store", description = "the store API") public interface StoreApi { @@ -35,7 +33,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId); @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -46,7 +44,7 @@ public interface StoreApi { @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - ResponseEntity> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> getInventory(); @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) @@ -57,7 +55,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId); @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) @@ -67,6 +65,6 @@ public interface StoreApi { @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java index 8d84a45d949..6e463e1307f 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java @@ -2,9 +2,10 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -15,66 +16,90 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class StoreApiController implements StoreApi { + + private static final Logger log = LoggerFactory.getLogger(StoreApiController.class); + private final ObjectMapper objectMapper; - public StoreApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public StoreApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> getInventory(@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> getInventory() { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java index 0f8609bc6ac..3dbcf7293cd 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,12 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "user", description = "the user API") public interface UserApi { @@ -34,7 +32,7 @@ public interface UserApi { @RequestMapping(value = "/user", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @@ -43,7 +41,7 @@ public interface UserApi { @RequestMapping(value = "/user/createWithArray", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @@ -52,7 +50,7 @@ public interface UserApi { @RequestMapping(value = "/user/createWithList", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @@ -62,7 +60,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -73,7 +71,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username); @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -83,7 +81,7 @@ public interface UserApi { @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password); @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @@ -92,7 +90,7 @@ public interface UserApi { @RequestMapping(value = "/user/logout", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity logoutUser(); @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @@ -102,6 +100,6 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java index b0bf6f65380..e96dfe648b4 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java @@ -2,9 +2,10 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -15,87 +16,101 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class UserApiController implements UserApi { + + private static final Logger log = LoggerFactory.getLogger(UserApiController.class); + private final ObjectMapper objectMapper; - public UserApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public UserApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123", User.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123", User.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, - @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue("aeiou", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("aeiou", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("\"\"", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity logoutUser(@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity logoutUser() { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username, - @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/FormatTest.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/FormatTest.java index 9d47a2e4245..9a7f3ff8be1 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/FormatTest.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/FormatTest.java @@ -71,7 +71,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(10) @Max(100) +@Min(10) @Max(100) public Integer getInteger() { return integer; } @@ -93,7 +93,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(20) @Max(200) +@Min(20) @Max(200) public Integer getInt32() { return int32; } @@ -137,7 +137,7 @@ public class FormatTest { @NotNull @Valid - @DecimalMin("32.1") @DecimalMax("543.2") +@DecimalMin("32.1") @DecimalMax("543.2") public BigDecimal getNumber() { return number; } @@ -159,7 +159,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("54.3") @DecimalMax("987.6") +@DecimalMin("54.3") @DecimalMax("987.6") public Float getFloat() { return _float; } @@ -181,7 +181,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("67.8") @DecimalMax("123.4") +@DecimalMin("67.8") @DecimalMax("123.4") public Double getDouble() { return _double; } @@ -201,7 +201,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Pattern(regexp="/[a-z]/i") +@Pattern(regexp="/[a-z]/i") public String getString() { return string; } @@ -222,7 +222,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") +@Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") public byte[] getByte() { return _byte; } @@ -327,7 +327,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Size(min=10,max=64) +@Size(min=10,max=64) public String getPassword() { return password; } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/AnotherFakeApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/AnotherFakeApi.java index a54382d9a2f..3c73a0fc9e8 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/AnotherFakeApi.java @@ -6,10 +6,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,16 +17,16 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "another-fake", description = "the another-fake API") public interface AnotherFakeApi { + AnotherFakeApiDelegate getDelegate(); + @ApiOperation(value = "To test special tags", nickname = "testSpecialTags", notes = "To test special tags", response = Client.class, tags={ "$another-fake?", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) @@ -35,9 +34,8 @@ public interface AnotherFakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - default ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + return getDelegate().testSpecialTags(body); } } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/AnotherFakeApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/AnotherFakeApiController.java index b1b9e947700..e3570fece01 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/AnotherFakeApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/AnotherFakeApiController.java @@ -1,32 +1,9 @@ package io.swagger.api; -import io.swagger.model.Client; - -import io.swagger.annotations.*; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import javax.validation.constraints.*; -import javax.validation.Valid; @Controller public class AnotherFakeApiController implements AnotherFakeApi { - private final ObjectMapper objectMapper; - - public AnotherFakeApiController(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } private final AnotherFakeApiDelegate delegate; @@ -35,10 +12,8 @@ public class AnotherFakeApiController implements AnotherFakeApi { this.delegate = delegate; } - public ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.testSpecialTags(body); + @Override + public AnotherFakeApiDelegate getDelegate() { + return delegate; } - } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/AnotherFakeApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/AnotherFakeApiDelegate.java index 2ff944839dc..f90bc38b5a4 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/AnotherFakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/AnotherFakeApiDelegate.java @@ -1,28 +1,57 @@ package io.swagger.api; import io.swagger.model.Client; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; +import javax.servlet.http.HttpServletRequest; import java.util.List; +import java.util.Optional; /** * A delegate to be called by the {@link AnotherFakeApiController}}. - * Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation. - * Instead, use spring to autowire this class into the {@link AnotherFakeApiController}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. */ public interface AnotherFakeApiDelegate { + Logger log = LoggerFactory.getLogger(AnotherFakeApi.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + /** * @see AnotherFakeApi#testSpecialTags */ default ResponseEntity testSpecialTags(Client body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default AnotherFakeApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApi.java index 29cfced7039..3b0cb73a377 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApi.java @@ -10,10 +10,9 @@ import io.swagger.model.Client; import java.time.LocalDate; import java.time.OffsetDateTime; import io.swagger.model.OuterComposite; - import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -22,24 +21,23 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "fake", description = "the fake API") public interface FakeApi { + FakeApiDelegate getDelegate(); + @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) @RequestMapping(value = "/fake/outer/boolean", method = RequestMethod.POST) - default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + return getDelegate().fakeOuterBooleanSerialize(body); } @@ -48,9 +46,8 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) @RequestMapping(value = "/fake/outer/composite", method = RequestMethod.POST) - default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + return getDelegate().fakeOuterCompositeSerialize(body); } @@ -59,9 +56,8 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) @RequestMapping(value = "/fake/outer/number", method = RequestMethod.POST) - default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + return getDelegate().fakeOuterNumberSerialize(body); } @@ -70,9 +66,8 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output string", response = String.class) }) @RequestMapping(value = "/fake/outer/string", method = RequestMethod.POST) - default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + return getDelegate().fakeOuterStringSerialize(body); } @@ -83,9 +78,8 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - default ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + return getDelegate().testClientModel(body); } @@ -99,9 +93,8 @@ public interface FakeApi { produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, method = RequestMethod.POST) - default ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { + return getDelegate().testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); } @@ -113,9 +106,8 @@ public interface FakeApi { produces = { "*/*" }, consumes = { "*/*" }, method = RequestMethod.GET) - default ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { + return getDelegate().testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble); } @@ -125,9 +117,8 @@ public interface FakeApi { @RequestMapping(value = "/fake/inline-additionalProperties", consumes = { "application/json" }, method = RequestMethod.POST) - default ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) { + return getDelegate().testInlineAdditionalProperties(param); } @@ -137,9 +128,8 @@ public interface FakeApi { @RequestMapping(value = "/fake/jsonFormData", consumes = { "application/json" }, method = RequestMethod.GET) - default ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) { + return getDelegate().testJsonFormData(param, param2); } } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiController.java index c898df89b45..360cfa12ad7 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiController.java @@ -1,36 +1,9 @@ package io.swagger.api; -import java.math.BigDecimal; -import io.swagger.model.Client; -import java.time.LocalDate; -import java.time.OffsetDateTime; -import io.swagger.model.OuterComposite; - -import io.swagger.annotations.*; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import javax.validation.constraints.*; -import javax.validation.Valid; @Controller public class FakeApiController implements FakeApi { - private final ObjectMapper objectMapper; - - public FakeApiController(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } private final FakeApiDelegate delegate; @@ -39,79 +12,8 @@ public class FakeApiController implements FakeApi { this.delegate = delegate; } - public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.fakeOuterBooleanSerialize(body); + @Override + public FakeApiDelegate getDelegate() { + return delegate; } - - public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.fakeOuterCompositeSerialize(body); - } - - public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.fakeOuterNumberSerialize(body); - } - - public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.fakeOuterStringSerialize(body); - } - - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.testClientModel(body); - } - - public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number, - @ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double, - @ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, - @ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte, - @ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer, - @ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32, - @ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64, - @ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float, - @ApiParam(value = "None") @RequestPart(value="string", required=false) String string, - @ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary, - @ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date, - @ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime, - @ApiParam(value = "None") @RequestPart(value="password", required=false) String password, - @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); - } - - public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray, - @ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString, - @ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray, - @ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, - @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, - @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, - @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, - @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble); - } - - public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.testInlineAdditionalProperties(param); - } - - public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param, - @ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.testJsonFormData(param, param2); - } - } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiDelegate.java index f3ce2e50bd8..c58dc82e5b9 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiDelegate.java @@ -5,60 +5,133 @@ import io.swagger.model.Client; import java.time.LocalDate; import java.time.OffsetDateTime; import io.swagger.model.OuterComposite; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; +import javax.servlet.http.HttpServletRequest; import java.util.List; +import java.util.Optional; /** * A delegate to be called by the {@link FakeApiController}}. - * Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation. - * Instead, use spring to autowire this class into the {@link FakeApiController}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. */ public interface FakeApiDelegate { + Logger log = LoggerFactory.getLogger(FakeApi.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + /** * @see FakeApi#fakeOuterBooleanSerialize */ default ResponseEntity fakeOuterBooleanSerialize(Boolean body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ }", Boolean.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see FakeApi#fakeOuterCompositeSerialize */ default ResponseEntity fakeOuterCompositeSerialize(OuterComposite body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see FakeApi#fakeOuterNumberSerialize */ default ResponseEntity fakeOuterNumberSerialize(BigDecimal body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ }", BigDecimal.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see FakeApi#fakeOuterStringSerialize */ default ResponseEntity fakeOuterStringSerialize(String body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ }", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see FakeApi#testClientModel */ default ResponseEntity testClientModel(Client body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** @@ -78,8 +151,11 @@ public interface FakeApiDelegate { OffsetDateTime dateTime, String password, String paramCallback) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** @@ -93,16 +169,22 @@ public interface FakeApiDelegate { String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see FakeApi#testInlineAdditionalProperties */ default ResponseEntity testInlineAdditionalProperties(Object param) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** @@ -110,8 +192,11 @@ public interface FakeApiDelegate { */ default ResponseEntity testJsonFormData(String param, String param2) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeClassnameTestApi.java index 9473d86b65e..ef017ee1dc8 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeClassnameTestApi.java @@ -6,10 +6,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,16 +17,16 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "fake_classname_test", description = "the fake_classname_test API") public interface FakeClassnameTestApi { + FakeClassnameTestApiDelegate getDelegate(); + @ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "", response = Client.class, authorizations = { @Authorization(value = "api_key_query") }, tags={ "fake_classname_tags 123#$%^", }) @@ -37,9 +36,8 @@ public interface FakeClassnameTestApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - default ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + return getDelegate().testClassname(body); } } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeClassnameTestApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeClassnameTestApiController.java index cd4c0acd562..865fcb34720 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeClassnameTestApiController.java @@ -1,32 +1,9 @@ package io.swagger.api; -import io.swagger.model.Client; - -import io.swagger.annotations.*; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import javax.validation.constraints.*; -import javax.validation.Valid; @Controller public class FakeClassnameTestApiController implements FakeClassnameTestApi { - private final ObjectMapper objectMapper; - - public FakeClassnameTestApiController(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } private final FakeClassnameTestApiDelegate delegate; @@ -35,10 +12,8 @@ public class FakeClassnameTestApiController implements FakeClassnameTestApi { this.delegate = delegate; } - public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.testClassname(body); + @Override + public FakeClassnameTestApiDelegate getDelegate() { + return delegate; } - } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeClassnameTestApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeClassnameTestApiDelegate.java index 4177e820636..32cb063e052 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeClassnameTestApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeClassnameTestApiDelegate.java @@ -1,28 +1,57 @@ package io.swagger.api; import io.swagger.model.Client; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; +import javax.servlet.http.HttpServletRequest; import java.util.List; +import java.util.Optional; /** * A delegate to be called by the {@link FakeClassnameTestApiController}}. - * Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation. - * Instead, use spring to autowire this class into the {@link FakeClassnameTestApiController}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. */ public interface FakeClassnameTestApiDelegate { + Logger log = LoggerFactory.getLogger(FakeClassnameTestApi.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + /** * @see FakeClassnameTestApi#testClassname */ default ResponseEntity testClassname(Client body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FakeClassnameTestApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java index 97b085a2b78..b892573f52c 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java @@ -8,10 +8,9 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -20,16 +19,16 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "pet", description = "the pet API") public interface PetApi { + PetApiDelegate getDelegate(); + @ApiOperation(value = "Add a new pet to the store", nickname = "addPet", notes = "", authorizations = { @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @@ -42,9 +41,8 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.POST) - default ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + return getDelegate().addPet(body); } @@ -59,9 +57,8 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { + return getDelegate().deletePet(petId, apiKey); } @@ -77,9 +74,8 @@ public interface PetApi { @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity>(HttpStatus.OK); + default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { + return getDelegate().findPetsByStatus(status); } @@ -95,9 +91,8 @@ public interface PetApi { @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity>(HttpStatus.OK); + default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { + return getDelegate().findPetsByTags(tags); } @@ -111,9 +106,8 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { + return getDelegate().getPetById(petId); } @@ -131,9 +125,8 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.PUT) - default ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + return getDelegate().updatePet(body); } @@ -149,9 +142,8 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { + return getDelegate().updatePetWithForm(petId, name, status); } @@ -167,9 +159,8 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) { + return getDelegate().uploadFile(petId, additionalMetadata, file); } } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java index 066d7075248..bbcd9229039 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java @@ -1,34 +1,9 @@ package io.swagger.api; -import io.swagger.model.ModelApiResponse; -import io.swagger.model.Pet; -import org.springframework.core.io.Resource; - -import io.swagger.annotations.*; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import javax.validation.constraints.*; -import javax.validation.Valid; @Controller public class PetApiController implements PetApi { - private final ObjectMapper objectMapper; - - public PetApiController(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } private final PetApiDelegate delegate; @@ -37,57 +12,8 @@ public class PetApiController implements PetApi { this.delegate = delegate; } - public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.addPet(body); + @Override + public PetApiDelegate getDelegate() { + return delegate; } - - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.deletePet(petId, apiKey); - } - - public ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.findPetsByStatus(status); - } - - public ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.findPetsByTags(tags); - } - - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.getPetById(petId); - } - - public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.updatePet(body); - } - - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, - @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.updatePetWithForm(petId, name, status); - } - - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.uploadFile(petId, additionalMetadata, file); - } - } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiDelegate.java index 265e7046956..065e3d60441 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiDelegate.java @@ -3,28 +3,49 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; +import javax.servlet.http.HttpServletRequest; import java.util.List; +import java.util.Optional; /** * A delegate to be called by the {@link PetApiController}}. - * Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation. - * Instead, use spring to autowire this class into the {@link PetApiController}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. */ public interface PetApiDelegate { + Logger log = LoggerFactory.getLogger(PetApi.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + /** * @see PetApi#addPet */ default ResponseEntity addPet(Pet body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** @@ -32,40 +53,103 @@ public interface PetApiDelegate { */ default ResponseEntity deletePet(Long petId, String apiKey) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see PetApi#findPetsByStatus */ default ResponseEntity> findPetsByStatus(List status) { - // do some magic! - return new ResponseEntity>(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/xml")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see PetApi#findPetsByTags */ default ResponseEntity> findPetsByTags(List tags) { - // do some magic! - return new ResponseEntity>(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/xml")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see PetApi#getPetById */ default ResponseEntity getPetById(Long petId) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/xml")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue(" 123456789 doggie aeiou aeiou", Pet.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see PetApi#updatePet */ default ResponseEntity updatePet(Pet body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** @@ -74,8 +158,11 @@ public interface PetApiDelegate { default ResponseEntity updatePetWithForm(Long petId, String name, String status) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** @@ -84,8 +171,19 @@ public interface PetApiDelegate { default ResponseEntity uploadFile(Long petId, String additionalMetadata, MultipartFile file) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApi.java index 429c00ba069..40a3b4f23f3 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApi.java @@ -7,10 +7,9 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -19,16 +18,16 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "store", description = "the store API") public interface StoreApi { + StoreApiDelegate getDelegate(); + @ApiOperation(value = "Delete purchase order by ID", nickname = "deleteOrder", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @@ -36,9 +35,8 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { + return getDelegate().deleteOrder(orderId); } @@ -50,9 +48,8 @@ public interface StoreApi { @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - default ResponseEntity> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity>(HttpStatus.OK); + default ResponseEntity> getInventory() { + return getDelegate().getInventory(); } @@ -64,9 +61,8 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { + return getDelegate().getOrderById(orderId); } @@ -77,9 +73,8 @@ public interface StoreApi { @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - default ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { + return getDelegate().placeOrder(body); } } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiController.java index 45235d0af2e..a47931a4f70 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiController.java @@ -1,33 +1,9 @@ package io.swagger.api; -import java.util.Map; -import io.swagger.model.Order; - -import io.swagger.annotations.*; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import javax.validation.constraints.*; -import javax.validation.Valid; @Controller public class StoreApiController implements StoreApi { - private final ObjectMapper objectMapper; - - public StoreApiController(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } private final StoreApiDelegate delegate; @@ -36,27 +12,8 @@ public class StoreApiController implements StoreApi { this.delegate = delegate; } - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.deleteOrder(orderId); + @Override + public StoreApiDelegate getDelegate() { + return delegate; } - - public ResponseEntity> getInventory(@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.getInventory(); - } - - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.getOrderById(orderId); - } - - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.placeOrder(body); - } - } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiDelegate.java index 17a4dfc2a9d..17583c39939 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiDelegate.java @@ -2,52 +2,122 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; +import javax.servlet.http.HttpServletRequest; import java.util.List; +import java.util.Optional; /** * A delegate to be called by the {@link StoreApiController}}. - * Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation. - * Instead, use spring to autowire this class into the {@link StoreApiController}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. */ public interface StoreApiDelegate { + Logger log = LoggerFactory.getLogger(StoreApi.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + /** * @see StoreApi#deleteOrder */ default ResponseEntity deleteOrder(String orderId) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see StoreApi#getInventory */ default ResponseEntity> getInventory() { - // do some magic! - return new ResponseEntity>(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"key\" : 0}", Map.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see StoreApi#getOrderById */ default ResponseEntity getOrderById(Long orderId) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/xml")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see StoreApi#placeOrder */ default ResponseEntity placeOrder(Order body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/xml")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApi.java index 2ab8710c94e..db6ab0443be 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApi.java @@ -7,10 +7,9 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -19,25 +18,24 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "user", description = "the user API") public interface UserApi { + UserApiDelegate getDelegate(); + @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) @RequestMapping(value = "/user", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - default ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + return getDelegate().createUser(body); } @@ -47,9 +45,8 @@ public interface UserApi { @RequestMapping(value = "/user/createWithArray", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - default ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + return getDelegate().createUsersWithArrayInput(body); } @@ -59,9 +56,8 @@ public interface UserApi { @RequestMapping(value = "/user/createWithList", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - default ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + return getDelegate().createUsersWithListInput(body); } @@ -72,9 +68,8 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { + return getDelegate().deleteUser(username); } @@ -86,9 +81,8 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) { + return getDelegate().getUserByName(username); } @@ -99,9 +93,8 @@ public interface UserApi { @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { + return getDelegate().loginUser(username, password); } @@ -111,9 +104,8 @@ public interface UserApi { @RequestMapping(value = "/user/logout", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity logoutUser() { + return getDelegate().logoutUser(); } @@ -124,9 +116,8 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - default ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + default ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { + return getDelegate().updateUser(username, body); } } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiController.java index 0477eadb15c..3690e9ad6ab 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiController.java @@ -1,33 +1,9 @@ package io.swagger.api; -import java.util.List; -import io.swagger.model.User; - -import io.swagger.annotations.*; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import javax.validation.constraints.*; -import javax.validation.Valid; @Controller public class UserApiController implements UserApi { - private final ObjectMapper objectMapper; - - public UserApiController(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } private final UserApiDelegate delegate; @@ -36,53 +12,8 @@ public class UserApiController implements UserApi { this.delegate = delegate; } - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.createUser(body); + @Override + public UserApiDelegate getDelegate() { + return delegate; } - - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.createUsersWithArrayInput(body); - } - - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.createUsersWithListInput(body); - } - - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.deleteUser(username); - } - - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.getUserByName(username); - } - - public ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, - @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.loginUser(username, password); - } - - public ResponseEntity logoutUser(@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.logoutUser(); - } - - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username, - @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return delegate.updateUser(username, body); - } - } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiDelegate.java index 435efd58a8e..4e56d2e9252 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiDelegate.java @@ -2,60 +2,109 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; +import javax.servlet.http.HttpServletRequest; import java.util.List; +import java.util.Optional; /** * A delegate to be called by the {@link UserApiController}}. - * Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation. - * Instead, use spring to autowire this class into the {@link UserApiController}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. */ public interface UserApiDelegate { + Logger log = LoggerFactory.getLogger(UserApi.class); + + default Optional getObjectMapper() { + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + /** * @see UserApi#createUser */ default ResponseEntity createUser(User body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see UserApi#createUsersWithArrayInput */ default ResponseEntity createUsersWithArrayInput(List body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see UserApi#createUsersWithListInput */ default ResponseEntity createUsersWithListInput(List body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see UserApi#deleteUser */ default ResponseEntity deleteUser(String username) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see UserApi#getUserByName */ default ResponseEntity getUserByName(String username) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/xml")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123", User.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** @@ -63,16 +112,38 @@ public interface UserApiDelegate { */ default ResponseEntity loginUser(String username, String password) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/xml")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("aeiou", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** * @see UserApi#logoutUser */ default ResponseEntity logoutUser() { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** @@ -80,8 +151,11 @@ public interface UserApiDelegate { */ default ResponseEntity updateUser(String username, User body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/model/FormatTest.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/model/FormatTest.java index e809ba3ca62..c73949ecf4f 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/model/FormatTest.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/model/FormatTest.java @@ -71,7 +71,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(10) @Max(100) +@Min(10) @Max(100) public Integer getInteger() { return integer; } @@ -93,7 +93,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(20) @Max(200) +@Min(20) @Max(200) public Integer getInt32() { return int32; } @@ -137,7 +137,7 @@ public class FormatTest { @NotNull @Valid - @DecimalMin("32.1") @DecimalMax("543.2") +@DecimalMin("32.1") @DecimalMax("543.2") public BigDecimal getNumber() { return number; } @@ -159,7 +159,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("54.3") @DecimalMax("987.6") +@DecimalMin("54.3") @DecimalMax("987.6") public Float getFloat() { return _float; } @@ -181,7 +181,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("67.8") @DecimalMax("123.4") +@DecimalMin("67.8") @DecimalMax("123.4") public Double getDouble() { return _double; } @@ -201,7 +201,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Pattern(regexp="/[a-z]/i") +@Pattern(regexp="/[a-z]/i") public String getString() { return string; } @@ -222,7 +222,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") +@Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") public byte[] getByte() { return _byte; } @@ -327,7 +327,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Size(min=10,max=64) +@Size(min=10,max=64) public String getPassword() { return password; } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/AnotherFakeApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/AnotherFakeApi.java index a3fcfabaf12..6f6dd920913 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/AnotherFakeApi.java @@ -6,9 +6,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -17,12 +17,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "another-fake", description = "the another-fake API") public interface AnotherFakeApi { @@ -34,6 +32,6 @@ public interface AnotherFakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/AnotherFakeApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/AnotherFakeApiController.java index b1b9e947700..a6ed5ef62c8 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/AnotherFakeApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/AnotherFakeApiController.java @@ -1,9 +1,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -14,19 +14,12 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import java.util.List; @Controller public class AnotherFakeApiController implements AnotherFakeApi { - private final ObjectMapper objectMapper; - - public AnotherFakeApiController(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } private final AnotherFakeApiDelegate delegate; @@ -34,10 +27,7 @@ public class AnotherFakeApiController implements AnotherFakeApi { public AnotherFakeApiController(AnotherFakeApiDelegate delegate) { this.delegate = delegate; } - - public ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { return delegate.testSpecialTags(body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/AnotherFakeApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/AnotherFakeApiDelegate.java index b2b85be5817..78d22f6d607 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/AnotherFakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/AnotherFakeApiDelegate.java @@ -1,7 +1,6 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; @@ -10,8 +9,7 @@ import java.util.List; /** * A delegate to be called by the {@link AnotherFakeApiController}}. - * Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation. - * Instead, use spring to autowire this class into the {@link AnotherFakeApiController}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. */ public interface AnotherFakeApiDelegate { diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApi.java index 814003e2086..92b47fb2a37 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApi.java @@ -10,9 +10,9 @@ import io.swagger.model.Client; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import io.swagger.model.OuterComposite; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -21,12 +21,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "fake", description = "the fake API") public interface FakeApi { @@ -36,7 +34,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) @RequestMapping(value = "/fake/outer/boolean", method = RequestMethod.POST) - ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body); @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @@ -44,7 +42,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) @RequestMapping(value = "/fake/outer/composite", method = RequestMethod.POST) - ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body); @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @@ -52,7 +50,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) @RequestMapping(value = "/fake/outer/number", method = RequestMethod.POST) - ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body); @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @@ -60,7 +58,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output string", response = String.class) }) @RequestMapping(value = "/fake/outer/string", method = RequestMethod.POST) - ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body); @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @@ -70,7 +68,7 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = { @@ -83,7 +81,7 @@ public interface FakeApi { produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, method = RequestMethod.POST) - ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback); @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) @@ -94,7 +92,7 @@ public interface FakeApi { produces = { "*/*" }, consumes = { "*/*" }, method = RequestMethod.GET) - ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble); @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @@ -103,7 +101,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/inline-additionalProperties", consumes = { "application/json" }, method = RequestMethod.POST) - ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param); @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @@ -112,6 +110,6 @@ public interface FakeApi { @RequestMapping(value = "/fake/jsonFormData", consumes = { "application/json" }, method = RequestMethod.GET) - ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiController.java index 1f9c4d4fd12..6e05955afe3 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiController.java @@ -5,9 +5,9 @@ import io.swagger.model.Client; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import io.swagger.model.OuterComposite; - import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -18,19 +18,12 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import java.util.List; @Controller public class FakeApiController implements FakeApi { - private final ObjectMapper objectMapper; - - public FakeApiController(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } private final FakeApiDelegate delegate; @@ -38,79 +31,39 @@ public class FakeApiController implements FakeApi { public FakeApiController(FakeApiDelegate delegate) { this.delegate = delegate; } - - public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { return delegate.fakeOuterBooleanSerialize(body); } - public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { return delegate.fakeOuterCompositeSerialize(body); } - public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { return delegate.fakeOuterNumberSerialize(body); } - public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { return delegate.fakeOuterStringSerialize(body); } - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { return delegate.testClientModel(body); } - public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number, - @ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double, - @ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, - @ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte, - @ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer, - @ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32, - @ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64, - @ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float, - @ApiParam(value = "None") @RequestPart(value="string", required=false) String string, - @ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary, - @ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date, - @ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime, - @ApiParam(value = "None") @RequestPart(value="password", required=false) String password, - @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { return delegate.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); } - public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray, - @ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString, - @ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray, - @ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, - @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, - @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, - @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, - @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { return delegate.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble); } - public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) { return delegate.testInlineAdditionalProperties(param); } - public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param, - @ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) { return delegate.testJsonFormData(param, param2); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiDelegate.java index d4f5be8dbe7..297dfe50ea2 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiDelegate.java @@ -5,7 +5,6 @@ import io.swagger.model.Client; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import io.swagger.model.OuterComposite; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; @@ -14,8 +13,7 @@ import java.util.List; /** * A delegate to be called by the {@link FakeApiController}}. - * Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation. - * Instead, use spring to autowire this class into the {@link FakeApiController}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. */ public interface FakeApiDelegate { diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeClassnameTestApi.java index 00fffe8a123..8316190673c 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeClassnameTestApi.java @@ -6,9 +6,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -17,12 +17,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "fake_classname_test", description = "the fake_classname_test API") public interface FakeClassnameTestApi { @@ -36,6 +34,6 @@ public interface FakeClassnameTestApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeClassnameTestApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeClassnameTestApiController.java index cd4c0acd562..1db51794a68 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeClassnameTestApiController.java @@ -1,9 +1,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -14,19 +14,12 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import java.util.List; @Controller public class FakeClassnameTestApiController implements FakeClassnameTestApi { - private final ObjectMapper objectMapper; - - public FakeClassnameTestApiController(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } private final FakeClassnameTestApiDelegate delegate; @@ -34,10 +27,7 @@ public class FakeClassnameTestApiController implements FakeClassnameTestApi { public FakeClassnameTestApiController(FakeClassnameTestApiDelegate delegate) { this.delegate = delegate; } - - public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { return delegate.testClassname(body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeClassnameTestApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeClassnameTestApiDelegate.java index 35615202ad3..e17c67de45e 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeClassnameTestApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeClassnameTestApiDelegate.java @@ -1,7 +1,6 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; @@ -10,8 +9,7 @@ import java.util.List; /** * A delegate to be called by the {@link FakeClassnameTestApiController}}. - * Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation. - * Instead, use spring to autowire this class into the {@link FakeClassnameTestApiController}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. */ public interface FakeClassnameTestApiDelegate { diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java index 247fa4dec59..d4604e9380e 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java @@ -8,9 +8,9 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -19,12 +19,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "pet", description = "the pet API") public interface PetApi { @@ -41,7 +39,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.POST) - ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = { @@ -55,7 +53,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -70,7 +68,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status); @ApiOperation(value = "Finds Pets by tags", nickname = "findPetsByTags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -85,7 +83,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags); @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -98,7 +96,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -115,7 +113,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.PUT) - ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = { @@ -130,7 +128,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status); @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -145,6 +143,6 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java index 066d7075248..e688818e64e 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java @@ -3,9 +3,9 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -16,19 +16,12 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import java.util.List; @Controller public class PetApiController implements PetApi { - private final ObjectMapper objectMapper; - - public PetApiController(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } private final PetApiDelegate delegate; @@ -36,57 +29,35 @@ public class PetApiController implements PetApi { public PetApiController(PetApiDelegate delegate) { this.delegate = delegate; } - - public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return delegate.addPet(body); } - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { return delegate.deletePet(petId, apiKey); } - public ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { return delegate.findPetsByStatus(status); } - public ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { return delegate.findPetsByTags(tags); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { return delegate.getPetById(petId); } - public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return delegate.updatePet(body); } - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, - @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { return delegate.updatePetWithForm(petId, name, status); } - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) { return delegate.uploadFile(petId, additionalMetadata, file); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiDelegate.java index fef5d600cc4..33e49dca56a 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiDelegate.java @@ -3,7 +3,6 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; @@ -12,8 +11,7 @@ import java.util.List; /** * A delegate to be called by the {@link PetApiController}}. - * Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation. - * Instead, use spring to autowire this class into the {@link PetApiController}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. */ public interface PetApiDelegate { diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApi.java index f0dd4e2d631..f23d712511f 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,12 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "store", description = "the store API") public interface StoreApi { @@ -35,7 +33,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId); @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -46,7 +44,7 @@ public interface StoreApi { @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - ResponseEntity> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> getInventory(); @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) @@ -57,7 +55,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId); @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) @@ -67,6 +65,6 @@ public interface StoreApi { @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiController.java index 45235d0af2e..58c433d2f64 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiController.java @@ -2,9 +2,9 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -15,19 +15,12 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import java.util.List; @Controller public class StoreApiController implements StoreApi { - private final ObjectMapper objectMapper; - - public StoreApiController(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } private final StoreApiDelegate delegate; @@ -35,27 +28,19 @@ public class StoreApiController implements StoreApi { public StoreApiController(StoreApiDelegate delegate) { this.delegate = delegate; } - - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { return delegate.deleteOrder(orderId); } - public ResponseEntity> getInventory(@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity> getInventory() { return delegate.getInventory(); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { return delegate.getOrderById(orderId); } - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { return delegate.placeOrder(body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiDelegate.java index ddf2901926a..beb95d79367 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiDelegate.java @@ -2,7 +2,6 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; @@ -11,8 +10,7 @@ import java.util.List; /** * A delegate to be called by the {@link StoreApiController}}. - * Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation. - * Instead, use spring to autowire this class into the {@link StoreApiController}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. */ public interface StoreApiDelegate { diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApi.java index 0f8609bc6ac..3dbcf7293cd 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,12 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "user", description = "the user API") public interface UserApi { @@ -34,7 +32,7 @@ public interface UserApi { @RequestMapping(value = "/user", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @@ -43,7 +41,7 @@ public interface UserApi { @RequestMapping(value = "/user/createWithArray", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @@ -52,7 +50,7 @@ public interface UserApi { @RequestMapping(value = "/user/createWithList", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @@ -62,7 +60,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -73,7 +71,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username); @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -83,7 +81,7 @@ public interface UserApi { @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password); @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @@ -92,7 +90,7 @@ public interface UserApi { @RequestMapping(value = "/user/logout", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity logoutUser(); @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @@ -102,6 +100,6 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiController.java index 0477eadb15c..41425f19af1 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiController.java @@ -2,9 +2,9 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -15,19 +15,12 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import java.util.List; @Controller public class UserApiController implements UserApi { - private final ObjectMapper objectMapper; - - public UserApiController(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } private final UserApiDelegate delegate; @@ -35,53 +28,35 @@ public class UserApiController implements UserApi { public UserApiController(UserApiDelegate delegate) { this.delegate = delegate; } - - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { return delegate.createUser(body); } - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return delegate.createUsersWithArrayInput(body); } - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return delegate.createUsersWithListInput(body); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { return delegate.deleteUser(username); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) { return delegate.getUserByName(username); } - public ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, - @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { return delegate.loginUser(username, password); } - public ResponseEntity logoutUser(@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity logoutUser() { return delegate.logoutUser(); } - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username, - @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { return delegate.updateUser(username, body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiDelegate.java index 7c2e86e1a95..4c4d0905c8b 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiDelegate.java @@ -2,7 +2,6 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; @@ -11,8 +10,7 @@ import java.util.List; /** * A delegate to be called by the {@link UserApiController}}. - * Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation. - * Instead, use spring to autowire this class into the {@link UserApiController}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. */ public interface UserApiDelegate { diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/model/FormatTest.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/model/FormatTest.java index 9d47a2e4245..9a7f3ff8be1 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/model/FormatTest.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/model/FormatTest.java @@ -71,7 +71,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(10) @Max(100) +@Min(10) @Max(100) public Integer getInteger() { return integer; } @@ -93,7 +93,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(20) @Max(200) +@Min(20) @Max(200) public Integer getInt32() { return int32; } @@ -137,7 +137,7 @@ public class FormatTest { @NotNull @Valid - @DecimalMin("32.1") @DecimalMax("543.2") +@DecimalMin("32.1") @DecimalMax("543.2") public BigDecimal getNumber() { return number; } @@ -159,7 +159,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("54.3") @DecimalMax("987.6") +@DecimalMin("54.3") @DecimalMax("987.6") public Float getFloat() { return _float; } @@ -181,7 +181,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("67.8") @DecimalMax("123.4") +@DecimalMin("67.8") @DecimalMax("123.4") public Double getDouble() { return _double; } @@ -201,7 +201,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Pattern(regexp="/[a-z]/i") +@Pattern(regexp="/[a-z]/i") public String getString() { return string; } @@ -222,7 +222,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") +@Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") public byte[] getByte() { return _byte; } @@ -327,7 +327,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Size(min=10,max=64) +@Size(min=10,max=64) public String getPassword() { return password; } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/AnotherFakeApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/AnotherFakeApi.java index d9e7d4a9fbb..b64d01acfd1 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/AnotherFakeApi.java @@ -6,9 +6,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -17,12 +17,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "another-fake", description = "the another-fake API") public interface AnotherFakeApi { @@ -36,6 +34,6 @@ public interface AnotherFakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/AnotherFakeApiController.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/AnotherFakeApiController.java index 02fe84a126e..1f969f15713 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/AnotherFakeApiController.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/AnotherFakeApiController.java @@ -1,9 +1,10 @@ package io.swagger.api; import io.swagger.model.Client; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -14,29 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class AnotherFakeApiController implements AnotherFakeApi { + + private static final Logger log = LoggerFactory.getLogger(AnotherFakeApiController.class); + private final ObjectMapper objectMapper; - public AnotherFakeApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public AnotherFakeApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApi.java index 75bd99fd360..9c60fd29bea 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApi.java @@ -10,9 +10,9 @@ import io.swagger.model.Client; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import io.swagger.model.OuterComposite; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -21,12 +21,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "fake", description = "the fake API") public interface FakeApi { @@ -38,7 +36,7 @@ public interface FakeApi { }) @RequestMapping(value = "/fake/outer/boolean", method = RequestMethod.POST) - ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body); @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @@ -48,7 +46,7 @@ public interface FakeApi { }) @RequestMapping(value = "/fake/outer/composite", method = RequestMethod.POST) - ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body); @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @@ -58,7 +56,7 @@ public interface FakeApi { }) @RequestMapping(value = "/fake/outer/number", method = RequestMethod.POST) - ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body); @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @@ -68,7 +66,7 @@ public interface FakeApi { }) @RequestMapping(value = "/fake/outer/string", method = RequestMethod.POST) - ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body); @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @@ -80,7 +78,7 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = { @@ -95,7 +93,7 @@ public interface FakeApi { produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, method = RequestMethod.POST) - ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback); @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) @@ -110,7 +108,7 @@ public interface FakeApi { produces = { "*/*" }, consumes = { "*/*" }, method = RequestMethod.GET) - ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble); @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @@ -121,7 +119,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/inline-additionalProperties", consumes = { "application/json" }, method = RequestMethod.POST) - ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param); @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @@ -132,6 +130,6 @@ public interface FakeApi { @RequestMapping(value = "/fake/jsonFormData", consumes = { "application/json" }, method = RequestMethod.GET) - ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2); } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApiController.java index 36b114491c4..9d135bee8d7 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApiController.java @@ -5,9 +5,10 @@ import io.swagger.model.Client; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import io.swagger.model.OuterComposite; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -18,116 +19,115 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class FakeApiController implements FakeApi { + + private static final Logger log = LoggerFactory.getLogger(FakeApiController.class); + private final ObjectMapper objectMapper; - public FakeApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", Boolean.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", Boolean.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number, - @ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double, - @ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, - @ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte, - @ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer, - @ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32, - @ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64, - @ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float, - @ApiParam(value = "None") @RequestPart(value="string", required=false) String string, - @ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary, - @ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date, - @ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime, - @ApiParam(value = "None") @RequestPart(value="password", required=false) String password, - @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray, - @ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString, - @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, - @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, - @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, - @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param, - @ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeClassnameTestApi.java index 4625f340a18..6fd233b0e39 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeClassnameTestApi.java @@ -6,9 +6,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -17,12 +17,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "fake_classname_test", description = "the fake_classname_test API") public interface FakeClassnameTestApi { @@ -38,6 +36,6 @@ public interface FakeClassnameTestApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeClassnameTestApiController.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeClassnameTestApiController.java index ea2c0016470..37288b4c860 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeClassnameTestApiController.java @@ -1,9 +1,10 @@ package io.swagger.api; import io.swagger.model.Client; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -14,29 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class FakeClassnameTestApiController implements FakeClassnameTestApi { + + private static final Logger log = LoggerFactory.getLogger(FakeClassnameTestApiController.class); + private final ObjectMapper objectMapper; - public FakeClassnameTestApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeClassnameTestApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApi.java index da2e8650690..81a60b11f13 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApi.java @@ -8,9 +8,9 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -19,12 +19,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "pet", description = "the pet API") public interface PetApi { @@ -43,7 +41,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.POST) - ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = { @@ -60,7 +58,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId); @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -77,7 +75,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status); @ApiOperation(value = "Finds Pets by tags", nickname = "findPetsByTags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -94,7 +92,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags); @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -109,7 +107,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -128,7 +126,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.PUT) - ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = { @@ -145,7 +143,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status); @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -162,6 +160,6 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file); } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApiController.java index 731b377d9bf..9bf771741b8 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApiController.java @@ -3,9 +3,10 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -16,105 +17,128 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class PetApiController implements PetApi { + + private static final Logger log = LoggerFactory.getLogger(PetApiController.class); + private final ObjectMapper objectMapper; - public PetApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public PetApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 doggie aeiou aeiou", Pet.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 doggie aeiou aeiou", Pet.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, - @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApi.java index 5e1427e459b..f6d21087d1b 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,12 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "store", description = "the store API") public interface StoreApi { @@ -37,7 +35,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId); @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -50,7 +48,7 @@ public interface StoreApi { @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - ResponseEntity> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> getInventory(); @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) @@ -63,7 +61,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId); @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) @@ -75,6 +73,6 @@ public interface StoreApi { @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApiController.java index 8d84a45d949..6e463e1307f 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApiController.java @@ -2,9 +2,10 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -15,66 +16,90 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class StoreApiController implements StoreApi { + + private static final Logger log = LoggerFactory.getLogger(StoreApiController.class); + private final ObjectMapper objectMapper; - public StoreApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public StoreApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> getInventory(@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> getInventory() { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApi.java index cce5a66a1ac..04bd05d9973 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,12 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "user", description = "the user API") public interface UserApi { @@ -36,7 +34,7 @@ public interface UserApi { @RequestMapping(value = "/user", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @@ -47,7 +45,7 @@ public interface UserApi { @RequestMapping(value = "/user/createWithArray", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @@ -58,7 +56,7 @@ public interface UserApi { @RequestMapping(value = "/user/createWithList", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @@ -70,7 +68,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -83,7 +81,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username); @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -95,7 +93,7 @@ public interface UserApi { @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password); @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @@ -106,7 +104,7 @@ public interface UserApi { @RequestMapping(value = "/user/logout", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity logoutUser(); @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @@ -118,6 +116,6 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApiController.java index b0bf6f65380..e96dfe648b4 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApiController.java @@ -2,9 +2,10 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -15,87 +16,101 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class UserApiController implements UserApi { + + private static final Logger log = LoggerFactory.getLogger(UserApiController.class); + private final ObjectMapper objectMapper; - public UserApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public UserApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123", User.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123", User.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, - @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue("aeiou", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("aeiou", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("\"\"", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity logoutUser(@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity logoutUser() { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username, - @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/model/FormatTest.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/model/FormatTest.java index 9d47a2e4245..9a7f3ff8be1 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/model/FormatTest.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/model/FormatTest.java @@ -71,7 +71,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(10) @Max(100) +@Min(10) @Max(100) public Integer getInteger() { return integer; } @@ -93,7 +93,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(20) @Max(200) +@Min(20) @Max(200) public Integer getInt32() { return int32; } @@ -137,7 +137,7 @@ public class FormatTest { @NotNull @Valid - @DecimalMin("32.1") @DecimalMax("543.2") +@DecimalMin("32.1") @DecimalMax("543.2") public BigDecimal getNumber() { return number; } @@ -159,7 +159,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("54.3") @DecimalMax("987.6") +@DecimalMin("54.3") @DecimalMax("987.6") public Float getFloat() { return _float; } @@ -181,7 +181,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("67.8") @DecimalMax("123.4") +@DecimalMin("67.8") @DecimalMax("123.4") public Double getDouble() { return _double; } @@ -201,7 +201,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Pattern(regexp="/[a-z]/i") +@Pattern(regexp="/[a-z]/i") public String getString() { return string; } @@ -222,7 +222,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") +@Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") public byte[] getByte() { return _byte; } @@ -327,7 +327,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Size(min=10,max=64) +@Size(min=10,max=64) public String getPassword() { return password; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/AnotherFakeApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/AnotherFakeApi.java index 62ca3f0eaa2..8364594a3ee 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/AnotherFakeApi.java @@ -6,9 +6,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -17,13 +17,11 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; +import javax.validation.Valid; +import javax.validation.constraints.*; import java.util.List; import java.util.Optional; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; -import javax.validation.Valid; @Api(value = "another-fake", description = "the another-fake API") public interface AnotherFakeApi { @@ -35,6 +33,6 @@ public interface AnotherFakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/AnotherFakeApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/AnotherFakeApiController.java index 6868090b4db..a730e5898f0 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/AnotherFakeApiController.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/AnotherFakeApiController.java @@ -1,9 +1,10 @@ package io.swagger.api; import io.swagger.model.Client; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -14,30 +15,40 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import java.util.Optional; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; +import java.io.IOException; +import java.util.List; @Controller public class AnotherFakeApiController implements AnotherFakeApi { + + private static final Logger log = LoggerFactory.getLogger(AnotherFakeApiController.class); + private final ObjectMapper objectMapper; - public AnotherFakeApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public AnotherFakeApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApi.java index 60ba7b12cbe..4daad28bdb5 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApi.java @@ -10,9 +10,9 @@ import io.swagger.model.Client; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import io.swagger.model.OuterComposite; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -21,13 +21,11 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; +import javax.validation.Valid; +import javax.validation.constraints.*; import java.util.List; import java.util.Optional; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; -import javax.validation.Valid; @Api(value = "fake", description = "the fake API") public interface FakeApi { @@ -37,7 +35,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) @RequestMapping(value = "/fake/outer/boolean", method = RequestMethod.POST) - ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body); @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @@ -45,7 +43,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) @RequestMapping(value = "/fake/outer/composite", method = RequestMethod.POST) - ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body); @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @@ -53,7 +51,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) @RequestMapping(value = "/fake/outer/number", method = RequestMethod.POST) - ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body); @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @@ -61,7 +59,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output string", response = String.class) }) @RequestMapping(value = "/fake/outer/string", method = RequestMethod.POST) - ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body); @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @@ -71,7 +69,7 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = { @@ -84,7 +82,7 @@ public interface FakeApi { produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, method = RequestMethod.POST) - ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback); @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) @@ -95,7 +93,7 @@ public interface FakeApi { produces = { "*/*" }, consumes = { "*/*" }, method = RequestMethod.GET) - ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) Optional> enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) Optional enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) Optional> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") Optional enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Optional enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) Optional> enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) Optional enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) Optional> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") Optional enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Optional enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble); @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @@ -104,7 +102,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/inline-additionalProperties", consumes = { "application/json" }, method = RequestMethod.POST) - ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param); @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @@ -113,6 +111,6 @@ public interface FakeApi { @RequestMapping(value = "/fake/jsonFormData", consumes = { "application/json" }, method = RequestMethod.GET) - ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2); } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApiController.java index 7a93d8657c7..55c9b827cc7 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApiController.java @@ -5,9 +5,10 @@ import io.swagger.model.Client; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import io.swagger.model.OuterComposite; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -18,119 +19,116 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import java.util.Optional; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; +import java.io.IOException; +import java.util.List; @Controller public class FakeApiController implements FakeApi { + + private static final Logger log = LoggerFactory.getLogger(FakeApiController.class); + private final ObjectMapper objectMapper; - public FakeApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", Boolean.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", Boolean.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number, - @ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double, - @ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, - @ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte, - @ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer, - @ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32, - @ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64, - @ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float, - @ApiParam(value = "None") @RequestPart(value="string", required=false) String string, - @ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary, - @ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date, - @ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime, - @ApiParam(value = "None") @RequestPart(value="password", required=false) String password, - @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray, - @ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString, - @ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) Optional> enumHeaderStringArray, - @ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) Optional enumHeaderString, - @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) Optional> enumQueryStringArray, - @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") Optional enumQueryString, - @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Optional enumQueryInteger, - @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) Optional> enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) Optional enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) Optional> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") Optional enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Optional enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param, - @ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeClassnameTestApi.java index 18477c21ccf..a2041e4522a 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeClassnameTestApi.java @@ -6,9 +6,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -17,13 +17,11 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; +import javax.validation.Valid; +import javax.validation.constraints.*; import java.util.List; import java.util.Optional; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; -import javax.validation.Valid; @Api(value = "fake_classname_test", description = "the fake_classname_test API") public interface FakeClassnameTestApi { @@ -37,6 +35,6 @@ public interface FakeClassnameTestApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeClassnameTestApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeClassnameTestApiController.java index 211f2f7487c..a87bffa6586 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeClassnameTestApiController.java @@ -1,9 +1,10 @@ package io.swagger.api; import io.swagger.model.Client; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -14,30 +15,40 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import java.util.Optional; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; +import java.io.IOException; +import java.util.List; @Controller public class FakeClassnameTestApiController implements FakeClassnameTestApi { + + private static final Logger log = LoggerFactory.getLogger(FakeClassnameTestApiController.class); + private final ObjectMapper objectMapper; - public FakeClassnameTestApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeClassnameTestApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApi.java index a185f9061ae..3fe21700e12 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApi.java @@ -8,9 +8,9 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -19,13 +19,11 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; +import javax.validation.Valid; +import javax.validation.constraints.*; import java.util.List; import java.util.Optional; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; -import javax.validation.Valid; @Api(value = "pet", description = "the pet API") public interface PetApi { @@ -42,7 +40,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.POST) - ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = { @@ -56,7 +54,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) Optional apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) Optional apiKey); @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -71,7 +69,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status); @ApiOperation(value = "Finds Pets by tags", nickname = "findPetsByTags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -86,7 +84,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags); @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -99,7 +97,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -116,7 +114,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.PUT) - ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = { @@ -131,7 +129,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status); @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -146,6 +144,6 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file); } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApiController.java index 5d82b397bb7..9e97a9347ff 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApiController.java @@ -3,9 +3,10 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -16,107 +17,129 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import java.util.Optional; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; +import java.io.IOException; +import java.util.List; @Controller public class PetApiController implements PetApi { + + private static final Logger log = LoggerFactory.getLogger(PetApiController.class); + private final ObjectMapper objectMapper; - public PetApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public PetApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) Optional apiKey, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) Optional apiKey) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 doggie aeiou aeiou", Pet.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 doggie aeiou aeiou", Pet.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, - @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApi.java index 3df1045f37a..021b7830489 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,13 +18,11 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; +import javax.validation.Valid; +import javax.validation.constraints.*; import java.util.List; import java.util.Optional; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; -import javax.validation.Valid; @Api(value = "store", description = "the store API") public interface StoreApi { @@ -36,7 +34,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId); @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -47,7 +45,7 @@ public interface StoreApi { @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - ResponseEntity> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> getInventory(); @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) @@ -58,7 +56,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId); @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) @@ -68,6 +66,6 @@ public interface StoreApi { @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApiController.java index 3b61ee56049..1ee1125dc1b 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApiController.java @@ -2,9 +2,10 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -15,67 +16,91 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import java.util.Optional; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; +import java.io.IOException; +import java.util.List; @Controller public class StoreApiController implements StoreApi { + + private static final Logger log = LoggerFactory.getLogger(StoreApiController.class); + private final ObjectMapper objectMapper; - public StoreApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public StoreApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> getInventory(@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> getInventory() { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApi.java index d62e4a644c2..bf116aa378c 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,13 +18,11 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; +import javax.validation.Valid; +import javax.validation.constraints.*; import java.util.List; import java.util.Optional; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; -import javax.validation.Valid; @Api(value = "user", description = "the user API") public interface UserApi { @@ -35,7 +33,7 @@ public interface UserApi { @RequestMapping(value = "/user", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @@ -44,7 +42,7 @@ public interface UserApi { @RequestMapping(value = "/user/createWithArray", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @@ -53,7 +51,7 @@ public interface UserApi { @RequestMapping(value = "/user/createWithList", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @@ -63,7 +61,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -74,7 +72,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username); @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -84,7 +82,7 @@ public interface UserApi { @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password); @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @@ -93,7 +91,7 @@ public interface UserApi { @RequestMapping(value = "/user/logout", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity logoutUser(); @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @@ -103,6 +101,6 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApiController.java index a1d88ff251a..cf47c9ce282 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApiController.java @@ -2,9 +2,10 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -15,88 +16,102 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import java.util.Optional; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; +import java.io.IOException; +import java.util.List; @Controller public class UserApiController implements UserApi { + + private static final Logger log = LoggerFactory.getLogger(UserApiController.class); + private final ObjectMapper objectMapper; - public UserApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public UserApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123", User.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123", User.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, - @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue("aeiou", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("aeiou", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("\"\"", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity logoutUser(@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity logoutUser() { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username, - @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/FormatTest.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/FormatTest.java index 9d47a2e4245..9a7f3ff8be1 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/FormatTest.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/model/FormatTest.java @@ -71,7 +71,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(10) @Max(100) +@Min(10) @Max(100) public Integer getInteger() { return integer; } @@ -93,7 +93,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(20) @Max(200) +@Min(20) @Max(200) public Integer getInt32() { return int32; } @@ -137,7 +137,7 @@ public class FormatTest { @NotNull @Valid - @DecimalMin("32.1") @DecimalMax("543.2") +@DecimalMin("32.1") @DecimalMax("543.2") public BigDecimal getNumber() { return number; } @@ -159,7 +159,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("54.3") @DecimalMax("987.6") +@DecimalMin("54.3") @DecimalMax("987.6") public Float getFloat() { return _float; } @@ -181,7 +181,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("67.8") @DecimalMax("123.4") +@DecimalMin("67.8") @DecimalMax("123.4") public Double getDouble() { return _double; } @@ -201,7 +201,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Pattern(regexp="/[a-z]/i") +@Pattern(regexp="/[a-z]/i") public String getString() { return string; } @@ -222,7 +222,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") +@Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") public byte[] getByte() { return _byte; } @@ -327,7 +327,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Size(min=10,max=64) +@Size(min=10,max=64) public String getPassword() { return password; } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/AnotherFakeApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/AnotherFakeApi.java index a3fcfabaf12..6f6dd920913 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/AnotherFakeApi.java @@ -6,9 +6,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -17,12 +17,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "another-fake", description = "the another-fake API") public interface AnotherFakeApi { @@ -34,6 +32,6 @@ public interface AnotherFakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/AnotherFakeApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/AnotherFakeApiController.java index 02fe84a126e..1f969f15713 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/AnotherFakeApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/AnotherFakeApiController.java @@ -1,9 +1,10 @@ package io.swagger.api; import io.swagger.model.Client; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -14,29 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class AnotherFakeApiController implements AnotherFakeApi { + + private static final Logger log = LoggerFactory.getLogger(AnotherFakeApiController.class); + private final ObjectMapper objectMapper; - public AnotherFakeApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public AnotherFakeApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApi.java index 814003e2086..92b47fb2a37 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApi.java @@ -10,9 +10,9 @@ import io.swagger.model.Client; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import io.swagger.model.OuterComposite; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -21,12 +21,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "fake", description = "the fake API") public interface FakeApi { @@ -36,7 +34,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) @RequestMapping(value = "/fake/outer/boolean", method = RequestMethod.POST) - ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body); @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @@ -44,7 +42,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) @RequestMapping(value = "/fake/outer/composite", method = RequestMethod.POST) - ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body); @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @@ -52,7 +50,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) @RequestMapping(value = "/fake/outer/number", method = RequestMethod.POST) - ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body); @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @@ -60,7 +58,7 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output string", response = String.class) }) @RequestMapping(value = "/fake/outer/string", method = RequestMethod.POST) - ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body); @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @@ -70,7 +68,7 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = { @@ -83,7 +81,7 @@ public interface FakeApi { produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, method = RequestMethod.POST) - ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback); @ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", }) @@ -94,7 +92,7 @@ public interface FakeApi { produces = { "*/*" }, consumes = { "*/*" }, method = RequestMethod.GET) - ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble); @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @@ -103,7 +101,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/inline-additionalProperties", consumes = { "application/json" }, method = RequestMethod.POST) - ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param); @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @@ -112,6 +110,6 @@ public interface FakeApi { @RequestMapping(value = "/fake/jsonFormData", consumes = { "application/json" }, method = RequestMethod.GET) - ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApiController.java index e3eebeca3b2..360e1d910d7 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApiController.java @@ -5,9 +5,10 @@ import io.swagger.model.Client; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import io.swagger.model.OuterComposite; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -18,118 +19,115 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class FakeApiController implements FakeApi { + + private static final Logger log = LoggerFactory.getLogger(FakeApiController.class); + private final ObjectMapper objectMapper; - public FakeApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", Boolean.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", Boolean.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ }", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ }", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number, - @ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double, - @ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, - @ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte, - @ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer, - @ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32, - @ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64, - @ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float, - @ApiParam(value = "None") @RequestPart(value="string", required=false) String string, - @ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary, - @ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date, - @ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime, - @ApiParam(value = "None") @RequestPart(value="password", required=false) String password, - @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray, - @ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString, - @ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray, - @ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, - @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, - @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, - @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, - @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param, - @ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeClassnameTestApi.java index 00fffe8a123..8316190673c 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeClassnameTestApi.java @@ -6,9 +6,9 @@ package io.swagger.api; import io.swagger.model.Client; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -17,12 +17,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "fake_classname_test", description = "the fake_classname_test API") public interface FakeClassnameTestApi { @@ -36,6 +34,6 @@ public interface FakeClassnameTestApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeClassnameTestApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeClassnameTestApiController.java index ea2c0016470..37288b4c860 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeClassnameTestApiController.java @@ -1,9 +1,10 @@ package io.swagger.api; import io.swagger.model.Client; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -14,29 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class FakeClassnameTestApiController implements FakeClassnameTestApi { + + private static final Logger log = LoggerFactory.getLogger(FakeClassnameTestApiController.class); + private final ObjectMapper objectMapper; - public FakeClassnameTestApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FakeClassnameTestApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java index 247fa4dec59..d4604e9380e 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java @@ -8,9 +8,9 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -19,12 +19,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "pet", description = "the pet API") public interface PetApi { @@ -41,7 +39,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.POST) - ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = { @@ -55,7 +53,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -70,7 +68,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status); @ApiOperation(value = "Finds Pets by tags", nickname = "findPetsByTags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -85,7 +83,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags); @ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -98,7 +96,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -115,7 +113,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.PUT) - ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = { @@ -130,7 +128,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status); @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -145,6 +143,6 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java index 5a6f5dc2808..a3890cf787d 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java @@ -3,9 +3,10 @@ package io.swagger.api; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; import org.springframework.core.io.Resource; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -16,106 +17,128 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class PetApiController implements PetApi { + + private static final Logger log = LoggerFactory.getLogger(PetApiController.class); + private final ObjectMapper objectMapper; - public PetApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public PetApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 doggie aeiou aeiou", Pet.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 doggie aeiou aeiou", Pet.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, - @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId, - @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java index f0dd4e2d631..f23d712511f 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,12 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "store", description = "the store API") public interface StoreApi { @@ -35,7 +33,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId); @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -46,7 +44,7 @@ public interface StoreApi { @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - ResponseEntity> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity> getInventory(); @ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) @@ -57,7 +55,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId); @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) @@ -67,6 +65,6 @@ public interface StoreApi { @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java index 8d84a45d949..6e463e1307f 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java @@ -2,9 +2,10 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -15,66 +16,90 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class StoreApiController implements StoreApi { + + private static final Logger log = LoggerFactory.getLogger(StoreApiController.class); + private final ObjectMapper objectMapper; - public StoreApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public StoreApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity> getInventory(@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity> getInventory() { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/json")) { - return new ResponseEntity>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.OK); + try { + return new ResponseEntity>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java index 0f8609bc6ac..3dbcf7293cd 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java @@ -7,9 +7,9 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,12 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.*; import javax.validation.Valid; +import javax.validation.constraints.*; +import java.util.List; @Api(value = "user", description = "the user API") public interface UserApi { @@ -34,7 +32,7 @@ public interface UserApi { @RequestMapping(value = "/user", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @@ -43,7 +41,7 @@ public interface UserApi { @RequestMapping(value = "/user/createWithArray", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @@ -52,7 +50,7 @@ public interface UserApi { @RequestMapping(value = "/user/createWithList", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @@ -62,7 +60,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -73,7 +71,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username); @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -83,7 +81,7 @@ public interface UserApi { @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password); @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @@ -92,7 +90,7 @@ public interface UserApi { @RequestMapping(value = "/user/logout", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity logoutUser(); @ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @@ -102,6 +100,6 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java index b0bf6f65380..e96dfe648b4 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java @@ -2,9 +2,10 @@ package io.swagger.api; import java.util.List; import io.swagger.model.User; - +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.*; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -15,87 +16,101 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; -import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import javax.validation.constraints.*; import javax.validation.Valid; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.List; @Controller public class UserApiController implements UserApi { + + private static final Logger log = LoggerFactory.getLogger(UserApiController.class); + private final ObjectMapper objectMapper; - public UserApiController(ObjectMapper objectMapper) { + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public UserApiController(ObjectMapper objectMapper, HttpServletRequest request) { this.objectMapper = objectMapper; + this.request = request; } - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123", User.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123", User.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, - @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - + public ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { + String accept = request.getHeader("Accept"); if (accept != null && accept.contains("application/xml")) { - return new ResponseEntity(objectMapper.readValue("aeiou", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("aeiou", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/xml", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - if (accept != null && accept.contains("application/json")) { - return new ResponseEntity(objectMapper.readValue("\"\"", String.class), HttpStatus.OK); + try { + return new ResponseEntity(objectMapper.readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (IOException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } } - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity logoutUser(@RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity logoutUser() { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username, - @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, - @RequestHeader(value = "Accept", required = false) String accept) throws Exception { - // do some magic! - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); } } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/model/FormatTest.java b/samples/server/petstore/springboot/src/main/java/io/swagger/model/FormatTest.java index 9d47a2e4245..9a7f3ff8be1 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/model/FormatTest.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/model/FormatTest.java @@ -71,7 +71,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(10) @Max(100) +@Min(10) @Max(100) public Integer getInteger() { return integer; } @@ -93,7 +93,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Min(20) @Max(200) +@Min(20) @Max(200) public Integer getInt32() { return int32; } @@ -137,7 +137,7 @@ public class FormatTest { @NotNull @Valid - @DecimalMin("32.1") @DecimalMax("543.2") +@DecimalMin("32.1") @DecimalMax("543.2") public BigDecimal getNumber() { return number; } @@ -159,7 +159,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("54.3") @DecimalMax("987.6") +@DecimalMin("54.3") @DecimalMax("987.6") public Float getFloat() { return _float; } @@ -181,7 +181,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @DecimalMin("67.8") @DecimalMax("123.4") +@DecimalMin("67.8") @DecimalMax("123.4") public Double getDouble() { return _double; } @@ -201,7 +201,7 @@ public class FormatTest { **/ @ApiModelProperty(value = "") - @Pattern(regexp="/[a-z]/i") +@Pattern(regexp="/[a-z]/i") public String getString() { return string; } @@ -222,7 +222,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") +@Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") public byte[] getByte() { return _byte; } @@ -327,7 +327,7 @@ public class FormatTest { @ApiModelProperty(required = true, value = "") @NotNull - @Size(min=10,max=64) +@Size(min=10,max=64) public String getPassword() { return password; }