From fb883e5f035ed46fbc3ff9c18599a6beac8352cb Mon Sep 17 00:00:00 2001 From: wing328 Date: Sun, 24 Apr 2016 16:33:15 +0800 Subject: [PATCH] add back groovy code generator --- .../languages/GroovyClientCodegen.java | 93 ++++++++ .../src/main/resources/Groovy/api.mustache | 56 +++-- .../resources/Groovy/build.gradle.mustache | 23 +- .../services/io.swagger.codegen.CodegenConfig | 3 +- samples/client/petstore/groovy/build.gradle | 42 ++++ .../groovy/io/swagger/api/ApiUtils.groovy | 50 ++++ .../main/groovy/io/swagger/api/PetApi.groovy | 184 +++++++++++++++ .../groovy/io/swagger/api/StoreApi.groovy | 93 ++++++++ .../main/groovy/io/swagger/api/UserApi.groovy | 185 +++++++++++++++ .../groovy/io/swagger/model/Category.groovy | 16 ++ .../io/swagger/model/ModelApiResponse.groovy | 18 ++ .../main/groovy/io/swagger/model/Order.groovy | 27 +++ .../main/groovy/io/swagger/model/Pet.groovy | 30 +++ .../main/groovy/io/swagger/model/Tag.groovy | 16 ++ .../main/groovy/io/swagger/model/User.groovy | 29 +++ .../main/java/io/swagger/api/ApiUtils.groovy | 50 ++++ .../main/java/io/swagger/api/PetApi.groovy | 218 ++++++++++++++++++ .../main/java/io/swagger/api/StoreApi.groovy | 104 +++++++++ .../main/java/io/swagger/api/UserApi.groovy | 200 ++++++++++++++++ .../java/io/swagger/model/Category.groovy | 16 ++ .../io/swagger/model/ModelApiResponse.groovy | 18 ++ .../main/java/io/swagger/model/Order.groovy | 27 +++ .../src/main/java/io/swagger/model/Pet.groovy | 30 +++ .../src/main/java/io/swagger/model/Tag.groovy | 16 ++ .../main/java/io/swagger/model/User.groovy | 29 +++ 25 files changed, 1536 insertions(+), 37 deletions(-) create mode 100644 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java create mode 100644 samples/client/petstore/groovy/build.gradle create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/api/ApiUtils.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Category.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/model/ModelApiResponse.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Order.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Pet.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Tag.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/model/User.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/api/ApiUtils.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/api/PetApi.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/api/StoreApi.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/api/UserApi.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/model/Category.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/model/ModelApiResponse.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/model/Order.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/model/Pet.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/model/Tag.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/model/User.groovy diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java new file mode 100644 index 00000000000..2812d2a301b --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java @@ -0,0 +1,93 @@ +package io.swagger.codegen.languages; + +import io.swagger.codegen.*; +import io.swagger.models.Operation; + +import java.io.File; +import java.util.*; + +public class GroovyClientCodegen extends JavaClientCodegen { + public static final String CONFIG_PACKAGE = "configPackage"; + protected String title = "Petstore Server"; + protected String configPackage = ""; + protected String templateFileName = "api.mustache"; + + public GroovyClientCodegen() { + super(); + + sourceFolder = projectFolder + File.separator + "groovy"; + outputFolder = "generated-code/groovy"; + modelTemplateFiles.put("model.mustache", ".groovy"); + apiTemplateFiles.put(templateFileName, ".groovy"); + embeddedTemplateDir = templateDir = "Groovy"; + + apiPackage = "io.swagger.api"; + modelPackage = "io.swagger.model"; + configPackage = "io.swagger.configuration"; + invokerPackage = "io.swagger.api"; + artifactId = "swagger-spring-mvc-server"; + + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); + additionalProperties.put("title", title); + additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); + additionalProperties.put(CONFIG_PACKAGE, configPackage); + + cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code")); + + supportedLibraries.clear(); + } + + @Override + public CodegenType getTag() { + return CodegenType.CLIENT; + } + + @Override + public String getName() { + return "groovy"; + } + + @Override + public String getHelp() { + return "Generates a Groovy API client (beta)."; + } + + @Override + public void processOpts() { + super.processOpts(); + + // clear model and api doc template as this codegen + // does not support auto-generated markdown doc at the moment + modelDocTemplateFiles.remove("model_doc.mustache"); + apiDocTemplateFiles.remove("api_doc.mustache"); + + if (additionalProperties.containsKey(CONFIG_PACKAGE)) { + this.setConfigPackage((String) additionalProperties.get(CONFIG_PACKAGE)); + } + + supportingFiles.clear(); + supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle")); + // TODO readme to be added later + //supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); + supportingFiles.add(new SupportingFile("ApiUtils.mustache", + (sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiUtils.groovy")); + + } + + @Override + public String toApiName(String name) { + if (name.length() == 0) { + return "DefaultApi"; + } + name = sanitizeName(name); + return camelize(name) + "Api"; + } + + public void setConfigPackage(String configPackage) { + this.configPackage = configPackage; + } + +} diff --git a/modules/swagger-codegen/src/main/resources/Groovy/api.mustache b/modules/swagger-codegen/src/main/resources/Groovy/api.mustache index 0d60fa2a96f..c952718b6ec 100644 --- a/modules/swagger-codegen/src/main/resources/Groovy/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Groovy/api.mustache @@ -1,14 +1,9 @@ package {{package}}; - - - - import groovyx.net.http.* import static groovyx.net.http.ContentType.* import static groovyx.net.http.Method.* import {{invokerPackage}}.ApiUtils -//------------- {{#imports}}import {{import}} {{/imports}} @@ -21,36 +16,37 @@ class {{classname}} { String basePath = "{{basePath}}" String versionPath = "/api/v1" + {{#operation}} + def {{operationId}} ({{#allParams}} {{{dataType}}} {{paramName}},{{/allParams}} Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "{{path}}" - {{#operation}} - def {{nickname}} ({{#allParams}} {{{dataType}}} {{paramName}},{{/allParams}} Closure onSuccess, Closure onFailure) { - // create path and map variables - String resourcePath = "{{path}}" + // query params + def queryParams = [:] + def headerParams = [:] + + {{#allParams}} + {{#required}} + // verify required params are set + if ({{paramName}} == null) { + throw new RuntimeException("missing required params {{paramName}}") + } + {{/required}} + {{/allParams}} + {{#queryParams}}if (!"null".equals(String.valueOf({{paramName}}))) + queryParams.put("{{paramName}}", String.valueOf({{paramName}})) + {{/queryParams}} - // query params - def queryParams = [:] - def headerParams = [:] + {{#headerParams}} + headerParams.put("{{paramName}}", {{paramName}}) + {{/headerParams}} - {{#allParams}} - // verify required params are set - if({{/allParams}}{{#required}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/required}}{{#allParams}}) { - throw new RuntimeException("missing required params") - } - {{/allParams}} - - {{#queryParams}}if(!"null".equals(String.valueOf({{paramName}}))) - queryParams.put("{{paramName}}", String.valueOf({{paramName}})) - {{/queryParams}} - - {{#headerParams}}headerParams.put("{{paramName}}", {{paramName}}) - {{/headerParams}} - - invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "{{httpMethod}}", "{{returnContainer}}", {{#returnBaseType}}{{{returnBaseType}}}.class {{/returnBaseType}}{{^returnBaseType}}null {{/returnBaseType}}) - - } - {{/operation}} + + } + {{/operation}} } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/Groovy/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Groovy/build.gradle.mustache index 49edec87133..238f5e6e09f 100644 --- a/modules/swagger-codegen/src/main/resources/Groovy/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Groovy/build.gradle.mustache @@ -17,15 +17,26 @@ buildscript { } repositories { - mavenCentral() - mavenLocal() - mavenCentral(artifactUrls: ['http://maven.springframework.org/milestone']) - maven { url "http://$artifactory:8080/artifactory/repo" } + mavenCentral() + mavenLocal() + mavenCentral(artifactUrls: ['http://maven.springframework.org/milestone']) + maven { url "http://$artifactory:8080/artifactory/repo" } +} + +ext { + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" } dependencies { - groovy "org.codehaus.groovy:groovy-all:2.0.5" - compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.6' + compile 'org.codehaus.groovy:groovy-all:2.4.6' + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version" + compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5" + compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1' } task wrapper(type: Wrapper) { gradleVersion = '1.6' } diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig index 21a75b23d5c..22823c95626 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig @@ -6,6 +6,7 @@ io.swagger.codegen.languages.DartClientCodegen io.swagger.codegen.languages.FlashClientCodegen io.swagger.codegen.languages.FlaskConnexionCodegen io.swagger.codegen.languages.GoClientCodegen +io.swagger.codegen.languages.GroovyClientCodegen io.swagger.codegen.languages.JavaClientCodegen io.swagger.codegen.languages.JavaJerseyServerCodegen io.swagger.codegen.languages.JavaCXFServerCodegen @@ -41,4 +42,4 @@ io.swagger.codegen.languages.AkkaScalaClientCodegen io.swagger.codegen.languages.CsharpDotNet2ClientCodegen io.swagger.codegen.languages.ClojureClientCodegen io.swagger.codegen.languages.HaskellServantCodegen -io.swagger.codegen.languages.LumenServerCodegen \ No newline at end of file +io.swagger.codegen.languages.LumenServerCodegen diff --git a/samples/client/petstore/groovy/build.gradle b/samples/client/petstore/groovy/build.gradle new file mode 100644 index 00000000000..238f5e6e09f --- /dev/null +++ b/samples/client/petstore/groovy/build.gradle @@ -0,0 +1,42 @@ +apply plugin: 'groovy' +apply plugin: 'idea' +apply plugin: 'eclipse' + +def artifactory = 'buildserver.supportspace.com' +group = 'com.supportspace' +archivesBaseName = 'swagger-gen-groovy' +version = '0.1' + +buildscript { + repositories { + maven { url 'http://repo.jfrog.org/artifactory/gradle-plugins' } + } + dependencies { + classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.16') + } +} + +repositories { + mavenCentral() + mavenLocal() + mavenCentral(artifactUrls: ['http://maven.springframework.org/milestone']) + maven { url "http://$artifactory:8080/artifactory/repo" } +} + +ext { + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" +} + +dependencies { + compile 'org.codehaus.groovy:groovy-all:2.4.6' + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version" + compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5" + compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1' +} + +task wrapper(type: Wrapper) { gradleVersion = '1.6' } diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/ApiUtils.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/ApiUtils.groovy new file mode 100644 index 00000000000..877ed4e4647 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/ApiUtils.groovy @@ -0,0 +1,50 @@ +package io.swagger.api; + +import groovyx.net.http.HTTPBuilder +import groovyx.net.http.Method + +import static groovyx.net.http.ContentType.JSON +import static java.net.URI.create; + +class ApiUtils { + + def invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, method, container, type) { + def (url, uriPath) = buildUrlAndUriPath(basePath, versionPath, resourcePath) + println "url=$url uriPath=$uriPath" + def http = new HTTPBuilder(url) + http.request( Method.valueOf(method), JSON ) { + uri.path = uriPath + uri.query = queryParams + response.success = { resp, json -> + if (type != null) { + onSuccess(parse(json, container, type)) + } + } + response.failure = { resp -> + onFailure(resp.status, resp.statusLine.reasonPhrase) + } + } + } + + + def buildUrlAndUriPath(basePath, versionPath, resourcePath) { + // HTTPBuilder expects to get as its constructor parameter an URL, + // without any other additions like path, therefore we need to cut the path + // from the basePath as it is represented by swagger APIs + // we use java.net.URI to manipulate the basePath + // then the uriPath will hold the rest of the path + URI baseUri = create(basePath) + def pathOnly = baseUri.getPath() + [basePath-pathOnly, pathOnly+versionPath+resourcePath] + } + + + def parse(object, container, clazz) { + if (container == "List") { + return object.collect {parse(it, "", clazz)} + } else { + return clazz.newInstance(object) + } + } + +} diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy new file mode 100644 index 00000000000..5aae4924239 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy @@ -0,0 +1,184 @@ +package io.swagger.api; + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils + +import io.swagger.model.Pet +import java.io.File +import io.swagger.model.ModelApiResponse + +import java.util.*; + +@Mixin(ApiUtils) +class PetApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + def addPet ( Pet body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def deletePet ( Long petId, String apiKey, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/{petId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (petId == null) { + throw new RuntimeException("missing required params petId") + } + + + headerParams.put("apiKey", apiKey) + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def findPetsByStatus ( List status, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/findByStatus" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (status == null) { + throw new RuntimeException("missing required params status") + } + + if (!"null".equals(String.valueOf(status))) + queryParams.put("status", String.valueOf(status)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "array", + Pet.class ) + + } + def findPetsByTags ( List tags, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/findByTags" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (tags == null) { + throw new RuntimeException("missing required params tags") + } + + if (!"null".equals(String.valueOf(tags))) + queryParams.put("tags", String.valueOf(tags)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "array", + Pet.class ) + + } + def getPetById ( Long petId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/{petId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (petId == null) { + throw new RuntimeException("missing required params petId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + Pet.class ) + + } + def updatePet ( Pet body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "PUT", "", + null ) + + } + def updatePetWithForm ( Long petId, String name, String status, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/{petId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (petId == null) { + throw new RuntimeException("missing required params petId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def uploadFile ( Long petId, String additionalMetadata, File file, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/{petId}/uploadImage" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (petId == null) { + throw new RuntimeException("missing required params petId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + ModelApiResponse.class ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy new file mode 100644 index 00000000000..0cf30090200 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy @@ -0,0 +1,93 @@ +package io.swagger.api; + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils + +import io.swagger.model.Order + +import java.util.*; + +@Mixin(ApiUtils) +class StoreApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + def deleteOrder ( String orderId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/store/order/{orderId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (orderId == null) { + throw new RuntimeException("missing required params orderId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def getInventory ( Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/store/inventory" + + // query params + def queryParams = [:] + def headerParams = [:] + + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "map", + Map.class ) + + } + def getOrderById ( Long orderId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/store/order/{orderId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (orderId == null) { + throw new RuntimeException("missing required params orderId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + Order.class ) + + } + def placeOrder ( Order body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/store/order" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + Order.class ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy new file mode 100644 index 00000000000..5a8a4b2eea8 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy @@ -0,0 +1,185 @@ +package io.swagger.api; + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils + +import io.swagger.model.User + +import java.util.*; + +@Mixin(ApiUtils) +class UserApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + def createUser ( User body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def createUsersWithArrayInput ( List body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/createWithArray" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def createUsersWithListInput ( List body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/createWithList" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def deleteUser ( String username, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/{username}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (username == null) { + throw new RuntimeException("missing required params username") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def getUserByName ( String username, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/{username}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (username == null) { + throw new RuntimeException("missing required params username") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + User.class ) + + } + def loginUser ( String username, String password, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/login" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (username == null) { + throw new RuntimeException("missing required params username") + } + // verify required params are set + if (password == null) { + throw new RuntimeException("missing required params password") + } + + if (!"null".equals(String.valueOf(username))) + queryParams.put("username", String.valueOf(username)) +if (!"null".equals(String.valueOf(password))) + queryParams.put("password", String.valueOf(password)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + String.class ) + + } + def logoutUser ( Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/logout" + + // query params + def queryParams = [:] + def headerParams = [:] + + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + null ) + + } + def updateUser ( String username, User body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/{username}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (username == null) { + throw new RuntimeException("missing required params username") + } + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "PUT", "", + null ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Category.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Category.groovy new file mode 100644 index 00000000000..29509e64e54 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Category.groovy @@ -0,0 +1,16 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class Category { + + Long id = null + + String name = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/ModelApiResponse.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/ModelApiResponse.groovy new file mode 100644 index 00000000000..505752a6dc3 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/ModelApiResponse.groovy @@ -0,0 +1,18 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class ModelApiResponse { + + Integer code = null + + String type = null + + String message = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Order.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Order.groovy new file mode 100644 index 00000000000..815c72846d9 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Order.groovy @@ -0,0 +1,27 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Date; +@Canonical +class Order { + + Long id = null + + Long petId = null + + Integer quantity = null + + Date shipDate = null + + /* Order Status */ + String status = null + + Boolean complete = false + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Pet.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Pet.groovy new file mode 100644 index 00000000000..667ce9430f4 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Pet.groovy @@ -0,0 +1,30 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.Category; +import io.swagger.model.Tag; +import java.util.ArrayList; +import java.util.List; +@Canonical +class Pet { + + Long id = null + + Category category = null + + String name = null + + List photoUrls = new ArrayList() + + List tags = new ArrayList() + + /* pet status in the store */ + String status = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Tag.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Tag.groovy new file mode 100644 index 00000000000..5c30c04a5ff --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Tag.groovy @@ -0,0 +1,16 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class Tag { + + Long id = null + + String name = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/User.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/User.groovy new file mode 100644 index 00000000000..6889661e9e5 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/User.groovy @@ -0,0 +1,29 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class User { + + Long id = null + + String username = null + + String firstName = null + + String lastName = null + + String email = null + + String password = null + + String phone = null + + /* User Status */ + Integer userStatus = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/api/ApiUtils.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/api/ApiUtils.groovy new file mode 100644 index 00000000000..877ed4e4647 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/api/ApiUtils.groovy @@ -0,0 +1,50 @@ +package io.swagger.api; + +import groovyx.net.http.HTTPBuilder +import groovyx.net.http.Method + +import static groovyx.net.http.ContentType.JSON +import static java.net.URI.create; + +class ApiUtils { + + def invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, method, container, type) { + def (url, uriPath) = buildUrlAndUriPath(basePath, versionPath, resourcePath) + println "url=$url uriPath=$uriPath" + def http = new HTTPBuilder(url) + http.request( Method.valueOf(method), JSON ) { + uri.path = uriPath + uri.query = queryParams + response.success = { resp, json -> + if (type != null) { + onSuccess(parse(json, container, type)) + } + } + response.failure = { resp -> + onFailure(resp.status, resp.statusLine.reasonPhrase) + } + } + } + + + def buildUrlAndUriPath(basePath, versionPath, resourcePath) { + // HTTPBuilder expects to get as its constructor parameter an URL, + // without any other additions like path, therefore we need to cut the path + // from the basePath as it is represented by swagger APIs + // we use java.net.URI to manipulate the basePath + // then the uriPath will hold the rest of the path + URI baseUri = create(basePath) + def pathOnly = baseUri.getPath() + [basePath-pathOnly, pathOnly+versionPath+resourcePath] + } + + + def parse(object, container, clazz) { + if (container == "List") { + return object.collect {parse(it, "", clazz)} + } else { + return clazz.newInstance(object) + } + } + +} diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/api/PetApi.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/api/PetApi.groovy new file mode 100644 index 00000000000..a8b0bebeedc --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/api/PetApi.groovy @@ -0,0 +1,218 @@ +package io.swagger.api; + + + + + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils +//------------- + +import io.swagger.model.Pet +import java.io.File +import io.swagger.model.ModelApiResponse + +import java.util.*; + +@Mixin(ApiUtils) +class PetApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + + def addPet ( Pet body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def deletePet ( Long petId, String apiKey, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{petId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + + headerParams.put("apiKey", apiKey) + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def findPetsByStatus ( List status, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/findByStatus" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + if(!"null".equals(String.valueOf(status))) + queryParams.put("status", String.valueOf(status)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "List", + Pet.class ) + + } + def findPetsByTags ( List tags, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/findByTags" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + if(!"null".equals(String.valueOf(tags))) + queryParams.put("tags", String.valueOf(tags)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "List", + Pet.class ) + + } + def getPetById ( Long petId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{petId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + Pet.class ) + + } + def updatePet ( Pet body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "PUT", "", + null ) + + } + def updatePetWithForm ( Long petId, String name, String status, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{petId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def uploadFile ( Long petId, String additionalMetadata, File file, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{petId}/uploadImage" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + ModelApiResponse.class ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/api/StoreApi.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/api/StoreApi.groovy new file mode 100644 index 00000000000..681000fbcdb --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/api/StoreApi.groovy @@ -0,0 +1,104 @@ +package io.swagger.api; + + + + + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils +//------------- + +import java.util.Map +import io.swagger.model.Order + +import java.util.*; + +@Mixin(ApiUtils) +class StoreApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + + def deleteOrder ( String orderId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/order/{orderId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def getInventory ( Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/inventory" + + + // query params + def queryParams = [:] + def headerParams = [:] + + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "Map", + Map.class ) + + } + def getOrderById ( Long orderId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/order/{orderId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + Order.class ) + + } + def placeOrder ( Order body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/order" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + Order.class ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/api/UserApi.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/api/UserApi.groovy new file mode 100644 index 00000000000..033057a08eb --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/api/UserApi.groovy @@ -0,0 +1,200 @@ +package io.swagger.api; + + + + + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils +//------------- + +import io.swagger.model.User +import java.util.List + +import java.util.*; + +@Mixin(ApiUtils) +class UserApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + + def createUser ( User body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def createUsersWithArrayInput ( List body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/createWithArray" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def createUsersWithListInput ( List body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/createWithList" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def deleteUser ( String username, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{username}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def getUserByName ( String username, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{username}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + User.class ) + + } + def loginUser ( String username, String password, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/login" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + if(!"null".equals(String.valueOf(username))) + queryParams.put("username", String.valueOf(username)) +if(!"null".equals(String.valueOf(password))) + queryParams.put("password", String.valueOf(password)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + String.class ) + + } + def logoutUser ( Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/logout" + + + // query params + def queryParams = [:] + def headerParams = [:] + + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + null ) + + } + def updateUser ( String username, User body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{username}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "PUT", "", + null ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/Category.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Category.groovy new file mode 100644 index 00000000000..29509e64e54 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Category.groovy @@ -0,0 +1,16 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class Category { + + Long id = null + + String name = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/ModelApiResponse.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/ModelApiResponse.groovy new file mode 100644 index 00000000000..505752a6dc3 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/ModelApiResponse.groovy @@ -0,0 +1,18 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class ModelApiResponse { + + Integer code = null + + String type = null + + String message = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/Order.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Order.groovy new file mode 100644 index 00000000000..815c72846d9 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Order.groovy @@ -0,0 +1,27 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Date; +@Canonical +class Order { + + Long id = null + + Long petId = null + + Integer quantity = null + + Date shipDate = null + + /* Order Status */ + String status = null + + Boolean complete = false + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/Pet.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Pet.groovy new file mode 100644 index 00000000000..667ce9430f4 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Pet.groovy @@ -0,0 +1,30 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.Category; +import io.swagger.model.Tag; +import java.util.ArrayList; +import java.util.List; +@Canonical +class Pet { + + Long id = null + + Category category = null + + String name = null + + List photoUrls = new ArrayList() + + List tags = new ArrayList() + + /* pet status in the store */ + String status = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/Tag.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Tag.groovy new file mode 100644 index 00000000000..5c30c04a5ff --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Tag.groovy @@ -0,0 +1,16 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class Tag { + + Long id = null + + String name = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/User.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/User.groovy new file mode 100644 index 00000000000..6889661e9e5 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/User.groovy @@ -0,0 +1,29 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class User { + + Long id = null + + String username = null + + String firstName = null + + String lastName = null + + String email = null + + String password = null + + String phone = null + + /* User Status */ + Integer userStatus = null + + +} +