From 0811e0bce35fe4da022b4a695d07ba1e56c6214d Mon Sep 17 00:00:00 2001 From: Camille Chafer Date: Thu, 2 Apr 2015 16:22:52 +0200 Subject: [PATCH 1/5] Add Akka-Scala client generator. This client uses Spray as Http Client. --- .../wordnik/swagger/codegen/CodegenModel.java | 2 +- .../swagger/codegen/CodegenResponse.java | 1 + .../swagger/codegen/CodegenSecurity.java | 11 +- .../swagger/codegen/DefaultCodegen.java | 31 +- .../languages/AkkaScalaClientCodegen.java | 365 ++++++++++++++++++ .../com.wordnik.swagger.codegen.CodegenConfig | 3 +- .../main/resources/akka-scala/api.mustache | 43 +++ .../resources/akka-scala/apiInvoker.mustache | 323 ++++++++++++++++ .../resources/akka-scala/apiRequest.mustache | 50 +++ .../resources/akka-scala/apiSettings.mustache | 32 ++ .../akka-scala/enumsSerializers.mustache | 42 ++ .../resources/akka-scala/javadoc.mustache | 21 + .../akka-scala/methodParameters.mustache | 1 + .../main/resources/akka-scala/model.mustache | 30 ++ .../akka-scala/operationReturnType.mustache | 1 + .../akka-scala/paramCreation.mustache | 1 + .../main/resources/akka-scala/pom.mustache | 227 +++++++++++ .../resources/akka-scala/reference.mustache | 24 ++ .../resources/akka-scala/requests.mustache | 166 ++++++++ .../akka-scala/responseState.mustache | 1 + .../src/test/resources/2_0/requiredTest.json | 93 +++++ .../src/test/scala/CodegenTest.scala | 38 +- 22 files changed, 1483 insertions(+), 23 deletions(-) create mode 100644 modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/AkkaScalaClientCodegen.java create mode 100644 modules/swagger-codegen/src/main/resources/akka-scala/api.mustache create mode 100644 modules/swagger-codegen/src/main/resources/akka-scala/apiInvoker.mustache create mode 100644 modules/swagger-codegen/src/main/resources/akka-scala/apiRequest.mustache create mode 100644 modules/swagger-codegen/src/main/resources/akka-scala/apiSettings.mustache create mode 100644 modules/swagger-codegen/src/main/resources/akka-scala/enumsSerializers.mustache create mode 100644 modules/swagger-codegen/src/main/resources/akka-scala/javadoc.mustache create mode 100644 modules/swagger-codegen/src/main/resources/akka-scala/methodParameters.mustache create mode 100644 modules/swagger-codegen/src/main/resources/akka-scala/model.mustache create mode 100644 modules/swagger-codegen/src/main/resources/akka-scala/operationReturnType.mustache create mode 100644 modules/swagger-codegen/src/main/resources/akka-scala/paramCreation.mustache create mode 100644 modules/swagger-codegen/src/main/resources/akka-scala/pom.mustache create mode 100644 modules/swagger-codegen/src/main/resources/akka-scala/reference.mustache create mode 100644 modules/swagger-codegen/src/main/resources/akka-scala/requests.mustache create mode 100644 modules/swagger-codegen/src/main/resources/akka-scala/responseState.mustache create mode 100644 modules/swagger-codegen/src/test/resources/2_0/requiredTest.json diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenModel.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenModel.java index 169886da22..d1bfc90ba2 100644 --- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenModel.java +++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenModel.java @@ -11,6 +11,6 @@ public class CodegenModel { public String defaultValue; public List vars = new ArrayList(); public Set imports = new HashSet(); - public Boolean hasVars, emptyVars, hasMoreModels; + public Boolean hasVars, emptyVars, hasMoreModels, hasEnums; public ExternalDocs externalDocs; } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenResponse.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenResponse.java index 15931c9fd2..b23c5f7212 100644 --- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenResponse.java +++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenResponse.java @@ -8,6 +8,7 @@ public class CodegenResponse { public List> examples; public final List headers = new ArrayList(); public String dataType, baseType, containerType; + public Boolean isDefault; public Boolean simpleType; public Boolean primitiveType; public Boolean isMapContainer; diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenSecurity.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenSecurity.java index 889a9419c6..00d56ea213 100644 --- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenSecurity.java +++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenSecurity.java @@ -1,11 +1,10 @@ package com.wordnik.swagger.codegen; public class CodegenSecurity { - String name; - String type; - Boolean hasMore, isBasic, isOAuth, isApiKey; + public String name; + public String type; + public Boolean hasMore, isBasic, isOAuth, isApiKey; // ApiKey specific - String keyParamName; - Boolean isKeyInQuery, isKeyInHeader; - + public String keyParamName; + public Boolean isKeyInQuery, isKeyInHeader; } diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/DefaultCodegen.java index 0a6e955b95..0055c968ed 100644 --- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/DefaultCodegen.java @@ -166,6 +166,9 @@ public class DefaultCodegen { return name; } + public String toEnumName(CodegenProperty property) { + return StringUtils.capitalize(property.name) + "Enum"; + } public String escapeReservedWord(String name) { throw new RuntimeException("reserved word " + name + " not allowed"); @@ -450,6 +453,7 @@ public class DefaultCodegen { } if(impl.getProperties() != null && impl.getProperties().size() > 0) { m.hasVars = true; + m.hasEnums = false; for(String key: impl.getProperties().keySet()) { Property prop = impl.getProperties().get(key); @@ -477,6 +481,8 @@ public class DefaultCodegen { } m.vars.add(cp); count += 1; + if (cp.isEnum) + m.hasEnums = true; if(count != impl.getProperties().keySet().size()) cp.hasMore = new Boolean(true); if(cp.isContainer != null) { @@ -569,7 +575,7 @@ public class DefaultCodegen { // this can cause issues for clients which don't support enums if(property.isEnum) - property.datatypeWithEnum = StringUtils.capitalize(property.name) + "Enum"; + property.datatypeWithEnum = toEnumName(property); else property.datatypeWithEnum = property.datatype; @@ -702,7 +708,6 @@ public class DefaultCodegen { if (operation.getResponses() != null && !operation.getResponses().isEmpty()) { Response methodResponse = findMethodResponse(operation.getResponses()); - CodegenResponse methodCodegenResponse = null; for (Map.Entry entry : operation.getResponses().entrySet()) { Response response = entry.getValue(); @@ -712,9 +717,7 @@ public class DefaultCodegen { !defaultIncludes.contains(r.baseType) && !languageSpecificPrimitives.contains(r.baseType)) imports.add(r.baseType); - - if (response == methodResponse) - methodCodegenResponse = r; + r.isDefault = response == methodResponse; op.responses.add(r); } op.responses.get(op.responses.size() - 1).hasMore = false; @@ -897,6 +900,19 @@ public class DefaultCodegen { collectionFormat = qp.getCollectionFormat(); CodegenProperty pr = fromProperty("inner", inner); p.baseType = pr.datatype; + p.isContainer = true; + imports.add(pr.baseType); + } + else if("object".equals(qp.getType())) { + Property inner = qp.getItems(); + if(inner == null) { + LOGGER.warn("warning! No inner type supplied for map parameter \"" + qp.getName() + "\", using String"); + inner = new StringProperty().description("//TODO automatically added by swagger-codegen"); + } + property = new MapProperty(inner); + collectionFormat = qp.getCollectionFormat(); + CodegenProperty pr = fromProperty("inner", inner); + p.baseType = pr.datatype; imports.add(pr.baseType); } else @@ -905,6 +921,7 @@ public class DefaultCodegen { LOGGER.warn("warning! Property type \"" + qp.getType() + "\" not found for parameter \"" + param.getName() + "\", using String"); property = new StringProperty().description("//TODO automatically added by swagger-codegen. Type was " + qp.getType() + " but not supported"); } + property.setRequired(param.getRequired()); CodegenProperty model = fromProperty(qp.getName(), property); p.collectionFormat = collectionFormat; p.dataType = model.datatype; @@ -928,6 +945,7 @@ public class DefaultCodegen { else { // TODO: missing format, so this will not always work Property prop = PropertyBuilder.build(impl.getType(), null, null); + prop.setRequired(bp.getRequired()); CodegenProperty cp = fromProperty("property", prop); if(cp != null) { p.dataType = cp.datatype; @@ -941,6 +959,7 @@ public class DefaultCodegen { CodegenModel cm = fromModel(bp.getName(), impl); // get the single property ArrayProperty ap = new ArrayProperty().items(impl.getItems()); + ap.setRequired(param.getRequired()); CodegenProperty cp = fromProperty("inner", ap); if(cp.complexType != null) { imports.add(cp.complexType); @@ -1148,4 +1167,4 @@ public class DefaultCodegen { } -} +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/AkkaScalaClientCodegen.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/AkkaScalaClientCodegen.java new file mode 100644 index 0000000000..ee2da7aa92 --- /dev/null +++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/AkkaScalaClientCodegen.java @@ -0,0 +1,365 @@ +package com.wordnik.swagger.codegen.languages; + +import com.google.common.base.CaseFormat; +import com.samskivert.mustache.Mustache; +import com.samskivert.mustache.Template; +import com.wordnik.swagger.codegen.*; +import com.wordnik.swagger.models.auth.SecuritySchemeDefinition; +import com.wordnik.swagger.models.properties.*; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; +import java.util.*; + +public class AkkaScalaClientCodegen extends DefaultCodegen implements CodegenConfig { + Logger LOGGER = LoggerFactory.getLogger(AkkaScalaClientCodegen.class); + + protected String mainPackage = "io.swagger.client"; + + protected String invokerPackage = mainPackage + ".core"; + protected String groupId = "com.wordnik"; + protected String artifactId = "swagger-client"; + protected String artifactVersion = "1.0.0"; + protected String sourceFolder = "src/main/scala"; + protected String resourcesFolder = "src/main/resources"; + protected String configKey = "apiRequest"; + protected int defaultTimeoutInMs = 5000; + protected String configKeyPath = mainPackage; + + protected boolean registerNonStandardStatusCodes = true; + protected boolean renderJavadoc = true; + protected boolean removeOAuthSecurities = true; + /** + * If set to true, only the default response (the one with le lowest 2XX code) will be considered as a success, and all + * others as ApiErrors. + * If set to false, all responses defined in the model will be considered as a success upon reception. Only http errors, + * unmarshalling problems and any other RuntimeException will be considered as ApiErrors. + */ + protected boolean onlyOneSuccess = true; + + public CodegenType getTag() { + return CodegenType.CLIENT; + } + + public String getName() { + return "akka-scala"; + } + + public String getHelp() { + return "Generates a Scala client library base on Akka/Spray."; + } + + public AkkaScalaClientCodegen() { + super(); + outputFolder = "generated-code/scala"; + modelTemplateFiles.put("model.mustache", ".scala"); + apiTemplateFiles.put("api.mustache", ".scala"); + templateDir = "akka-scala"; + apiPackage = mainPackage + ".api"; + modelPackage = mainPackage + ".model"; + + reservedWords = new HashSet( + Arrays.asList( + "abstract", "case", "catch", "class", "def", "do", "else", "extends", + "false", "final", "finally", "for", "forSome", "if", "implicit", + "import", "lazy", "match", "new", "null", "object", "override", "package", + "private", "protected", "return", "sealed", "super", "this", "throw", + "trait", "try", "true", "type", "val", "var", "while", "with", "yield") + ); + + additionalProperties.put("invokerPackage", invokerPackage); + additionalProperties.put("groupId", groupId); + additionalProperties.put("artifactId", artifactId); + additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put("configKey", configKey); + additionalProperties.put("configKeyPath", configKeyPath); + additionalProperties.put("defaultTimeout", defaultTimeoutInMs); + if (renderJavadoc) + additionalProperties.put("javadocRenderer", new JavadocLambda()); + additionalProperties.put("fnCapitalize", new CapitalizeLambda()); + additionalProperties.put("fnCamelize", new CamelizeLambda(false)); + additionalProperties.put("fnEnumEntry", new EnumEntryLambda()); + additionalProperties.put("onlyOneSuccess", onlyOneSuccess); + + supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); + supportingFiles.add(new SupportingFile("reference.mustache", resourcesFolder, "reference.conf")); + final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator); + supportingFiles.add(new SupportingFile("apiRequest.mustache", invokerFolder, "ApiRequest.scala")); + supportingFiles.add(new SupportingFile("apiInvoker.mustache", invokerFolder, "ApiInvoker.scala")); + supportingFiles.add(new SupportingFile("requests.mustache", invokerFolder, "requests.scala")); + supportingFiles.add(new SupportingFile("apiSettings.mustache", invokerFolder, "ApiSettings.scala")); + final String apiFolder = (sourceFolder + File.separator + apiPackage).replace(".", File.separator); + supportingFiles.add(new SupportingFile("enumsSerializers.mustache", apiFolder, "EnumsSerializers.scala")); + + importMapping.remove("Seq"); + importMapping.remove("List"); + importMapping.remove("Set"); + importMapping.remove("Map"); + + importMapping.put("DateTime", "org.joda.time.DateTime"); + + typeMapping = new HashMap(); + typeMapping.put("array", "Seq"); + typeMapping.put("set", "Set"); + typeMapping.put("boolean", "Boolean"); + typeMapping.put("string", "String"); + typeMapping.put("int", "Int"); + typeMapping.put("integer", "Int"); + typeMapping.put("long", "Long"); + typeMapping.put("float", "Float"); + typeMapping.put("byte", "Byte"); + typeMapping.put("short", "Short"); + typeMapping.put("char", "Char"); + typeMapping.put("long", "Long"); + typeMapping.put("double", "Double"); + typeMapping.put("object", "Any"); + typeMapping.put("file", "File"); + typeMapping.put("number", "Double"); + + languageSpecificPrimitives = new HashSet( + Arrays.asList( + "String", + "boolean", + "Boolean", + "Double", + "Int", + "Long", + "Float", + "Object", + "List", + "Seq", + "Map") + ); + instantiationTypes.put("array", "ListBuffer"); + instantiationTypes.put("map", "Map"); + } + + @Override + public String escapeReservedWord(String name) { + return "`" + name + "`"; + } + + @Override + public String apiFileFolder() { + return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar); + } + + public String modelFileFolder() { + return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar); + } + + @Override + public Map postProcessOperations(Map objs) { + if (registerNonStandardStatusCodes) { + try { + @SuppressWarnings("unchecked") + Map> opsMap = (Map>) objs.get("operations"); + HashSet unknownCodes = new HashSet(); + for (CodegenOperation operation : opsMap.get("operation")) { + for (CodegenResponse response : operation.responses) { + if ("default".equals(response.code)) + continue; + try { + int code = Integer.parseInt(response.code); + if (code >= 600) { + unknownCodes.add(code); + } + } catch (NumberFormatException e) { + LOGGER.error("Status code is not an integer : response.code", e); + } + } + } + if (!unknownCodes.isEmpty()) { + additionalProperties.put("unknownStatusCodes", unknownCodes); + } + } catch (Exception e) { + LOGGER.error("Unable to find operations List", e); + } + } + return super.postProcessOperations(objs); + } + + @Override + public String getTypeDeclaration(Property p) { + if (p instanceof ArrayProperty) { + ArrayProperty ap = (ArrayProperty) p; + Property inner = ap.getItems(); + return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]"; + } else if (p instanceof MapProperty) { + MapProperty mp = (MapProperty) p; + Property inner = mp.getAdditionalProperties(); + + return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]"; + } + return super.getTypeDeclaration(p); + } + + @Override + public List fromSecurity(Map schemes) { + final List codegenSecurities = super.fromSecurity(schemes); + if (!removeOAuthSecurities) + return codegenSecurities; + + // Remove OAuth securities + Iterator it = codegenSecurities.iterator(); + while (it.hasNext()) { + final CodegenSecurity security = it.next(); + if (security.isOAuth) + it.remove(); + } + // Adapt 'hasMore' + it = codegenSecurities.iterator(); + while (it.hasNext()) { + final CodegenSecurity security = it.next(); + security.hasMore = it.hasNext(); + } + + if (codegenSecurities.isEmpty()) + return null; + return codegenSecurities; + } + + @Override + public String toOperationId(String operationId) { + return super.toOperationId(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, operationId)); + } + + private String formatIdentifier(String name, boolean capitalized) { + String identifier = camelize(name); + if (capitalized) + identifier = StringUtils.capitalize(identifier); + if (identifier.matches("[a-zA-Z_$][\\w_$]+") && !reservedWords.contains(identifier)) + return identifier; + return escapeReservedWord(identifier); + } + + @Override + public String toParamName(String name) { return formatIdentifier(name, false); } + + @Override + public String toVarName(String name) { + return formatIdentifier(name, false); + } + + @Override + public String toEnumName(CodegenProperty property) + { + return formatIdentifier(property.baseName, true); + } + + @Override + public String getSwaggerType(Property p) { + String swaggerType = super.getSwaggerType(p); + String type; + if (typeMapping.containsKey(swaggerType)) { + type = typeMapping.get(swaggerType); + if (languageSpecificPrimitives.contains(type)) + return toModelName(type); + } else + type = swaggerType; + return toModelName(type); + } + + @Override + public String toInstantiationType(Property p) { + if (p instanceof MapProperty) { + MapProperty ap = (MapProperty) p; + String inner = getSwaggerType(ap.getAdditionalProperties()); + return instantiationTypes.get("map") + "[String, " + inner + "]"; + } else if (p instanceof ArrayProperty) { + ArrayProperty ap = (ArrayProperty) p; + String inner = getSwaggerType(ap.getItems()); + return instantiationTypes.get("array") + "[" + inner + "]"; + } else + return null; + } + + public String toDefaultValue(Property p) { + if (!p.getRequired()) + return "None"; + if (p instanceof StringProperty) + return "null"; + else if (p instanceof BooleanProperty) + return "null"; + else if (p instanceof DateProperty) + return "null"; + else if (p instanceof DateTimeProperty) + return "null"; + else if (p instanceof DoubleProperty) + return "null"; + else if (p instanceof FloatProperty) + return "null"; + else if (p instanceof IntegerProperty) + return "null"; + else if (p instanceof LongProperty) + return "null"; + else if (p instanceof MapProperty) { + MapProperty ap = (MapProperty) p; + String inner = getSwaggerType(ap.getAdditionalProperties()); + return "Map[String, " + inner + "].empty "; + } else if (p instanceof ArrayProperty) { + ArrayProperty ap = (ArrayProperty) p; + String inner = getSwaggerType(ap.getItems()); + return "Seq[" + inner + "].empty "; + } else + return "null"; + } + + private static abstract class CustomLambda implements Mustache.Lambda { + @Override + public void execute(Template.Fragment frag, Writer out) throws IOException { + final StringWriter tempWriter = new StringWriter(); + frag.execute(tempWriter); + out.write(formatFragment(tempWriter.toString())); + } + public abstract String formatFragment(String fragment); + } + + + private static class JavadocLambda extends CustomLambda { + @Override + public String formatFragment(String fragment) { + final String[] lines = fragment.split("\\r?\\n"); + final StringBuilder sb = new StringBuilder(); + sb.append(" /**\n"); + for (String line : lines) { + sb.append(" * ").append(line).append("\n"); + } + sb.append(" */\n"); + return sb.toString(); + } + } + + private static class CapitalizeLambda extends CustomLambda { + @Override + public String formatFragment(String fragment) { + return StringUtils.capitalize(fragment); + } + } + + private static class CamelizeLambda extends CustomLambda { + private final boolean capitalizeFirst; + + public CamelizeLambda(boolean capitalizeFirst) { + this.capitalizeFirst = capitalizeFirst; + } + + @Override + public String formatFragment(String fragment) { + return camelize(fragment, !capitalizeFirst); + } + } + + private class EnumEntryLambda extends CustomLambda { + @Override + public String formatFragment(String fragment) { + return formatIdentifier(fragment, true); + } + } + +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/com.wordnik.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/com.wordnik.swagger.codegen.CodegenConfig index 6535948ad8..3bd4df773c 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/com.wordnik.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/com.wordnik.swagger.codegen.CodegenConfig @@ -15,4 +15,5 @@ com.wordnik.swagger.codegen.languages.StaticDocCodegen com.wordnik.swagger.codegen.languages.StaticHtmlGenerator com.wordnik.swagger.codegen.languages.SwaggerGenerator com.wordnik.swagger.codegen.languages.SwaggerYamlGenerator -com.wordnik.swagger.codegen.languages.TizenClientCodegen \ No newline at end of file +com.wordnik.swagger.codegen.languages.TizenClientCodegen +com.wordnik.swagger.codegen.languages.AkkaScalaClientCodegen diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/api.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/api.mustache new file mode 100644 index 0000000000..34523b8035 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/akka-scala/api.mustache @@ -0,0 +1,43 @@ +package {{package}} + +{{#imports}} +import {{import}} +{{/imports}} +import {{invokerPackage}}._ +import {{invokerPackage}}.CollectionFormats._ +import {{invokerPackage}}.ApiKeyLocations._ + +{{#operations}} +object {{classname}} { + +{{#operation}} +{{#javadocRenderer}} +{{>javadoc}} +{{/javadocRenderer}} + def {{operationId}}({{>methodParameters}}): ApiRequest[{{>operationReturnType}}] = + ApiRequest[{{>operationReturnType}}](ApiMethods.{{httpMethod.toUpperCase}}, "{{basePath}}", "{{path}}", {{#consumes.0}}"{{mediaType}}"{{/consumes.0}}{{^consumes}}"application/json"{{/consumes}}) + {{#authMethods}}{{#isApiKey}}.withApiKey(apiKey, "{{keyParamName}}", {{#isKeyInQuery}}QUERY{{/isKeyInQuery}}{{#isKeyInHeader}}HEADER{{/isKeyInHeader}}) + {{/isApiKey}}{{#isBasic}}.withCredentials(basicAuth) + {{/isBasic}}{{/authMethods}}{{#bodyParam}}.withBody({{paramName}}) + {{/bodyParam}}{{#formParams}}.withFormParam({{>paramCreation}}) + {{/formParams}}{{#queryParams}}.withQueryParam({{>paramCreation}}) + {{/queryParams}}{{#pathParams}}.withPathParam({{>paramCreation}}) + {{/pathParams}}{{#headerParams}}.withHeaderParam({{>paramCreation}}) + {{/headerParams}}{{#responses}}{{^isWildcard}}{{#dataType}}.with{{>responseState}}Response[{{dataType}}]({{code}}) + {{/dataType}}{{^dataType}}.with{{>responseState}}Response[Unit]({{code}}) + {{/dataType}}{{/isWildcard}}{{/responses}}{{#responses}}{{#isWildcard}}{{#dataType}}.withDefault{{>responseState}}Response[{{dataType}}]() + {{/dataType}}{{^dataType}}.withDefault{{>responseState}}Response[Unit]() + {{/dataType}}{{/isWildcard}}{{/responses}}{{^responseHeaders.isEmpty}} + object {{#fnCapitalize}}{{operationId}}{{/fnCapitalize}}Headers { {{#responseHeaders}} + def {{name}}(r: ApiReturnWithHeaders) = r.get{{^isContainer}}{{baseType}}{{/isContainer}}{{#isContainer}}String{{/isContainer}}Header("{{baseName}}"){{/responseHeaders}} + } + {{/responseHeaders.isEmpty}} +{{/operation}} + +{{#unknownStatusCodes}} + ApiInvoker.addCustomStatusCode({{value}}, isSuccess = false) +{{/unknownStatusCodes}} + +} + +{{/operations}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/apiInvoker.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/apiInvoker.mustache new file mode 100644 index 0000000000..0dde367343 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/akka-scala/apiInvoker.mustache @@ -0,0 +1,323 @@ +package {{invokerPackage}} + +import java.io.File +import java.security.cert.X509Certificate +import javax.net.ssl._ + +import akka.actor.ActorSystem +import akka.io.IO +import akka.pattern.ask +import akka.util.Timeout +import org.joda.time.DateTime +import org.joda.time.format.ISODateTimeFormat +import org.json4s.JsonAST.JString +import org.json4s._ +import org.json4s.jackson.JsonMethods._ +import org.json4s.jackson.Serialization +import spray.can.Http +import spray.can.Http.HostConnectorSetup +import spray.client.pipelining +import spray.client.pipelining._ +import spray.http.HttpEncodings._ +import spray.http.HttpHeaders.{RawHeader, `Accept-Encoding`} +import spray.http.Uri.Query +import spray.http._ +import spray.http.parser.HttpParser +import spray.httpx.encoding.{Deflate, Encoder, Gzip} +import spray.httpx.unmarshalling._ +import spray.io.ClientSSLEngineProvider + +import scala.concurrent.{ExecutionContext, Future} +import scala.reflect.ClassTag +import scala.util.control.NonFatal + +object ApiInvoker { + + def apply()(implicit system: ActorSystem): ApiInvoker = + apply(DefaultFormats + DateTimeSerializer) + def apply(serializers: Traversable[Serializer[_]])(implicit system: ActorSystem): ApiInvoker = + apply(DefaultFormats + DateTimeSerializer ++ serializers) + def apply(formats: Formats)(implicit system: ActorSystem): ApiInvoker = new ApiInvoker(formats) + + case class CustomStatusCode(value: Int, reason: String = "Application-defined status code", isSuccess: Boolean = true) + + def addCustomStatusCode(code: CustomStatusCode): Unit = addCustomStatusCode(code.value, code.reason, code.isSuccess) + + def addCustomStatusCode(code: Int, reason: String = "Application defined code", isSuccess: Boolean = true) = { + StatusCodes.getForKey(code) foreach { c => + StatusCodes.registerCustom(code, reason, reason, isSuccess, allowsEntity = true) + } + } + + /** + * Allows request execution without calling apiInvoker.execute(request) + * request.response can be used to get a future of the ApiResponse generated. + * request.result can be used to get a future of the expected ApiResponse content. If content doesn't match, a + * Future will failed with a ClassCastException + * @param request the apiRequest to be executed + */ + implicit class ApiRequestImprovements[T](request: ApiRequest[T]) { + + def response(invoker: ApiInvoker)(implicit ec: ExecutionContext, system: ActorSystem): Future[ApiResponse[T]] = + response(ec, system, invoker) + + def response(implicit ec: ExecutionContext, system: ActorSystem, invoker: ApiInvoker): Future[ApiResponse[T]] = + invoker.execute(request) + + def result[U <: T](implicit c: ClassTag[U], ec: ExecutionContext, system: ActorSystem, invoker: ApiInvoker): Future[U] = + invoker.execute(request).map(_.content).mapTo[U] + + } + + /** + * Allows transformation from ApiMethod to spray HttpMethods + * @param method the ApiMethod to be converted + */ + implicit class ApiMethodExtensions(val method: ApiMethod) { + def toSprayMethod: HttpMethod = HttpMethods.getForKey(method.value).getOrElse(HttpMethods.GET) + } + + case object DateTimeSerializer extends CustomSerializer[DateTime](format => ( { + case JString(s) => + ISODateTimeFormat.dateTimeParser().parseDateTime(s) + }, { + case d: DateTime => + JString(ISODateTimeFormat.dateTimeParser().print(d)) + })) +} + +class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends UntrustedSslContext with CustomContentTypes { + + import io.swagger.client.core.ApiInvoker._ + import io.swagger.client.core.ParametersMap._ + + implicit val ec = system.dispatcher + implicit val jsonFormats = formats + + def settings = ApiSettings(system) + + import spray.http.MessagePredicate._ + + val CompressionFilter = MessagePredicate({ _ => settings.compressionEnabled}) && + Encoder.DefaultFilter && + minEntitySize(settings.compressionSizeThreshold) + + settings.customCodes.foreach(addCustomStatusCode) + + private def addAuthentication(credentialsSeq: Seq[Credentials]): pipelining.RequestTransformer = + request => + credentialsSeq.foldLeft(request) { + case (req, BasicCredentials(login, password)) => + req ~> addCredentials(BasicHttpCredentials(login, password)) + case (req, ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) => + req ~> addHeader(RawHeader(keyName, keyValue.value)) + case (req, _) => req + } + + private def addHeaders(headers: Map[String, Any]): pipelining.RequestTransformer = { request => + + val rawHeaders = for { + (name, value) <- headers.asFormattedParams + header = RawHeader(name, String.valueOf(value)) + } yield header + + request.withHeaders(rawHeaders.toList) + } + + private def bodyPart(name: String, value: Any): BodyPart = { + value match { + case f: File => + BodyPart(f, name) + case v: String => + BodyPart(HttpEntity(String.valueOf(v))) + case NumericValue(v) => + BodyPart(HttpEntity(String.valueOf(v))) + case m: ApiModel => + BodyPart(HttpEntity(Serialization.write(m))) + } + } + + private def formDataContent(request: ApiRequest[_]) = { + val params = request.formParams.asFormattedParams + if (params.isEmpty) + None + else + Some( + normalizedContentType(request.contentType).mediaType match { + case MediaTypes.`multipart/form-data` => + MultipartFormData(params.map { case (name, value) => (name, bodyPart(name, value))}) + case MediaTypes.`application/x-www-form-urlencoded` => + FormData(params.mapValues(String.valueOf)) + case m: MediaType => // Default : application/x-www-form-urlencoded. + FormData(params.mapValues(String.valueOf)) + } + ) + } + + private def bodyContent(request: ApiRequest[_]): Option[Any] = { + request.bodyParam.map(Extraction.decompose).map(compact) + } + + private def createRequest(uri: Uri, request: ApiRequest[_]): HttpRequest = { + + val builder = new RequestBuilder(request.method.toSprayMethod) + val httpRequest = request.method.toSprayMethod match { + case HttpMethods.GET | HttpMethods.DELETE => builder.apply(uri) + case HttpMethods.POST | HttpMethods.PUT => + formDataContent(request) orElse bodyContent(request) match { + case Some(c: FormData) => + builder.apply(uri, c) + case Some(c: MultipartFormData) => + builder.apply(uri, c) + case Some(c: String) => + builder.apply(uri, HttpEntity(normalizedContentType(request.contentType), c)) + case _ => + builder.apply(uri, HttpEntity(normalizedContentType(request.contentType), " ")) + } + case _ => builder.apply(uri) + } + + httpRequest ~> + addHeaders(request.headerParams) ~> + addAuthentication(request.credentials) ~> + encode(Gzip(CompressionFilter)) + } + + def makeQuery(r: ApiRequest[_]): Query = { + r.credentials.foldLeft(r.queryParams) { + case (params, ApiKeyCredentials(key, keyName, ApiKeyLocations.QUERY)) => + params + (keyName -> key.value) + case (params, _) => params + }.asFormattedParams + .mapValues(String.valueOf) + .foldRight[Query](Uri.Query.Empty) { + case ((name, value), acc) => acc.+:(name, value) + } + } + + def makeUri(r: ApiRequest[_]): Uri = { + val opPath = r.operationPath.replaceAll("\\{format\\}", "json") + val opPathWithParams = r.pathParams.asFormattedParams + .mapValues(String.valueOf) + .foldLeft(opPath) { + case (path, (name, value)) => path.replaceAll(s"\\{$name\\}", value) + } + val query = makeQuery(r) + + Uri(r.basePath + opPathWithParams).withQuery(query) + } + + def execute[T](r: ApiRequest[T]): Future[ApiResponse[T]] = { + try { + implicit val timeout: Timeout = settings.connectionTimeout + + val uri = makeUri(r) + + val connector = HostConnectorSetup( + uri.authority.host.toString, + uri.effectivePort, + sslEncryption = "https".equals(uri.scheme), + defaultHeaders = settings.defaultHeaders ++ List(`Accept-Encoding`(gzip, deflate))) + + val request = createRequest(uri, r) + + for { + Http.HostConnectorInfo(hostConnector, _) <- IO(Http) ? connector + response <- hostConnector.ask(request).mapTo[HttpResponse] + } yield { + response ~> decode(Deflate) ~> decode(Gzip) ~> unmarshallApiResponse(r) + } + } + catch { + case NonFatal(x) => Future.failed(x) + } + } + + def unmarshallApiResponse[T](request: ApiRequest[T])(response: HttpResponse): ApiResponse[T] = { + request.responseForCode(response.status.intValue) match { + case Some( (manifest: Manifest[T], state: ResponseState) ) => + entityUnmarshaller(manifest)(response.entity) match { + case Right(value) ⇒ + state match { + case ResponseState.Success => + ApiResponse(response.status.intValue, value, response.headers.map(header => (header.name, header.value)).toMap) + case ResponseState.Error => + throw new ApiError(response.status.intValue, "Error response received", + Some(value), + headers = response.headers.map(header => (header.name, header.value)).toMap) + } + + case Left(MalformedContent(error, Some(cause))) ⇒ + throw new ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString), cause) + + case Left(MalformedContent(error, None)) ⇒ + throw new ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString)) + + case Left(ContentExpected) ⇒ + throw new ApiError(response.status.intValue, s"Unable to unmarshall empty response to [$manifest]", Some(response.entity.toString)) + } + + case _ => throw new ApiError(response.status.intValue, "Unexpected response code", Some(response.entity.toString)) + } + } + + def entityUnmarshaller[T](implicit mf: Manifest[T]): Unmarshaller[T] = + Unmarshaller[T](MediaTypes.`application/json`) { + case x: HttpEntity.NonEmpty ⇒ + parse(x.asString(defaultCharset = HttpCharsets.`UTF-8`)) + .noNulls + .camelizeKeys + .extract[T] + } + +} + +sealed trait CustomContentTypes { + + def normalizedContentType(original: String): ContentType = + MediaTypes.forExtension(original) map (ContentType(_)) getOrElse parseContentType(original) + + def parseContentType(contentType: String): ContentType = { + val contentTypeAsRawHeader = HttpHeaders.RawHeader("Content-Type", contentType) + val parsedContentTypeHeader = HttpParser.parseHeader(contentTypeAsRawHeader) + (parsedContentTypeHeader: @unchecked) match { + case Right(ct: HttpHeaders.`Content-Type`) => + ct.contentType + case Left(error: ErrorInfo) => + throw new IllegalArgumentException( + s"Error converting '$contentType' to a ContentType header: '${error.summary}'") + } + } +} + +sealed trait UntrustedSslContext { + this: ApiInvoker => + + implicit lazy val trustfulSslContext: SSLContext = { + settings.alwaysTrustCertificates match { + case false => + SSLContext.getDefault + + case true => + class IgnoreX509TrustManager extends X509TrustManager { + def checkClientTrusted(chain: Array[X509Certificate], authType: String): Unit = {} + + def checkServerTrusted(chain: Array[X509Certificate], authType: String): Unit = {} + + def getAcceptedIssuers = null + } + + val context = SSLContext.getInstance("TLS") + context.init(null, Array(new IgnoreX509TrustManager), null) + context + } + } + + implicit val clientSSLEngineProvider = + ClientSSLEngineProvider { + _ => + val engine = trustfulSslContext.createSSLEngine() + engine.setUseClientMode(true) + engine + } +} diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/apiRequest.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/apiRequest.mustache new file mode 100644 index 0000000000..3016768f7a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/akka-scala/apiRequest.mustache @@ -0,0 +1,50 @@ +package {{invokerPackage}} + +sealed trait ResponseState +object ResponseState { + case object Success extends ResponseState + case object Error extends ResponseState +} + +case class ApiRequest[U]( + // required fields + method: ApiMethod, + basePath: String, + operationPath: String, + contentType: String, + + // optional fields + responses: Map[Int, (Manifest[_], ResponseState)] = Map.empty, + bodyParam: Option[Any] = None, + formParams: Map[String, Any] = Map.empty, + pathParams: Map[String, Any] = Map.empty, + queryParams: Map[String, Any] = Map.empty, + headerParams: Map[String, Any] = Map.empty, + credentials: Seq[Credentials] = List.empty) { + + def withCredentials(cred: Credentials) = copy[U](credentials = credentials :+ cred) + + def withApiKey(key: ApiKeyValue, keyName: String, location: ApiKeyLocation) = withCredentials(ApiKeyCredentials(key, keyName, location)) + + def withSuccessResponse[T](code: Int)(implicit m: Manifest[T]) = copy[U](responses = responses + (code -> (m, ResponseState.Success))) + + def withErrorResponse[T](code: Int)(implicit m: Manifest[T]) = copy[U](responses = responses + (code -> (m, ResponseState.Error))) + + def withDefaultSuccessResponse[T](implicit m: Manifest[T]) = withSuccessResponse[T](0) + + def withDefaultErrorResponse[T](implicit m: Manifest[T]) = withErrorResponse[T](0) + + def responseForCode(statusCode: Int): Option[(Manifest[_], ResponseState)] = responses.get(statusCode) orElse responses.get(0) + + def withoutBody() = copy[U](bodyParam = None) + + def withBody(body: Any) = copy[U](bodyParam = Some(body)) + + def withFormParam(name: String, value: Any) = copy[U](formParams = formParams + (name -> value)) + + def withPathParam(name: String, value: Any) = copy[U](pathParams = pathParams + (name -> value)) + + def withQueryParam(name: String, value: Any) = copy[U](queryParams = queryParams + (name -> value)) + + def withHeaderParam(name: String, value: Any) = copy[U](headerParams = headerParams + (name -> value)) +} diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/apiSettings.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/apiSettings.mustache new file mode 100644 index 0000000000..d3ffe3613a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/akka-scala/apiSettings.mustache @@ -0,0 +1,32 @@ +package {{invokerPackage}} + +import java.util.concurrent.TimeUnit + +import akka.actor.{ExtendedActorSystem, Extension, ExtensionKey} +import com.typesafe.config.Config +import io.swagger.client.core.ApiInvoker.CustomStatusCode +import spray.http.HttpHeaders.RawHeader + +import scala.collection.JavaConversions._ +import scala.concurrent.duration.FiniteDuration + +class ApiSettings(config: Config) extends Extension { + def this(system: ExtendedActorSystem) = this(system.settings.config) + + private def cfg = config.getConfig("io.swagger.client.apiRequest") + + val alwaysTrustCertificates = cfg.getBoolean("trust-certificates") + val defaultHeaders = cfg.getConfig("default-headers").entrySet.toList.map(c => RawHeader(c.getKey, c.getValue.render)) + val connectionTimeout = FiniteDuration(cfg.getDuration("connection-timeout", TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS) + val compressionEnabled = cfg.getBoolean("compression.enabled") + val compressionSizeThreshold = cfg.getBytes("compression.size-threshold").toInt + val customCodes = cfg.getConfigList("custom-codes").toList.map { c => CustomStatusCode( + c.getInt("code"), + c.getString("reason"), + c.getBoolean("success")) + } + + +} + +object ApiSettings extends ExtensionKey[ApiSettings] diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/enumsSerializers.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/enumsSerializers.mustache new file mode 100644 index 0000000000..52f1fd3e33 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/akka-scala/enumsSerializers.mustache @@ -0,0 +1,42 @@ +package {{apiPackage}} + +import {{modelPackage}}._ +import org.json4s._ +import scala.reflect.ClassTag + +object EnumsSerializers { + + def all = Seq[Serializer[_]](){{#models}}{{#model}}{{#hasEnums}}{{#vars}}{{#isEnum}} :+ + new EnumNameSerializer({{classname}}Enums.{{datatypeWithEnum}}){{/isEnum}}{{/vars}}{{/hasEnums}}{{/model}}{{/models}} + + + + private class EnumNameSerializer[E <: Enumeration: ClassTag](enum: E) + extends Serializer[E#Value] { + import JsonDSL._ + + val EnumerationClass = classOf[E#Value] + + def deserialize(implicit format: Formats): + PartialFunction[(TypeInfo, JValue), E#Value] = { + case (t @ TypeInfo(EnumerationClass, _), json) if isValid(json) => { + json match { + case JString(value) => + enum.withName(value) + case value => + throw new MappingException(s"Can't convert $value to $EnumerationClass") + } + } + } + + private[this] def isValid(json: JValue) = json match { + case JString(value) if enum.values.exists(_.toString == value) => true + case _ => false + } + + def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { + case i: E#Value => i.toString + } + } + +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/javadoc.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/javadoc.mustache new file mode 100644 index 0000000000..0d22fd6237 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/akka-scala/javadoc.mustache @@ -0,0 +1,21 @@ +{{^notes.isEmpty}} +{{notes}} +{{/notes.isEmpty}} + +Expected answers: +{{#responses}} + code {{code}} : {{dataType}} {{^message.isEmpty}}({{message}}){{/message.isEmpty}}{{^headers.isEmpty}} + Headers :{{#headers}} + {{baseName}} - {{description}}{{/headers}}{{/headers.isEmpty}} +{{/responses}} +{{#authMethods.0}} + +Available security schemes: +{{#authMethods}} + {{name}} ({{type}}) +{{/authMethods}} +{{/authMethods.0}} + +{{#allParams}} +@param {{paramName}} {{description}} +{{/allParams}} diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/methodParameters.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/methodParameters.mustache new file mode 100644 index 0000000000..3e1ab33f66 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/akka-scala/methodParameters.mustache @@ -0,0 +1 @@ +{{#allParams}}{{paramName}}: {{#required}}{{dataType}}{{/required}}{{^required}}{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}Option[{{dataType}}]{{/isContainer}}{{/required}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}{{^required}}{{^isContainer}} = None{{/isContainer}}{{/required}}{{/defaultValue}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#authMethods.0}})(implicit {{#authMethods}}{{#isApiKey}}apiKey: ApiKeyValue{{/isApiKey}}{{#isBasic}}basicAuth: BasicCredentials{{/isBasic}}{{#hasMore}}, {{/hasMore}}{{/authMethods}}{{/authMethods.0}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/model.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/model.mustache new file mode 100644 index 0000000000..a7395b5f03 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/akka-scala/model.mustache @@ -0,0 +1,30 @@ +package {{package}} + +import {{invokerPackage}}.ApiModel +import org.joda.time.DateTime + +{{#models}} +{{#model}} + +case class {{classname}} ( + {{#vars}}{{#description}}/* {{{description}}} */ + {{/description}}{{name}}: {{^required}}Option[{{/required}}{{^isEnum}}{{datatype}}{{/isEnum}}{{#isEnum}}{{classname}}Enums.{{datatypeWithEnum}}{{/isEnum}}{{^required}}]{{/required}}{{#hasMore}},{{/hasMore}}{{^hasMore}}){{/hasMore}} + {{/vars}} extends ApiModel + +{{#hasEnums}} +object {{classname}}Enums { + + {{#vars}}{{#isEnum}}type {{datatypeWithEnum}} = {{datatypeWithEnum}}.Value + {{/isEnum}}{{/vars}} + {{#vars}}{{#isEnum}}object {{datatypeWithEnum}} extends Enumeration { +{{#_enum}} + val {{#fnEnumEntry}}{{.}}{{/fnEnumEntry}} = Value("{{.}}") +{{/_enum}} + } + + {{/isEnum}}{{/vars}} +} +{{/hasEnums}} +{{/model}} +{{/models}} + diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/operationReturnType.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/operationReturnType.mustache new file mode 100644 index 0000000000..e9d2be5340 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/akka-scala/operationReturnType.mustache @@ -0,0 +1 @@ +{{#onlyOneSuccess}}{{^defaultResponse}}Unit{{/defaultResponse}}{{#responses}}{{#isDefault}}{{#dataType}}{{dataType}}{{/dataType}}{{^dataType}}Unit{{/dataType}}{{/isDefault}}{{/responses}}{{/onlyOneSuccess}}{{^onlyOneSuccess}}{{#responses}}{{#-first}}{{^hasMore}}{{#dataType}}{{dataType}}{{/dataType}}{{^dataType}}Unit{{/dataType}}{{/hasMore}}{{#hasMore}}Any{{/hasMore}}{{/-first}}{{/responses}}{{/onlyOneSuccess}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/paramCreation.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/paramCreation.mustache new file mode 100644 index 0000000000..f93d376503 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/akka-scala/paramCreation.mustache @@ -0,0 +1 @@ +"{{baseName}}", {{#isContainer}}ArrayValues({{paramName}}{{#collectionFormat}}, {{collectionFormat.toUpperCase}}{{/collectionFormat}}){{/isContainer}}{{^isContainer}}{{paramName}}{{/isContainer}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/pom.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/pom.mustache new file mode 100644 index 0000000000..0d65c13595 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/akka-scala/pom.mustache @@ -0,0 +1,227 @@ + + 4.0.0 + {{groupId}} + {{artifactId}} + jar + {{artifactId}} + {{artifactVersion}} + + 2.2.0 + + + + + maven-mongodb-plugin-repo + maven mongodb plugin repository + http://maven-mongodb-plugin.googlecode.com/svn/maven/repo + default + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + pertest + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + jar + test-jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add_sources + generate-sources + + add-source + + + + + src/main/java + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + 1.6 + 1.6 + + + + net.alchim31.maven + scala-maven-plugin + ${scala-maven-plugin-version} + + + scala-compile-first + process-resources + + add-source + compile + + + + scala-test-compile + process-test-resources + + testCompile + + + + + + -feature + + + -Xms128m + -Xmx1500m + + + + + + + + + org.scala-tools + maven-scala-plugin + + ${scala-version} + + + + + + + org.scala-lang + scala-library + ${scala-version} + + + com.wordnik + swagger-core + ${swagger-core-version} + + + org.scalatest + scalatest_2.10 + ${scala-test-version} + test + + + junit + junit + ${junit-version} + test + + + joda-time + joda-time + ${joda-time-version} + + + org.joda + joda-convert + ${joda-version} + + + com.typesafe + config + 1.2.1 + + + com.typesafe.akka + akka-actor_2.10 + ${akka-version} + + + io.spray + spray-client + ${spray-version} + + + org.json4s + json4s-jackson_2.10 + ${json4s-jackson-version} + + + + 2.10.4 + 3.2.11 + 3.2.11 + 1.3.1 + 2.3.9 + 1.2 + 2.2 + 1.5.0-M1 + 1.0.0 + + 4.8.1 + 3.1.5 + 2.1.3 + + diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/reference.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/reference.mustache new file mode 100644 index 0000000000..1a28a8962e --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/akka-scala/reference.mustache @@ -0,0 +1,24 @@ +{{configKeyPath}} { + + {{configKey}} { + + compression { + enabled: false + size-threshold: 0 + } + + trust-certificates: true + + connection-timeout: {{defaultTimeout}}ms + + default-headers { + "userAgent": "{{artifactId}}_{{artifactVersion}}" + } + + // let you define custom http status code, as in : + // { code: 601, reason: "some custom http status code", success: false } + custom-codes : [] + } +} + +spray.can.host-connector.max-redirects = 10 \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/requests.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/requests.mustache new file mode 100644 index 0000000000..145354203f --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/akka-scala/requests.mustache @@ -0,0 +1,166 @@ +package {{invokerPackage}} + +import java.io.File +import java.net.URLEncoder +import scala.util.Try + +sealed trait ApiReturnWithHeaders { + def headers: Map[String, String] + def header(name: String): Option[String] = headers.get(name) + def getStringHeader(name: String) = header(name) + def getIntHeader(name: String) = castedHeader(name, java.lang.Integer.parseInt) + def getLongHeader(name: String) = castedHeader(name, java.lang.Long.parseLong) + def getFloatHeader(name: String) = castedHeader(name, java.lang.Float.parseFloat) + def getDoubleHeader(name: String) = castedHeader(name, java.lang.Double.parseDouble) + def getBooleanHeader(name: String) = castedHeader(name, java.lang.Boolean.parseBoolean) + private def castedHeader[U](name: String, conversion: String => U): Option[U] = { Try { header(name).map( conversion ) }.get } +} + +sealed case class ApiResponse[T](code: Int, content: T, headers: Map[String, String] = Map.empty) + extends ApiReturnWithHeaders + +sealed case class ApiError[T](code: Int, message: String, responseContent: Option[T], cause: Throwable = null, headers: Map[String, String] = Map.empty) + extends Throwable(s"($code) $message.${responseContent.map(s => s" Content : $s").getOrElse("")}", cause) + with ApiReturnWithHeaders + +sealed case class ApiMethod(value: String) + +object ApiMethods { + val CONNECT = ApiMethod("CONNECT") + val DELETE = ApiMethod("DELETE") + val GET = ApiMethod("GET") + val HEAD = ApiMethod("HEAD") + val OPTIONS = ApiMethod("OPTIONS") + val PATCH = ApiMethod("PATCH") + val POST = ApiMethod("POST") + val PUT = ApiMethod("PUT") + val TRACE = ApiMethod("TRACE") +} + +/** + * This trait needs to be added to any model defined by the api. + */ +trait ApiModel + +/** + * Single trait defining a credential that can be transformed to a paramName / paramValue tupple + */ +sealed trait Credentials { + def asQueryParam: Option[(String, String)] = None +} + +sealed case class BasicCredentials(user: String, password: String) extends Credentials + +sealed case class ApiKeyCredentials(key: ApiKeyValue, keyName: String, location: ApiKeyLocation) extends Credentials { + override def asQueryParam: Option[(String, String)] = location match { + case ApiKeyLocations.QUERY => Some((keyName, key.value)) + case _ => None + } +} + +sealed case class ApiKeyValue(value: String) + +sealed trait ApiKeyLocation + +object ApiKeyLocations { + + case object QUERY extends ApiKeyLocation + + case object HEADER extends ApiKeyLocation +} + + +/** + * Case class used to unapply numeric values only in pattern matching + * @param value the string representation of the numeric value + */ +sealed case class NumericValue(value: String) { + override def toString = value +} + +object NumericValue { + def unapply(n: Any): Option[NumericValue] = n match { + case (_: Int | _: Long | _: Float | _: Double | _: Boolean | _: Byte) => Some(NumericValue(String.valueOf(n))) + case _ => None + } +} + +/** + * Used for params being arrays + */ +sealed case class ArrayValues(values: Seq[Any], format: CollectionFormat = CollectionFormats.CSV) + +object ArrayValues { + def apply(values: Option[Seq[Any]], format: CollectionFormat): ArrayValues = + ArrayValues(values.getOrElse(Seq.empty), format) + + def apply(values: Option[Seq[Any]]): ArrayValues = ArrayValues(values, CollectionFormats.CSV) +} + + +/** + * Defines how arrays should be rendered in query strings. + */ +sealed trait CollectionFormat + +trait MergedArrayFormat extends CollectionFormat { + def separator: String +} + +object CollectionFormats { + + case object CSV extends MergedArrayFormat { + override val separator = "," + } + + case object TSV extends MergedArrayFormat { + override val separator = "\t" + } + + case object SSV extends MergedArrayFormat { + override val separator = " " + } + + case object PIPES extends MergedArrayFormat { + override val separator = "|" + } + + case object MULTI extends CollectionFormat + +} + +object ParametersMap { + + /** + * Pimp parameters maps (Map[String, Any]) in order to transform them in a sequence of String -> Any tupples, + * with valid url-encoding, arrays handling, files preservation, ... + */ + implicit class ParametersMapImprovements(val m: Map[String, Any]) { + + def asFormattedParamsList = m.toList.flatMap(formattedParams) + + def asFormattedParams = m.flatMap(formattedParams) + + private def urlEncode(v: Any) = URLEncoder.encode(String.valueOf(v), "utf-8").replaceAll("\\+", "%20") + + private def formattedParams(tuple: (String, Any)): Seq[(String, Any)] = formattedParams(tuple._1, tuple._2) + + private def formattedParams(name: String, value: Any): Seq[(String, Any)] = value match { + case arr: ArrayValues => + arr.format match { + case CollectionFormats.MULTI => arr.values.flatMap(formattedParams(name, _)) + case format: MergedArrayFormat => Seq((name, arr.values.mkString(format.separator))) + } + case None => Seq.empty + case Some(opt) => + formattedParams(name, opt) + case s: Seq[Any] => + formattedParams(name, ArrayValues(s)) + case v: String => Seq((name, urlEncode(v))) + case NumericValue(v) => Seq((name, urlEncode(v))) + case f: File => Seq((name, f)) + case m: ApiModel => Seq((name, m)) + } + + } +} diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/responseState.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/responseState.mustache new file mode 100644 index 0000000000..c6d44b86d8 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/akka-scala/responseState.mustache @@ -0,0 +1 @@ +{{#onlyOneSuccess}}{{#isDefault}}Success{{/isDefault}}{{^isDefault}}Error{{/isDefault}}{{/onlyOneSuccess}}{{^onlyOneSuccess}}Success{{/onlyOneSuccess}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/test/resources/2_0/requiredTest.json b/modules/swagger-codegen/src/test/resources/2_0/requiredTest.json new file mode 100644 index 0000000000..88106746d2 --- /dev/null +++ b/modules/swagger-codegen/src/test/resources/2_0/requiredTest.json @@ -0,0 +1,93 @@ +{ + "swagger": "2.0", + "info": { + "description": "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters", + "version": "1.0.0", + "title": "Swagger Petstore", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "email": "apiteam@wordnik.com" + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "host": "petstore.swagger.io", + "basePath": "/v2", + "schemes": [ + "http" + ], + "paths": { + "/tests/requiredParams": { + "get": { + "tags": [ + "tests" + ], + "summary": "Operation with required parameters", + "description": "", + "operationId": "requiredParams", + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "param1", + "in": "formData", + "description": "Some required parameter", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "param2", + "in": "formData", + "description": "Some optional parameter", + "required": false, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation. Retuning a simple int.", + "schema": { + "type": "integer", + "format": "int64" + } + } + } + } + } + }, + "securityDefinitions": { + "api_key": { + "type": "apiKey", + "name": "api_key", + "in": "header" + }, + "petstore_auth": { + "type": "oauth2", + "authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog", + "flow": "implicit", + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } + } + }, + "definitions": { + "CustomModel": { + "required": ["id"], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string", + "example": "doggie" + } + } + } + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/test/scala/CodegenTest.scala b/modules/swagger-codegen/src/test/scala/CodegenTest.scala index 9e2a1d9fa9..5ce3582515 100644 --- a/modules/swagger-codegen/src/test/scala/CodegenTest.scala +++ b/modules/swagger-codegen/src/test/scala/CodegenTest.scala @@ -1,15 +1,9 @@ -import com.wordnik.swagger.models._ -import com.wordnik.swagger.util.Json -import io.swagger.parser._ - import com.wordnik.swagger.codegen.DefaultCodegen - +import com.wordnik.swagger.models.properties.Property +import io.swagger.parser._ import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner -import org.scalatest.FlatSpec -import org.scalatest.Matchers - -import scala.collection.JavaConverters._ +import org.scalatest.{FlatSpec, Matchers} @RunWith(classOf[JUnitRunner]) class CodegenTest extends FlatSpec with Matchers { @@ -95,6 +89,32 @@ class CodegenTest extends FlatSpec with Matchers { statusParam.hasMore should be (null) } + it should "handle required parameters from a 2.0 spec as required when figuring out Swagger types" in { + val model = new SwaggerParser() + .read("src/test/resources/2_0/requiredTest.json") + + val codegen = new DefaultCodegen() { + override def getSwaggerType(p: Property) = Option(p) match { + case Some(property) if !property.getRequired => + "Optional<" + super.getSwaggerType(p) + ">" + case other => super.getSwaggerType(p) + } + } + val path = "/tests/requiredParams" + val p = model.getPaths().get(path).getGet() + val op = codegen.fromOperation(path, "get", p, model.getDefinitions) + + val formParams = op.formParams + formParams.size should be(2) + val requiredParam = formParams.get(0) + requiredParam.dataType should be("Long") + + val optionalParam = formParams.get(1) + optionalParam.dataType should be("Optional") + + op.returnType should be("Long") + } + it should "select main response from a 2.0 spec using the lowest 2XX code" in { val model = new SwaggerParser() .read("src/test/resources/2_0/responseSelectionTest.json") From 2ce55115a631d74b32e7fbb76168baebebd3a9d3 Mon Sep 17 00:00:00 2001 From: Camille Chafer Date: Thu, 2 Apr 2015 16:26:16 +0200 Subject: [PATCH 2/5] Add wordnik and petstore examples --- samples/client/petstore/akka-scala/pom.xml | 227 ++++++++++++ .../src/main/resources/reference.conf | 24 ++ .../swagger/client/api/EnumsSerializers.scala | 43 +++ .../scala/io/swagger/client/api/PetApi.scala | 139 ++++++++ .../io/swagger/client/api/StoreApi.scala | 73 ++++ .../scala/io/swagger/client/api/UserApi.scala | 123 +++++++ .../io/swagger/client/core/ApiInvoker.scala | 323 ++++++++++++++++++ .../io/swagger/client/core/ApiRequest.scala | 50 +++ .../io/swagger/client/core/ApiSettings.scala | 32 ++ .../io/swagger/client/core/requests.scala | 166 +++++++++ .../io/swagger/client/model/Category.scala | 12 + .../scala/io/swagger/client/model/Order.scala | 29 ++ .../scala/io/swagger/client/model/Pet.scala | 29 ++ .../scala/io/swagger/client/model/Tag.scala | 12 + .../scala/io/swagger/client/model/User.scala | 19 ++ samples/client/wordnik/akka-scala/pom.xml | 227 ++++++++++++ .../src/main/resources/reference.conf | 24 ++ .../io/swagger/client/api/AccountApi.scala | 109 ++++++ .../swagger/client/api/EnumsSerializers.scala | 41 +++ .../scala/io/swagger/client/api/WordApi.scala | 253 ++++++++++++++ .../io/swagger/client/api/WordListApi.scala | 154 +++++++++ .../io/swagger/client/api/WordListsApi.scala | 34 ++ .../io/swagger/client/api/WordsApi.scala | 181 ++++++++++ .../io/swagger/client/core/ApiInvoker.scala | 323 ++++++++++++++++++ .../io/swagger/client/core/ApiRequest.scala | 50 +++ .../io/swagger/client/core/ApiSettings.scala | 32 ++ .../io/swagger/client/core/requests.scala | 166 +++++++++ .../swagger/client/model/ApiTokenStatus.scala | 16 + .../io/swagger/client/model/AudioFile.scala | 24 ++ .../io/swagger/client/model/AudioType.scala | 12 + .../client/model/AuthenticationToken.scala | 13 + .../io/swagger/client/model/Bigram.scala | 15 + .../io/swagger/client/model/Category.scala | 12 + .../io/swagger/client/model/Citation.scala | 12 + .../client/model/ContentProvider.scala | 12 + .../io/swagger/client/model/Definition.scala | 26 ++ .../model/DefinitionSearchResults.scala | 12 + .../io/swagger/client/model/Example.scala | 22 ++ .../client/model/ExampleSearchResults.scala | 12 + .../swagger/client/model/ExampleUsage.scala | 11 + .../scala/io/swagger/client/model/Facet.scala | 12 + .../io/swagger/client/model/FacetValue.scala | 12 + .../io/swagger/client/model/Frequency.scala | 12 + .../client/model/FrequencySummary.scala | 15 + .../scala/io/swagger/client/model/Label.scala | 12 + .../scala/io/swagger/client/model/Note.scala | 14 + .../swagger/client/model/PartOfSpeech.scala | 13 + .../io/swagger/client/model/Related.scala | 17 + .../scala/io/swagger/client/model/Root.scala | 13 + .../io/swagger/client/model/ScoredWord.scala | 21 ++ .../io/swagger/client/model/Sentence.scala | 16 + .../client/model/SimpleDefinition.scala | 14 + .../swagger/client/model/SimpleExample.scala | 14 + .../io/swagger/client/model/StringValue.scala | 11 + .../io/swagger/client/model/Syllable.scala | 13 + .../io/swagger/client/model/TextPron.scala | 13 + .../scala/io/swagger/client/model/User.scala | 18 + .../io/swagger/client/model/WordList.scala | 21 ++ .../swagger/client/model/WordListWord.scala | 17 + .../io/swagger/client/model/WordObject.scala | 16 + .../swagger/client/model/WordOfTheDay.scala | 22 ++ .../client/model/WordSearchResult.scala | 13 + .../client/model/WordSearchResults.scala | 12 + 63 files changed, 3435 insertions(+) create mode 100644 samples/client/petstore/akka-scala/pom.xml create mode 100644 samples/client/petstore/akka-scala/src/main/resources/reference.conf create mode 100644 samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala create mode 100644 samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala create mode 100644 samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala create mode 100644 samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala create mode 100644 samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala create mode 100644 samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala create mode 100644 samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala create mode 100644 samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/requests.scala create mode 100644 samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Category.scala create mode 100644 samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Order.scala create mode 100644 samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Pet.scala create mode 100644 samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Tag.scala create mode 100644 samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/User.scala create mode 100644 samples/client/wordnik/akka-scala/pom.xml create mode 100644 samples/client/wordnik/akka-scala/src/main/resources/reference.conf create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/AccountApi.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListsApi.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/requests.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ApiTokenStatus.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioFile.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioType.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AuthenticationToken.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Bigram.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Category.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Citation.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ContentProvider.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Definition.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/DefinitionSearchResults.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Example.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleSearchResults.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleUsage.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Facet.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FacetValue.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Frequency.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FrequencySummary.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Label.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Note.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/PartOfSpeech.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Related.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Root.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ScoredWord.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Sentence.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleDefinition.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleExample.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/StringValue.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Syllable.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/TextPron.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/User.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordList.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordListWord.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordObject.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordOfTheDay.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResult.scala create mode 100644 samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResults.scala diff --git a/samples/client/petstore/akka-scala/pom.xml b/samples/client/petstore/akka-scala/pom.xml new file mode 100644 index 0000000000..f865a97c38 --- /dev/null +++ b/samples/client/petstore/akka-scala/pom.xml @@ -0,0 +1,227 @@ + + 4.0.0 + com.wordnik + swagger-client + jar + swagger-client + 1.0.0 + + 2.2.0 + + + + + maven-mongodb-plugin-repo + maven mongodb plugin repository + http://maven-mongodb-plugin.googlecode.com/svn/maven/repo + default + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + pertest + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + jar + test-jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add_sources + generate-sources + + add-source + + + + + src/main/java + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + 1.6 + 1.6 + + + + net.alchim31.maven + scala-maven-plugin + ${scala-maven-plugin-version} + + + scala-compile-first + process-resources + + add-source + compile + + + + scala-test-compile + process-test-resources + + testCompile + + + + + + -feature + + + -Xms128m + -Xmx1500m + + + + + + + + + org.scala-tools + maven-scala-plugin + + ${scala-version} + + + + + + + org.scala-lang + scala-library + ${scala-version} + + + com.wordnik + swagger-core + ${swagger-core-version} + + + org.scalatest + scalatest_2.10 + ${scala-test-version} + test + + + junit + junit + ${junit-version} + test + + + joda-time + joda-time + ${joda-time-version} + + + org.joda + joda-convert + ${joda-version} + + + com.typesafe + config + 1.2.1 + + + com.typesafe.akka + akka-actor_2.10 + ${akka-version} + + + io.spray + spray-client + ${spray-version} + + + org.json4s + json4s-jackson_2.10 + ${json4s-jackson-version} + + + + 2.10.4 + 3.2.11 + 3.2.11 + 1.3.1 + 2.3.9 + 1.2 + 2.2 + 1.5.0-M1 + 1.0.0 + + 4.8.1 + 3.1.5 + 2.1.3 + + diff --git a/samples/client/petstore/akka-scala/src/main/resources/reference.conf b/samples/client/petstore/akka-scala/src/main/resources/reference.conf new file mode 100644 index 0000000000..f993f765ed --- /dev/null +++ b/samples/client/petstore/akka-scala/src/main/resources/reference.conf @@ -0,0 +1,24 @@ +io.swagger.client { + + apiRequest { + + compression { + enabled: false + size-threshold: 0 + } + + trust-certificates: true + + connection-timeout: 5000ms + + default-headers { + "userAgent": "swagger-client_1.0.0" + } + + // let you define custom http status code, as in : + // { code: 601, reason: "some custom http status code", success: false } + custom-codes : [] + } +} + +spray.can.host-connector.max-redirects = 10 \ No newline at end of file diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala new file mode 100644 index 0000000000..c8c0d2454e --- /dev/null +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala @@ -0,0 +1,43 @@ +package io.swagger.client.api + +import io.swagger.client.model._ +import org.json4s._ +import scala.reflect.ClassTag + +object EnumsSerializers { + + def all = Seq[Serializer[_]]() :+ + new EnumNameSerializer(PetEnums.Status) :+ + new EnumNameSerializer(OrderEnums.Status) + + + + private class EnumNameSerializer[E <: Enumeration: ClassTag](enum: E) + extends Serializer[E#Value] { + import JsonDSL._ + + val EnumerationClass = classOf[E#Value] + + def deserialize(implicit format: Formats): + PartialFunction[(TypeInfo, JValue), E#Value] = { + case (t @ TypeInfo(EnumerationClass, _), json) if isValid(json) => { + json match { + case JString(value) => + enum.withName(value) + case value => + throw new MappingException(s"Can't convert $value to $EnumerationClass") + } + } + } + + private[this] def isValid(json: JValue) = json match { + case JString(value) if enum.values.exists(_.toString == value) => true + case _ => false + } + + def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { + case i: E#Value => i.toString + } + } + +} \ No newline at end of file diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala new file mode 100644 index 0000000000..d56d3f855a --- /dev/null +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala @@ -0,0 +1,139 @@ +package io.swagger.client.api + +import io.swagger.client.model.Pet +import java.io.File +import io.swagger.client.core._ +import io.swagger.client.core.CollectionFormats._ +import io.swagger.client.core.ApiKeyLocations._ + +object PetApi { + + /** + * + * Expected answers: + * code 405 : (Validation exception) + * code 404 : (Pet not found) + * code 400 : (Invalid ID supplied) + * + * @param Body Pet object that needs to be added to the store + */ + def updatePet(Body: Option[Pet] = None): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.PUT, "http://petstore.swagger.io/v2", "/pet", "application/json") + .withBody(Body) + .withErrorResponse[Unit](405) + .withErrorResponse[Unit](404) + .withErrorResponse[Unit](400) + + /** + * + * Expected answers: + * code 405 : (Invalid input) + * + * @param Body Pet object that needs to be added to the store + */ + def addPet(Body: Option[Pet] = None): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet", "application/json") + .withBody(Body) + .withErrorResponse[Unit](405) + + /** + * Multiple status values can be provided with comma seperated strings + * + * Expected answers: + * code 200 : Seq[Pet] (successful operation) + * code 400 : (Invalid status value) + * + * @param Status Status values that need to be considered for filter + */ + def findPetsByStatus(Status: Seq[String]): ApiRequest[Seq[Pet]] = + ApiRequest[Seq[Pet]](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/findByStatus", "application/json") + .withQueryParam("status", ArrayValues(Status, MULTI)) + .withSuccessResponse[Seq[Pet]](200) + .withErrorResponse[Unit](400) + + /** + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * + * Expected answers: + * code 200 : Seq[Pet] (successful operation) + * code 400 : (Invalid tag value) + * + * @param Tags Tags to filter by + */ + def findPetsByTags(Tags: Seq[String]): ApiRequest[Seq[Pet]] = + ApiRequest[Seq[Pet]](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/findByTags", "application/json") + .withQueryParam("tags", ArrayValues(Tags, MULTI)) + .withSuccessResponse[Seq[Pet]](200) + .withErrorResponse[Unit](400) + + /** + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * + * Expected answers: + * code 404 : (Pet not found) + * code 200 : Pet (successful operation) + * code 400 : (Invalid ID supplied) + * + * Available security schemes: + * api_key (apiKey) + * + * @param PetId ID of pet that needs to be fetched + */ + def getPetById(PetId: Long)(implicit apiKey: ApiKeyValue): ApiRequest[Pet] = + ApiRequest[Pet](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/json") + .withApiKey(apiKey, "api_key", HEADER) + .withPathParam("petId", PetId) + .withErrorResponse[Unit](404) + .withSuccessResponse[Pet](200) + .withErrorResponse[Unit](400) + + /** + * + * Expected answers: + * code 405 : (Invalid input) + * + * @param PetId ID of pet that needs to be updated + * @param Name Updated name of the pet + * @param Status Updated status of the pet + */ + def updatePetWithForm(PetId: String, Name: Option[String] = None, Status: Option[String] = None): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/x-www-form-urlencoded") + .withFormParam("name", Name) + .withFormParam("status", Status) + .withPathParam("petId", PetId) + .withErrorResponse[Unit](405) + + /** + * + * Expected answers: + * code 400 : (Invalid pet value) + * + * @param ApiKey + * @param PetId Pet id to delete + */ + def deletePet(ApiKey: Option[String] = None, PetId: Long): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.DELETE, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/json") + .withPathParam("petId", PetId) + .withHeaderParam("api_key", ApiKey) + .withErrorResponse[Unit](400) + + /** + * + * Expected answers: + * code 0 : (successful operation) + * + * @param PetId ID of pet to update + * @param AdditionalMetadata Additional data to pass to server + * @param File file to upload + */ + def uploadFile(PetId: Long, AdditionalMetadata: Option[String] = None, File: Option[File] = None): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet/{petId}/uploadImage", "multipart/form-data") + .withFormParam("additionalMetadata", AdditionalMetadata) + .withFormParam("file", File) + .withPathParam("petId", PetId) + .withSuccessResponse[Unit](0) + + + +} + diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala new file mode 100644 index 0000000000..a1391954a7 --- /dev/null +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala @@ -0,0 +1,73 @@ +package io.swagger.client.api + +import io.swagger.client.model.Order +import io.swagger.client.core._ +import io.swagger.client.core.CollectionFormats._ +import io.swagger.client.core.ApiKeyLocations._ + +object StoreApi { + + /** + * Returns a map of status codes to quantities + * + * Expected answers: + * code 200 : Map[String, Int] (successful operation) + * + * Available security schemes: + * api_key (apiKey) + */ + def getInventory()(implicit apiKey: ApiKeyValue): ApiRequest[Map[String, Int]] = + ApiRequest[Map[String, Int]](ApiMethods.GET, "http://petstore.swagger.io/v2", "/store/inventory", "application/json") + .withApiKey(apiKey, "api_key", HEADER) + .withSuccessResponse[Map[String, Int]](200) + + /** + * + * Expected answers: + * code 200 : Order (successful operation) + * code 400 : (Invalid Order) + * + * @param Body order placed for purchasing the pet + */ + def placeOrder(Body: Option[Order] = None): ApiRequest[Order] = + ApiRequest[Order](ApiMethods.POST, "http://petstore.swagger.io/v2", "/store/order", "application/json") + .withBody(Body) + .withSuccessResponse[Order](200) + .withErrorResponse[Unit](400) + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + * Expected answers: + * code 404 : (Order not found) + * code 200 : Order (successful operation) + * code 400 : (Invalid ID supplied) + * + * @param OrderId ID of pet that needs to be fetched + */ + def getOrderById(OrderId: String): ApiRequest[Order] = + ApiRequest[Order](ApiMethods.GET, "http://petstore.swagger.io/v2", "/store/order/{orderId}", "application/json") + .withPathParam("orderId", OrderId) + .withErrorResponse[Unit](404) + .withSuccessResponse[Order](200) + .withErrorResponse[Unit](400) + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + * Expected answers: + * code 404 : (Order not found) + * code 400 : (Invalid ID supplied) + * + * @param OrderId ID of the order that needs to be deleted + */ + def deleteOrder(OrderId: String): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.DELETE, "http://petstore.swagger.io/v2", "/store/order/{orderId}", "application/json") + .withPathParam("orderId", OrderId) + .withErrorResponse[Unit](404) + .withErrorResponse[Unit](400) + + + +} + diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala new file mode 100644 index 0000000000..77aade9a9e --- /dev/null +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala @@ -0,0 +1,123 @@ +package io.swagger.client.api + +import io.swagger.client.model.User +import io.swagger.client.core._ +import io.swagger.client.core.CollectionFormats._ +import io.swagger.client.core.ApiKeyLocations._ + +object UserApi { + + /** + * This can only be done by the logged in user. + * + * Expected answers: + * code 0 : (successful operation) + * + * @param Body Created user object + */ + def createUser(Body: Option[User] = None): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user", "application/json") + .withBody(Body) + .withSuccessResponse[Unit](0) + + /** + * + * Expected answers: + * code 0 : (successful operation) + * + * @param Body List of user object + */ + def createUsersWithArrayInput(Body: Seq[User]): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user/createWithArray", "application/json") + .withBody(Body) + .withSuccessResponse[Unit](0) + + /** + * + * Expected answers: + * code 0 : (successful operation) + * + * @param Body List of user object + */ + def createUsersWithListInput(Body: Seq[User]): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user/createWithList", "application/json") + .withBody(Body) + .withSuccessResponse[Unit](0) + + /** + * + * Expected answers: + * code 200 : String (successful operation) + * code 400 : (Invalid username/password supplied) + * + * @param Username The user name for login + * @param Password The password for login in clear text + */ + def loginUser(Username: Option[String] = None, Password: Option[String] = None): ApiRequest[String] = + ApiRequest[String](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/login", "application/json") + .withQueryParam("username", Username) + .withQueryParam("password", Password) + .withSuccessResponse[String](200) + .withErrorResponse[Unit](400) + + /** + * + * Expected answers: + * code 0 : (successful operation) + */ + def logoutUser(): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/logout", "application/json") + .withSuccessResponse[Unit](0) + + /** + * + * Expected answers: + * code 404 : (User not found) + * code 200 : User (successful operation) + * code 400 : (Invalid username supplied) + * + * @param Username The name that needs to be fetched. Use user1 for testing. + */ + def getUserByName(Username: String): ApiRequest[User] = + ApiRequest[User](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/{username}", "application/json") + .withPathParam("username", Username) + .withErrorResponse[Unit](404) + .withSuccessResponse[User](200) + .withErrorResponse[Unit](400) + + /** + * This can only be done by the logged in user. + * + * Expected answers: + * code 404 : (User not found) + * code 400 : (Invalid user supplied) + * + * @param Username name that need to be deleted + * @param Body Updated user object + */ + def updateUser(Username: String, Body: Option[User] = None): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.PUT, "http://petstore.swagger.io/v2", "/user/{username}", "application/json") + .withBody(Body) + .withPathParam("username", Username) + .withErrorResponse[Unit](404) + .withErrorResponse[Unit](400) + + /** + * This can only be done by the logged in user. + * + * Expected answers: + * code 404 : (User not found) + * code 400 : (Invalid username supplied) + * + * @param Username The name that needs to be deleted + */ + def deleteUser(Username: String): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.DELETE, "http://petstore.swagger.io/v2", "/user/{username}", "application/json") + .withPathParam("username", Username) + .withErrorResponse[Unit](404) + .withErrorResponse[Unit](400) + + + +} + diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala new file mode 100644 index 0000000000..3b11d86601 --- /dev/null +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala @@ -0,0 +1,323 @@ +package io.swagger.client.core + +import java.io.File +import java.security.cert.X509Certificate +import javax.net.ssl._ + +import akka.actor.ActorSystem +import akka.io.IO +import akka.pattern.ask +import akka.util.Timeout +import org.joda.time.DateTime +import org.joda.time.format.ISODateTimeFormat +import org.json4s.JsonAST.JString +import org.json4s._ +import org.json4s.jackson.JsonMethods._ +import org.json4s.jackson.Serialization +import spray.can.Http +import spray.can.Http.HostConnectorSetup +import spray.client.pipelining +import spray.client.pipelining._ +import spray.http.HttpEncodings._ +import spray.http.HttpHeaders.{RawHeader, `Accept-Encoding`} +import spray.http.Uri.Query +import spray.http._ +import spray.http.parser.HttpParser +import spray.httpx.encoding.{Deflate, Encoder, Gzip} +import spray.httpx.unmarshalling._ +import spray.io.ClientSSLEngineProvider + +import scala.concurrent.{ExecutionContext, Future} +import scala.reflect.ClassTag +import scala.util.control.NonFatal + +object ApiInvoker { + + def apply()(implicit system: ActorSystem): ApiInvoker = + apply(DefaultFormats + DateTimeSerializer) + def apply(serializers: Traversable[Serializer[_]])(implicit system: ActorSystem): ApiInvoker = + apply(DefaultFormats + DateTimeSerializer ++ serializers) + def apply(formats: Formats)(implicit system: ActorSystem): ApiInvoker = new ApiInvoker(formats) + + case class CustomStatusCode(value: Int, reason: String = "Application-defined status code", isSuccess: Boolean = true) + + def addCustomStatusCode(code: CustomStatusCode): Unit = addCustomStatusCode(code.value, code.reason, code.isSuccess) + + def addCustomStatusCode(code: Int, reason: String = "Application defined code", isSuccess: Boolean = true) = { + StatusCodes.getForKey(code) foreach { c => + StatusCodes.registerCustom(code, reason, reason, isSuccess, allowsEntity = true) + } + } + + /** + * Allows request execution without calling apiInvoker.execute(request) + * request.response can be used to get a future of the ApiResponse generated. + * request.result can be used to get a future of the expected ApiResponse content. If content doesn't match, a + * Future will failed with a ClassCastException + * @param request the apiRequest to be executed + */ + implicit class ApiRequestImprovements[T](request: ApiRequest[T]) { + + def response(invoker: ApiInvoker)(implicit ec: ExecutionContext, system: ActorSystem): Future[ApiResponse[T]] = + response(ec, system, invoker) + + def response(implicit ec: ExecutionContext, system: ActorSystem, invoker: ApiInvoker): Future[ApiResponse[T]] = + invoker.execute(request) + + def result[U <: T](implicit c: ClassTag[U], ec: ExecutionContext, system: ActorSystem, invoker: ApiInvoker): Future[U] = + invoker.execute(request).map(_.content).mapTo[U] + + } + + /** + * Allows transformation from ApiMethod to spray HttpMethods + * @param method the ApiMethod to be converted + */ + implicit class ApiMethodExtensions(val method: ApiMethod) { + def toSprayMethod: HttpMethod = HttpMethods.getForKey(method.value).getOrElse(HttpMethods.GET) + } + + case object DateTimeSerializer extends CustomSerializer[DateTime](format => ( { + case JString(s) => + ISODateTimeFormat.dateTimeParser().parseDateTime(s) + }, { + case d: DateTime => + JString(ISODateTimeFormat.dateTimeParser().print(d)) + })) +} + +class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends UntrustedSslContext with CustomContentTypes { + + import io.swagger.client.core.ApiInvoker._ + import io.swagger.client.core.ParametersMap._ + + implicit val ec = system.dispatcher + implicit val jsonFormats = formats + + def settings = ApiSettings(system) + + import spray.http.MessagePredicate._ + + val CompressionFilter = MessagePredicate({ _ => settings.compressionEnabled}) && + Encoder.DefaultFilter && + minEntitySize(settings.compressionSizeThreshold) + + settings.customCodes.foreach(addCustomStatusCode) + + private def addAuthentication(credentialsSeq: Seq[Credentials]): pipelining.RequestTransformer = + request => + credentialsSeq.foldLeft(request) { + case (req, BasicCredentials(login, password)) => + req ~> addCredentials(BasicHttpCredentials(login, password)) + case (req, ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) => + req ~> addHeader(RawHeader(keyName, keyValue.value)) + case (req, _) => req + } + + private def addHeaders(headers: Map[String, Any]): pipelining.RequestTransformer = { request => + + val rawHeaders = for { + (name, value) <- headers.asFormattedParams + header = RawHeader(name, String.valueOf(value)) + } yield header + + request.withHeaders(rawHeaders.toList) + } + + private def bodyPart(name: String, value: Any): BodyPart = { + value match { + case f: File => + BodyPart(f, name) + case v: String => + BodyPart(HttpEntity(String.valueOf(v))) + case NumericValue(v) => + BodyPart(HttpEntity(String.valueOf(v))) + case m: ApiModel => + BodyPart(HttpEntity(Serialization.write(m))) + } + } + + private def formDataContent(request: ApiRequest[_]) = { + val params = request.formParams.asFormattedParams + if (params.isEmpty) + None + else + Some( + normalizedContentType(request.contentType).mediaType match { + case MediaTypes.`multipart/form-data` => + MultipartFormData(params.map { case (name, value) => (name, bodyPart(name, value))}) + case MediaTypes.`application/x-www-form-urlencoded` => + FormData(params.mapValues(String.valueOf)) + case m: MediaType => // Default : application/x-www-form-urlencoded. + FormData(params.mapValues(String.valueOf)) + } + ) + } + + private def bodyContent(request: ApiRequest[_]): Option[Any] = { + request.bodyParam.map(Extraction.decompose).map(compact) + } + + private def createRequest(uri: Uri, request: ApiRequest[_]): HttpRequest = { + + val builder = new RequestBuilder(request.method.toSprayMethod) + val httpRequest = request.method.toSprayMethod match { + case HttpMethods.GET | HttpMethods.DELETE => builder.apply(uri) + case HttpMethods.POST | HttpMethods.PUT => + formDataContent(request) orElse bodyContent(request) match { + case Some(c: FormData) => + builder.apply(uri, c) + case Some(c: MultipartFormData) => + builder.apply(uri, c) + case Some(c: String) => + builder.apply(uri, HttpEntity(normalizedContentType(request.contentType), c)) + case _ => + builder.apply(uri, HttpEntity(normalizedContentType(request.contentType), " ")) + } + case _ => builder.apply(uri) + } + + httpRequest ~> + addHeaders(request.headerParams) ~> + addAuthentication(request.credentials) ~> + encode(Gzip(CompressionFilter)) + } + + def makeQuery(r: ApiRequest[_]): Query = { + r.credentials.foldLeft(r.queryParams) { + case (params, ApiKeyCredentials(key, keyName, ApiKeyLocations.QUERY)) => + params + (keyName -> key.value) + case (params, _) => params + }.asFormattedParams + .mapValues(String.valueOf) + .foldRight[Query](Uri.Query.Empty) { + case ((name, value), acc) => acc.+:(name, value) + } + } + + def makeUri(r: ApiRequest[_]): Uri = { + val opPath = r.operationPath.replaceAll("\\{format\\}", "json") + val opPathWithParams = r.pathParams.asFormattedParams + .mapValues(String.valueOf) + .foldLeft(opPath) { + case (path, (name, value)) => path.replaceAll(s"\\{$name\\}", value) + } + val query = makeQuery(r) + + Uri(r.basePath + opPathWithParams).withQuery(query) + } + + def execute[T](r: ApiRequest[T]): Future[ApiResponse[T]] = { + try { + implicit val timeout: Timeout = settings.connectionTimeout + + val uri = makeUri(r) + + val connector = HostConnectorSetup( + uri.authority.host.toString, + uri.effectivePort, + sslEncryption = "https".equals(uri.scheme), + defaultHeaders = settings.defaultHeaders ++ List(`Accept-Encoding`(gzip, deflate))) + + val request = createRequest(uri, r) + + for { + Http.HostConnectorInfo(hostConnector, _) <- IO(Http) ? connector + response <- hostConnector.ask(request).mapTo[HttpResponse] + } yield { + response ~> decode(Deflate) ~> decode(Gzip) ~> unmarshallApiResponse(r) + } + } + catch { + case NonFatal(x) => Future.failed(x) + } + } + + def unmarshallApiResponse[T](request: ApiRequest[T])(response: HttpResponse): ApiResponse[T] = { + request.responseForCode(response.status.intValue) match { + case Some( (manifest: Manifest[T], state: ResponseState) ) => + entityUnmarshaller(manifest)(response.entity) match { + case Right(value) ⇒ + state match { + case ResponseState.Success => + ApiResponse(response.status.intValue, value, response.headers.map(header => (header.name, header.value)).toMap) + case ResponseState.Error => + throw new ApiError(response.status.intValue, "Error response received", + Some(value), + headers = response.headers.map(header => (header.name, header.value)).toMap) + } + + case Left(MalformedContent(error, Some(cause))) ⇒ + throw new ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString), cause) + + case Left(MalformedContent(error, None)) ⇒ + throw new ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString)) + + case Left(ContentExpected) ⇒ + throw new ApiError(response.status.intValue, s"Unable to unmarshall empty response to [$manifest]", Some(response.entity.toString)) + } + + case _ => throw new ApiError(response.status.intValue, "Unexpected response code", Some(response.entity.toString)) + } + } + + def entityUnmarshaller[T](implicit mf: Manifest[T]): Unmarshaller[T] = + Unmarshaller[T](MediaTypes.`application/json`) { + case x: HttpEntity.NonEmpty ⇒ + parse(x.asString(defaultCharset = HttpCharsets.`UTF-8`)) + .noNulls + .camelizeKeys + .extract[T] + } + +} + +sealed trait CustomContentTypes { + + def normalizedContentType(original: String): ContentType = + MediaTypes.forExtension(original) map (ContentType(_)) getOrElse parseContentType(original) + + def parseContentType(contentType: String): ContentType = { + val contentTypeAsRawHeader = HttpHeaders.RawHeader("Content-Type", contentType) + val parsedContentTypeHeader = HttpParser.parseHeader(contentTypeAsRawHeader) + (parsedContentTypeHeader: @unchecked) match { + case Right(ct: HttpHeaders.`Content-Type`) => + ct.contentType + case Left(error: ErrorInfo) => + throw new IllegalArgumentException( + s"Error converting '$contentType' to a ContentType header: '${error.summary}'") + } + } +} + +sealed trait UntrustedSslContext { + this: ApiInvoker => + + implicit lazy val trustfulSslContext: SSLContext = { + settings.alwaysTrustCertificates match { + case false => + SSLContext.getDefault + + case true => + class IgnoreX509TrustManager extends X509TrustManager { + def checkClientTrusted(chain: Array[X509Certificate], authType: String): Unit = {} + + def checkServerTrusted(chain: Array[X509Certificate], authType: String): Unit = {} + + def getAcceptedIssuers = null + } + + val context = SSLContext.getInstance("TLS") + context.init(null, Array(new IgnoreX509TrustManager), null) + context + } + } + + implicit val clientSSLEngineProvider = + ClientSSLEngineProvider { + _ => + val engine = trustfulSslContext.createSSLEngine() + engine.setUseClientMode(true) + engine + } +} diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala new file mode 100644 index 0000000000..0588193cfb --- /dev/null +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala @@ -0,0 +1,50 @@ +package io.swagger.client.core + +sealed trait ResponseState +object ResponseState { + case object Success extends ResponseState + case object Error extends ResponseState +} + +case class ApiRequest[U]( + // required fields + method: ApiMethod, + basePath: String, + operationPath: String, + contentType: String, + + // optional fields + responses: Map[Int, (Manifest[_], ResponseState)] = Map.empty, + bodyParam: Option[Any] = None, + formParams: Map[String, Any] = Map.empty, + pathParams: Map[String, Any] = Map.empty, + queryParams: Map[String, Any] = Map.empty, + headerParams: Map[String, Any] = Map.empty, + credentials: Seq[Credentials] = List.empty) { + + def withCredentials(cred: Credentials) = copy[U](credentials = credentials :+ cred) + + def withApiKey(key: ApiKeyValue, keyName: String, location: ApiKeyLocation) = withCredentials(ApiKeyCredentials(key, keyName, location)) + + def withSuccessResponse[T](code: Int)(implicit m: Manifest[T]) = copy[U](responses = responses + (code -> (m, ResponseState.Success))) + + def withErrorResponse[T](code: Int)(implicit m: Manifest[T]) = copy[U](responses = responses + (code -> (m, ResponseState.Error))) + + def withDefaultSuccessResponse[T](implicit m: Manifest[T]) = withSuccessResponse[T](0) + + def withDefaultErrorResponse[T](implicit m: Manifest[T]) = withErrorResponse[T](0) + + def responseForCode(statusCode: Int): Option[(Manifest[_], ResponseState)] = responses.get(statusCode) orElse responses.get(0) + + def withoutBody() = copy[U](bodyParam = None) + + def withBody(body: Any) = copy[U](bodyParam = Some(body)) + + def withFormParam(name: String, value: Any) = copy[U](formParams = formParams + (name -> value)) + + def withPathParam(name: String, value: Any) = copy[U](pathParams = pathParams + (name -> value)) + + def withQueryParam(name: String, value: Any) = copy[U](queryParams = queryParams + (name -> value)) + + def withHeaderParam(name: String, value: Any) = copy[U](headerParams = headerParams + (name -> value)) +} diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala new file mode 100644 index 0000000000..3162fb9f6b --- /dev/null +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala @@ -0,0 +1,32 @@ +package io.swagger.client.core + +import java.util.concurrent.TimeUnit + +import akka.actor.{ExtendedActorSystem, Extension, ExtensionKey} +import com.typesafe.config.Config +import io.swagger.client.core.ApiInvoker.CustomStatusCode +import spray.http.HttpHeaders.RawHeader + +import scala.collection.JavaConversions._ +import scala.concurrent.duration.FiniteDuration + +class ApiSettings(config: Config) extends Extension { + def this(system: ExtendedActorSystem) = this(system.settings.config) + + private def cfg = config.getConfig("io.swagger.client.apiRequest") + + val alwaysTrustCertificates = cfg.getBoolean("trust-certificates") + val defaultHeaders = cfg.getConfig("default-headers").entrySet.toList.map(c => RawHeader(c.getKey, c.getValue.render)) + val connectionTimeout = FiniteDuration(cfg.getDuration("connection-timeout", TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS) + val compressionEnabled = cfg.getBoolean("compression.enabled") + val compressionSizeThreshold = cfg.getBytes("compression.size-threshold").toInt + val customCodes = cfg.getConfigList("custom-codes").toList.map { c => CustomStatusCode( + c.getInt("code"), + c.getString("reason"), + c.getBoolean("success")) + } + + +} + +object ApiSettings extends ExtensionKey[ApiSettings] diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/requests.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/requests.scala new file mode 100644 index 0000000000..a096a994ea --- /dev/null +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/requests.scala @@ -0,0 +1,166 @@ +package io.swagger.client.core + +import java.io.File +import java.net.URLEncoder +import scala.util.Try + +sealed trait ApiReturnWithHeaders { + def headers: Map[String, String] + def header(name: String): Option[String] = headers.get(name) + def getStringHeader(name: String) = header(name) + def getIntHeader(name: String) = castedHeader(name, java.lang.Integer.parseInt) + def getLongHeader(name: String) = castedHeader(name, java.lang.Long.parseLong) + def getFloatHeader(name: String) = castedHeader(name, java.lang.Float.parseFloat) + def getDoubleHeader(name: String) = castedHeader(name, java.lang.Double.parseDouble) + def getBooleanHeader(name: String) = castedHeader(name, java.lang.Boolean.parseBoolean) + private def castedHeader[U](name: String, conversion: String => U): Option[U] = { Try { header(name).map( conversion ) }.get } +} + +sealed case class ApiResponse[T](code: Int, content: T, headers: Map[String, String] = Map.empty) + extends ApiReturnWithHeaders + +sealed case class ApiError[T](code: Int, message: String, responseContent: Option[T], cause: Throwable = null, headers: Map[String, String] = Map.empty) + extends Throwable(s"($code) $message.${responseContent.map(s => s" Content : $s").getOrElse("")}", cause) + with ApiReturnWithHeaders + +sealed case class ApiMethod(value: String) + +object ApiMethods { + val CONNECT = ApiMethod("CONNECT") + val DELETE = ApiMethod("DELETE") + val GET = ApiMethod("GET") + val HEAD = ApiMethod("HEAD") + val OPTIONS = ApiMethod("OPTIONS") + val PATCH = ApiMethod("PATCH") + val POST = ApiMethod("POST") + val PUT = ApiMethod("PUT") + val TRACE = ApiMethod("TRACE") +} + +/** + * This trait needs to be added to any model defined by the api. + */ +trait ApiModel + +/** + * Single trait defining a credential that can be transformed to a paramName / paramValue tupple + */ +sealed trait Credentials { + def asQueryParam: Option[(String, String)] = None +} + +sealed case class BasicCredentials(user: String, password: String) extends Credentials + +sealed case class ApiKeyCredentials(key: ApiKeyValue, keyName: String, location: ApiKeyLocation) extends Credentials { + override def asQueryParam: Option[(String, String)] = location match { + case ApiKeyLocations.QUERY => Some((keyName, key.value)) + case _ => None + } +} + +sealed case class ApiKeyValue(value: String) + +sealed trait ApiKeyLocation + +object ApiKeyLocations { + + case object QUERY extends ApiKeyLocation + + case object HEADER extends ApiKeyLocation +} + + +/** + * Case class used to unapply numeric values only in pattern matching + * @param value the string representation of the numeric value + */ +sealed case class NumericValue(value: String) { + override def toString = value +} + +object NumericValue { + def unapply(n: Any): Option[NumericValue] = n match { + case (_: Int | _: Long | _: Float | _: Double | _: Boolean | _: Byte) => Some(NumericValue(String.valueOf(n))) + case _ => None + } +} + +/** + * Used for params being arrays + */ +sealed case class ArrayValues(values: Seq[Any], format: CollectionFormat = CollectionFormats.CSV) + +object ArrayValues { + def apply(values: Option[Seq[Any]], format: CollectionFormat): ArrayValues = + ArrayValues(values.getOrElse(Seq.empty), format) + + def apply(values: Option[Seq[Any]]): ArrayValues = ArrayValues(values, CollectionFormats.CSV) +} + + +/** + * Defines how arrays should be rendered in query strings. + */ +sealed trait CollectionFormat + +trait MergedArrayFormat extends CollectionFormat { + def separator: String +} + +object CollectionFormats { + + case object CSV extends MergedArrayFormat { + override val separator = "," + } + + case object TSV extends MergedArrayFormat { + override val separator = "\t" + } + + case object SSV extends MergedArrayFormat { + override val separator = " " + } + + case object PIPES extends MergedArrayFormat { + override val separator = "|" + } + + case object MULTI extends CollectionFormat + +} + +object ParametersMap { + + /** + * Pimp parameters maps (Map[String, Any]) in order to transform them in a sequence of String -> Any tupples, + * with valid url-encoding, arrays handling, files preservation, ... + */ + implicit class ParametersMapImprovements(val m: Map[String, Any]) { + + def asFormattedParamsList = m.toList.flatMap(formattedParams) + + def asFormattedParams = m.flatMap(formattedParams) + + private def urlEncode(v: Any) = URLEncoder.encode(String.valueOf(v), "utf-8").replaceAll("\\+", "%20") + + private def formattedParams(tuple: (String, Any)): Seq[(String, Any)] = formattedParams(tuple._1, tuple._2) + + private def formattedParams(name: String, value: Any): Seq[(String, Any)] = value match { + case arr: ArrayValues => + arr.format match { + case CollectionFormats.MULTI => arr.values.flatMap(formattedParams(name, _)) + case format: MergedArrayFormat => Seq((name, arr.values.mkString(format.separator))) + } + case None => Seq.empty + case Some(opt) => + formattedParams(name, opt) + case s: Seq[Any] => + formattedParams(name, ArrayValues(s)) + case v: String => Seq((name, urlEncode(v))) + case NumericValue(v) => Seq((name, urlEncode(v))) + case f: File => Seq((name, f)) + case m: ApiModel => Seq((name, m)) + } + + } +} diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Category.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Category.scala new file mode 100644 index 0000000000..5eec9d159d --- /dev/null +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Category.scala @@ -0,0 +1,12 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Category ( + Id: Option[Long], + Name: Option[String]) + extends ApiModel + + diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Order.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Order.scala new file mode 100644 index 0000000000..5fe2c3d0a6 --- /dev/null +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Order.scala @@ -0,0 +1,29 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Order ( + Id: Option[Long], + PetId: Option[Long], + Quantity: Option[Int], + ShipDate: Option[DateTime], + /* Order Status */ + Status: Option[OrderEnums.Status], + Complete: Option[Boolean]) + extends ApiModel + +object OrderEnums { + + type Status = Status.Value + + object Status extends Enumeration { + val Placed = Value("placed") + val Approved = Value("approved") + val Delivered = Value("delivered") + } + + +} + diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Pet.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Pet.scala new file mode 100644 index 0000000000..5007c7d958 --- /dev/null +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Pet.scala @@ -0,0 +1,29 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Pet ( + Id: Option[Long], + Category: Option[Category], + Name: String, + PhotoUrls: Seq[String], + Tags: Option[Seq[Tag]], + /* pet status in the store */ + Status: Option[PetEnums.Status]) + extends ApiModel + +object PetEnums { + + type Status = Status.Value + + object Status extends Enumeration { + val Available = Value("available") + val Pending = Value("pending") + val Sold = Value("sold") + } + + +} + diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Tag.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Tag.scala new file mode 100644 index 0000000000..8f7c3f2aa4 --- /dev/null +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Tag.scala @@ -0,0 +1,12 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Tag ( + Id: Option[Long], + Name: Option[String]) + extends ApiModel + + diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/User.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/User.scala new file mode 100644 index 0000000000..c9772f5361 --- /dev/null +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/User.scala @@ -0,0 +1,19 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class User ( + Id: Option[Long], + Username: Option[String], + FirstName: Option[String], + LastName: Option[String], + Email: Option[String], + Password: Option[String], + Phone: Option[String], + /* User Status */ + UserStatus: Option[Int]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/pom.xml b/samples/client/wordnik/akka-scala/pom.xml new file mode 100644 index 0000000000..f865a97c38 --- /dev/null +++ b/samples/client/wordnik/akka-scala/pom.xml @@ -0,0 +1,227 @@ + + 4.0.0 + com.wordnik + swagger-client + jar + swagger-client + 1.0.0 + + 2.2.0 + + + + + maven-mongodb-plugin-repo + maven mongodb plugin repository + http://maven-mongodb-plugin.googlecode.com/svn/maven/repo + default + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + pertest + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + jar + test-jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add_sources + generate-sources + + add-source + + + + + src/main/java + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + 1.6 + 1.6 + + + + net.alchim31.maven + scala-maven-plugin + ${scala-maven-plugin-version} + + + scala-compile-first + process-resources + + add-source + compile + + + + scala-test-compile + process-test-resources + + testCompile + + + + + + -feature + + + -Xms128m + -Xmx1500m + + + + + + + + + org.scala-tools + maven-scala-plugin + + ${scala-version} + + + + + + + org.scala-lang + scala-library + ${scala-version} + + + com.wordnik + swagger-core + ${swagger-core-version} + + + org.scalatest + scalatest_2.10 + ${scala-test-version} + test + + + junit + junit + ${junit-version} + test + + + joda-time + joda-time + ${joda-time-version} + + + org.joda + joda-convert + ${joda-version} + + + com.typesafe + config + 1.2.1 + + + com.typesafe.akka + akka-actor_2.10 + ${akka-version} + + + io.spray + spray-client + ${spray-version} + + + org.json4s + json4s-jackson_2.10 + ${json4s-jackson-version} + + + + 2.10.4 + 3.2.11 + 3.2.11 + 1.3.1 + 2.3.9 + 1.2 + 2.2 + 1.5.0-M1 + 1.0.0 + + 4.8.1 + 3.1.5 + 2.1.3 + + diff --git a/samples/client/wordnik/akka-scala/src/main/resources/reference.conf b/samples/client/wordnik/akka-scala/src/main/resources/reference.conf new file mode 100644 index 0000000000..f993f765ed --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/resources/reference.conf @@ -0,0 +1,24 @@ +io.swagger.client { + + apiRequest { + + compression { + enabled: false + size-threshold: 0 + } + + trust-certificates: true + + connection-timeout: 5000ms + + default-headers { + "userAgent": "swagger-client_1.0.0" + } + + // let you define custom http status code, as in : + // { code: 601, reason: "some custom http status code", success: false } + custom-codes : [] + } +} + +spray.can.host-connector.max-redirects = 10 \ No newline at end of file diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/AccountApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/AccountApi.scala new file mode 100644 index 0000000000..920159a629 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/AccountApi.scala @@ -0,0 +1,109 @@ +package io.swagger.client.api + +import io.swagger.client.model.ApiTokenStatus +import io.swagger.client.model.AuthenticationToken +import io.swagger.client.model.User +import io.swagger.client.model.WordList +import io.swagger.client.core._ +import io.swagger.client.core.CollectionFormats._ +import io.swagger.client.core.ApiKeyLocations._ + +object AccountApi { + + /** + * + * + * Expected answers: + * code 200 : ApiTokenStatus (Usage statistics for the supplied API key) + * code 400 : (No token supplied.) + * code 404 : (No API account with supplied token.) + * + * @param ApiKey Wordnik authentication token + */ + def getApiTokenStatus(ApiKey: Option[String] = None): ApiRequest[ApiTokenStatus] = + ApiRequest[ApiTokenStatus](ApiMethods.GET, "https://api.wordnik.com/v4", "/account.json/apiTokenStatus", "application/json") + .withHeaderParam("api_key", ApiKey) + .withSuccessResponse[ApiTokenStatus](200) + .withErrorResponse[Unit](400) + .withErrorResponse[Unit](404) + + /** + * + * + * Expected answers: + * code 200 : AuthenticationToken (A valid authentication token) + * code 403 : (Account not available.) + * code 404 : (User not found.) + * + * @param Username A confirmed Wordnik username + * @param Password The user's password + */ + def authenticate(Username: String, Password: String): ApiRequest[AuthenticationToken] = + ApiRequest[AuthenticationToken](ApiMethods.GET, "https://api.wordnik.com/v4", "/account.json/authenticate/{username}", "application/json") + .withQueryParam("password", Password) + .withPathParam("username", Username) + .withSuccessResponse[AuthenticationToken](200) + .withErrorResponse[Unit](403) + .withErrorResponse[Unit](404) + + /** + * + * + * Expected answers: + * code 200 : AuthenticationToken (A valid authentication token) + * code 403 : (Account not available.) + * code 404 : (User not found.) + * + * @param Username A confirmed Wordnik username + * @param Body The user's password + */ + def authenticatePost(Username: String, Body: String): ApiRequest[AuthenticationToken] = + ApiRequest[AuthenticationToken](ApiMethods.POST, "https://api.wordnik.com/v4", "/account.json/authenticate/{username}", "application/json") + .withBody(Body) + .withPathParam("username", Username) + .withSuccessResponse[AuthenticationToken](200) + .withErrorResponse[Unit](403) + .withErrorResponse[Unit](404) + + /** + * Requires a valid auth_token to be set. + * + * Expected answers: + * code 200 : User (The logged-in user) + * code 403 : (Not logged in.) + * code 404 : (User not found.) + * + * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + */ + def getLoggedInUser(AuthToken: String): ApiRequest[User] = + ApiRequest[User](ApiMethods.GET, "https://api.wordnik.com/v4", "/account.json/user", "application/json") + .withHeaderParam("auth_token", AuthToken) + .withSuccessResponse[User](200) + .withErrorResponse[Unit](403) + .withErrorResponse[Unit](404) + + /** + * + * + * Expected answers: + * code 200 : Seq[WordList] (success) + * code 403 : (Not authenticated.) + * code 404 : (User account not found.) + * + * @param AuthToken auth_token of logged-in user + * @param Skip Results to skip + * @param Limit Maximum number of results to return + */ + def getWordListsForLoggedInUser(AuthToken: String, Skip: Option[Int] = None, Limit: Option[Int] = None): ApiRequest[Seq[WordList]] = + ApiRequest[Seq[WordList]](ApiMethods.GET, "https://api.wordnik.com/v4", "/account.json/wordLists", "application/json") + .withQueryParam("skip", Skip) + .withQueryParam("limit", Limit) + .withHeaderParam("auth_token", AuthToken) + .withSuccessResponse[Seq[WordList]](200) + .withErrorResponse[Unit](403) + .withErrorResponse[Unit](404) + + + +} + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala new file mode 100644 index 0000000000..c95a49ad0b --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala @@ -0,0 +1,41 @@ +package io.swagger.client.api + +import io.swagger.client.model._ +import org.json4s._ +import scala.reflect.ClassTag + +object EnumsSerializers { + + def all = Seq[Serializer[_]]() + + + + private class EnumNameSerializer[E <: Enumeration: ClassTag](enum: E) + extends Serializer[E#Value] { + import JsonDSL._ + + val EnumerationClass = classOf[E#Value] + + def deserialize(implicit format: Formats): + PartialFunction[(TypeInfo, JValue), E#Value] = { + case (t @ TypeInfo(EnumerationClass, _), json) if isValid(json) => { + json match { + case JString(value) => + enum.withName(value) + case value => + throw new MappingException(s"Can't convert $value to $EnumerationClass") + } + } + } + + private[this] def isValid(json: JValue) = json match { + case JString(value) if enum.values.exists(_.toString == value) => true + case _ => false + } + + def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { + case i: E#Value => i.toString + } + } + +} \ No newline at end of file diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala new file mode 100644 index 0000000000..bbcf2dd357 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala @@ -0,0 +1,253 @@ +package io.swagger.client.api + +import io.swagger.client.model.WordObject +import io.swagger.client.model.AudioFile +import io.swagger.client.model.Definition +import io.swagger.client.model.FrequencySummary +import io.swagger.client.model.Bigram +import io.swagger.client.model.Example +import io.swagger.client.core._ +import io.swagger.client.core.CollectionFormats._ +import io.swagger.client.core.ApiKeyLocations._ + +object WordApi { + + /** + * + * + * Expected answers: + * code 200 : WordObject (success) + * code 400 : (Invalid word supplied.) + * + * @param Word String value of WordObject to return + * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param IncludeSuggestions Return suggestions (for correct spelling, case variants, etc.) + */ + def getWord(Word: String, UseCanonical: Option[String] = None, IncludeSuggestions: Option[String] = None): ApiRequest[WordObject] = + ApiRequest[WordObject](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}", "application/json") + .withQueryParam("useCanonical", UseCanonical) + .withQueryParam("includeSuggestions", IncludeSuggestions) + .withPathParam("word", Word) + .withSuccessResponse[WordObject](200) + .withErrorResponse[Unit](400) + + /** + * The metadata includes a time-expiring fileUrl which allows reading the audio file directly from the API. Currently only audio pronunciations from the American Heritage Dictionary in mp3 format are supported. + * + * Expected answers: + * code 200 : Seq[AudioFile] (success) + * code 400 : (Invalid word supplied.) + * + * @param Word Word to get audio for. + * @param UseCanonical Use the canonical form of the word + * @param Limit Maximum number of results to return + */ + def getAudio(Word: String, UseCanonical: Option[String] = None, Limit: Option[Int] = None): ApiRequest[Seq[AudioFile]] = + ApiRequest[Seq[AudioFile]](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/audio", "application/json") + .withQueryParam("useCanonical", UseCanonical) + .withQueryParam("limit", Limit) + .withPathParam("word", Word) + .withSuccessResponse[Seq[AudioFile]](200) + .withErrorResponse[Unit](400) + + /** + * + * + * Expected answers: + * code 200 : Seq[Definition] (success) + * code 400 : (Invalid word supplied.) + * code 404 : (No definitions found.) + * + * @param Word Word to return definitions for + * @param Limit Maximum number of results to return + * @param PartOfSpeech CSV list of part-of-speech types + * @param IncludeRelated Return related words with definitions + * @param SourceDictionaries Source dictionary to return definitions from. If 'all' is received, results are returned from all sources. If multiple values are received (e.g. 'century,wiktionary'), results are returned from the first specified dictionary that has definitions. If left blank, results are returned from the first dictionary that has definitions. By default, dictionaries are searched in this order: ahd, wiktionary, webster, century, wordnet + * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param IncludeTags Return a closed set of XML tags in response + */ + def getDefinitions(Word: String, Limit: Option[Int] = None, PartOfSpeech: Option[String] = None, IncludeRelated: Option[String] = None, SourceDictionaries: Seq[String], UseCanonical: Option[String] = None, IncludeTags: Option[String] = None): ApiRequest[Seq[Definition]] = + ApiRequest[Seq[Definition]](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/definitions", "application/json") + .withQueryParam("limit", Limit) + .withQueryParam("partOfSpeech", PartOfSpeech) + .withQueryParam("includeRelated", IncludeRelated) + .withQueryParam("sourceDictionaries", ArrayValues(SourceDictionaries, CSV)) + .withQueryParam("useCanonical", UseCanonical) + .withQueryParam("includeTags", IncludeTags) + .withPathParam("word", Word) + .withSuccessResponse[Seq[Definition]](200) + .withErrorResponse[Unit](400) + .withErrorResponse[Unit](404) + + /** + * + * + * Expected answers: + * code 200 : Seq[String] (success) + * code 400 : (Invalid word supplied.) + * code 404 : (No definitions found.) + * + * @param Word Word to return + * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + */ + def getEtymologies(Word: String, UseCanonical: Option[String] = None): ApiRequest[Seq[String]] = + ApiRequest[Seq[String]](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/etymologies", "application/json") + .withQueryParam("useCanonical", UseCanonical) + .withPathParam("word", Word) + .withSuccessResponse[Seq[String]](200) + .withErrorResponse[Unit](400) + .withErrorResponse[Unit](404) + + /** + * + * + * Expected answers: + * code 200 : (success) + * code 400 : (Invalid word supplied.) + * + * @param Word Word to return examples for + * @param IncludeDuplicates Show duplicate examples from different sources + * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param Skip Results to skip + * @param Limit Maximum number of results to return + */ + def getExamples(Word: String, IncludeDuplicates: Option[String] = None, UseCanonical: Option[String] = None, Skip: Option[Int] = None, Limit: Option[Int] = None): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/examples", "application/json") + .withQueryParam("includeDuplicates", IncludeDuplicates) + .withQueryParam("useCanonical", UseCanonical) + .withQueryParam("skip", Skip) + .withQueryParam("limit", Limit) + .withPathParam("word", Word) + .withSuccessResponse[Unit](200) + .withErrorResponse[Unit](400) + + /** + * + * + * Expected answers: + * code 200 : FrequencySummary (success) + * code 400 : (Invalid word supplied.) + * code 404 : (No results.) + * + * @param Word Word to return + * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param StartYear Starting Year + * @param EndYear Ending Year + */ + def getWordFrequency(Word: String, UseCanonical: Option[String] = None, StartYear: Option[Int] = None, EndYear: Option[Int] = None): ApiRequest[FrequencySummary] = + ApiRequest[FrequencySummary](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/frequency", "application/json") + .withQueryParam("useCanonical", UseCanonical) + .withQueryParam("startYear", StartYear) + .withQueryParam("endYear", EndYear) + .withPathParam("word", Word) + .withSuccessResponse[FrequencySummary](200) + .withErrorResponse[Unit](400) + .withErrorResponse[Unit](404) + + /** + * + * + * Expected answers: + * code 200 : (success) + * code 400 : (Invalid word supplied.) + * + * @param Word Word to get syllables for + * @param UseCanonical If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param SourceDictionary Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet. + * @param Limit Maximum number of results to return + */ + def getHyphenation(Word: String, UseCanonical: Option[String] = None, SourceDictionary: Option[String] = None, Limit: Option[Int] = None): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/hyphenation", "application/json") + .withQueryParam("useCanonical", UseCanonical) + .withQueryParam("sourceDictionary", SourceDictionary) + .withQueryParam("limit", Limit) + .withPathParam("word", Word) + .withSuccessResponse[Unit](200) + .withErrorResponse[Unit](400) + + /** + * + * + * Expected answers: + * code 200 : Seq[Bigram] (success) + * code 400 : (Invalid word supplied.) + * + * @param Word Word to fetch phrases for + * @param Limit Maximum number of results to return + * @param Wlmi Minimum WLMI for the phrase + * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + */ + def getPhrases(Word: String, Limit: Option[Int] = None, Wlmi: Option[Int] = None, UseCanonical: Option[String] = None): ApiRequest[Seq[Bigram]] = + ApiRequest[Seq[Bigram]](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/phrases", "application/json") + .withQueryParam("limit", Limit) + .withQueryParam("wlmi", Wlmi) + .withQueryParam("useCanonical", UseCanonical) + .withPathParam("word", Word) + .withSuccessResponse[Seq[Bigram]](200) + .withErrorResponse[Unit](400) + + /** + * + * + * Expected answers: + * code 200 : (success) + * code 400 : (Invalid word supplied.) + * + * @param Word Word to get pronunciations for + * @param UseCanonical If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param SourceDictionary Get from a single dictionary + * @param TypeFormat Text pronunciation type + * @param Limit Maximum number of results to return + */ + def getTextPronunciations(Word: String, UseCanonical: Option[String] = None, SourceDictionary: Option[String] = None, TypeFormat: Option[String] = None, Limit: Option[Int] = None): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/pronunciations", "application/json") + .withQueryParam("useCanonical", UseCanonical) + .withQueryParam("sourceDictionary", SourceDictionary) + .withQueryParam("typeFormat", TypeFormat) + .withQueryParam("limit", Limit) + .withPathParam("word", Word) + .withSuccessResponse[Unit](200) + .withErrorResponse[Unit](400) + + /** + * + * + * Expected answers: + * code 200 : (success) + * code 400 : (Invalid word supplied.) + * + * @param Word Word to fetch relationships for + * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param RelationshipTypes Limits the total results per type of relationship type + * @param LimitPerRelationshipType Restrict to the supplied relationship types + */ + def getRelatedWords(Word: String, UseCanonical: Option[String] = None, RelationshipTypes: Option[String] = None, LimitPerRelationshipType: Option[Int] = None): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/relatedWords", "application/json") + .withQueryParam("useCanonical", UseCanonical) + .withQueryParam("relationshipTypes", RelationshipTypes) + .withQueryParam("limitPerRelationshipType", LimitPerRelationshipType) + .withPathParam("word", Word) + .withSuccessResponse[Unit](200) + .withErrorResponse[Unit](400) + + /** + * + * + * Expected answers: + * code 200 : Example (success) + * code 400 : (Invalid word supplied.) + * + * @param Word Word to fetch examples for + * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + */ + def getTopExample(Word: String, UseCanonical: Option[String] = None): ApiRequest[Example] = + ApiRequest[Example](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/topExample", "application/json") + .withQueryParam("useCanonical", UseCanonical) + .withPathParam("word", Word) + .withSuccessResponse[Example](200) + .withErrorResponse[Unit](400) + + + +} + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala new file mode 100644 index 0000000000..8d34cfd3f3 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala @@ -0,0 +1,154 @@ +package io.swagger.client.api + +import io.swagger.client.model.WordList +import io.swagger.client.model.StringValue +import io.swagger.client.core._ +import io.swagger.client.core.CollectionFormats._ +import io.swagger.client.core.ApiKeyLocations._ + +object WordListApi { + + /** + * + * + * Expected answers: + * code 200 : WordList (success) + * code 400 : (Invalid ID supplied) + * code 403 : (Not Authorized to access WordList) + * code 404 : (WordList not found) + * + * @param Permalink permalink of WordList to fetch + * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + */ + def getWordListByPermalink(Permalink: String, AuthToken: String): ApiRequest[WordList] = + ApiRequest[WordList](ApiMethods.GET, "https://api.wordnik.com/v4", "/wordList.json/{permalink}", "application/json") + .withPathParam("permalink", Permalink) + .withHeaderParam("auth_token", AuthToken) + .withSuccessResponse[WordList](200) + .withErrorResponse[Unit](400) + .withErrorResponse[Unit](403) + .withErrorResponse[Unit](404) + + /** + * + * + * Expected answers: + * code 200 : (success) + * code 400 : (Invalid ID supplied) + * code 403 : (Not Authorized to update WordList) + * code 404 : (WordList not found) + * + * @param Permalink permalink of WordList to update + * @param Body Updated WordList + * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + */ + def updateWordList(Permalink: String, Body: Option[WordList] = None, AuthToken: String): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.PUT, "https://api.wordnik.com/v4", "/wordList.json/{permalink}", "application/json") + .withBody(Body) + .withPathParam("permalink", Permalink) + .withHeaderParam("auth_token", AuthToken) + .withSuccessResponse[Unit](200) + .withErrorResponse[Unit](400) + .withErrorResponse[Unit](403) + .withErrorResponse[Unit](404) + + /** + * + * + * Expected answers: + * code 200 : (success) + * code 400 : (Invalid ID supplied) + * code 403 : (Not Authorized to delete WordList) + * code 404 : (WordList not found) + * + * @param Permalink ID of WordList to delete + * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + */ + def deleteWordList(Permalink: String, AuthToken: String): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.DELETE, "https://api.wordnik.com/v4", "/wordList.json/{permalink}", "application/json") + .withPathParam("permalink", Permalink) + .withHeaderParam("auth_token", AuthToken) + .withSuccessResponse[Unit](200) + .withErrorResponse[Unit](400) + .withErrorResponse[Unit](403) + .withErrorResponse[Unit](404) + + /** + * + * + * Expected answers: + * code 200 : (success) + * code 400 : (Invalid permalink supplied) + * code 403 : (Not Authorized to modify WordList) + * code 404 : (WordList not found) + * + * @param Permalink permalink of WordList to use + * @param Body Words to remove from WordList + * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + */ + def deleteWordsFromWordList(Permalink: String, Body: Seq[StringValue], AuthToken: String): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.POST, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/deleteWords", "application/json") + .withBody(Body) + .withPathParam("permalink", Permalink) + .withHeaderParam("auth_token", AuthToken) + .withSuccessResponse[Unit](200) + .withErrorResponse[Unit](400) + .withErrorResponse[Unit](403) + .withErrorResponse[Unit](404) + + /** + * + * + * Expected answers: + * code 200 : (success) + * code 400 : (Invalid ID supplied) + * code 403 : (Not Authorized to access WordList) + * code 404 : (WordList not found) + * + * @param Permalink ID of WordList to use + * @param SortBy Field to sort by + * @param SortOrder Direction to sort + * @param Skip Results to skip + * @param Limit Maximum number of results to return + * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + */ + def getWordListWords(Permalink: String, SortBy: Option[String] = None, SortOrder: Option[String] = None, Skip: Option[Int] = None, Limit: Option[Int] = None, AuthToken: String): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.GET, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/words", "application/json") + .withQueryParam("sortBy", SortBy) + .withQueryParam("sortOrder", SortOrder) + .withQueryParam("skip", Skip) + .withQueryParam("limit", Limit) + .withPathParam("permalink", Permalink) + .withHeaderParam("auth_token", AuthToken) + .withSuccessResponse[Unit](200) + .withErrorResponse[Unit](400) + .withErrorResponse[Unit](403) + .withErrorResponse[Unit](404) + + /** + * + * + * Expected answers: + * code 200 : (success) + * code 400 : (Invalid permalink supplied) + * code 403 : (Not Authorized to access WordList) + * code 404 : (WordList not found) + * + * @param Permalink permalink of WordList to user + * @param Body Array of words to add to WordList + * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + */ + def addWordsToWordList(Permalink: String, Body: Seq[StringValue], AuthToken: String): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.POST, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/words", "application/json") + .withBody(Body) + .withPathParam("permalink", Permalink) + .withHeaderParam("auth_token", AuthToken) + .withSuccessResponse[Unit](200) + .withErrorResponse[Unit](400) + .withErrorResponse[Unit](403) + .withErrorResponse[Unit](404) + + + +} + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListsApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListsApi.scala new file mode 100644 index 0000000000..a2540c383a --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListsApi.scala @@ -0,0 +1,34 @@ +package io.swagger.client.api + +import io.swagger.client.model.WordList +import io.swagger.client.core._ +import io.swagger.client.core.CollectionFormats._ +import io.swagger.client.core.ApiKeyLocations._ + +object WordListsApi { + + /** + * + * + * Expected answers: + * code 200 : WordList (success) + * code 400 : (Invalid WordList supplied or mandatory fields are missing) + * code 403 : (Not authenticated) + * code 404 : (WordList owner not found) + * + * @param Body WordList to create + * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + */ + def createWordList(Body: Option[WordList] = None, AuthToken: String): ApiRequest[WordList] = + ApiRequest[WordList](ApiMethods.POST, "https://api.wordnik.com/v4", "/wordLists.json", "application/json") + .withBody(Body) + .withHeaderParam("auth_token", AuthToken) + .withSuccessResponse[WordList](200) + .withErrorResponse[Unit](400) + .withErrorResponse[Unit](403) + .withErrorResponse[Unit](404) + + + +} + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala new file mode 100644 index 0000000000..4ca9ab1310 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala @@ -0,0 +1,181 @@ +package io.swagger.client.api + +import io.swagger.client.model.WordObject +import io.swagger.client.model.DefinitionSearchResults +import io.swagger.client.model.WordSearchResults +import io.swagger.client.model.WordOfTheDay +import io.swagger.client.core._ +import io.swagger.client.core.CollectionFormats._ +import io.swagger.client.core.ApiKeyLocations._ + +object WordsApi { + + /** + * + * + * Expected answers: + * code 200 : WordObject (success) + * code 404 : (No word found.) + * + * @param HasDictionaryDef Only return words with dictionary definitions + * @param IncludePartOfSpeech CSV part-of-speech values to include + * @param ExcludePartOfSpeech CSV part-of-speech values to exclude + * @param MinCorpusCount Minimum corpus frequency for terms + * @param MaxCorpusCount Maximum corpus frequency for terms + * @param MinDictionaryCount Minimum dictionary count + * @param MaxDictionaryCount Maximum dictionary count + * @param MinLength Minimum word length + * @param MaxLength Maximum word length + */ + def getRandomWord(HasDictionaryDef: Option[String] = None, IncludePartOfSpeech: Option[String] = None, ExcludePartOfSpeech: Option[String] = None, MinCorpusCount: Option[Int] = None, MaxCorpusCount: Option[Int] = None, MinDictionaryCount: Option[Int] = None, MaxDictionaryCount: Option[Int] = None, MinLength: Option[Int] = None, MaxLength: Option[Int] = None): ApiRequest[WordObject] = + ApiRequest[WordObject](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/randomWord", "application/json") + .withQueryParam("hasDictionaryDef", HasDictionaryDef) + .withQueryParam("includePartOfSpeech", IncludePartOfSpeech) + .withQueryParam("excludePartOfSpeech", ExcludePartOfSpeech) + .withQueryParam("minCorpusCount", MinCorpusCount) + .withQueryParam("maxCorpusCount", MaxCorpusCount) + .withQueryParam("minDictionaryCount", MinDictionaryCount) + .withQueryParam("maxDictionaryCount", MaxDictionaryCount) + .withQueryParam("minLength", MinLength) + .withQueryParam("maxLength", MaxLength) + .withSuccessResponse[WordObject](200) + .withErrorResponse[Unit](404) + + /** + * + * + * Expected answers: + * code 200 : (success) + * code 400 : (Invalid term supplied.) + * code 404 : (No results.) + * + * @param HasDictionaryDef Only return words with dictionary definitions + * @param IncludePartOfSpeech CSV part-of-speech values to include + * @param ExcludePartOfSpeech CSV part-of-speech values to exclude + * @param MinCorpusCount Minimum corpus frequency for terms + * @param MaxCorpusCount Maximum corpus frequency for terms + * @param MinDictionaryCount Minimum dictionary count + * @param MaxDictionaryCount Maximum dictionary count + * @param MinLength Minimum word length + * @param MaxLength Maximum word length + * @param SortBy Attribute to sort by + * @param SortOrder Sort direction + * @param Limit Maximum number of results to return + */ + def getRandomWords(HasDictionaryDef: Option[String] = None, IncludePartOfSpeech: Option[String] = None, ExcludePartOfSpeech: Option[String] = None, MinCorpusCount: Option[Int] = None, MaxCorpusCount: Option[Int] = None, MinDictionaryCount: Option[Int] = None, MaxDictionaryCount: Option[Int] = None, MinLength: Option[Int] = None, MaxLength: Option[Int] = None, SortBy: Option[String] = None, SortOrder: Option[String] = None, Limit: Option[Int] = None): ApiRequest[UnitUnit] = + ApiRequest[UnitUnit](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/randomWords", "application/json") + .withQueryParam("hasDictionaryDef", HasDictionaryDef) + .withQueryParam("includePartOfSpeech", IncludePartOfSpeech) + .withQueryParam("excludePartOfSpeech", ExcludePartOfSpeech) + .withQueryParam("minCorpusCount", MinCorpusCount) + .withQueryParam("maxCorpusCount", MaxCorpusCount) + .withQueryParam("minDictionaryCount", MinDictionaryCount) + .withQueryParam("maxDictionaryCount", MaxDictionaryCount) + .withQueryParam("minLength", MinLength) + .withQueryParam("maxLength", MaxLength) + .withQueryParam("sortBy", SortBy) + .withQueryParam("sortOrder", SortOrder) + .withQueryParam("limit", Limit) + .withSuccessResponse[Unit](200) + .withErrorResponse[Unit](400) + .withErrorResponse[Unit](404) + + /** + * + * + * Expected answers: + * code 200 : DefinitionSearchResults (success) + * code 400 : (Invalid term supplied.) + * + * @param Query Search term + * @param FindSenseForWord Restricts words and finds closest sense + * @param IncludeSourceDictionaries Only include these comma-delimited source dictionaries + * @param ExcludeSourceDictionaries Exclude these comma-delimited source dictionaries + * @param IncludePartOfSpeech Only include these comma-delimited parts of speech + * @param ExcludePartOfSpeech Exclude these comma-delimited parts of speech + * @param MinCorpusCount Minimum corpus frequency for terms + * @param MaxCorpusCount Maximum corpus frequency for terms + * @param MinLength Minimum word length + * @param MaxLength Maximum word length + * @param ExpandTerms Expand terms + * @param IncludeTags Return a closed set of XML tags in response + * @param SortBy Attribute to sort by + * @param SortOrder Sort direction + * @param Skip Results to skip + * @param Limit Maximum number of results to return + */ + def reverseDictionary(Query: String, FindSenseForWord: Option[String] = None, IncludeSourceDictionaries: Option[String] = None, ExcludeSourceDictionaries: Option[String] = None, IncludePartOfSpeech: Option[String] = None, ExcludePartOfSpeech: Option[String] = None, MinCorpusCount: Option[Int] = None, MaxCorpusCount: Option[Int] = None, MinLength: Option[Int] = None, MaxLength: Option[Int] = None, ExpandTerms: Option[String] = None, IncludeTags: Option[String] = None, SortBy: Option[String] = None, SortOrder: Option[String] = None, Skip: Option[String] = None, Limit: Option[Int] = None): ApiRequest[DefinitionSearchResults] = + ApiRequest[DefinitionSearchResults](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/reverseDictionary", "application/json") + .withQueryParam("query", Query) + .withQueryParam("findSenseForWord", FindSenseForWord) + .withQueryParam("includeSourceDictionaries", IncludeSourceDictionaries) + .withQueryParam("excludeSourceDictionaries", ExcludeSourceDictionaries) + .withQueryParam("includePartOfSpeech", IncludePartOfSpeech) + .withQueryParam("excludePartOfSpeech", ExcludePartOfSpeech) + .withQueryParam("minCorpusCount", MinCorpusCount) + .withQueryParam("maxCorpusCount", MaxCorpusCount) + .withQueryParam("minLength", MinLength) + .withQueryParam("maxLength", MaxLength) + .withQueryParam("expandTerms", ExpandTerms) + .withQueryParam("includeTags", IncludeTags) + .withQueryParam("sortBy", SortBy) + .withQueryParam("sortOrder", SortOrder) + .withQueryParam("skip", Skip) + .withQueryParam("limit", Limit) + .withSuccessResponse[DefinitionSearchResults](200) + .withErrorResponse[Unit](400) + + /** + * + * + * Expected answers: + * code 200 : WordSearchResults (success) + * code 400 : (Invalid query supplied.) + * + * @param Query Search query + * @param CaseSensitive Search case sensitive + * @param IncludePartOfSpeech Only include these comma-delimited parts of speech + * @param ExcludePartOfSpeech Exclude these comma-delimited parts of speech + * @param MinCorpusCount Minimum corpus frequency for terms + * @param MaxCorpusCount Maximum corpus frequency for terms + * @param MinDictionaryCount Minimum number of dictionary entries for words returned + * @param MaxDictionaryCount Maximum dictionary definition count + * @param MinLength Minimum word length + * @param MaxLength Maximum word length + * @param Skip Results to skip + * @param Limit Maximum number of results to return + */ + def searchWords(Query: String, CaseSensitive: Option[String] = None, IncludePartOfSpeech: Option[String] = None, ExcludePartOfSpeech: Option[String] = None, MinCorpusCount: Option[Int] = None, MaxCorpusCount: Option[Int] = None, MinDictionaryCount: Option[Int] = None, MaxDictionaryCount: Option[Int] = None, MinLength: Option[Int] = None, MaxLength: Option[Int] = None, Skip: Option[Int] = None, Limit: Option[Int] = None): ApiRequest[WordSearchResults] = + ApiRequest[WordSearchResults](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/search/{query}", "application/json") + .withQueryParam("caseSensitive", CaseSensitive) + .withQueryParam("includePartOfSpeech", IncludePartOfSpeech) + .withQueryParam("excludePartOfSpeech", ExcludePartOfSpeech) + .withQueryParam("minCorpusCount", MinCorpusCount) + .withQueryParam("maxCorpusCount", MaxCorpusCount) + .withQueryParam("minDictionaryCount", MinDictionaryCount) + .withQueryParam("maxDictionaryCount", MaxDictionaryCount) + .withQueryParam("minLength", MinLength) + .withQueryParam("maxLength", MaxLength) + .withQueryParam("skip", Skip) + .withQueryParam("limit", Limit) + .withPathParam("query", Query) + .withSuccessResponse[WordSearchResults](200) + .withErrorResponse[Unit](400) + + /** + * + * + * Expected answers: + * code 0 : WordOfTheDay (success) + * + * @param Date Fetches by date in yyyy-MM-dd + */ + def getWordOfTheDay(Date: Option[String] = None): ApiRequest[WordOfTheDay] = + ApiRequest[WordOfTheDay](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/wordOfTheDay", "application/json") + .withQueryParam("date", Date) + .withSuccessResponse[WordOfTheDay](0) + + + +} + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala new file mode 100644 index 0000000000..3b11d86601 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala @@ -0,0 +1,323 @@ +package io.swagger.client.core + +import java.io.File +import java.security.cert.X509Certificate +import javax.net.ssl._ + +import akka.actor.ActorSystem +import akka.io.IO +import akka.pattern.ask +import akka.util.Timeout +import org.joda.time.DateTime +import org.joda.time.format.ISODateTimeFormat +import org.json4s.JsonAST.JString +import org.json4s._ +import org.json4s.jackson.JsonMethods._ +import org.json4s.jackson.Serialization +import spray.can.Http +import spray.can.Http.HostConnectorSetup +import spray.client.pipelining +import spray.client.pipelining._ +import spray.http.HttpEncodings._ +import spray.http.HttpHeaders.{RawHeader, `Accept-Encoding`} +import spray.http.Uri.Query +import spray.http._ +import spray.http.parser.HttpParser +import spray.httpx.encoding.{Deflate, Encoder, Gzip} +import spray.httpx.unmarshalling._ +import spray.io.ClientSSLEngineProvider + +import scala.concurrent.{ExecutionContext, Future} +import scala.reflect.ClassTag +import scala.util.control.NonFatal + +object ApiInvoker { + + def apply()(implicit system: ActorSystem): ApiInvoker = + apply(DefaultFormats + DateTimeSerializer) + def apply(serializers: Traversable[Serializer[_]])(implicit system: ActorSystem): ApiInvoker = + apply(DefaultFormats + DateTimeSerializer ++ serializers) + def apply(formats: Formats)(implicit system: ActorSystem): ApiInvoker = new ApiInvoker(formats) + + case class CustomStatusCode(value: Int, reason: String = "Application-defined status code", isSuccess: Boolean = true) + + def addCustomStatusCode(code: CustomStatusCode): Unit = addCustomStatusCode(code.value, code.reason, code.isSuccess) + + def addCustomStatusCode(code: Int, reason: String = "Application defined code", isSuccess: Boolean = true) = { + StatusCodes.getForKey(code) foreach { c => + StatusCodes.registerCustom(code, reason, reason, isSuccess, allowsEntity = true) + } + } + + /** + * Allows request execution without calling apiInvoker.execute(request) + * request.response can be used to get a future of the ApiResponse generated. + * request.result can be used to get a future of the expected ApiResponse content. If content doesn't match, a + * Future will failed with a ClassCastException + * @param request the apiRequest to be executed + */ + implicit class ApiRequestImprovements[T](request: ApiRequest[T]) { + + def response(invoker: ApiInvoker)(implicit ec: ExecutionContext, system: ActorSystem): Future[ApiResponse[T]] = + response(ec, system, invoker) + + def response(implicit ec: ExecutionContext, system: ActorSystem, invoker: ApiInvoker): Future[ApiResponse[T]] = + invoker.execute(request) + + def result[U <: T](implicit c: ClassTag[U], ec: ExecutionContext, system: ActorSystem, invoker: ApiInvoker): Future[U] = + invoker.execute(request).map(_.content).mapTo[U] + + } + + /** + * Allows transformation from ApiMethod to spray HttpMethods + * @param method the ApiMethod to be converted + */ + implicit class ApiMethodExtensions(val method: ApiMethod) { + def toSprayMethod: HttpMethod = HttpMethods.getForKey(method.value).getOrElse(HttpMethods.GET) + } + + case object DateTimeSerializer extends CustomSerializer[DateTime](format => ( { + case JString(s) => + ISODateTimeFormat.dateTimeParser().parseDateTime(s) + }, { + case d: DateTime => + JString(ISODateTimeFormat.dateTimeParser().print(d)) + })) +} + +class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends UntrustedSslContext with CustomContentTypes { + + import io.swagger.client.core.ApiInvoker._ + import io.swagger.client.core.ParametersMap._ + + implicit val ec = system.dispatcher + implicit val jsonFormats = formats + + def settings = ApiSettings(system) + + import spray.http.MessagePredicate._ + + val CompressionFilter = MessagePredicate({ _ => settings.compressionEnabled}) && + Encoder.DefaultFilter && + minEntitySize(settings.compressionSizeThreshold) + + settings.customCodes.foreach(addCustomStatusCode) + + private def addAuthentication(credentialsSeq: Seq[Credentials]): pipelining.RequestTransformer = + request => + credentialsSeq.foldLeft(request) { + case (req, BasicCredentials(login, password)) => + req ~> addCredentials(BasicHttpCredentials(login, password)) + case (req, ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) => + req ~> addHeader(RawHeader(keyName, keyValue.value)) + case (req, _) => req + } + + private def addHeaders(headers: Map[String, Any]): pipelining.RequestTransformer = { request => + + val rawHeaders = for { + (name, value) <- headers.asFormattedParams + header = RawHeader(name, String.valueOf(value)) + } yield header + + request.withHeaders(rawHeaders.toList) + } + + private def bodyPart(name: String, value: Any): BodyPart = { + value match { + case f: File => + BodyPart(f, name) + case v: String => + BodyPart(HttpEntity(String.valueOf(v))) + case NumericValue(v) => + BodyPart(HttpEntity(String.valueOf(v))) + case m: ApiModel => + BodyPart(HttpEntity(Serialization.write(m))) + } + } + + private def formDataContent(request: ApiRequest[_]) = { + val params = request.formParams.asFormattedParams + if (params.isEmpty) + None + else + Some( + normalizedContentType(request.contentType).mediaType match { + case MediaTypes.`multipart/form-data` => + MultipartFormData(params.map { case (name, value) => (name, bodyPart(name, value))}) + case MediaTypes.`application/x-www-form-urlencoded` => + FormData(params.mapValues(String.valueOf)) + case m: MediaType => // Default : application/x-www-form-urlencoded. + FormData(params.mapValues(String.valueOf)) + } + ) + } + + private def bodyContent(request: ApiRequest[_]): Option[Any] = { + request.bodyParam.map(Extraction.decompose).map(compact) + } + + private def createRequest(uri: Uri, request: ApiRequest[_]): HttpRequest = { + + val builder = new RequestBuilder(request.method.toSprayMethod) + val httpRequest = request.method.toSprayMethod match { + case HttpMethods.GET | HttpMethods.DELETE => builder.apply(uri) + case HttpMethods.POST | HttpMethods.PUT => + formDataContent(request) orElse bodyContent(request) match { + case Some(c: FormData) => + builder.apply(uri, c) + case Some(c: MultipartFormData) => + builder.apply(uri, c) + case Some(c: String) => + builder.apply(uri, HttpEntity(normalizedContentType(request.contentType), c)) + case _ => + builder.apply(uri, HttpEntity(normalizedContentType(request.contentType), " ")) + } + case _ => builder.apply(uri) + } + + httpRequest ~> + addHeaders(request.headerParams) ~> + addAuthentication(request.credentials) ~> + encode(Gzip(CompressionFilter)) + } + + def makeQuery(r: ApiRequest[_]): Query = { + r.credentials.foldLeft(r.queryParams) { + case (params, ApiKeyCredentials(key, keyName, ApiKeyLocations.QUERY)) => + params + (keyName -> key.value) + case (params, _) => params + }.asFormattedParams + .mapValues(String.valueOf) + .foldRight[Query](Uri.Query.Empty) { + case ((name, value), acc) => acc.+:(name, value) + } + } + + def makeUri(r: ApiRequest[_]): Uri = { + val opPath = r.operationPath.replaceAll("\\{format\\}", "json") + val opPathWithParams = r.pathParams.asFormattedParams + .mapValues(String.valueOf) + .foldLeft(opPath) { + case (path, (name, value)) => path.replaceAll(s"\\{$name\\}", value) + } + val query = makeQuery(r) + + Uri(r.basePath + opPathWithParams).withQuery(query) + } + + def execute[T](r: ApiRequest[T]): Future[ApiResponse[T]] = { + try { + implicit val timeout: Timeout = settings.connectionTimeout + + val uri = makeUri(r) + + val connector = HostConnectorSetup( + uri.authority.host.toString, + uri.effectivePort, + sslEncryption = "https".equals(uri.scheme), + defaultHeaders = settings.defaultHeaders ++ List(`Accept-Encoding`(gzip, deflate))) + + val request = createRequest(uri, r) + + for { + Http.HostConnectorInfo(hostConnector, _) <- IO(Http) ? connector + response <- hostConnector.ask(request).mapTo[HttpResponse] + } yield { + response ~> decode(Deflate) ~> decode(Gzip) ~> unmarshallApiResponse(r) + } + } + catch { + case NonFatal(x) => Future.failed(x) + } + } + + def unmarshallApiResponse[T](request: ApiRequest[T])(response: HttpResponse): ApiResponse[T] = { + request.responseForCode(response.status.intValue) match { + case Some( (manifest: Manifest[T], state: ResponseState) ) => + entityUnmarshaller(manifest)(response.entity) match { + case Right(value) ⇒ + state match { + case ResponseState.Success => + ApiResponse(response.status.intValue, value, response.headers.map(header => (header.name, header.value)).toMap) + case ResponseState.Error => + throw new ApiError(response.status.intValue, "Error response received", + Some(value), + headers = response.headers.map(header => (header.name, header.value)).toMap) + } + + case Left(MalformedContent(error, Some(cause))) ⇒ + throw new ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString), cause) + + case Left(MalformedContent(error, None)) ⇒ + throw new ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString)) + + case Left(ContentExpected) ⇒ + throw new ApiError(response.status.intValue, s"Unable to unmarshall empty response to [$manifest]", Some(response.entity.toString)) + } + + case _ => throw new ApiError(response.status.intValue, "Unexpected response code", Some(response.entity.toString)) + } + } + + def entityUnmarshaller[T](implicit mf: Manifest[T]): Unmarshaller[T] = + Unmarshaller[T](MediaTypes.`application/json`) { + case x: HttpEntity.NonEmpty ⇒ + parse(x.asString(defaultCharset = HttpCharsets.`UTF-8`)) + .noNulls + .camelizeKeys + .extract[T] + } + +} + +sealed trait CustomContentTypes { + + def normalizedContentType(original: String): ContentType = + MediaTypes.forExtension(original) map (ContentType(_)) getOrElse parseContentType(original) + + def parseContentType(contentType: String): ContentType = { + val contentTypeAsRawHeader = HttpHeaders.RawHeader("Content-Type", contentType) + val parsedContentTypeHeader = HttpParser.parseHeader(contentTypeAsRawHeader) + (parsedContentTypeHeader: @unchecked) match { + case Right(ct: HttpHeaders.`Content-Type`) => + ct.contentType + case Left(error: ErrorInfo) => + throw new IllegalArgumentException( + s"Error converting '$contentType' to a ContentType header: '${error.summary}'") + } + } +} + +sealed trait UntrustedSslContext { + this: ApiInvoker => + + implicit lazy val trustfulSslContext: SSLContext = { + settings.alwaysTrustCertificates match { + case false => + SSLContext.getDefault + + case true => + class IgnoreX509TrustManager extends X509TrustManager { + def checkClientTrusted(chain: Array[X509Certificate], authType: String): Unit = {} + + def checkServerTrusted(chain: Array[X509Certificate], authType: String): Unit = {} + + def getAcceptedIssuers = null + } + + val context = SSLContext.getInstance("TLS") + context.init(null, Array(new IgnoreX509TrustManager), null) + context + } + } + + implicit val clientSSLEngineProvider = + ClientSSLEngineProvider { + _ => + val engine = trustfulSslContext.createSSLEngine() + engine.setUseClientMode(true) + engine + } +} diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala new file mode 100644 index 0000000000..0588193cfb --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala @@ -0,0 +1,50 @@ +package io.swagger.client.core + +sealed trait ResponseState +object ResponseState { + case object Success extends ResponseState + case object Error extends ResponseState +} + +case class ApiRequest[U]( + // required fields + method: ApiMethod, + basePath: String, + operationPath: String, + contentType: String, + + // optional fields + responses: Map[Int, (Manifest[_], ResponseState)] = Map.empty, + bodyParam: Option[Any] = None, + formParams: Map[String, Any] = Map.empty, + pathParams: Map[String, Any] = Map.empty, + queryParams: Map[String, Any] = Map.empty, + headerParams: Map[String, Any] = Map.empty, + credentials: Seq[Credentials] = List.empty) { + + def withCredentials(cred: Credentials) = copy[U](credentials = credentials :+ cred) + + def withApiKey(key: ApiKeyValue, keyName: String, location: ApiKeyLocation) = withCredentials(ApiKeyCredentials(key, keyName, location)) + + def withSuccessResponse[T](code: Int)(implicit m: Manifest[T]) = copy[U](responses = responses + (code -> (m, ResponseState.Success))) + + def withErrorResponse[T](code: Int)(implicit m: Manifest[T]) = copy[U](responses = responses + (code -> (m, ResponseState.Error))) + + def withDefaultSuccessResponse[T](implicit m: Manifest[T]) = withSuccessResponse[T](0) + + def withDefaultErrorResponse[T](implicit m: Manifest[T]) = withErrorResponse[T](0) + + def responseForCode(statusCode: Int): Option[(Manifest[_], ResponseState)] = responses.get(statusCode) orElse responses.get(0) + + def withoutBody() = copy[U](bodyParam = None) + + def withBody(body: Any) = copy[U](bodyParam = Some(body)) + + def withFormParam(name: String, value: Any) = copy[U](formParams = formParams + (name -> value)) + + def withPathParam(name: String, value: Any) = copy[U](pathParams = pathParams + (name -> value)) + + def withQueryParam(name: String, value: Any) = copy[U](queryParams = queryParams + (name -> value)) + + def withHeaderParam(name: String, value: Any) = copy[U](headerParams = headerParams + (name -> value)) +} diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala new file mode 100644 index 0000000000..3162fb9f6b --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala @@ -0,0 +1,32 @@ +package io.swagger.client.core + +import java.util.concurrent.TimeUnit + +import akka.actor.{ExtendedActorSystem, Extension, ExtensionKey} +import com.typesafe.config.Config +import io.swagger.client.core.ApiInvoker.CustomStatusCode +import spray.http.HttpHeaders.RawHeader + +import scala.collection.JavaConversions._ +import scala.concurrent.duration.FiniteDuration + +class ApiSettings(config: Config) extends Extension { + def this(system: ExtendedActorSystem) = this(system.settings.config) + + private def cfg = config.getConfig("io.swagger.client.apiRequest") + + val alwaysTrustCertificates = cfg.getBoolean("trust-certificates") + val defaultHeaders = cfg.getConfig("default-headers").entrySet.toList.map(c => RawHeader(c.getKey, c.getValue.render)) + val connectionTimeout = FiniteDuration(cfg.getDuration("connection-timeout", TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS) + val compressionEnabled = cfg.getBoolean("compression.enabled") + val compressionSizeThreshold = cfg.getBytes("compression.size-threshold").toInt + val customCodes = cfg.getConfigList("custom-codes").toList.map { c => CustomStatusCode( + c.getInt("code"), + c.getString("reason"), + c.getBoolean("success")) + } + + +} + +object ApiSettings extends ExtensionKey[ApiSettings] diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/requests.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/requests.scala new file mode 100644 index 0000000000..a096a994ea --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/requests.scala @@ -0,0 +1,166 @@ +package io.swagger.client.core + +import java.io.File +import java.net.URLEncoder +import scala.util.Try + +sealed trait ApiReturnWithHeaders { + def headers: Map[String, String] + def header(name: String): Option[String] = headers.get(name) + def getStringHeader(name: String) = header(name) + def getIntHeader(name: String) = castedHeader(name, java.lang.Integer.parseInt) + def getLongHeader(name: String) = castedHeader(name, java.lang.Long.parseLong) + def getFloatHeader(name: String) = castedHeader(name, java.lang.Float.parseFloat) + def getDoubleHeader(name: String) = castedHeader(name, java.lang.Double.parseDouble) + def getBooleanHeader(name: String) = castedHeader(name, java.lang.Boolean.parseBoolean) + private def castedHeader[U](name: String, conversion: String => U): Option[U] = { Try { header(name).map( conversion ) }.get } +} + +sealed case class ApiResponse[T](code: Int, content: T, headers: Map[String, String] = Map.empty) + extends ApiReturnWithHeaders + +sealed case class ApiError[T](code: Int, message: String, responseContent: Option[T], cause: Throwable = null, headers: Map[String, String] = Map.empty) + extends Throwable(s"($code) $message.${responseContent.map(s => s" Content : $s").getOrElse("")}", cause) + with ApiReturnWithHeaders + +sealed case class ApiMethod(value: String) + +object ApiMethods { + val CONNECT = ApiMethod("CONNECT") + val DELETE = ApiMethod("DELETE") + val GET = ApiMethod("GET") + val HEAD = ApiMethod("HEAD") + val OPTIONS = ApiMethod("OPTIONS") + val PATCH = ApiMethod("PATCH") + val POST = ApiMethod("POST") + val PUT = ApiMethod("PUT") + val TRACE = ApiMethod("TRACE") +} + +/** + * This trait needs to be added to any model defined by the api. + */ +trait ApiModel + +/** + * Single trait defining a credential that can be transformed to a paramName / paramValue tupple + */ +sealed trait Credentials { + def asQueryParam: Option[(String, String)] = None +} + +sealed case class BasicCredentials(user: String, password: String) extends Credentials + +sealed case class ApiKeyCredentials(key: ApiKeyValue, keyName: String, location: ApiKeyLocation) extends Credentials { + override def asQueryParam: Option[(String, String)] = location match { + case ApiKeyLocations.QUERY => Some((keyName, key.value)) + case _ => None + } +} + +sealed case class ApiKeyValue(value: String) + +sealed trait ApiKeyLocation + +object ApiKeyLocations { + + case object QUERY extends ApiKeyLocation + + case object HEADER extends ApiKeyLocation +} + + +/** + * Case class used to unapply numeric values only in pattern matching + * @param value the string representation of the numeric value + */ +sealed case class NumericValue(value: String) { + override def toString = value +} + +object NumericValue { + def unapply(n: Any): Option[NumericValue] = n match { + case (_: Int | _: Long | _: Float | _: Double | _: Boolean | _: Byte) => Some(NumericValue(String.valueOf(n))) + case _ => None + } +} + +/** + * Used for params being arrays + */ +sealed case class ArrayValues(values: Seq[Any], format: CollectionFormat = CollectionFormats.CSV) + +object ArrayValues { + def apply(values: Option[Seq[Any]], format: CollectionFormat): ArrayValues = + ArrayValues(values.getOrElse(Seq.empty), format) + + def apply(values: Option[Seq[Any]]): ArrayValues = ArrayValues(values, CollectionFormats.CSV) +} + + +/** + * Defines how arrays should be rendered in query strings. + */ +sealed trait CollectionFormat + +trait MergedArrayFormat extends CollectionFormat { + def separator: String +} + +object CollectionFormats { + + case object CSV extends MergedArrayFormat { + override val separator = "," + } + + case object TSV extends MergedArrayFormat { + override val separator = "\t" + } + + case object SSV extends MergedArrayFormat { + override val separator = " " + } + + case object PIPES extends MergedArrayFormat { + override val separator = "|" + } + + case object MULTI extends CollectionFormat + +} + +object ParametersMap { + + /** + * Pimp parameters maps (Map[String, Any]) in order to transform them in a sequence of String -> Any tupples, + * with valid url-encoding, arrays handling, files preservation, ... + */ + implicit class ParametersMapImprovements(val m: Map[String, Any]) { + + def asFormattedParamsList = m.toList.flatMap(formattedParams) + + def asFormattedParams = m.flatMap(formattedParams) + + private def urlEncode(v: Any) = URLEncoder.encode(String.valueOf(v), "utf-8").replaceAll("\\+", "%20") + + private def formattedParams(tuple: (String, Any)): Seq[(String, Any)] = formattedParams(tuple._1, tuple._2) + + private def formattedParams(name: String, value: Any): Seq[(String, Any)] = value match { + case arr: ArrayValues => + arr.format match { + case CollectionFormats.MULTI => arr.values.flatMap(formattedParams(name, _)) + case format: MergedArrayFormat => Seq((name, arr.values.mkString(format.separator))) + } + case None => Seq.empty + case Some(opt) => + formattedParams(name, opt) + case s: Seq[Any] => + formattedParams(name, ArrayValues(s)) + case v: String => Seq((name, urlEncode(v))) + case NumericValue(v) => Seq((name, urlEncode(v))) + case f: File => Seq((name, f)) + case m: ApiModel => Seq((name, m)) + } + + } +} diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ApiTokenStatus.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ApiTokenStatus.scala new file mode 100644 index 0000000000..41a0615c0e --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ApiTokenStatus.scala @@ -0,0 +1,16 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class ApiTokenStatus ( + Valid: Option[Boolean], + Token: Option[String], + ResetsInMillis: Option[Long], + RemainingCalls: Option[Long], + ExpiresInMillis: Option[Long], + TotalRequests: Option[Long]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioFile.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioFile.scala new file mode 100644 index 0000000000..6f3b759a2c --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioFile.scala @@ -0,0 +1,24 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class AudioFile ( + AttributionUrl: Option[String], + CommentCount: Option[Int], + VoteCount: Option[Int], + FileUrl: Option[String], + AudioType: Option[String], + Id: Option[Long], + Duration: Option[Double], + AttributionText: Option[String], + CreatedBy: Option[String], + Description: Option[String], + CreatedAt: Option[DateTime], + VoteWeightedAverage: Option[Float], + VoteAverage: Option[Float], + Word: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioType.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioType.scala new file mode 100644 index 0000000000..deda697e9e --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioType.scala @@ -0,0 +1,12 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class AudioType ( + Id: Option[Int], + Name: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AuthenticationToken.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AuthenticationToken.scala new file mode 100644 index 0000000000..169571959e --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AuthenticationToken.scala @@ -0,0 +1,13 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class AuthenticationToken ( + Token: Option[String], + UserId: Option[Long], + UserSignature: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Bigram.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Bigram.scala new file mode 100644 index 0000000000..0559c35f7f --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Bigram.scala @@ -0,0 +1,15 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Bigram ( + Count: Option[Long], + Gram2: Option[String], + Gram1: Option[String], + Wlmi: Option[Double], + Mi: Option[Double]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Category.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Category.scala new file mode 100644 index 0000000000..5eec9d159d --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Category.scala @@ -0,0 +1,12 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Category ( + Id: Option[Long], + Name: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Citation.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Citation.scala new file mode 100644 index 0000000000..af02512406 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Citation.scala @@ -0,0 +1,12 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Citation ( + Cite: Option[String], + Source: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ContentProvider.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ContentProvider.scala new file mode 100644 index 0000000000..be35406b63 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ContentProvider.scala @@ -0,0 +1,12 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class ContentProvider ( + Id: Option[Int], + Name: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Definition.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Definition.scala new file mode 100644 index 0000000000..00b5893216 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Definition.scala @@ -0,0 +1,26 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Definition ( + ExtendedText: Option[String], + Text: Option[String], + SourceDictionary: Option[String], + Citations: Option[Seq[Citation]], + Labels: Option[Seq[Label]], + Score: Option[Float], + ExampleUses: Option[Seq[ExampleUsage]], + AttributionUrl: Option[String], + SeqString: Option[String], + AttributionText: Option[String], + RelatedWords: Option[Seq[Related]], + Sequence: Option[String], + Word: Option[String], + Notes: Option[Seq[Note]], + TextProns: Option[Seq[TextPron]], + PartOfSpeech: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/DefinitionSearchResults.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/DefinitionSearchResults.scala new file mode 100644 index 0000000000..a757637d42 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/DefinitionSearchResults.scala @@ -0,0 +1,12 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class DefinitionSearchResults ( + Results: Option[Seq[Definition]], + TotalResults: Option[Int]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Example.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Example.scala new file mode 100644 index 0000000000..9604f2aa62 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Example.scala @@ -0,0 +1,22 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Example ( + Id: Option[Long], + ExampleId: Option[Long], + Title: Option[String], + Text: Option[String], + Score: Option[ScoredWord], + Sentence: Option[Sentence], + Word: Option[String], + Provider: Option[ContentProvider], + Year: Option[Int], + Rating: Option[Float], + DocumentId: Option[Long], + Url: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleSearchResults.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleSearchResults.scala new file mode 100644 index 0000000000..8ef6be3f17 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleSearchResults.scala @@ -0,0 +1,12 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class ExampleSearchResults ( + Facets: Option[Seq[Facet]], + Examples: Option[Seq[Example]]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleUsage.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleUsage.scala new file mode 100644 index 0000000000..2e6fff5f97 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleUsage.scala @@ -0,0 +1,11 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class ExampleUsage ( + Text: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Facet.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Facet.scala new file mode 100644 index 0000000000..4e113440c5 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Facet.scala @@ -0,0 +1,12 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Facet ( + FacetValues: Option[Seq[FacetValue]], + Name: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FacetValue.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FacetValue.scala new file mode 100644 index 0000000000..4d4d729485 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FacetValue.scala @@ -0,0 +1,12 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class FacetValue ( + Count: Option[Long], + Value: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Frequency.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Frequency.scala new file mode 100644 index 0000000000..595e001c6a --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Frequency.scala @@ -0,0 +1,12 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Frequency ( + Count: Option[Long], + Year: Option[Int]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FrequencySummary.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FrequencySummary.scala new file mode 100644 index 0000000000..3f0ac1c0c5 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FrequencySummary.scala @@ -0,0 +1,15 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class FrequencySummary ( + UnknownYearCount: Option[Int], + TotalCount: Option[Long], + FrequencyString: Option[String], + Word: Option[String], + Frequency: Option[Seq[Frequency]]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Label.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Label.scala new file mode 100644 index 0000000000..52b386526c --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Label.scala @@ -0,0 +1,12 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Label ( + Text: Option[String], + Type: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Note.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Note.scala new file mode 100644 index 0000000000..6975837dcb --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Note.scala @@ -0,0 +1,14 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Note ( + NoteType: Option[String], + AppliesTo: Option[Seq[String]], + Value: Option[String], + Pos: Option[Int]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/PartOfSpeech.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/PartOfSpeech.scala new file mode 100644 index 0000000000..8a659ce487 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/PartOfSpeech.scala @@ -0,0 +1,13 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class PartOfSpeech ( + Roots: Option[Seq[Root]], + StorageAbbr: Option[Seq[String]], + AllCategories: Option[Seq[Category]]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Related.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Related.scala new file mode 100644 index 0000000000..d514783837 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Related.scala @@ -0,0 +1,17 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Related ( + Label1: Option[String], + RelationshipType: Option[String], + Label2: Option[String], + Label3: Option[String], + Words: Option[Seq[String]], + Gram: Option[String], + Label4: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Root.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Root.scala new file mode 100644 index 0000000000..b8580e33ef --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Root.scala @@ -0,0 +1,13 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Root ( + Id: Option[Long], + Name: Option[String], + Categories: Option[Seq[Category]]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ScoredWord.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ScoredWord.scala new file mode 100644 index 0000000000..79401c1e1b --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ScoredWord.scala @@ -0,0 +1,21 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class ScoredWord ( + Position: Option[Int], + Id: Option[Long], + DocTermCount: Option[Int], + Lemma: Option[String], + WordType: Option[String], + Score: Option[Float], + SentenceId: Option[Long], + Word: Option[String], + Stopword: Option[Boolean], + BaseWordScore: Option[Double], + PartOfSpeech: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Sentence.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Sentence.scala new file mode 100644 index 0000000000..eb9944b10b --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Sentence.scala @@ -0,0 +1,16 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Sentence ( + HasScoredWords: Option[Boolean], + Id: Option[Long], + ScoredWords: Option[Seq[ScoredWord]], + Display: Option[String], + Rating: Option[Int], + DocumentMetadataId: Option[Long]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleDefinition.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleDefinition.scala new file mode 100644 index 0000000000..49ee8301c9 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleDefinition.scala @@ -0,0 +1,14 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class SimpleDefinition ( + Text: Option[String], + Source: Option[String], + Note: Option[String], + PartOfSpeech: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleExample.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleExample.scala new file mode 100644 index 0000000000..1eea4ee458 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleExample.scala @@ -0,0 +1,14 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class SimpleExample ( + Id: Option[Long], + Title: Option[String], + Text: Option[String], + Url: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/StringValue.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/StringValue.scala new file mode 100644 index 0000000000..71538e2425 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/StringValue.scala @@ -0,0 +1,11 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class StringValue ( + Word: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Syllable.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Syllable.scala new file mode 100644 index 0000000000..99ed72f350 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Syllable.scala @@ -0,0 +1,13 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class Syllable ( + Text: Option[String], + Seq: Option[Int], + Type: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/TextPron.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/TextPron.scala new file mode 100644 index 0000000000..7d3d59dd72 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/TextPron.scala @@ -0,0 +1,13 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class TextPron ( + Raw: Option[String], + Seq: Option[Int], + RawType: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/User.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/User.scala new file mode 100644 index 0000000000..6b1db4b0c8 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/User.scala @@ -0,0 +1,18 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class User ( + Id: Option[Long], + Username: Option[String], + Email: Option[String], + Status: Option[Int], + FaceBookId: Option[String], + UserName: Option[String], + DisplayName: Option[String], + Password: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordList.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordList.scala new file mode 100644 index 0000000000..9022b32efb --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordList.scala @@ -0,0 +1,21 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class WordList ( + Id: Option[Long], + Permalink: Option[String], + Name: Option[String], + CreatedAt: Option[DateTime], + UpdatedAt: Option[DateTime], + LastActivityAt: Option[DateTime], + Username: Option[String], + UserId: Option[Long], + Description: Option[String], + NumberWordsInList: Option[Long], + Type: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordListWord.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordListWord.scala new file mode 100644 index 0000000000..c15ddd7c58 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordListWord.scala @@ -0,0 +1,17 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class WordListWord ( + Id: Option[Long], + Word: Option[String], + Username: Option[String], + UserId: Option[Long], + CreatedAt: Option[DateTime], + NumberCommentsOnWord: Option[Long], + NumberLists: Option[Long]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordObject.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordObject.scala new file mode 100644 index 0000000000..a00491ba04 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordObject.scala @@ -0,0 +1,16 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class WordObject ( + Id: Option[Long], + Word: Option[String], + OriginalWord: Option[String], + Suggestions: Option[Seq[String]], + CanonicalForm: Option[String], + Vulgar: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordOfTheDay.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordOfTheDay.scala new file mode 100644 index 0000000000..8cfbf43243 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordOfTheDay.scala @@ -0,0 +1,22 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class WordOfTheDay ( + Id: Option[Long], + ParentId: Option[String], + Category: Option[String], + CreatedBy: Option[String], + CreatedAt: Option[DateTime], + ContentProvider: Option[ContentProvider], + HtmlExtra: Option[String], + Word: Option[String], + Definitions: Option[Seq[SimpleDefinition]], + Examples: Option[Seq[SimpleExample]], + Note: Option[String], + PublishDate: Option[DateTime]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResult.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResult.scala new file mode 100644 index 0000000000..ca2cb8182a --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResult.scala @@ -0,0 +1,13 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class WordSearchResult ( + Count: Option[Long], + Lexicality: Option[Double], + Word: Option[String]) + extends ApiModel + + diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResults.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResults.scala new file mode 100644 index 0000000000..a4715f1661 --- /dev/null +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResults.scala @@ -0,0 +1,12 @@ +package io.swagger.client.model + +import io.swagger.client.core.ApiModel +import org.joda.time.DateTime + + +case class WordSearchResults ( + SearchResults: Option[Seq[WordSearchResult]], + TotalResults: Option[Int]) + extends ApiModel + + From ef3811390fd950fd9a0afe841a69fd363b707120 Mon Sep 17 00:00:00 2001 From: Camille Chafer Date: Thu, 2 Apr 2015 17:46:26 +0200 Subject: [PATCH 3/5] Some fixes for Wordnik & Petstore examples --- .../swagger/codegen/CodegenResponse.java | 1 + .../main/resources/akka-scala/api.mustache | 4 ++-- .../akka-scala/operationReturnType.mustache | 2 +- .../scala/io/swagger/client/api/PetApi.scala | 6 ++--- .../scala/io/swagger/client/api/UserApi.scala | 24 +++++++++---------- .../scala/io/swagger/client/api/WordApi.scala | 16 ++++++------- .../io/swagger/client/api/WordListApi.scala | 20 ++++++++-------- .../io/swagger/client/api/WordsApi.scala | 6 ++--- 8 files changed, 40 insertions(+), 39 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenResponse.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenResponse.java index b23c5f7212..c4d9d2c6ed 100644 --- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenResponse.java +++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/CodegenResponse.java @@ -15,4 +15,5 @@ public class CodegenResponse { public Boolean isListContainer; public Object schema; public String jsonSchema; + public boolean isWildcard() { return "0".equals(code) || "default".equals(code); } } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/api.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/api.mustache index 34523b8035..fecf2827f0 100644 --- a/modules/swagger-codegen/src/main/resources/akka-scala/api.mustache +++ b/modules/swagger-codegen/src/main/resources/akka-scala/api.mustache @@ -25,8 +25,8 @@ object {{classname}} { {{/pathParams}}{{#headerParams}}.withHeaderParam({{>paramCreation}}) {{/headerParams}}{{#responses}}{{^isWildcard}}{{#dataType}}.with{{>responseState}}Response[{{dataType}}]({{code}}) {{/dataType}}{{^dataType}}.with{{>responseState}}Response[Unit]({{code}}) - {{/dataType}}{{/isWildcard}}{{/responses}}{{#responses}}{{#isWildcard}}{{#dataType}}.withDefault{{>responseState}}Response[{{dataType}}]() - {{/dataType}}{{^dataType}}.withDefault{{>responseState}}Response[Unit]() + {{/dataType}}{{/isWildcard}}{{/responses}}{{#responses}}{{#isWildcard}}{{#dataType}}.withDefault{{>responseState}}Response[{{dataType}}] + {{/dataType}}{{^dataType}}.withDefault{{>responseState}}Response[Unit] {{/dataType}}{{/isWildcard}}{{/responses}}{{^responseHeaders.isEmpty}} object {{#fnCapitalize}}{{operationId}}{{/fnCapitalize}}Headers { {{#responseHeaders}} def {{name}}(r: ApiReturnWithHeaders) = r.get{{^isContainer}}{{baseType}}{{/isContainer}}{{#isContainer}}String{{/isContainer}}Header("{{baseName}}"){{/responseHeaders}} diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/operationReturnType.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/operationReturnType.mustache index e9d2be5340..ba0924313f 100644 --- a/modules/swagger-codegen/src/main/resources/akka-scala/operationReturnType.mustache +++ b/modules/swagger-codegen/src/main/resources/akka-scala/operationReturnType.mustache @@ -1 +1 @@ -{{#onlyOneSuccess}}{{^defaultResponse}}Unit{{/defaultResponse}}{{#responses}}{{#isDefault}}{{#dataType}}{{dataType}}{{/dataType}}{{^dataType}}Unit{{/dataType}}{{/isDefault}}{{/responses}}{{/onlyOneSuccess}}{{^onlyOneSuccess}}{{#responses}}{{#-first}}{{^hasMore}}{{#dataType}}{{dataType}}{{/dataType}}{{^dataType}}Unit{{/dataType}}{{/hasMore}}{{#hasMore}}Any{{/hasMore}}{{/-first}}{{/responses}}{{/onlyOneSuccess}} \ No newline at end of file +{{#onlyOneSuccess}}{{^defaultResponse}}Unit{{/defaultResponse}}{{#defaultResponse}}{{#responses}}{{#isDefault}}{{#dataType}}{{dataType}}{{/dataType}}{{^dataType}}Unit{{/dataType}}{{/isDefault}}{{/responses}}{{/defaultResponse}}{{/onlyOneSuccess}}{{^onlyOneSuccess}}{{#responses}}{{#-first}}{{^hasMore}}{{#dataType}}{{dataType}}{{/dataType}}{{^dataType}}Unit{{/dataType}}{{/hasMore}}{{#hasMore}}Any{{/hasMore}}{{/-first}}{{/responses}}{{/onlyOneSuccess}} \ No newline at end of file diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala index d56d3f855a..abb8054e75 100644 --- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala @@ -126,12 +126,12 @@ object PetApi { * @param AdditionalMetadata Additional data to pass to server * @param File file to upload */ - def uploadFile(PetId: Long, AdditionalMetadata: Option[String] = None, File: Option[File] = None): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet/{petId}/uploadImage", "multipart/form-data") + def uploadFile(PetId: Long, AdditionalMetadata: Option[String] = None, File: Option[File] = None): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet/{petId}/uploadImage", "multipart/form-data") .withFormParam("additionalMetadata", AdditionalMetadata) .withFormParam("file", File) .withPathParam("petId", PetId) - .withSuccessResponse[Unit](0) + .withDefaultSuccessResponse[Unit] diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala index 77aade9a9e..9fb026d950 100644 --- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala @@ -15,10 +15,10 @@ object UserApi { * * @param Body Created user object */ - def createUser(Body: Option[User] = None): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user", "application/json") + def createUser(Body: Option[User] = None): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user", "application/json") .withBody(Body) - .withSuccessResponse[Unit](0) + .withDefaultSuccessResponse[Unit] /** * @@ -27,10 +27,10 @@ object UserApi { * * @param Body List of user object */ - def createUsersWithArrayInput(Body: Seq[User]): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user/createWithArray", "application/json") + def createUsersWithArrayInput(Body: Seq[User]): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user/createWithArray", "application/json") .withBody(Body) - .withSuccessResponse[Unit](0) + .withDefaultSuccessResponse[Unit] /** * @@ -39,10 +39,10 @@ object UserApi { * * @param Body List of user object */ - def createUsersWithListInput(Body: Seq[User]): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user/createWithList", "application/json") + def createUsersWithListInput(Body: Seq[User]): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user/createWithList", "application/json") .withBody(Body) - .withSuccessResponse[Unit](0) + .withDefaultSuccessResponse[Unit] /** * @@ -65,9 +65,9 @@ object UserApi { * Expected answers: * code 0 : (successful operation) */ - def logoutUser(): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/logout", "application/json") - .withSuccessResponse[Unit](0) + def logoutUser(): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/logout", "application/json") + .withDefaultSuccessResponse[Unit] /** * diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala index bbcf2dd357..36d706c4f4 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala @@ -111,8 +111,8 @@ object WordApi { * @param Skip Results to skip * @param Limit Maximum number of results to return */ - def getExamples(Word: String, IncludeDuplicates: Option[String] = None, UseCanonical: Option[String] = None, Skip: Option[Int] = None, Limit: Option[Int] = None): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/examples", "application/json") + def getExamples(Word: String, IncludeDuplicates: Option[String] = None, UseCanonical: Option[String] = None, Skip: Option[Int] = None, Limit: Option[Int] = None): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/examples", "application/json") .withQueryParam("includeDuplicates", IncludeDuplicates) .withQueryParam("useCanonical", UseCanonical) .withQueryParam("skip", Skip) @@ -156,8 +156,8 @@ object WordApi { * @param SourceDictionary Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet. * @param Limit Maximum number of results to return */ - def getHyphenation(Word: String, UseCanonical: Option[String] = None, SourceDictionary: Option[String] = None, Limit: Option[Int] = None): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/hyphenation", "application/json") + def getHyphenation(Word: String, UseCanonical: Option[String] = None, SourceDictionary: Option[String] = None, Limit: Option[Int] = None): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/hyphenation", "application/json") .withQueryParam("useCanonical", UseCanonical) .withQueryParam("sourceDictionary", SourceDictionary) .withQueryParam("limit", Limit) @@ -199,8 +199,8 @@ object WordApi { * @param TypeFormat Text pronunciation type * @param Limit Maximum number of results to return */ - def getTextPronunciations(Word: String, UseCanonical: Option[String] = None, SourceDictionary: Option[String] = None, TypeFormat: Option[String] = None, Limit: Option[Int] = None): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/pronunciations", "application/json") + def getTextPronunciations(Word: String, UseCanonical: Option[String] = None, SourceDictionary: Option[String] = None, TypeFormat: Option[String] = None, Limit: Option[Int] = None): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/pronunciations", "application/json") .withQueryParam("useCanonical", UseCanonical) .withQueryParam("sourceDictionary", SourceDictionary) .withQueryParam("typeFormat", TypeFormat) @@ -221,8 +221,8 @@ object WordApi { * @param RelationshipTypes Limits the total results per type of relationship type * @param LimitPerRelationshipType Restrict to the supplied relationship types */ - def getRelatedWords(Word: String, UseCanonical: Option[String] = None, RelationshipTypes: Option[String] = None, LimitPerRelationshipType: Option[Int] = None): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/relatedWords", "application/json") + def getRelatedWords(Word: String, UseCanonical: Option[String] = None, RelationshipTypes: Option[String] = None, LimitPerRelationshipType: Option[Int] = None): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/relatedWords", "application/json") .withQueryParam("useCanonical", UseCanonical) .withQueryParam("relationshipTypes", RelationshipTypes) .withQueryParam("limitPerRelationshipType", LimitPerRelationshipType) diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala index 8d34cfd3f3..54883fa07b 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala @@ -42,8 +42,8 @@ object WordListApi { * @param Body Updated WordList * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) */ - def updateWordList(Permalink: String, Body: Option[WordList] = None, AuthToken: String): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.PUT, "https://api.wordnik.com/v4", "/wordList.json/{permalink}", "application/json") + def updateWordList(Permalink: String, Body: Option[WordList] = None, AuthToken: String): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.PUT, "https://api.wordnik.com/v4", "/wordList.json/{permalink}", "application/json") .withBody(Body) .withPathParam("permalink", Permalink) .withHeaderParam("auth_token", AuthToken) @@ -64,8 +64,8 @@ object WordListApi { * @param Permalink ID of WordList to delete * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) */ - def deleteWordList(Permalink: String, AuthToken: String): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.DELETE, "https://api.wordnik.com/v4", "/wordList.json/{permalink}", "application/json") + def deleteWordList(Permalink: String, AuthToken: String): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.DELETE, "https://api.wordnik.com/v4", "/wordList.json/{permalink}", "application/json") .withPathParam("permalink", Permalink) .withHeaderParam("auth_token", AuthToken) .withSuccessResponse[Unit](200) @@ -86,8 +86,8 @@ object WordListApi { * @param Body Words to remove from WordList * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) */ - def deleteWordsFromWordList(Permalink: String, Body: Seq[StringValue], AuthToken: String): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.POST, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/deleteWords", "application/json") + def deleteWordsFromWordList(Permalink: String, Body: Seq[StringValue], AuthToken: String): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.POST, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/deleteWords", "application/json") .withBody(Body) .withPathParam("permalink", Permalink) .withHeaderParam("auth_token", AuthToken) @@ -112,8 +112,8 @@ object WordListApi { * @param Limit Maximum number of results to return * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) */ - def getWordListWords(Permalink: String, SortBy: Option[String] = None, SortOrder: Option[String] = None, Skip: Option[Int] = None, Limit: Option[Int] = None, AuthToken: String): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.GET, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/words", "application/json") + def getWordListWords(Permalink: String, SortBy: Option[String] = None, SortOrder: Option[String] = None, Skip: Option[Int] = None, Limit: Option[Int] = None, AuthToken: String): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/words", "application/json") .withQueryParam("sortBy", SortBy) .withQueryParam("sortOrder", SortOrder) .withQueryParam("skip", Skip) @@ -138,8 +138,8 @@ object WordListApi { * @param Body Array of words to add to WordList * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) */ - def addWordsToWordList(Permalink: String, Body: Seq[StringValue], AuthToken: String): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.POST, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/words", "application/json") + def addWordsToWordList(Permalink: String, Body: Seq[StringValue], AuthToken: String): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.POST, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/words", "application/json") .withBody(Body) .withPathParam("permalink", Permalink) .withHeaderParam("auth_token", AuthToken) diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala index 4ca9ab1310..1a58a2f413 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala @@ -62,8 +62,8 @@ object WordsApi { * @param SortOrder Sort direction * @param Limit Maximum number of results to return */ - def getRandomWords(HasDictionaryDef: Option[String] = None, IncludePartOfSpeech: Option[String] = None, ExcludePartOfSpeech: Option[String] = None, MinCorpusCount: Option[Int] = None, MaxCorpusCount: Option[Int] = None, MinDictionaryCount: Option[Int] = None, MaxDictionaryCount: Option[Int] = None, MinLength: Option[Int] = None, MaxLength: Option[Int] = None, SortBy: Option[String] = None, SortOrder: Option[String] = None, Limit: Option[Int] = None): ApiRequest[UnitUnit] = - ApiRequest[UnitUnit](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/randomWords", "application/json") + def getRandomWords(HasDictionaryDef: Option[String] = None, IncludePartOfSpeech: Option[String] = None, ExcludePartOfSpeech: Option[String] = None, MinCorpusCount: Option[Int] = None, MaxCorpusCount: Option[Int] = None, MinDictionaryCount: Option[Int] = None, MaxDictionaryCount: Option[Int] = None, MinLength: Option[Int] = None, MaxLength: Option[Int] = None, SortBy: Option[String] = None, SortOrder: Option[String] = None, Limit: Option[Int] = None): ApiRequest[Unit] = + ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/randomWords", "application/json") .withQueryParam("hasDictionaryDef", HasDictionaryDef) .withQueryParam("includePartOfSpeech", IncludePartOfSpeech) .withQueryParam("excludePartOfSpeech", ExcludePartOfSpeech) @@ -173,7 +173,7 @@ object WordsApi { def getWordOfTheDay(Date: Option[String] = None): ApiRequest[WordOfTheDay] = ApiRequest[WordOfTheDay](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/wordOfTheDay", "application/json") .withQueryParam("date", Date) - .withSuccessResponse[WordOfTheDay](0) + .withDefaultSuccessResponse[WordOfTheDay] From 6c4765fd00322dbd25b764b20152cc965a473c98 Mon Sep 17 00:00:00 2001 From: Camille Chafer Date: Thu, 2 Apr 2015 18:00:25 +0200 Subject: [PATCH 4/5] Parameters names where camelized with first letter not lower --- .../swagger/codegen/languages/AkkaScalaClientCodegen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/AkkaScalaClientCodegen.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/AkkaScalaClientCodegen.java index ee2da7aa92..fff8deb99f 100644 --- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/AkkaScalaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/AkkaScalaClientCodegen.java @@ -230,7 +230,7 @@ public class AkkaScalaClientCodegen extends DefaultCodegen implements CodegenCon } private String formatIdentifier(String name, boolean capitalized) { - String identifier = camelize(name); + String identifier = camelize(name, true); if (capitalized) identifier = StringUtils.capitalize(identifier); if (identifier.matches("[a-zA-Z_$][\\w_$]+") && !reservedWords.contains(identifier)) From 65b6d210bc81a1e0a68a63bd2f6415580c400f73 Mon Sep 17 00:00:00 2001 From: Camille Chafer Date: Thu, 2 Apr 2015 18:02:21 +0200 Subject: [PATCH 5/5] Examples updated with names lower-camelized --- .../scala/io/swagger/client/api/PetApi.scala | 68 +++--- .../io/swagger/client/api/StoreApi.scala | 18 +- .../scala/io/swagger/client/api/UserApi.scala | 50 ++--- .../io/swagger/client/model/Category.scala | 4 +- .../scala/io/swagger/client/model/Order.scala | 12 +- .../scala/io/swagger/client/model/Pet.scala | 12 +- .../scala/io/swagger/client/model/Tag.scala | 4 +- .../scala/io/swagger/client/model/User.scala | 16 +- .../io/swagger/client/api/AccountApi.scala | 46 ++-- .../scala/io/swagger/client/api/WordApi.scala | 194 ++++++++-------- .../io/swagger/client/api/WordListApi.scala | 88 ++++---- .../io/swagger/client/api/WordListsApi.scala | 10 +- .../io/swagger/client/api/WordsApi.scala | 210 +++++++++--------- .../swagger/client/model/ApiTokenStatus.scala | 12 +- .../io/swagger/client/model/AudioFile.scala | 28 +-- .../io/swagger/client/model/AudioType.scala | 4 +- .../client/model/AuthenticationToken.scala | 6 +- .../io/swagger/client/model/Bigram.scala | 10 +- .../io/swagger/client/model/Category.scala | 4 +- .../io/swagger/client/model/Citation.scala | 4 +- .../client/model/ContentProvider.scala | 4 +- .../io/swagger/client/model/Definition.scala | 32 +-- .../model/DefinitionSearchResults.scala | 4 +- .../io/swagger/client/model/Example.scala | 24 +- .../client/model/ExampleSearchResults.scala | 4 +- .../swagger/client/model/ExampleUsage.scala | 2 +- .../scala/io/swagger/client/model/Facet.scala | 4 +- .../io/swagger/client/model/FacetValue.scala | 4 +- .../io/swagger/client/model/Frequency.scala | 4 +- .../client/model/FrequencySummary.scala | 10 +- .../scala/io/swagger/client/model/Label.scala | 4 +- .../scala/io/swagger/client/model/Note.scala | 8 +- .../swagger/client/model/PartOfSpeech.scala | 6 +- .../io/swagger/client/model/Related.scala | 14 +- .../scala/io/swagger/client/model/Root.scala | 6 +- .../io/swagger/client/model/ScoredWord.scala | 22 +- .../io/swagger/client/model/Sentence.scala | 12 +- .../client/model/SimpleDefinition.scala | 8 +- .../swagger/client/model/SimpleExample.scala | 8 +- .../io/swagger/client/model/StringValue.scala | 2 +- .../io/swagger/client/model/Syllable.scala | 6 +- .../io/swagger/client/model/TextPron.scala | 6 +- .../scala/io/swagger/client/model/User.scala | 16 +- .../io/swagger/client/model/WordList.scala | 22 +- .../swagger/client/model/WordListWord.scala | 14 +- .../io/swagger/client/model/WordObject.scala | 12 +- .../swagger/client/model/WordOfTheDay.scala | 24 +- .../client/model/WordSearchResult.scala | 6 +- .../client/model/WordSearchResults.scala | 4 +- 49 files changed, 546 insertions(+), 546 deletions(-) diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala index abb8054e75..d5ae6fd65f 100644 --- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala @@ -15,11 +15,11 @@ object PetApi { * code 404 : (Pet not found) * code 400 : (Invalid ID supplied) * - * @param Body Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store */ - def updatePet(Body: Option[Pet] = None): ApiRequest[Unit] = + def updatePet(body: Option[Pet] = None): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.PUT, "http://petstore.swagger.io/v2", "/pet", "application/json") - .withBody(Body) + .withBody(body) .withErrorResponse[Unit](405) .withErrorResponse[Unit](404) .withErrorResponse[Unit](400) @@ -29,11 +29,11 @@ object PetApi { * Expected answers: * code 405 : (Invalid input) * - * @param Body Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store */ - def addPet(Body: Option[Pet] = None): ApiRequest[Unit] = + def addPet(body: Option[Pet] = None): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet", "application/json") - .withBody(Body) + .withBody(body) .withErrorResponse[Unit](405) /** @@ -43,11 +43,11 @@ object PetApi { * code 200 : Seq[Pet] (successful operation) * code 400 : (Invalid status value) * - * @param Status Status values that need to be considered for filter + * @param status Status values that need to be considered for filter */ - def findPetsByStatus(Status: Seq[String]): ApiRequest[Seq[Pet]] = + def findPetsByStatus(status: Seq[String]): ApiRequest[Seq[Pet]] = ApiRequest[Seq[Pet]](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/findByStatus", "application/json") - .withQueryParam("status", ArrayValues(Status, MULTI)) + .withQueryParam("status", ArrayValues(status, MULTI)) .withSuccessResponse[Seq[Pet]](200) .withErrorResponse[Unit](400) @@ -58,11 +58,11 @@ object PetApi { * code 200 : Seq[Pet] (successful operation) * code 400 : (Invalid tag value) * - * @param Tags Tags to filter by + * @param tags Tags to filter by */ - def findPetsByTags(Tags: Seq[String]): ApiRequest[Seq[Pet]] = + def findPetsByTags(tags: Seq[String]): ApiRequest[Seq[Pet]] = ApiRequest[Seq[Pet]](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/findByTags", "application/json") - .withQueryParam("tags", ArrayValues(Tags, MULTI)) + .withQueryParam("tags", ArrayValues(tags, MULTI)) .withSuccessResponse[Seq[Pet]](200) .withErrorResponse[Unit](400) @@ -77,12 +77,12 @@ object PetApi { * Available security schemes: * api_key (apiKey) * - * @param PetId ID of pet that needs to be fetched + * @param petId ID of pet that needs to be fetched */ - def getPetById(PetId: Long)(implicit apiKey: ApiKeyValue): ApiRequest[Pet] = + def getPetById(petId: Long)(implicit apiKey: ApiKeyValue): ApiRequest[Pet] = ApiRequest[Pet](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/json") .withApiKey(apiKey, "api_key", HEADER) - .withPathParam("petId", PetId) + .withPathParam("petId", petId) .withErrorResponse[Unit](404) .withSuccessResponse[Pet](200) .withErrorResponse[Unit](400) @@ -92,15 +92,15 @@ object PetApi { * Expected answers: * code 405 : (Invalid input) * - * @param PetId ID of pet that needs to be updated - * @param Name Updated name of the pet - * @param Status Updated status of the pet + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet */ - def updatePetWithForm(PetId: String, Name: Option[String] = None, Status: Option[String] = None): ApiRequest[Unit] = + def updatePetWithForm(petId: String, name: Option[String] = None, status: Option[String] = None): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/x-www-form-urlencoded") - .withFormParam("name", Name) - .withFormParam("status", Status) - .withPathParam("petId", PetId) + .withFormParam("name", name) + .withFormParam("status", status) + .withPathParam("petId", petId) .withErrorResponse[Unit](405) /** @@ -108,13 +108,13 @@ object PetApi { * Expected answers: * code 400 : (Invalid pet value) * - * @param ApiKey - * @param PetId Pet id to delete + * @param apiKey + * @param petId Pet id to delete */ - def deletePet(ApiKey: Option[String] = None, PetId: Long): ApiRequest[Unit] = + def deletePet(apiKey: Option[String] = None, petId: Long): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.DELETE, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/json") - .withPathParam("petId", PetId) - .withHeaderParam("api_key", ApiKey) + .withPathParam("petId", petId) + .withHeaderParam("api_key", apiKey) .withErrorResponse[Unit](400) /** @@ -122,15 +122,15 @@ object PetApi { * Expected answers: * code 0 : (successful operation) * - * @param PetId ID of pet to update - * @param AdditionalMetadata Additional data to pass to server - * @param File file to upload + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload */ - def uploadFile(PetId: Long, AdditionalMetadata: Option[String] = None, File: Option[File] = None): ApiRequest[Unit] = + def uploadFile(petId: Long, additionalMetadata: Option[String] = None, file: Option[File] = None): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet/{petId}/uploadImage", "multipart/form-data") - .withFormParam("additionalMetadata", AdditionalMetadata) - .withFormParam("file", File) - .withPathParam("petId", PetId) + .withFormParam("additionalMetadata", additionalMetadata) + .withFormParam("file", file) + .withPathParam("petId", petId) .withDefaultSuccessResponse[Unit] diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala index a1391954a7..686e85e105 100644 --- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala @@ -27,11 +27,11 @@ object StoreApi { * code 200 : Order (successful operation) * code 400 : (Invalid Order) * - * @param Body order placed for purchasing the pet + * @param body order placed for purchasing the pet */ - def placeOrder(Body: Option[Order] = None): ApiRequest[Order] = + def placeOrder(body: Option[Order] = None): ApiRequest[Order] = ApiRequest[Order](ApiMethods.POST, "http://petstore.swagger.io/v2", "/store/order", "application/json") - .withBody(Body) + .withBody(body) .withSuccessResponse[Order](200) .withErrorResponse[Unit](400) @@ -43,11 +43,11 @@ object StoreApi { * code 200 : Order (successful operation) * code 400 : (Invalid ID supplied) * - * @param OrderId ID of pet that needs to be fetched + * @param orderId ID of pet that needs to be fetched */ - def getOrderById(OrderId: String): ApiRequest[Order] = + def getOrderById(orderId: String): ApiRequest[Order] = ApiRequest[Order](ApiMethods.GET, "http://petstore.swagger.io/v2", "/store/order/{orderId}", "application/json") - .withPathParam("orderId", OrderId) + .withPathParam("orderId", orderId) .withErrorResponse[Unit](404) .withSuccessResponse[Order](200) .withErrorResponse[Unit](400) @@ -59,11 +59,11 @@ object StoreApi { * code 404 : (Order not found) * code 400 : (Invalid ID supplied) * - * @param OrderId ID of the order that needs to be deleted + * @param orderId ID of the order that needs to be deleted */ - def deleteOrder(OrderId: String): ApiRequest[Unit] = + def deleteOrder(orderId: String): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.DELETE, "http://petstore.swagger.io/v2", "/store/order/{orderId}", "application/json") - .withPathParam("orderId", OrderId) + .withPathParam("orderId", orderId) .withErrorResponse[Unit](404) .withErrorResponse[Unit](400) diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala index 9fb026d950..4c2ab10e9e 100644 --- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala @@ -13,11 +13,11 @@ object UserApi { * Expected answers: * code 0 : (successful operation) * - * @param Body Created user object + * @param body Created user object */ - def createUser(Body: Option[User] = None): ApiRequest[Unit] = + def createUser(body: Option[User] = None): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user", "application/json") - .withBody(Body) + .withBody(body) .withDefaultSuccessResponse[Unit] /** @@ -25,11 +25,11 @@ object UserApi { * Expected answers: * code 0 : (successful operation) * - * @param Body List of user object + * @param body List of user object */ - def createUsersWithArrayInput(Body: Seq[User]): ApiRequest[Unit] = + def createUsersWithArrayInput(body: Seq[User]): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user/createWithArray", "application/json") - .withBody(Body) + .withBody(body) .withDefaultSuccessResponse[Unit] /** @@ -37,11 +37,11 @@ object UserApi { * Expected answers: * code 0 : (successful operation) * - * @param Body List of user object + * @param body List of user object */ - def createUsersWithListInput(Body: Seq[User]): ApiRequest[Unit] = + def createUsersWithListInput(body: Seq[User]): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user/createWithList", "application/json") - .withBody(Body) + .withBody(body) .withDefaultSuccessResponse[Unit] /** @@ -50,13 +50,13 @@ object UserApi { * code 200 : String (successful operation) * code 400 : (Invalid username/password supplied) * - * @param Username The user name for login - * @param Password The password for login in clear text + * @param username The user name for login + * @param password The password for login in clear text */ - def loginUser(Username: Option[String] = None, Password: Option[String] = None): ApiRequest[String] = + def loginUser(username: Option[String] = None, password: Option[String] = None): ApiRequest[String] = ApiRequest[String](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/login", "application/json") - .withQueryParam("username", Username) - .withQueryParam("password", Password) + .withQueryParam("username", username) + .withQueryParam("password", password) .withSuccessResponse[String](200) .withErrorResponse[Unit](400) @@ -76,11 +76,11 @@ object UserApi { * code 200 : User (successful operation) * code 400 : (Invalid username supplied) * - * @param Username The name that needs to be fetched. Use user1 for testing. + * @param username The name that needs to be fetched. Use user1 for testing. */ - def getUserByName(Username: String): ApiRequest[User] = + def getUserByName(username: String): ApiRequest[User] = ApiRequest[User](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/{username}", "application/json") - .withPathParam("username", Username) + .withPathParam("username", username) .withErrorResponse[Unit](404) .withSuccessResponse[User](200) .withErrorResponse[Unit](400) @@ -92,13 +92,13 @@ object UserApi { * code 404 : (User not found) * code 400 : (Invalid user supplied) * - * @param Username name that need to be deleted - * @param Body Updated user object + * @param username name that need to be deleted + * @param body Updated user object */ - def updateUser(Username: String, Body: Option[User] = None): ApiRequest[Unit] = + def updateUser(username: String, body: Option[User] = None): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.PUT, "http://petstore.swagger.io/v2", "/user/{username}", "application/json") - .withBody(Body) - .withPathParam("username", Username) + .withBody(body) + .withPathParam("username", username) .withErrorResponse[Unit](404) .withErrorResponse[Unit](400) @@ -109,11 +109,11 @@ object UserApi { * code 404 : (User not found) * code 400 : (Invalid username supplied) * - * @param Username The name that needs to be deleted + * @param username The name that needs to be deleted */ - def deleteUser(Username: String): ApiRequest[Unit] = + def deleteUser(username: String): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.DELETE, "http://petstore.swagger.io/v2", "/user/{username}", "application/json") - .withPathParam("username", Username) + .withPathParam("username", username) .withErrorResponse[Unit](404) .withErrorResponse[Unit](400) diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Category.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Category.scala index 5eec9d159d..af66bc1475 100644 --- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Category.scala +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Category.scala @@ -5,8 +5,8 @@ import org.joda.time.DateTime case class Category ( - Id: Option[Long], - Name: Option[String]) + id: Option[Long], + name: Option[String]) extends ApiModel diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Order.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Order.scala index 5fe2c3d0a6..83a40fb55d 100644 --- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Order.scala +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Order.scala @@ -5,13 +5,13 @@ import org.joda.time.DateTime case class Order ( - Id: Option[Long], - PetId: Option[Long], - Quantity: Option[Int], - ShipDate: Option[DateTime], + id: Option[Long], + petId: Option[Long], + quantity: Option[Int], + shipDate: Option[DateTime], /* Order Status */ - Status: Option[OrderEnums.Status], - Complete: Option[Boolean]) + status: Option[OrderEnums.Status], + complete: Option[Boolean]) extends ApiModel object OrderEnums { diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Pet.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Pet.scala index 5007c7d958..8cd3c61cb6 100644 --- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Pet.scala +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Pet.scala @@ -5,13 +5,13 @@ import org.joda.time.DateTime case class Pet ( - Id: Option[Long], - Category: Option[Category], - Name: String, - PhotoUrls: Seq[String], - Tags: Option[Seq[Tag]], + id: Option[Long], + category: Option[Category], + name: String, + photoUrls: Seq[String], + tags: Option[Seq[Tag]], /* pet status in the store */ - Status: Option[PetEnums.Status]) + status: Option[PetEnums.Status]) extends ApiModel object PetEnums { diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Tag.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Tag.scala index 8f7c3f2aa4..58aabadabe 100644 --- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Tag.scala +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Tag.scala @@ -5,8 +5,8 @@ import org.joda.time.DateTime case class Tag ( - Id: Option[Long], - Name: Option[String]) + id: Option[Long], + name: Option[String]) extends ApiModel diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/User.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/User.scala index c9772f5361..dd0bce1d8a 100644 --- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/User.scala +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/User.scala @@ -5,15 +5,15 @@ import org.joda.time.DateTime case class User ( - Id: Option[Long], - Username: Option[String], - FirstName: Option[String], - LastName: Option[String], - Email: Option[String], - Password: Option[String], - Phone: Option[String], + id: Option[Long], + username: Option[String], + firstName: Option[String], + lastName: Option[String], + email: Option[String], + password: Option[String], + phone: Option[String], /* User Status */ - UserStatus: Option[Int]) + userStatus: Option[Int]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/AccountApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/AccountApi.scala index 920159a629..8168c1c0f4 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/AccountApi.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/AccountApi.scala @@ -18,11 +18,11 @@ object AccountApi { * code 400 : (No token supplied.) * code 404 : (No API account with supplied token.) * - * @param ApiKey Wordnik authentication token + * @param apiKey Wordnik authentication token */ - def getApiTokenStatus(ApiKey: Option[String] = None): ApiRequest[ApiTokenStatus] = + def getApiTokenStatus(apiKey: Option[String] = None): ApiRequest[ApiTokenStatus] = ApiRequest[ApiTokenStatus](ApiMethods.GET, "https://api.wordnik.com/v4", "/account.json/apiTokenStatus", "application/json") - .withHeaderParam("api_key", ApiKey) + .withHeaderParam("api_key", apiKey) .withSuccessResponse[ApiTokenStatus](200) .withErrorResponse[Unit](400) .withErrorResponse[Unit](404) @@ -35,13 +35,13 @@ object AccountApi { * code 403 : (Account not available.) * code 404 : (User not found.) * - * @param Username A confirmed Wordnik username - * @param Password The user's password + * @param username A confirmed Wordnik username + * @param password The user's password */ - def authenticate(Username: String, Password: String): ApiRequest[AuthenticationToken] = + def authenticate(username: String, password: String): ApiRequest[AuthenticationToken] = ApiRequest[AuthenticationToken](ApiMethods.GET, "https://api.wordnik.com/v4", "/account.json/authenticate/{username}", "application/json") - .withQueryParam("password", Password) - .withPathParam("username", Username) + .withQueryParam("password", password) + .withPathParam("username", username) .withSuccessResponse[AuthenticationToken](200) .withErrorResponse[Unit](403) .withErrorResponse[Unit](404) @@ -54,13 +54,13 @@ object AccountApi { * code 403 : (Account not available.) * code 404 : (User not found.) * - * @param Username A confirmed Wordnik username - * @param Body The user's password + * @param username A confirmed Wordnik username + * @param body The user's password */ - def authenticatePost(Username: String, Body: String): ApiRequest[AuthenticationToken] = + def authenticatePost(username: String, body: String): ApiRequest[AuthenticationToken] = ApiRequest[AuthenticationToken](ApiMethods.POST, "https://api.wordnik.com/v4", "/account.json/authenticate/{username}", "application/json") - .withBody(Body) - .withPathParam("username", Username) + .withBody(body) + .withPathParam("username", username) .withSuccessResponse[AuthenticationToken](200) .withErrorResponse[Unit](403) .withErrorResponse[Unit](404) @@ -73,11 +73,11 @@ object AccountApi { * code 403 : (Not logged in.) * code 404 : (User not found.) * - * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) */ - def getLoggedInUser(AuthToken: String): ApiRequest[User] = + def getLoggedInUser(authToken: String): ApiRequest[User] = ApiRequest[User](ApiMethods.GET, "https://api.wordnik.com/v4", "/account.json/user", "application/json") - .withHeaderParam("auth_token", AuthToken) + .withHeaderParam("auth_token", authToken) .withSuccessResponse[User](200) .withErrorResponse[Unit](403) .withErrorResponse[Unit](404) @@ -90,15 +90,15 @@ object AccountApi { * code 403 : (Not authenticated.) * code 404 : (User account not found.) * - * @param AuthToken auth_token of logged-in user - * @param Skip Results to skip - * @param Limit Maximum number of results to return + * @param authToken auth_token of logged-in user + * @param skip Results to skip + * @param limit Maximum number of results to return */ - def getWordListsForLoggedInUser(AuthToken: String, Skip: Option[Int] = None, Limit: Option[Int] = None): ApiRequest[Seq[WordList]] = + def getWordListsForLoggedInUser(authToken: String, skip: Option[Int] = None, limit: Option[Int] = None): ApiRequest[Seq[WordList]] = ApiRequest[Seq[WordList]](ApiMethods.GET, "https://api.wordnik.com/v4", "/account.json/wordLists", "application/json") - .withQueryParam("skip", Skip) - .withQueryParam("limit", Limit) - .withHeaderParam("auth_token", AuthToken) + .withQueryParam("skip", skip) + .withQueryParam("limit", limit) + .withHeaderParam("auth_token", authToken) .withSuccessResponse[Seq[WordList]](200) .withErrorResponse[Unit](403) .withErrorResponse[Unit](404) diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala index 36d706c4f4..3c85b1a857 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala @@ -19,15 +19,15 @@ object WordApi { * code 200 : WordObject (success) * code 400 : (Invalid word supplied.) * - * @param Word String value of WordObject to return - * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. - * @param IncludeSuggestions Return suggestions (for correct spelling, case variants, etc.) + * @param word String value of WordObject to return + * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param includeSuggestions Return suggestions (for correct spelling, case variants, etc.) */ - def getWord(Word: String, UseCanonical: Option[String] = None, IncludeSuggestions: Option[String] = None): ApiRequest[WordObject] = + def getWord(word: String, useCanonical: Option[String] = None, includeSuggestions: Option[String] = None): ApiRequest[WordObject] = ApiRequest[WordObject](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}", "application/json") - .withQueryParam("useCanonical", UseCanonical) - .withQueryParam("includeSuggestions", IncludeSuggestions) - .withPathParam("word", Word) + .withQueryParam("useCanonical", useCanonical) + .withQueryParam("includeSuggestions", includeSuggestions) + .withPathParam("word", word) .withSuccessResponse[WordObject](200) .withErrorResponse[Unit](400) @@ -38,15 +38,15 @@ object WordApi { * code 200 : Seq[AudioFile] (success) * code 400 : (Invalid word supplied.) * - * @param Word Word to get audio for. - * @param UseCanonical Use the canonical form of the word - * @param Limit Maximum number of results to return + * @param word Word to get audio for. + * @param useCanonical Use the canonical form of the word + * @param limit Maximum number of results to return */ - def getAudio(Word: String, UseCanonical: Option[String] = None, Limit: Option[Int] = None): ApiRequest[Seq[AudioFile]] = + def getAudio(word: String, useCanonical: Option[String] = None, limit: Option[Int] = None): ApiRequest[Seq[AudioFile]] = ApiRequest[Seq[AudioFile]](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/audio", "application/json") - .withQueryParam("useCanonical", UseCanonical) - .withQueryParam("limit", Limit) - .withPathParam("word", Word) + .withQueryParam("useCanonical", useCanonical) + .withQueryParam("limit", limit) + .withPathParam("word", word) .withSuccessResponse[Seq[AudioFile]](200) .withErrorResponse[Unit](400) @@ -58,23 +58,23 @@ object WordApi { * code 400 : (Invalid word supplied.) * code 404 : (No definitions found.) * - * @param Word Word to return definitions for - * @param Limit Maximum number of results to return - * @param PartOfSpeech CSV list of part-of-speech types - * @param IncludeRelated Return related words with definitions - * @param SourceDictionaries Source dictionary to return definitions from. If 'all' is received, results are returned from all sources. If multiple values are received (e.g. 'century,wiktionary'), results are returned from the first specified dictionary that has definitions. If left blank, results are returned from the first dictionary that has definitions. By default, dictionaries are searched in this order: ahd, wiktionary, webster, century, wordnet - * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. - * @param IncludeTags Return a closed set of XML tags in response + * @param word Word to return definitions for + * @param limit Maximum number of results to return + * @param partOfSpeech CSV list of part-of-speech types + * @param includeRelated Return related words with definitions + * @param sourceDictionaries Source dictionary to return definitions from. If 'all' is received, results are returned from all sources. If multiple values are received (e.g. 'century,wiktionary'), results are returned from the first specified dictionary that has definitions. If left blank, results are returned from the first dictionary that has definitions. By default, dictionaries are searched in this order: ahd, wiktionary, webster, century, wordnet + * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param includeTags Return a closed set of XML tags in response */ - def getDefinitions(Word: String, Limit: Option[Int] = None, PartOfSpeech: Option[String] = None, IncludeRelated: Option[String] = None, SourceDictionaries: Seq[String], UseCanonical: Option[String] = None, IncludeTags: Option[String] = None): ApiRequest[Seq[Definition]] = + def getDefinitions(word: String, limit: Option[Int] = None, partOfSpeech: Option[String] = None, includeRelated: Option[String] = None, sourceDictionaries: Seq[String], useCanonical: Option[String] = None, includeTags: Option[String] = None): ApiRequest[Seq[Definition]] = ApiRequest[Seq[Definition]](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/definitions", "application/json") - .withQueryParam("limit", Limit) - .withQueryParam("partOfSpeech", PartOfSpeech) - .withQueryParam("includeRelated", IncludeRelated) - .withQueryParam("sourceDictionaries", ArrayValues(SourceDictionaries, CSV)) - .withQueryParam("useCanonical", UseCanonical) - .withQueryParam("includeTags", IncludeTags) - .withPathParam("word", Word) + .withQueryParam("limit", limit) + .withQueryParam("partOfSpeech", partOfSpeech) + .withQueryParam("includeRelated", includeRelated) + .withQueryParam("sourceDictionaries", ArrayValues(sourceDictionaries, CSV)) + .withQueryParam("useCanonical", useCanonical) + .withQueryParam("includeTags", includeTags) + .withPathParam("word", word) .withSuccessResponse[Seq[Definition]](200) .withErrorResponse[Unit](400) .withErrorResponse[Unit](404) @@ -87,13 +87,13 @@ object WordApi { * code 400 : (Invalid word supplied.) * code 404 : (No definitions found.) * - * @param Word Word to return - * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param word Word to return + * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. */ - def getEtymologies(Word: String, UseCanonical: Option[String] = None): ApiRequest[Seq[String]] = + def getEtymologies(word: String, useCanonical: Option[String] = None): ApiRequest[Seq[String]] = ApiRequest[Seq[String]](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/etymologies", "application/json") - .withQueryParam("useCanonical", UseCanonical) - .withPathParam("word", Word) + .withQueryParam("useCanonical", useCanonical) + .withPathParam("word", word) .withSuccessResponse[Seq[String]](200) .withErrorResponse[Unit](400) .withErrorResponse[Unit](404) @@ -105,19 +105,19 @@ object WordApi { * code 200 : (success) * code 400 : (Invalid word supplied.) * - * @param Word Word to return examples for - * @param IncludeDuplicates Show duplicate examples from different sources - * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. - * @param Skip Results to skip - * @param Limit Maximum number of results to return + * @param word Word to return examples for + * @param includeDuplicates Show duplicate examples from different sources + * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param skip Results to skip + * @param limit Maximum number of results to return */ - def getExamples(Word: String, IncludeDuplicates: Option[String] = None, UseCanonical: Option[String] = None, Skip: Option[Int] = None, Limit: Option[Int] = None): ApiRequest[Unit] = + def getExamples(word: String, includeDuplicates: Option[String] = None, useCanonical: Option[String] = None, skip: Option[Int] = None, limit: Option[Int] = None): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/examples", "application/json") - .withQueryParam("includeDuplicates", IncludeDuplicates) - .withQueryParam("useCanonical", UseCanonical) - .withQueryParam("skip", Skip) - .withQueryParam("limit", Limit) - .withPathParam("word", Word) + .withQueryParam("includeDuplicates", includeDuplicates) + .withQueryParam("useCanonical", useCanonical) + .withQueryParam("skip", skip) + .withQueryParam("limit", limit) + .withPathParam("word", word) .withSuccessResponse[Unit](200) .withErrorResponse[Unit](400) @@ -129,17 +129,17 @@ object WordApi { * code 400 : (Invalid word supplied.) * code 404 : (No results.) * - * @param Word Word to return - * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. - * @param StartYear Starting Year - * @param EndYear Ending Year + * @param word Word to return + * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param startYear Starting Year + * @param endYear Ending Year */ - def getWordFrequency(Word: String, UseCanonical: Option[String] = None, StartYear: Option[Int] = None, EndYear: Option[Int] = None): ApiRequest[FrequencySummary] = + def getWordFrequency(word: String, useCanonical: Option[String] = None, startYear: Option[Int] = None, endYear: Option[Int] = None): ApiRequest[FrequencySummary] = ApiRequest[FrequencySummary](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/frequency", "application/json") - .withQueryParam("useCanonical", UseCanonical) - .withQueryParam("startYear", StartYear) - .withQueryParam("endYear", EndYear) - .withPathParam("word", Word) + .withQueryParam("useCanonical", useCanonical) + .withQueryParam("startYear", startYear) + .withQueryParam("endYear", endYear) + .withPathParam("word", word) .withSuccessResponse[FrequencySummary](200) .withErrorResponse[Unit](400) .withErrorResponse[Unit](404) @@ -151,17 +151,17 @@ object WordApi { * code 200 : (success) * code 400 : (Invalid word supplied.) * - * @param Word Word to get syllables for - * @param UseCanonical If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested. - * @param SourceDictionary Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet. - * @param Limit Maximum number of results to return + * @param word Word to get syllables for + * @param useCanonical If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param sourceDictionary Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet. + * @param limit Maximum number of results to return */ - def getHyphenation(Word: String, UseCanonical: Option[String] = None, SourceDictionary: Option[String] = None, Limit: Option[Int] = None): ApiRequest[Unit] = + def getHyphenation(word: String, useCanonical: Option[String] = None, sourceDictionary: Option[String] = None, limit: Option[Int] = None): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/hyphenation", "application/json") - .withQueryParam("useCanonical", UseCanonical) - .withQueryParam("sourceDictionary", SourceDictionary) - .withQueryParam("limit", Limit) - .withPathParam("word", Word) + .withQueryParam("useCanonical", useCanonical) + .withQueryParam("sourceDictionary", sourceDictionary) + .withQueryParam("limit", limit) + .withPathParam("word", word) .withSuccessResponse[Unit](200) .withErrorResponse[Unit](400) @@ -172,17 +172,17 @@ object WordApi { * code 200 : Seq[Bigram] (success) * code 400 : (Invalid word supplied.) * - * @param Word Word to fetch phrases for - * @param Limit Maximum number of results to return - * @param Wlmi Minimum WLMI for the phrase - * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param word Word to fetch phrases for + * @param limit Maximum number of results to return + * @param wlmi Minimum WLMI for the phrase + * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. */ - def getPhrases(Word: String, Limit: Option[Int] = None, Wlmi: Option[Int] = None, UseCanonical: Option[String] = None): ApiRequest[Seq[Bigram]] = + def getPhrases(word: String, limit: Option[Int] = None, wlmi: Option[Int] = None, useCanonical: Option[String] = None): ApiRequest[Seq[Bigram]] = ApiRequest[Seq[Bigram]](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/phrases", "application/json") - .withQueryParam("limit", Limit) - .withQueryParam("wlmi", Wlmi) - .withQueryParam("useCanonical", UseCanonical) - .withPathParam("word", Word) + .withQueryParam("limit", limit) + .withQueryParam("wlmi", wlmi) + .withQueryParam("useCanonical", useCanonical) + .withPathParam("word", word) .withSuccessResponse[Seq[Bigram]](200) .withErrorResponse[Unit](400) @@ -193,19 +193,19 @@ object WordApi { * code 200 : (success) * code 400 : (Invalid word supplied.) * - * @param Word Word to get pronunciations for - * @param UseCanonical If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested. - * @param SourceDictionary Get from a single dictionary - * @param TypeFormat Text pronunciation type - * @param Limit Maximum number of results to return + * @param word Word to get pronunciations for + * @param useCanonical If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param sourceDictionary Get from a single dictionary + * @param typeFormat Text pronunciation type + * @param limit Maximum number of results to return */ - def getTextPronunciations(Word: String, UseCanonical: Option[String] = None, SourceDictionary: Option[String] = None, TypeFormat: Option[String] = None, Limit: Option[Int] = None): ApiRequest[Unit] = + def getTextPronunciations(word: String, useCanonical: Option[String] = None, sourceDictionary: Option[String] = None, typeFormat: Option[String] = None, limit: Option[Int] = None): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/pronunciations", "application/json") - .withQueryParam("useCanonical", UseCanonical) - .withQueryParam("sourceDictionary", SourceDictionary) - .withQueryParam("typeFormat", TypeFormat) - .withQueryParam("limit", Limit) - .withPathParam("word", Word) + .withQueryParam("useCanonical", useCanonical) + .withQueryParam("sourceDictionary", sourceDictionary) + .withQueryParam("typeFormat", typeFormat) + .withQueryParam("limit", limit) + .withPathParam("word", word) .withSuccessResponse[Unit](200) .withErrorResponse[Unit](400) @@ -216,17 +216,17 @@ object WordApi { * code 200 : (success) * code 400 : (Invalid word supplied.) * - * @param Word Word to fetch relationships for - * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. - * @param RelationshipTypes Limits the total results per type of relationship type - * @param LimitPerRelationshipType Restrict to the supplied relationship types + * @param word Word to fetch relationships for + * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param relationshipTypes Limits the total results per type of relationship type + * @param limitPerRelationshipType Restrict to the supplied relationship types */ - def getRelatedWords(Word: String, UseCanonical: Option[String] = None, RelationshipTypes: Option[String] = None, LimitPerRelationshipType: Option[Int] = None): ApiRequest[Unit] = + def getRelatedWords(word: String, useCanonical: Option[String] = None, relationshipTypes: Option[String] = None, limitPerRelationshipType: Option[Int] = None): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/relatedWords", "application/json") - .withQueryParam("useCanonical", UseCanonical) - .withQueryParam("relationshipTypes", RelationshipTypes) - .withQueryParam("limitPerRelationshipType", LimitPerRelationshipType) - .withPathParam("word", Word) + .withQueryParam("useCanonical", useCanonical) + .withQueryParam("relationshipTypes", relationshipTypes) + .withQueryParam("limitPerRelationshipType", limitPerRelationshipType) + .withPathParam("word", word) .withSuccessResponse[Unit](200) .withErrorResponse[Unit](400) @@ -237,13 +237,13 @@ object WordApi { * code 200 : Example (success) * code 400 : (Invalid word supplied.) * - * @param Word Word to fetch examples for - * @param UseCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. + * @param word Word to fetch examples for + * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. */ - def getTopExample(Word: String, UseCanonical: Option[String] = None): ApiRequest[Example] = + def getTopExample(word: String, useCanonical: Option[String] = None): ApiRequest[Example] = ApiRequest[Example](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/topExample", "application/json") - .withQueryParam("useCanonical", UseCanonical) - .withPathParam("word", Word) + .withQueryParam("useCanonical", useCanonical) + .withPathParam("word", word) .withSuccessResponse[Example](200) .withErrorResponse[Unit](400) diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala index 54883fa07b..6ff76587e1 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala @@ -17,13 +17,13 @@ object WordListApi { * code 403 : (Not Authorized to access WordList) * code 404 : (WordList not found) * - * @param Permalink permalink of WordList to fetch - * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + * @param permalink permalink of WordList to fetch + * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) */ - def getWordListByPermalink(Permalink: String, AuthToken: String): ApiRequest[WordList] = + def getWordListByPermalink(permalink: String, authToken: String): ApiRequest[WordList] = ApiRequest[WordList](ApiMethods.GET, "https://api.wordnik.com/v4", "/wordList.json/{permalink}", "application/json") - .withPathParam("permalink", Permalink) - .withHeaderParam("auth_token", AuthToken) + .withPathParam("permalink", permalink) + .withHeaderParam("auth_token", authToken) .withSuccessResponse[WordList](200) .withErrorResponse[Unit](400) .withErrorResponse[Unit](403) @@ -38,15 +38,15 @@ object WordListApi { * code 403 : (Not Authorized to update WordList) * code 404 : (WordList not found) * - * @param Permalink permalink of WordList to update - * @param Body Updated WordList - * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + * @param permalink permalink of WordList to update + * @param body Updated WordList + * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) */ - def updateWordList(Permalink: String, Body: Option[WordList] = None, AuthToken: String): ApiRequest[Unit] = + def updateWordList(permalink: String, body: Option[WordList] = None, authToken: String): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.PUT, "https://api.wordnik.com/v4", "/wordList.json/{permalink}", "application/json") - .withBody(Body) - .withPathParam("permalink", Permalink) - .withHeaderParam("auth_token", AuthToken) + .withBody(body) + .withPathParam("permalink", permalink) + .withHeaderParam("auth_token", authToken) .withSuccessResponse[Unit](200) .withErrorResponse[Unit](400) .withErrorResponse[Unit](403) @@ -61,13 +61,13 @@ object WordListApi { * code 403 : (Not Authorized to delete WordList) * code 404 : (WordList not found) * - * @param Permalink ID of WordList to delete - * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + * @param permalink ID of WordList to delete + * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) */ - def deleteWordList(Permalink: String, AuthToken: String): ApiRequest[Unit] = + def deleteWordList(permalink: String, authToken: String): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.DELETE, "https://api.wordnik.com/v4", "/wordList.json/{permalink}", "application/json") - .withPathParam("permalink", Permalink) - .withHeaderParam("auth_token", AuthToken) + .withPathParam("permalink", permalink) + .withHeaderParam("auth_token", authToken) .withSuccessResponse[Unit](200) .withErrorResponse[Unit](400) .withErrorResponse[Unit](403) @@ -82,15 +82,15 @@ object WordListApi { * code 403 : (Not Authorized to modify WordList) * code 404 : (WordList not found) * - * @param Permalink permalink of WordList to use - * @param Body Words to remove from WordList - * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + * @param permalink permalink of WordList to use + * @param body Words to remove from WordList + * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) */ - def deleteWordsFromWordList(Permalink: String, Body: Seq[StringValue], AuthToken: String): ApiRequest[Unit] = + def deleteWordsFromWordList(permalink: String, body: Seq[StringValue], authToken: String): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.POST, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/deleteWords", "application/json") - .withBody(Body) - .withPathParam("permalink", Permalink) - .withHeaderParam("auth_token", AuthToken) + .withBody(body) + .withPathParam("permalink", permalink) + .withHeaderParam("auth_token", authToken) .withSuccessResponse[Unit](200) .withErrorResponse[Unit](400) .withErrorResponse[Unit](403) @@ -105,21 +105,21 @@ object WordListApi { * code 403 : (Not Authorized to access WordList) * code 404 : (WordList not found) * - * @param Permalink ID of WordList to use - * @param SortBy Field to sort by - * @param SortOrder Direction to sort - * @param Skip Results to skip - * @param Limit Maximum number of results to return - * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + * @param permalink ID of WordList to use + * @param sortBy Field to sort by + * @param sortOrder Direction to sort + * @param skip Results to skip + * @param limit Maximum number of results to return + * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) */ - def getWordListWords(Permalink: String, SortBy: Option[String] = None, SortOrder: Option[String] = None, Skip: Option[Int] = None, Limit: Option[Int] = None, AuthToken: String): ApiRequest[Unit] = + def getWordListWords(permalink: String, sortBy: Option[String] = None, sortOrder: Option[String] = None, skip: Option[Int] = None, limit: Option[Int] = None, authToken: String): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/words", "application/json") - .withQueryParam("sortBy", SortBy) - .withQueryParam("sortOrder", SortOrder) - .withQueryParam("skip", Skip) - .withQueryParam("limit", Limit) - .withPathParam("permalink", Permalink) - .withHeaderParam("auth_token", AuthToken) + .withQueryParam("sortBy", sortBy) + .withQueryParam("sortOrder", sortOrder) + .withQueryParam("skip", skip) + .withQueryParam("limit", limit) + .withPathParam("permalink", permalink) + .withHeaderParam("auth_token", authToken) .withSuccessResponse[Unit](200) .withErrorResponse[Unit](400) .withErrorResponse[Unit](403) @@ -134,15 +134,15 @@ object WordListApi { * code 403 : (Not Authorized to access WordList) * code 404 : (WordList not found) * - * @param Permalink permalink of WordList to user - * @param Body Array of words to add to WordList - * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + * @param permalink permalink of WordList to user + * @param body Array of words to add to WordList + * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) */ - def addWordsToWordList(Permalink: String, Body: Seq[StringValue], AuthToken: String): ApiRequest[Unit] = + def addWordsToWordList(permalink: String, body: Seq[StringValue], authToken: String): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.POST, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/words", "application/json") - .withBody(Body) - .withPathParam("permalink", Permalink) - .withHeaderParam("auth_token", AuthToken) + .withBody(body) + .withPathParam("permalink", permalink) + .withHeaderParam("auth_token", authToken) .withSuccessResponse[Unit](200) .withErrorResponse[Unit](400) .withErrorResponse[Unit](403) diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListsApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListsApi.scala index a2540c383a..cad9a37ba8 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListsApi.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListsApi.scala @@ -16,13 +16,13 @@ object WordListsApi { * code 403 : (Not authenticated) * code 404 : (WordList owner not found) * - * @param Body WordList to create - * @param AuthToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) + * @param body WordList to create + * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above) */ - def createWordList(Body: Option[WordList] = None, AuthToken: String): ApiRequest[WordList] = + def createWordList(body: Option[WordList] = None, authToken: String): ApiRequest[WordList] = ApiRequest[WordList](ApiMethods.POST, "https://api.wordnik.com/v4", "/wordLists.json", "application/json") - .withBody(Body) - .withHeaderParam("auth_token", AuthToken) + .withBody(body) + .withHeaderParam("auth_token", authToken) .withSuccessResponse[WordList](200) .withErrorResponse[Unit](400) .withErrorResponse[Unit](403) diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala index 1a58a2f413..b3b3367925 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala @@ -17,27 +17,27 @@ object WordsApi { * code 200 : WordObject (success) * code 404 : (No word found.) * - * @param HasDictionaryDef Only return words with dictionary definitions - * @param IncludePartOfSpeech CSV part-of-speech values to include - * @param ExcludePartOfSpeech CSV part-of-speech values to exclude - * @param MinCorpusCount Minimum corpus frequency for terms - * @param MaxCorpusCount Maximum corpus frequency for terms - * @param MinDictionaryCount Minimum dictionary count - * @param MaxDictionaryCount Maximum dictionary count - * @param MinLength Minimum word length - * @param MaxLength Maximum word length + * @param hasDictionaryDef Only return words with dictionary definitions + * @param includePartOfSpeech CSV part-of-speech values to include + * @param excludePartOfSpeech CSV part-of-speech values to exclude + * @param minCorpusCount Minimum corpus frequency for terms + * @param maxCorpusCount Maximum corpus frequency for terms + * @param minDictionaryCount Minimum dictionary count + * @param maxDictionaryCount Maximum dictionary count + * @param minLength Minimum word length + * @param maxLength Maximum word length */ - def getRandomWord(HasDictionaryDef: Option[String] = None, IncludePartOfSpeech: Option[String] = None, ExcludePartOfSpeech: Option[String] = None, MinCorpusCount: Option[Int] = None, MaxCorpusCount: Option[Int] = None, MinDictionaryCount: Option[Int] = None, MaxDictionaryCount: Option[Int] = None, MinLength: Option[Int] = None, MaxLength: Option[Int] = None): ApiRequest[WordObject] = + def getRandomWord(hasDictionaryDef: Option[String] = None, includePartOfSpeech: Option[String] = None, excludePartOfSpeech: Option[String] = None, minCorpusCount: Option[Int] = None, maxCorpusCount: Option[Int] = None, minDictionaryCount: Option[Int] = None, maxDictionaryCount: Option[Int] = None, minLength: Option[Int] = None, maxLength: Option[Int] = None): ApiRequest[WordObject] = ApiRequest[WordObject](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/randomWord", "application/json") - .withQueryParam("hasDictionaryDef", HasDictionaryDef) - .withQueryParam("includePartOfSpeech", IncludePartOfSpeech) - .withQueryParam("excludePartOfSpeech", ExcludePartOfSpeech) - .withQueryParam("minCorpusCount", MinCorpusCount) - .withQueryParam("maxCorpusCount", MaxCorpusCount) - .withQueryParam("minDictionaryCount", MinDictionaryCount) - .withQueryParam("maxDictionaryCount", MaxDictionaryCount) - .withQueryParam("minLength", MinLength) - .withQueryParam("maxLength", MaxLength) + .withQueryParam("hasDictionaryDef", hasDictionaryDef) + .withQueryParam("includePartOfSpeech", includePartOfSpeech) + .withQueryParam("excludePartOfSpeech", excludePartOfSpeech) + .withQueryParam("minCorpusCount", minCorpusCount) + .withQueryParam("maxCorpusCount", maxCorpusCount) + .withQueryParam("minDictionaryCount", minDictionaryCount) + .withQueryParam("maxDictionaryCount", maxDictionaryCount) + .withQueryParam("minLength", minLength) + .withQueryParam("maxLength", maxLength) .withSuccessResponse[WordObject](200) .withErrorResponse[Unit](404) @@ -49,33 +49,33 @@ object WordsApi { * code 400 : (Invalid term supplied.) * code 404 : (No results.) * - * @param HasDictionaryDef Only return words with dictionary definitions - * @param IncludePartOfSpeech CSV part-of-speech values to include - * @param ExcludePartOfSpeech CSV part-of-speech values to exclude - * @param MinCorpusCount Minimum corpus frequency for terms - * @param MaxCorpusCount Maximum corpus frequency for terms - * @param MinDictionaryCount Minimum dictionary count - * @param MaxDictionaryCount Maximum dictionary count - * @param MinLength Minimum word length - * @param MaxLength Maximum word length - * @param SortBy Attribute to sort by - * @param SortOrder Sort direction - * @param Limit Maximum number of results to return + * @param hasDictionaryDef Only return words with dictionary definitions + * @param includePartOfSpeech CSV part-of-speech values to include + * @param excludePartOfSpeech CSV part-of-speech values to exclude + * @param minCorpusCount Minimum corpus frequency for terms + * @param maxCorpusCount Maximum corpus frequency for terms + * @param minDictionaryCount Minimum dictionary count + * @param maxDictionaryCount Maximum dictionary count + * @param minLength Minimum word length + * @param maxLength Maximum word length + * @param sortBy Attribute to sort by + * @param sortOrder Sort direction + * @param limit Maximum number of results to return */ - def getRandomWords(HasDictionaryDef: Option[String] = None, IncludePartOfSpeech: Option[String] = None, ExcludePartOfSpeech: Option[String] = None, MinCorpusCount: Option[Int] = None, MaxCorpusCount: Option[Int] = None, MinDictionaryCount: Option[Int] = None, MaxDictionaryCount: Option[Int] = None, MinLength: Option[Int] = None, MaxLength: Option[Int] = None, SortBy: Option[String] = None, SortOrder: Option[String] = None, Limit: Option[Int] = None): ApiRequest[Unit] = + def getRandomWords(hasDictionaryDef: Option[String] = None, includePartOfSpeech: Option[String] = None, excludePartOfSpeech: Option[String] = None, minCorpusCount: Option[Int] = None, maxCorpusCount: Option[Int] = None, minDictionaryCount: Option[Int] = None, maxDictionaryCount: Option[Int] = None, minLength: Option[Int] = None, maxLength: Option[Int] = None, sortBy: Option[String] = None, sortOrder: Option[String] = None, limit: Option[Int] = None): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/randomWords", "application/json") - .withQueryParam("hasDictionaryDef", HasDictionaryDef) - .withQueryParam("includePartOfSpeech", IncludePartOfSpeech) - .withQueryParam("excludePartOfSpeech", ExcludePartOfSpeech) - .withQueryParam("minCorpusCount", MinCorpusCount) - .withQueryParam("maxCorpusCount", MaxCorpusCount) - .withQueryParam("minDictionaryCount", MinDictionaryCount) - .withQueryParam("maxDictionaryCount", MaxDictionaryCount) - .withQueryParam("minLength", MinLength) - .withQueryParam("maxLength", MaxLength) - .withQueryParam("sortBy", SortBy) - .withQueryParam("sortOrder", SortOrder) - .withQueryParam("limit", Limit) + .withQueryParam("hasDictionaryDef", hasDictionaryDef) + .withQueryParam("includePartOfSpeech", includePartOfSpeech) + .withQueryParam("excludePartOfSpeech", excludePartOfSpeech) + .withQueryParam("minCorpusCount", minCorpusCount) + .withQueryParam("maxCorpusCount", maxCorpusCount) + .withQueryParam("minDictionaryCount", minDictionaryCount) + .withQueryParam("maxDictionaryCount", maxDictionaryCount) + .withQueryParam("minLength", minLength) + .withQueryParam("maxLength", maxLength) + .withQueryParam("sortBy", sortBy) + .withQueryParam("sortOrder", sortOrder) + .withQueryParam("limit", limit) .withSuccessResponse[Unit](200) .withErrorResponse[Unit](400) .withErrorResponse[Unit](404) @@ -87,41 +87,41 @@ object WordsApi { * code 200 : DefinitionSearchResults (success) * code 400 : (Invalid term supplied.) * - * @param Query Search term - * @param FindSenseForWord Restricts words and finds closest sense - * @param IncludeSourceDictionaries Only include these comma-delimited source dictionaries - * @param ExcludeSourceDictionaries Exclude these comma-delimited source dictionaries - * @param IncludePartOfSpeech Only include these comma-delimited parts of speech - * @param ExcludePartOfSpeech Exclude these comma-delimited parts of speech - * @param MinCorpusCount Minimum corpus frequency for terms - * @param MaxCorpusCount Maximum corpus frequency for terms - * @param MinLength Minimum word length - * @param MaxLength Maximum word length - * @param ExpandTerms Expand terms - * @param IncludeTags Return a closed set of XML tags in response - * @param SortBy Attribute to sort by - * @param SortOrder Sort direction - * @param Skip Results to skip - * @param Limit Maximum number of results to return + * @param query Search term + * @param findSenseForWord Restricts words and finds closest sense + * @param includeSourceDictionaries Only include these comma-delimited source dictionaries + * @param excludeSourceDictionaries Exclude these comma-delimited source dictionaries + * @param includePartOfSpeech Only include these comma-delimited parts of speech + * @param excludePartOfSpeech Exclude these comma-delimited parts of speech + * @param minCorpusCount Minimum corpus frequency for terms + * @param maxCorpusCount Maximum corpus frequency for terms + * @param minLength Minimum word length + * @param maxLength Maximum word length + * @param expandTerms Expand terms + * @param includeTags Return a closed set of XML tags in response + * @param sortBy Attribute to sort by + * @param sortOrder Sort direction + * @param skip Results to skip + * @param limit Maximum number of results to return */ - def reverseDictionary(Query: String, FindSenseForWord: Option[String] = None, IncludeSourceDictionaries: Option[String] = None, ExcludeSourceDictionaries: Option[String] = None, IncludePartOfSpeech: Option[String] = None, ExcludePartOfSpeech: Option[String] = None, MinCorpusCount: Option[Int] = None, MaxCorpusCount: Option[Int] = None, MinLength: Option[Int] = None, MaxLength: Option[Int] = None, ExpandTerms: Option[String] = None, IncludeTags: Option[String] = None, SortBy: Option[String] = None, SortOrder: Option[String] = None, Skip: Option[String] = None, Limit: Option[Int] = None): ApiRequest[DefinitionSearchResults] = + def reverseDictionary(query: String, findSenseForWord: Option[String] = None, includeSourceDictionaries: Option[String] = None, excludeSourceDictionaries: Option[String] = None, includePartOfSpeech: Option[String] = None, excludePartOfSpeech: Option[String] = None, minCorpusCount: Option[Int] = None, maxCorpusCount: Option[Int] = None, minLength: Option[Int] = None, maxLength: Option[Int] = None, expandTerms: Option[String] = None, includeTags: Option[String] = None, sortBy: Option[String] = None, sortOrder: Option[String] = None, skip: Option[String] = None, limit: Option[Int] = None): ApiRequest[DefinitionSearchResults] = ApiRequest[DefinitionSearchResults](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/reverseDictionary", "application/json") - .withQueryParam("query", Query) - .withQueryParam("findSenseForWord", FindSenseForWord) - .withQueryParam("includeSourceDictionaries", IncludeSourceDictionaries) - .withQueryParam("excludeSourceDictionaries", ExcludeSourceDictionaries) - .withQueryParam("includePartOfSpeech", IncludePartOfSpeech) - .withQueryParam("excludePartOfSpeech", ExcludePartOfSpeech) - .withQueryParam("minCorpusCount", MinCorpusCount) - .withQueryParam("maxCorpusCount", MaxCorpusCount) - .withQueryParam("minLength", MinLength) - .withQueryParam("maxLength", MaxLength) - .withQueryParam("expandTerms", ExpandTerms) - .withQueryParam("includeTags", IncludeTags) - .withQueryParam("sortBy", SortBy) - .withQueryParam("sortOrder", SortOrder) - .withQueryParam("skip", Skip) - .withQueryParam("limit", Limit) + .withQueryParam("query", query) + .withQueryParam("findSenseForWord", findSenseForWord) + .withQueryParam("includeSourceDictionaries", includeSourceDictionaries) + .withQueryParam("excludeSourceDictionaries", excludeSourceDictionaries) + .withQueryParam("includePartOfSpeech", includePartOfSpeech) + .withQueryParam("excludePartOfSpeech", excludePartOfSpeech) + .withQueryParam("minCorpusCount", minCorpusCount) + .withQueryParam("maxCorpusCount", maxCorpusCount) + .withQueryParam("minLength", minLength) + .withQueryParam("maxLength", maxLength) + .withQueryParam("expandTerms", expandTerms) + .withQueryParam("includeTags", includeTags) + .withQueryParam("sortBy", sortBy) + .withQueryParam("sortOrder", sortOrder) + .withQueryParam("skip", skip) + .withQueryParam("limit", limit) .withSuccessResponse[DefinitionSearchResults](200) .withErrorResponse[Unit](400) @@ -132,33 +132,33 @@ object WordsApi { * code 200 : WordSearchResults (success) * code 400 : (Invalid query supplied.) * - * @param Query Search query - * @param CaseSensitive Search case sensitive - * @param IncludePartOfSpeech Only include these comma-delimited parts of speech - * @param ExcludePartOfSpeech Exclude these comma-delimited parts of speech - * @param MinCorpusCount Minimum corpus frequency for terms - * @param MaxCorpusCount Maximum corpus frequency for terms - * @param MinDictionaryCount Minimum number of dictionary entries for words returned - * @param MaxDictionaryCount Maximum dictionary definition count - * @param MinLength Minimum word length - * @param MaxLength Maximum word length - * @param Skip Results to skip - * @param Limit Maximum number of results to return + * @param query Search query + * @param caseSensitive Search case sensitive + * @param includePartOfSpeech Only include these comma-delimited parts of speech + * @param excludePartOfSpeech Exclude these comma-delimited parts of speech + * @param minCorpusCount Minimum corpus frequency for terms + * @param maxCorpusCount Maximum corpus frequency for terms + * @param minDictionaryCount Minimum number of dictionary entries for words returned + * @param maxDictionaryCount Maximum dictionary definition count + * @param minLength Minimum word length + * @param maxLength Maximum word length + * @param skip Results to skip + * @param limit Maximum number of results to return */ - def searchWords(Query: String, CaseSensitive: Option[String] = None, IncludePartOfSpeech: Option[String] = None, ExcludePartOfSpeech: Option[String] = None, MinCorpusCount: Option[Int] = None, MaxCorpusCount: Option[Int] = None, MinDictionaryCount: Option[Int] = None, MaxDictionaryCount: Option[Int] = None, MinLength: Option[Int] = None, MaxLength: Option[Int] = None, Skip: Option[Int] = None, Limit: Option[Int] = None): ApiRequest[WordSearchResults] = + def searchWords(query: String, caseSensitive: Option[String] = None, includePartOfSpeech: Option[String] = None, excludePartOfSpeech: Option[String] = None, minCorpusCount: Option[Int] = None, maxCorpusCount: Option[Int] = None, minDictionaryCount: Option[Int] = None, maxDictionaryCount: Option[Int] = None, minLength: Option[Int] = None, maxLength: Option[Int] = None, skip: Option[Int] = None, limit: Option[Int] = None): ApiRequest[WordSearchResults] = ApiRequest[WordSearchResults](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/search/{query}", "application/json") - .withQueryParam("caseSensitive", CaseSensitive) - .withQueryParam("includePartOfSpeech", IncludePartOfSpeech) - .withQueryParam("excludePartOfSpeech", ExcludePartOfSpeech) - .withQueryParam("minCorpusCount", MinCorpusCount) - .withQueryParam("maxCorpusCount", MaxCorpusCount) - .withQueryParam("minDictionaryCount", MinDictionaryCount) - .withQueryParam("maxDictionaryCount", MaxDictionaryCount) - .withQueryParam("minLength", MinLength) - .withQueryParam("maxLength", MaxLength) - .withQueryParam("skip", Skip) - .withQueryParam("limit", Limit) - .withPathParam("query", Query) + .withQueryParam("caseSensitive", caseSensitive) + .withQueryParam("includePartOfSpeech", includePartOfSpeech) + .withQueryParam("excludePartOfSpeech", excludePartOfSpeech) + .withQueryParam("minCorpusCount", minCorpusCount) + .withQueryParam("maxCorpusCount", maxCorpusCount) + .withQueryParam("minDictionaryCount", minDictionaryCount) + .withQueryParam("maxDictionaryCount", maxDictionaryCount) + .withQueryParam("minLength", minLength) + .withQueryParam("maxLength", maxLength) + .withQueryParam("skip", skip) + .withQueryParam("limit", limit) + .withPathParam("query", query) .withSuccessResponse[WordSearchResults](200) .withErrorResponse[Unit](400) @@ -168,11 +168,11 @@ object WordsApi { * Expected answers: * code 0 : WordOfTheDay (success) * - * @param Date Fetches by date in yyyy-MM-dd + * @param date Fetches by date in yyyy-MM-dd */ - def getWordOfTheDay(Date: Option[String] = None): ApiRequest[WordOfTheDay] = + def getWordOfTheDay(date: Option[String] = None): ApiRequest[WordOfTheDay] = ApiRequest[WordOfTheDay](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/wordOfTheDay", "application/json") - .withQueryParam("date", Date) + .withQueryParam("date", date) .withDefaultSuccessResponse[WordOfTheDay] diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ApiTokenStatus.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ApiTokenStatus.scala index 41a0615c0e..0887fb0ba7 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ApiTokenStatus.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ApiTokenStatus.scala @@ -5,12 +5,12 @@ import org.joda.time.DateTime case class ApiTokenStatus ( - Valid: Option[Boolean], - Token: Option[String], - ResetsInMillis: Option[Long], - RemainingCalls: Option[Long], - ExpiresInMillis: Option[Long], - TotalRequests: Option[Long]) + valid: Option[Boolean], + token: Option[String], + resetsInMillis: Option[Long], + remainingCalls: Option[Long], + expiresInMillis: Option[Long], + totalRequests: Option[Long]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioFile.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioFile.scala index 6f3b759a2c..3b3e9186b6 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioFile.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioFile.scala @@ -5,20 +5,20 @@ import org.joda.time.DateTime case class AudioFile ( - AttributionUrl: Option[String], - CommentCount: Option[Int], - VoteCount: Option[Int], - FileUrl: Option[String], - AudioType: Option[String], - Id: Option[Long], - Duration: Option[Double], - AttributionText: Option[String], - CreatedBy: Option[String], - Description: Option[String], - CreatedAt: Option[DateTime], - VoteWeightedAverage: Option[Float], - VoteAverage: Option[Float], - Word: Option[String]) + attributionUrl: Option[String], + commentCount: Option[Int], + voteCount: Option[Int], + fileUrl: Option[String], + audioType: Option[String], + id: Option[Long], + duration: Option[Double], + attributionText: Option[String], + createdBy: Option[String], + description: Option[String], + createdAt: Option[DateTime], + voteWeightedAverage: Option[Float], + voteAverage: Option[Float], + word: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioType.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioType.scala index deda697e9e..be7d0a1d5e 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioType.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioType.scala @@ -5,8 +5,8 @@ import org.joda.time.DateTime case class AudioType ( - Id: Option[Int], - Name: Option[String]) + id: Option[Int], + name: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AuthenticationToken.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AuthenticationToken.scala index 169571959e..981c7340d8 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AuthenticationToken.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AuthenticationToken.scala @@ -5,9 +5,9 @@ import org.joda.time.DateTime case class AuthenticationToken ( - Token: Option[String], - UserId: Option[Long], - UserSignature: Option[String]) + token: Option[String], + userId: Option[Long], + userSignature: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Bigram.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Bigram.scala index 0559c35f7f..c0a567c4ff 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Bigram.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Bigram.scala @@ -5,11 +5,11 @@ import org.joda.time.DateTime case class Bigram ( - Count: Option[Long], - Gram2: Option[String], - Gram1: Option[String], - Wlmi: Option[Double], - Mi: Option[Double]) + count: Option[Long], + gram2: Option[String], + gram1: Option[String], + wlmi: Option[Double], + mi: Option[Double]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Category.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Category.scala index 5eec9d159d..af66bc1475 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Category.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Category.scala @@ -5,8 +5,8 @@ import org.joda.time.DateTime case class Category ( - Id: Option[Long], - Name: Option[String]) + id: Option[Long], + name: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Citation.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Citation.scala index af02512406..16f7596150 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Citation.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Citation.scala @@ -5,8 +5,8 @@ import org.joda.time.DateTime case class Citation ( - Cite: Option[String], - Source: Option[String]) + cite: Option[String], + source: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ContentProvider.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ContentProvider.scala index be35406b63..c7832871f7 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ContentProvider.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ContentProvider.scala @@ -5,8 +5,8 @@ import org.joda.time.DateTime case class ContentProvider ( - Id: Option[Int], - Name: Option[String]) + id: Option[Int], + name: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Definition.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Definition.scala index 00b5893216..6274df1aa6 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Definition.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Definition.scala @@ -5,22 +5,22 @@ import org.joda.time.DateTime case class Definition ( - ExtendedText: Option[String], - Text: Option[String], - SourceDictionary: Option[String], - Citations: Option[Seq[Citation]], - Labels: Option[Seq[Label]], - Score: Option[Float], - ExampleUses: Option[Seq[ExampleUsage]], - AttributionUrl: Option[String], - SeqString: Option[String], - AttributionText: Option[String], - RelatedWords: Option[Seq[Related]], - Sequence: Option[String], - Word: Option[String], - Notes: Option[Seq[Note]], - TextProns: Option[Seq[TextPron]], - PartOfSpeech: Option[String]) + extendedText: Option[String], + text: Option[String], + sourceDictionary: Option[String], + citations: Option[Seq[Citation]], + labels: Option[Seq[Label]], + score: Option[Float], + exampleUses: Option[Seq[ExampleUsage]], + attributionUrl: Option[String], + seqString: Option[String], + attributionText: Option[String], + relatedWords: Option[Seq[Related]], + sequence: Option[String], + word: Option[String], + notes: Option[Seq[Note]], + textProns: Option[Seq[TextPron]], + partOfSpeech: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/DefinitionSearchResults.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/DefinitionSearchResults.scala index a757637d42..28d7d4e239 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/DefinitionSearchResults.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/DefinitionSearchResults.scala @@ -5,8 +5,8 @@ import org.joda.time.DateTime case class DefinitionSearchResults ( - Results: Option[Seq[Definition]], - TotalResults: Option[Int]) + results: Option[Seq[Definition]], + totalResults: Option[Int]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Example.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Example.scala index 9604f2aa62..0d4d52aec9 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Example.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Example.scala @@ -5,18 +5,18 @@ import org.joda.time.DateTime case class Example ( - Id: Option[Long], - ExampleId: Option[Long], - Title: Option[String], - Text: Option[String], - Score: Option[ScoredWord], - Sentence: Option[Sentence], - Word: Option[String], - Provider: Option[ContentProvider], - Year: Option[Int], - Rating: Option[Float], - DocumentId: Option[Long], - Url: Option[String]) + id: Option[Long], + exampleId: Option[Long], + title: Option[String], + text: Option[String], + score: Option[ScoredWord], + sentence: Option[Sentence], + word: Option[String], + provider: Option[ContentProvider], + year: Option[Int], + rating: Option[Float], + documentId: Option[Long], + url: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleSearchResults.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleSearchResults.scala index 8ef6be3f17..bd4494666d 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleSearchResults.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleSearchResults.scala @@ -5,8 +5,8 @@ import org.joda.time.DateTime case class ExampleSearchResults ( - Facets: Option[Seq[Facet]], - Examples: Option[Seq[Example]]) + facets: Option[Seq[Facet]], + examples: Option[Seq[Example]]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleUsage.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleUsage.scala index 2e6fff5f97..377ee69f27 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleUsage.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleUsage.scala @@ -5,7 +5,7 @@ import org.joda.time.DateTime case class ExampleUsage ( - Text: Option[String]) + text: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Facet.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Facet.scala index 4e113440c5..80d28578b7 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Facet.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Facet.scala @@ -5,8 +5,8 @@ import org.joda.time.DateTime case class Facet ( - FacetValues: Option[Seq[FacetValue]], - Name: Option[String]) + facetValues: Option[Seq[FacetValue]], + name: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FacetValue.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FacetValue.scala index 4d4d729485..8a6f5d78cb 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FacetValue.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FacetValue.scala @@ -5,8 +5,8 @@ import org.joda.time.DateTime case class FacetValue ( - Count: Option[Long], - Value: Option[String]) + count: Option[Long], + value: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Frequency.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Frequency.scala index 595e001c6a..58c29eb0b1 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Frequency.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Frequency.scala @@ -5,8 +5,8 @@ import org.joda.time.DateTime case class Frequency ( - Count: Option[Long], - Year: Option[Int]) + count: Option[Long], + year: Option[Int]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FrequencySummary.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FrequencySummary.scala index 3f0ac1c0c5..3eacadbde7 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FrequencySummary.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FrequencySummary.scala @@ -5,11 +5,11 @@ import org.joda.time.DateTime case class FrequencySummary ( - UnknownYearCount: Option[Int], - TotalCount: Option[Long], - FrequencyString: Option[String], - Word: Option[String], - Frequency: Option[Seq[Frequency]]) + unknownYearCount: Option[Int], + totalCount: Option[Long], + frequencyString: Option[String], + word: Option[String], + frequency: Option[Seq[Frequency]]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Label.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Label.scala index 52b386526c..5adba8e327 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Label.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Label.scala @@ -5,8 +5,8 @@ import org.joda.time.DateTime case class Label ( - Text: Option[String], - Type: Option[String]) + text: Option[String], + `type`: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Note.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Note.scala index 6975837dcb..ff0d72524e 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Note.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Note.scala @@ -5,10 +5,10 @@ import org.joda.time.DateTime case class Note ( - NoteType: Option[String], - AppliesTo: Option[Seq[String]], - Value: Option[String], - Pos: Option[Int]) + noteType: Option[String], + appliesTo: Option[Seq[String]], + value: Option[String], + pos: Option[Int]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/PartOfSpeech.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/PartOfSpeech.scala index 8a659ce487..182a8974ff 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/PartOfSpeech.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/PartOfSpeech.scala @@ -5,9 +5,9 @@ import org.joda.time.DateTime case class PartOfSpeech ( - Roots: Option[Seq[Root]], - StorageAbbr: Option[Seq[String]], - AllCategories: Option[Seq[Category]]) + roots: Option[Seq[Root]], + storageAbbr: Option[Seq[String]], + allCategories: Option[Seq[Category]]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Related.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Related.scala index d514783837..5fdd347cb3 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Related.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Related.scala @@ -5,13 +5,13 @@ import org.joda.time.DateTime case class Related ( - Label1: Option[String], - RelationshipType: Option[String], - Label2: Option[String], - Label3: Option[String], - Words: Option[Seq[String]], - Gram: Option[String], - Label4: Option[String]) + label1: Option[String], + relationshipType: Option[String], + label2: Option[String], + label3: Option[String], + words: Option[Seq[String]], + gram: Option[String], + label4: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Root.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Root.scala index b8580e33ef..ee134f8034 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Root.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Root.scala @@ -5,9 +5,9 @@ import org.joda.time.DateTime case class Root ( - Id: Option[Long], - Name: Option[String], - Categories: Option[Seq[Category]]) + id: Option[Long], + name: Option[String], + categories: Option[Seq[Category]]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ScoredWord.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ScoredWord.scala index 79401c1e1b..7c7b7e9b5a 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ScoredWord.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ScoredWord.scala @@ -5,17 +5,17 @@ import org.joda.time.DateTime case class ScoredWord ( - Position: Option[Int], - Id: Option[Long], - DocTermCount: Option[Int], - Lemma: Option[String], - WordType: Option[String], - Score: Option[Float], - SentenceId: Option[Long], - Word: Option[String], - Stopword: Option[Boolean], - BaseWordScore: Option[Double], - PartOfSpeech: Option[String]) + position: Option[Int], + id: Option[Long], + docTermCount: Option[Int], + lemma: Option[String], + wordType: Option[String], + score: Option[Float], + sentenceId: Option[Long], + word: Option[String], + stopword: Option[Boolean], + baseWordScore: Option[Double], + partOfSpeech: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Sentence.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Sentence.scala index eb9944b10b..99f7f0400a 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Sentence.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Sentence.scala @@ -5,12 +5,12 @@ import org.joda.time.DateTime case class Sentence ( - HasScoredWords: Option[Boolean], - Id: Option[Long], - ScoredWords: Option[Seq[ScoredWord]], - Display: Option[String], - Rating: Option[Int], - DocumentMetadataId: Option[Long]) + hasScoredWords: Option[Boolean], + id: Option[Long], + scoredWords: Option[Seq[ScoredWord]], + display: Option[String], + rating: Option[Int], + documentMetadataId: Option[Long]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleDefinition.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleDefinition.scala index 49ee8301c9..1807123222 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleDefinition.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleDefinition.scala @@ -5,10 +5,10 @@ import org.joda.time.DateTime case class SimpleDefinition ( - Text: Option[String], - Source: Option[String], - Note: Option[String], - PartOfSpeech: Option[String]) + text: Option[String], + source: Option[String], + note: Option[String], + partOfSpeech: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleExample.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleExample.scala index 1eea4ee458..4548c2ece3 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleExample.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleExample.scala @@ -5,10 +5,10 @@ import org.joda.time.DateTime case class SimpleExample ( - Id: Option[Long], - Title: Option[String], - Text: Option[String], - Url: Option[String]) + id: Option[Long], + title: Option[String], + text: Option[String], + url: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/StringValue.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/StringValue.scala index 71538e2425..bb36fabef8 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/StringValue.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/StringValue.scala @@ -5,7 +5,7 @@ import org.joda.time.DateTime case class StringValue ( - Word: Option[String]) + word: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Syllable.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Syllable.scala index 99ed72f350..0db80cb840 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Syllable.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Syllable.scala @@ -5,9 +5,9 @@ import org.joda.time.DateTime case class Syllable ( - Text: Option[String], - Seq: Option[Int], - Type: Option[String]) + text: Option[String], + seq: Option[Int], + `type`: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/TextPron.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/TextPron.scala index 7d3d59dd72..95d17c14fc 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/TextPron.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/TextPron.scala @@ -5,9 +5,9 @@ import org.joda.time.DateTime case class TextPron ( - Raw: Option[String], - Seq: Option[Int], - RawType: Option[String]) + raw: Option[String], + seq: Option[Int], + rawType: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/User.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/User.scala index 6b1db4b0c8..421c8f3210 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/User.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/User.scala @@ -5,14 +5,14 @@ import org.joda.time.DateTime case class User ( - Id: Option[Long], - Username: Option[String], - Email: Option[String], - Status: Option[Int], - FaceBookId: Option[String], - UserName: Option[String], - DisplayName: Option[String], - Password: Option[String]) + id: Option[Long], + username: Option[String], + email: Option[String], + status: Option[Int], + faceBookId: Option[String], + userName: Option[String], + displayName: Option[String], + password: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordList.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordList.scala index 9022b32efb..c46484d597 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordList.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordList.scala @@ -5,17 +5,17 @@ import org.joda.time.DateTime case class WordList ( - Id: Option[Long], - Permalink: Option[String], - Name: Option[String], - CreatedAt: Option[DateTime], - UpdatedAt: Option[DateTime], - LastActivityAt: Option[DateTime], - Username: Option[String], - UserId: Option[Long], - Description: Option[String], - NumberWordsInList: Option[Long], - Type: Option[String]) + id: Option[Long], + permalink: Option[String], + name: Option[String], + createdAt: Option[DateTime], + updatedAt: Option[DateTime], + lastActivityAt: Option[DateTime], + username: Option[String], + userId: Option[Long], + description: Option[String], + numberWordsInList: Option[Long], + `type`: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordListWord.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordListWord.scala index c15ddd7c58..062f1fe6a6 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordListWord.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordListWord.scala @@ -5,13 +5,13 @@ import org.joda.time.DateTime case class WordListWord ( - Id: Option[Long], - Word: Option[String], - Username: Option[String], - UserId: Option[Long], - CreatedAt: Option[DateTime], - NumberCommentsOnWord: Option[Long], - NumberLists: Option[Long]) + id: Option[Long], + word: Option[String], + username: Option[String], + userId: Option[Long], + createdAt: Option[DateTime], + numberCommentsOnWord: Option[Long], + numberLists: Option[Long]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordObject.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordObject.scala index a00491ba04..5f5c1c6a42 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordObject.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordObject.scala @@ -5,12 +5,12 @@ import org.joda.time.DateTime case class WordObject ( - Id: Option[Long], - Word: Option[String], - OriginalWord: Option[String], - Suggestions: Option[Seq[String]], - CanonicalForm: Option[String], - Vulgar: Option[String]) + id: Option[Long], + word: Option[String], + originalWord: Option[String], + suggestions: Option[Seq[String]], + canonicalForm: Option[String], + vulgar: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordOfTheDay.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordOfTheDay.scala index 8cfbf43243..6b94e34d21 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordOfTheDay.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordOfTheDay.scala @@ -5,18 +5,18 @@ import org.joda.time.DateTime case class WordOfTheDay ( - Id: Option[Long], - ParentId: Option[String], - Category: Option[String], - CreatedBy: Option[String], - CreatedAt: Option[DateTime], - ContentProvider: Option[ContentProvider], - HtmlExtra: Option[String], - Word: Option[String], - Definitions: Option[Seq[SimpleDefinition]], - Examples: Option[Seq[SimpleExample]], - Note: Option[String], - PublishDate: Option[DateTime]) + id: Option[Long], + parentId: Option[String], + category: Option[String], + createdBy: Option[String], + createdAt: Option[DateTime], + contentProvider: Option[ContentProvider], + htmlExtra: Option[String], + word: Option[String], + definitions: Option[Seq[SimpleDefinition]], + examples: Option[Seq[SimpleExample]], + note: Option[String], + publishDate: Option[DateTime]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResult.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResult.scala index ca2cb8182a..771fd35b2e 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResult.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResult.scala @@ -5,9 +5,9 @@ import org.joda.time.DateTime case class WordSearchResult ( - Count: Option[Long], - Lexicality: Option[Double], - Word: Option[String]) + count: Option[Long], + lexicality: Option[Double], + word: Option[String]) extends ApiModel diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResults.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResults.scala index a4715f1661..bc2af2a844 100644 --- a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResults.scala +++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResults.scala @@ -5,8 +5,8 @@ import org.joda.time.DateTime case class WordSearchResults ( - SearchResults: Option[Seq[WordSearchResult]], - TotalResults: Option[Int]) + searchResults: Option[Seq[WordSearchResult]], + totalResults: Option[Int]) extends ApiModel