diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java index af961e9983b..08410c47d44 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java @@ -17,6 +17,7 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen */ protected static final String JAXRS_TEMPLATE_DIRECTORY_NAME = "JavaJaxRS"; protected String implFolder = "src/main/java"; + protected String testResourcesFolder = "src/test/resources"; protected String title = "Swagger Server"; static Logger LOGGER = LoggerFactory.getLogger(AbstractJavaJAXRSServerCodegen.class); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFClientCodegen.java index 15bf08191a5..d1c9d41ae31 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFClientCodegen.java @@ -14,11 +14,14 @@ import io.swagger.codegen.CodegenProperty; import io.swagger.codegen.CodegenType; import io.swagger.codegen.SupportingFile; -import io.swagger.codegen.languages.features.CXFFeatures; -import io.swagger.codegen.languages.features.LoggingFeatures; +import io.swagger.codegen.languages.features.BeanValidationFeatures; +import io.swagger.codegen.languages.features.GzipTestFeatures; +import io.swagger.codegen.languages.features.JaxbFeatures; +import io.swagger.codegen.languages.features.LoggingTestFeatures; import io.swagger.models.Operation; -public class JavaCXFClientCodegen extends AbstractJavaCodegen implements CXFFeatures +public class JavaCXFClientCodegen extends AbstractJavaCodegen + implements BeanValidationFeatures, JaxbFeatures, GzipTestFeatures, LoggingTestFeatures { private static final Logger LOGGER = LoggerFactory.getLogger(JavaCXFClientCodegen.class); @@ -28,14 +31,13 @@ public class JavaCXFClientCodegen extends AbstractJavaCodegen implements CXFFeat */ protected static final String JAXRS_TEMPLATE_DIRECTORY_NAME = "JavaJaxRS"; + protected boolean useJaxbAnnotations = true; + protected boolean useBeanValidation = false; - protected boolean useGzipFeature = false; - - protected boolean useLoggingFeature = false; - - protected boolean useBeanValidationFeature = false; + protected boolean useGzipFeatureForTests = false; + protected boolean useLoggingFeatureForTests = false; public JavaCXFClientCodegen() { @@ -67,11 +69,12 @@ public JavaCXFClientCodegen() embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf"; + cliOptions.add(CliOption.newBoolean(USE_JAXB_ANNOTATIONS, "Use JAXB annotations for XML")); + cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations")); - cliOptions.add(CliOption.newBoolean(USE_GZIP_FEATURE, "Use Gzip Feature")); - cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION_FEATURE, "Use BeanValidation Feature")); - cliOptions.add(CliOption.newBoolean(USE_LOGGING_FEATURE, "Use Logging Feature")); + cliOptions.add(CliOption.newBoolean(USE_GZIP_FEATURE_FOR_TESTS, "Use Gzip Feature for tests")); + cliOptions.add(CliOption.newBoolean(USE_LOGGING_FEATURE_FOR_TESTS, "Use Logging Feature for tests")); } @@ -82,19 +85,19 @@ public void processOpts() { super.processOpts(); + if (additionalProperties.containsKey(USE_JAXB_ANNOTATIONS)) { + boolean useJaxbAnnotationsProp = convertPropertyToBooleanAndWriteBack(USE_JAXB_ANNOTATIONS); + this.setUseJaxbAnnotations(useJaxbAnnotationsProp); + } + if (additionalProperties.containsKey(USE_BEANVALIDATION)) { boolean useBeanValidationProp = convertPropertyToBooleanAndWriteBack(USE_BEANVALIDATION); this.setUseBeanValidation(useBeanValidationProp); } - this.setUseGzipFeature(convertPropertyToBooleanAndWriteBack(USE_GZIP_FEATURE)); - this.setUseLoggingFeature(convertPropertyToBooleanAndWriteBack(USE_LOGGING_FEATURE)); + this.setUseGzipFeatureForTests(convertPropertyToBooleanAndWriteBack(USE_GZIP_FEATURE_FOR_TESTS)); + this.setUseLoggingFeatureForTests(convertPropertyToBooleanAndWriteBack(USE_LOGGING_FEATURE_FOR_TESTS)); - boolean useBeanValidationFeature = convertPropertyToBooleanAndWriteBack(USE_BEANVALIDATION_FEATURE); - this.setUseBeanValidationFeature(useBeanValidationFeature); - if (useBeanValidationFeature) { - LOGGER.info("make sure your client supports Bean Validation 1.1"); - } supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen @@ -141,18 +144,16 @@ public void setUseBeanValidation(boolean useBeanValidation) { } - public void setUseGzipFeature(boolean useGzipFeature) { - this.useGzipFeature = useGzipFeature; + public void setUseJaxbAnnotations(boolean useJaxbAnnotations) { + this.useJaxbAnnotations = useJaxbAnnotations; } - - public void setUseLoggingFeature(boolean useLoggingFeature) { - this.useLoggingFeature = useLoggingFeature; + public void setUseGzipFeatureForTests(boolean useGzipFeatureForTests) { + this.useGzipFeatureForTests = useGzipFeatureForTests; } - - public void setUseBeanValidationFeature(boolean useBeanValidationFeature) { - this.useBeanValidationFeature = useBeanValidationFeature; + public void setUseLoggingFeatureForTests(boolean useLoggingFeatureForTests) { + this.useLoggingFeatureForTests = useLoggingFeatureForTests; } - + } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java index ced60722790..6404f74e3a0 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java @@ -14,30 +14,48 @@ import io.swagger.codegen.CodegenProperty; import io.swagger.codegen.SupportingFile; import io.swagger.codegen.languages.features.CXFServerFeatures; +import io.swagger.codegen.languages.features.GzipTestFeatures; +import io.swagger.codegen.languages.features.JaxbFeatures; +import io.swagger.codegen.languages.features.LoggingTestFeatures; import io.swagger.models.Operation; -public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen implements CXFServerFeatures +public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen + implements CXFServerFeatures, GzipTestFeatures, LoggingTestFeatures, JaxbFeatures { private static final Logger LOGGER = LoggerFactory.getLogger(JavaCXFServerCodegen.class); + protected boolean addConsumesProducesJson = true; + + protected boolean useJaxbAnnotations = true; + protected boolean useBeanValidation = false; protected boolean generateSpringApplication = false; + protected boolean useSpringAnnotationConfig = false; + protected boolean useSwaggerFeature = false; + protected boolean useSwaggerUI = false; + protected boolean useWadlFeature = false; protected boolean useMultipartFeature = false; - protected boolean useGzipFeature = false; - - protected boolean useLoggingFeature = false; - protected boolean useBeanValidationFeature = false; protected boolean generateSpringBootApplication= false; + protected boolean generateJbossDeploymentDescriptor = false; + + protected boolean useGzipFeature = false; + + protected boolean useGzipFeatureForTests = false; + + protected boolean useLoggingFeature = false; + + protected boolean useLoggingFeatureForTests = false; + public JavaCXFServerCodegen() { super(); @@ -64,18 +82,31 @@ public JavaCXFServerCodegen() embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf"; + cliOptions.add(CliOption.newBoolean(USE_JAXB_ANNOTATIONS, "Use JAXB annotations for XML")); + cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations")); cliOptions.add(CliOption.newBoolean(GENERATE_SPRING_APPLICATION, "Generate Spring application")); + cliOptions.add(CliOption.newBoolean(USE_SPRING_ANNOTATION_CONFIG, "Use Spring Annotation Config")); cliOptions.add(CliOption.newBoolean(USE_SWAGGER_FEATURE, "Use Swagger Feature")); + cliOptions.add(CliOption.newBoolean(USE_SWAGGER_UI, "Use Swagger UI")); + cliOptions.add(CliOption.newBoolean(USE_WADL_FEATURE, "Use WADL Feature")); cliOptions.add(CliOption.newBoolean(USE_MULTIPART_FEATURE, "Use Multipart Feature")); + cliOptions.add(CliOption.newBoolean(USE_GZIP_FEATURE, "Use Gzip Feature")); + cliOptions.add(CliOption.newBoolean(USE_GZIP_FEATURE_FOR_TESTS, "Use Gzip Feature for tests")); + cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION_FEATURE, "Use BeanValidation Feature")); cliOptions.add(CliOption.newBoolean(USE_LOGGING_FEATURE, "Use Logging Feature")); + cliOptions.add(CliOption.newBoolean(USE_LOGGING_FEATURE_FOR_TESTS, "Use Logging Feature for tests")); cliOptions.add(CliOption.newBoolean(GENERATE_SPRING_BOOT_APPLICATION, "Generate Spring Boot application")); + cliOptions.add( + CliOption.newBoolean(GENERATE_JBOSS_DEPLOYMENT_DESCRIPTOR, "Generate Jboss Deployment Descriptor")); + cliOptions + .add(CliOption.newBoolean(ADD_CONSUMES_PRODUCES_JSON, "Add @Consumes/@Produces Json to API interface")); } @@ -85,19 +116,33 @@ public void processOpts() { super.processOpts(); + if (additionalProperties.containsKey(USE_JAXB_ANNOTATIONS)) { + boolean useJaxbAnnotationsProp = convertPropertyToBooleanAndWriteBack(USE_JAXB_ANNOTATIONS); + this.setUseJaxbAnnotations(useJaxbAnnotationsProp); + } + if (additionalProperties.containsKey(USE_BEANVALIDATION)) { boolean useBeanValidationProp = convertPropertyToBooleanAndWriteBack(USE_BEANVALIDATION); this.setUseBeanValidation(useBeanValidationProp); } + if (additionalProperties.containsKey(ADD_CONSUMES_PRODUCES_JSON)) { + this.setAddConsumesProducesJson(convertPropertyToBooleanAndWriteBack(ADD_CONSUMES_PRODUCES_JSON)); + } + if (additionalProperties.containsKey(GENERATE_SPRING_APPLICATION)) { this.setGenerateSpringApplication(convertPropertyToBooleanAndWriteBack(GENERATE_SPRING_APPLICATION)); this.setUseSwaggerFeature(convertPropertyToBooleanAndWriteBack(USE_SWAGGER_FEATURE)); + this.setUseSwaggerUI(convertPropertyToBooleanAndWriteBack(USE_SWAGGER_UI)); + this.setUseWadlFeature(convertPropertyToBooleanAndWriteBack(USE_WADL_FEATURE)); this.setUseMultipartFeature(convertPropertyToBooleanAndWriteBack(USE_MULTIPART_FEATURE)); this.setUseGzipFeature(convertPropertyToBooleanAndWriteBack(USE_GZIP_FEATURE)); + this.setUseGzipFeatureForTests(convertPropertyToBooleanAndWriteBack(USE_GZIP_FEATURE_FOR_TESTS)); this.setUseLoggingFeature(convertPropertyToBooleanAndWriteBack(USE_LOGGING_FEATURE)); + this.setUseLoggingFeatureForTests(convertPropertyToBooleanAndWriteBack(USE_LOGGING_FEATURE_FOR_TESTS)); + this.setUseSpringAnnotationConfig(convertPropertyToBooleanAndWriteBack(USE_SPRING_ANNOTATION_CONFIG)); boolean useBeanValidationFeature = convertPropertyToBooleanAndWriteBack(USE_BEANVALIDATION_FEATURE); this.setUseBeanValidationFeature(useBeanValidationFeature); @@ -107,12 +152,20 @@ public void processOpts() this.setGenerateSpringBootApplication(convertPropertyToBooleanAndWriteBack(GENERATE_SPRING_BOOT_APPLICATION)); } - + if (additionalProperties.containsKey(GENERATE_JBOSS_DEPLOYMENT_DESCRIPTOR)) { + boolean generateJbossDeploymentDescriptorProp = convertPropertyToBooleanAndWriteBack( + GENERATE_JBOSS_DEPLOYMENT_DESCRIPTOR); + this.setGenerateJbossDeploymentDescriptor(generateJbossDeploymentDescriptorProp); + } + supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen writeOptional(outputFolder, new SupportingFile("server/pom.mustache", "", "pom.xml")); + writeOptional(outputFolder, + new SupportingFile("server/swagger-codegen-ignore.mustache", "", ".swagger-codegen-ignore")); + if (this.generateSpringApplication) { writeOptional(outputFolder, new SupportingFile("server/readme.md", "", "readme.md")); @@ -124,14 +177,19 @@ public void processOpts() ("src/main/webapp/WEB-INF"), "context.xml")); // Jboss - writeOptional(outputFolder, new SupportingFile("server/jboss-web.xml.mustache", - ("src/main/webapp/WEB-INF"), "jboss-web.xml")); + if (generateJbossDeploymentDescriptor) { + writeOptional(outputFolder, new SupportingFile("server/jboss-web.xml.mustache", + ("src/main/webapp/WEB-INF"), "jboss-web.xml")); + + } // Spring Boot if (this.generateSpringBootApplication) { writeOptional(outputFolder, new SupportingFile("server/SpringBootApplication.mustache", (testFolder + '/' + apiPackage).replace(".", "/"), "SpringBootApplication.java")); - + writeOptional(outputFolder, new SupportingFile("server/application.properties.mustache", + (testResourcesFolder + '/'), "application.properties")); + } } @@ -174,6 +232,9 @@ public void setGenerateSpringApplication(boolean generateSpringApplication) { this.generateSpringApplication = generateSpringApplication; } + public void setUseSpringAnnotationConfig(boolean useSpringAnnotationConfig) { + this.useSpringAnnotationConfig = useSpringAnnotationConfig; + } public void setUseSwaggerFeature(boolean useSwaggerFeature) { this.useSwaggerFeature = useSwaggerFeature; @@ -204,7 +265,32 @@ public void setUseBeanValidationFeature(boolean useBeanValidationFeature) { this.useBeanValidationFeature = useBeanValidationFeature; } - public void setGenerateSpringBootApplication(boolean generateSpringBootApplication) { + public void setGenerateSpringBootApplication(boolean generateSpringBootApplication) { this.generateSpringBootApplication = generateSpringBootApplication; } + + public void setUseJaxbAnnotations(boolean useJaxbAnnotations) { + this.useJaxbAnnotations = useJaxbAnnotations; + } + + public void setGenerateJbossDeploymentDescriptor(boolean generateJbossDeploymentDescriptor) { + this.generateJbossDeploymentDescriptor = generateJbossDeploymentDescriptor; + } + + public void setUseGzipFeatureForTests(boolean useGzipFeatureForTests) { + this.useGzipFeatureForTests = useGzipFeatureForTests; + } + + public void setUseLoggingFeatureForTests(boolean useLoggingFeatureForTests) { + this.useLoggingFeatureForTests = useLoggingFeatureForTests; + } + + public void setUseSwaggerUI(boolean useSwaggerUI) { + this.useSwaggerUI = useSwaggerUI; + } + + public void setAddConsumesProducesJson(boolean addConsumesProducesJson) { + this.addConsumesProducesJson = addConsumesProducesJson; + } + } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java index d2a462c1e2d..c1bd8a23cd5 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java @@ -1,6 +1,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.*; +import io.swagger.codegen.languages.features.JbossFeature; import io.swagger.models.Operation; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; @@ -8,7 +9,9 @@ import java.io.File; import java.util.*; -public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen { +public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen implements JbossFeature { + + protected boolean generateJbossDeploymentDescriptor = true; public JavaResteasyServerCodegen() { @@ -31,6 +34,9 @@ public JavaResteasyServerCodegen() { dateLibrary = "legacy";// TODO: change to joda embeddedTemplateDir = templateDir = "JavaJaxRS" + File.separator + "resteasy"; + + cliOptions.add( + CliOption.newBoolean(GENERATE_JBOSS_DEPLOYMENT_DESCRIPTOR, "Generate Jboss Deployment Descriptor")); } @Override @@ -47,6 +53,12 @@ public String getHelp() { public void processOpts() { super.processOpts(); + if (additionalProperties.containsKey(GENERATE_JBOSS_DEPLOYMENT_DESCRIPTOR)) { + boolean generateJbossDeploymentDescriptorProp = convertPropertyToBooleanAndWriteBack( + GENERATE_JBOSS_DEPLOYMENT_DESCRIPTOR); + this.setGenerateJbossDeploymentDescriptor(generateJbossDeploymentDescriptorProp); + } + writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml")); writeOptional(outputFolder, new SupportingFile("gradle.mustache", "", "build.gradle")); writeOptional(outputFolder, new SupportingFile("settingsGradle.mustache", "", "settings.gradle")); @@ -61,8 +73,12 @@ public void processOpts() { (sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java")); writeOptional(outputFolder, new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml")); - writeOptional(outputFolder, new SupportingFile("jboss-web.mustache", + + if (generateJbossDeploymentDescriptor) { + writeOptional(outputFolder, new SupportingFile("jboss-web.mustache", ("src/main/webapp/WEB-INF"), "jboss-web.xml")); + } + writeOptional(outputFolder, new SupportingFile("RestApplication.mustache", (sourceFolder + '/' + invokerPackage).replace(".", "/"), "RestApplication.java")); supportingFiles.add(new SupportingFile("StringUtil.mustache", @@ -198,4 +214,8 @@ public Map postProcessModelsEnum(Map objs) { return objs; } + + public void setGenerateJbossDeploymentDescriptor(boolean generateJbossDeploymentDescriptor) { + this.generateJbossDeploymentDescriptor = generateJbossDeploymentDescriptor; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/CXFFeatures.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/CXFFeatures.java index 64fa569c83f..638f0ebf5c8 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/CXFFeatures.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/CXFFeatures.java @@ -4,6 +4,8 @@ * Features supported by CXF 3 (client + server) * */ -public interface CXFFeatures extends LoggingFeatures, GzipFeatures, BeanValidationFeatures, BeanValidationExtendedFeatures { +public interface CXFFeatures extends LoggingFeatures, GzipFeatures, BeanValidationFeatures { + + } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/CXFServerFeatures.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/CXFServerFeatures.java index 5c12aaedef6..eaa012b987a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/CXFServerFeatures.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/CXFServerFeatures.java @@ -1,17 +1,24 @@ -package io.swagger.codegen.languages.features; - -/** - * Features supported by CXF 3 server - * - */ -public interface CXFServerFeatures extends CXFFeatures, SwaggerFeatures, SpringFeatures { - - public static final String USE_WADL_FEATURE = "useWadlFeature"; - - public static final String USE_MULTIPART_FEATURE = "useMultipartFeature"; - - public void setUseWadlFeature(boolean useWadlFeature); - - public void setUseMultipartFeature(boolean useMultipartFeature); - -} +package io.swagger.codegen.languages.features; + +/** + * Features supported by CXF 3 server + * + */ +public interface CXFServerFeatures + extends CXFFeatures, SwaggerFeatures, SpringFeatures, JbossFeature, BeanValidationExtendedFeatures, + SwaggerUIFeatures +{ + + public static final String USE_WADL_FEATURE = "useWadlFeature"; + + public static final String USE_MULTIPART_FEATURE = "useMultipartFeature"; + + public static final String ADD_CONSUMES_PRODUCES_JSON = "addConsumesProducesJson"; + + public void setUseWadlFeature(boolean useWadlFeature); + + public void setUseMultipartFeature(boolean useMultipartFeature); + + public void setAddConsumesProducesJson(boolean addConsumesProducesJson); + +} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/GzipFeatures.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/GzipFeatures.java index b117708232c..4cb9955187e 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/GzipFeatures.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/GzipFeatures.java @@ -3,7 +3,7 @@ public interface GzipFeatures { public static final String USE_GZIP_FEATURE = "useGzipFeature"; - + public void setUseGzipFeature(boolean useGzipFeature); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/GzipTestFeatures.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/GzipTestFeatures.java new file mode 100644 index 00000000000..871179ae991 --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/GzipTestFeatures.java @@ -0,0 +1,9 @@ +package io.swagger.codegen.languages.features; + +public interface GzipTestFeatures { + + public static final String USE_GZIP_FEATURE_FOR_TESTS = "useGzipFeatureForTests"; + + public void setUseGzipFeatureForTests(boolean useGzipFeatureForTests); + +} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/JaxbFeatures.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/JaxbFeatures.java new file mode 100644 index 00000000000..9693d6dcd07 --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/JaxbFeatures.java @@ -0,0 +1,7 @@ +package io.swagger.codegen.languages.features; + +public interface JaxbFeatures { + public static final String USE_JAXB_ANNOTATIONS = "useJaxbAnnotations"; + + public void setUseJaxbAnnotations(boolean useJaxbAnnotations); +} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/JbossFeature.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/JbossFeature.java new file mode 100644 index 00000000000..9cbbd34be81 --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/JbossFeature.java @@ -0,0 +1,9 @@ +package io.swagger.codegen.languages.features; + +public interface JbossFeature { + + public static final String GENERATE_JBOSS_DEPLOYMENT_DESCRIPTOR = "generateJbossDeploymentDescriptor"; + + public void setGenerateJbossDeploymentDescriptor(boolean generateJbossDeploymentDescriptor); + +} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/LoggingTestFeatures.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/LoggingTestFeatures.java new file mode 100644 index 00000000000..8a210f8a87c --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/LoggingTestFeatures.java @@ -0,0 +1,8 @@ +package io.swagger.codegen.languages.features; + +public interface LoggingTestFeatures { + public static final String USE_LOGGING_FEATURE_FOR_TESTS = "useLoggingFeatureForTests"; + + public void setUseLoggingFeatureForTests(boolean useLoggingFeatureForTests); + +} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/SpringFeatures.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/SpringFeatures.java index e7cb6c18228..0a3fad4202a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/SpringFeatures.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/SpringFeatures.java @@ -6,9 +6,13 @@ public interface SpringFeatures extends BeanValidationFeatures { public static final String GENERATE_SPRING_BOOT_APPLICATION = "generateSpringBootApplication"; + public static final String USE_SPRING_ANNOTATION_CONFIG = "useSpringAnnotationConfig"; + public void setGenerateSpringApplication(boolean useGenerateSpringApplication); public void setGenerateSpringBootApplication(boolean generateSpringBootApplication); + public void setUseSpringAnnotationConfig(boolean useSpringAnnotationConfig); + } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/SwaggerUIFeatures.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/SwaggerUIFeatures.java new file mode 100644 index 00000000000..1ed4a586287 --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/features/SwaggerUIFeatures.java @@ -0,0 +1,9 @@ +package io.swagger.codegen.languages.features; + +public interface SwaggerUIFeatures extends CXFFeatures { + + public static final String USE_SWAGGER_UI = "useSwaggerUI"; + + public void setUseSwaggerUI(boolean useSwaggerUI); + +} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache index f1efbe87c63..7fbcc9cea4d 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache @@ -1,36 +1,44 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; -import javax.ws.rs.*; -import javax.ws.rs.core.Response; - -import org.apache.cxf.jaxrs.ext.multipart.*; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -{{#useBeanValidation}} -import javax.validation.constraints.*; -{{/useBeanValidation}} - -@Path("/") -@Api(value = "/", description = "{{description}}") -public interface {{classname}} { -{{#operations}} -{{#operation}} - - @{{httpMethod}} - {{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}} - {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} - {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} - @ApiOperation(value = "{{summary}}", tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}} }) - public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); -{{/operation}} -} -{{/operations}} - +package {{package}}; + +{{#imports}}import {{import}}; +{{/imports}} + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.MediaType; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +{{#useBeanValidation}} +import javax.validation.constraints.*; +{{/useBeanValidation}} + +@Path("/") +@Api(value = "/", description = "{{description}}") +{{#addConsumesProducesJson}} +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +{{/addConsumesProducesJson}} +public interface {{classname}} { +{{#operations}} +{{#operation}} + + @{{httpMethod}} + {{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}} +{{#hasConsumes}} + @Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }) +{{/hasConsumes}} +{{#hasProduces}} + @Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }) +{{/hasProduces}} + @ApiOperation(value = "{{summary}}", tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}} }) + public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); +{{/operation}} +} +{{/operations}} + diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache index c0199a9b5ca..ee5d8269955 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache @@ -16,13 +16,19 @@ import org.apache.cxf.jaxrs.model.wadl.DocTarget; import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; +{{#useSpringAnnotationConfig}} +import org.springframework.stereotype.Service; +{{/useSpringAnnotationConfig}} +{{#useSpringAnnotationConfig}} +@Service("{{classname}}") +{{/useSpringAnnotationConfig}} {{#description}} {{/description}} public class {{classname}}ServiceImpl implements {{classname}} { {{#operations}} {{#operation}} - public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}} {{nickname}}({{#allParams}}{{>queryParamsImpl}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { + public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}} {{nickname}}({{#allParams}}{{>queryParamsImpl}}{{>pathParamsImpl}}{{>headerParamsImpl}}{{>bodyParams}}{{>formParamsImpl}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { // TODO: Implement... {{^vendorExtensions.x-java-is-response-void}}return null;{{/vendorExtensions.x-java-is-response-void}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api_test.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api_test.mustache index 43e9222d45e..34308df4314 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api_test.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api_test.mustache @@ -6,6 +6,7 @@ package {{package}}; {{/imports}} import org.junit.Test; import org.junit.Before; +import static org.junit.Assert.*; import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.client.JAXRSClientFactory; @@ -65,7 +66,7 @@ public class {{classname}}Test { providers.add(provider); {{#generateSpringBootApplication}} - api = JAXRSClientFactory.create("http://localhost:" + serverPort + "/services/services", {{classname}}.class, providers); + api = JAXRSClientFactory.create("http://localhost:" + serverPort + "/services", {{classname}}.class, providers); {{/generateSpringBootApplication}} {{^generateSpringBootApplication}} api = JAXRSClientFactory.create("{{basePath}}", {{classname}}.class, providers); @@ -73,7 +74,7 @@ public class {{classname}}Test { org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); -{{#useGzipFeature}} +{{#useGzipFeatureForTests}} // Example for using Gzipping GZIPOutInterceptor gzipOutInterceptor = new GZIPOutInterceptor(); // use Gzipping for first request sent to server @@ -81,11 +82,11 @@ public class {{classname}}Test { config.getOutInterceptors().add(gzipOutInterceptor); config.getInInterceptors().add(new GZIPInInterceptor()); -{{/useGzipFeature}} -{{#useLoggingFeature}} +{{/useGzipFeatureForTests}} +{{#useLoggingFeatureForTests}} LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor(); config.getOutInterceptors().add(loggingOutInterceptor); -{{/useLoggingFeature}} +{{/useLoggingFeatureForTests}} } {{#operations}}{{#operation}} @@ -100,11 +101,13 @@ public class {{classname}}Test { @Test public void {{operationId}}Test() { {{#allParams}} - {{{dataType}}} {{paramName}} = null; + {{^isFile}}{{{dataType}}} {{paramName}} = null;{{/isFile}}{{#isFile}}org.apache.cxf.jaxrs.ext.multipart.Attachment {{paramName}} = null;{{/isFile}} {{/allParams}} - // {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); - + //{{^vendorExtensions.x-java-is-response-void}}{{{returnType}}} response = {{/vendorExtensions.x-java-is-response-void}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + {{^vendorExtensions.x-java-is-response-void}}//assertNotNull(response);{{/vendorExtensions.x-java-is-response-void}} // TODO: test validations + + } {{/operation}}{{/operations}} } diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/beanValidationQueryParams.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/beanValidationQueryParams.mustache new file mode 100644 index 00000000000..cca08f4b2c4 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/beanValidationQueryParams.mustache @@ -0,0 +1 @@ +{{#required}} @NotNull{{/required}}{{#pattern}} @Pattern(regexp="{{pattern}}"){{/pattern}}{{#minLength}}{{#maxLength}} @Size(min={{minLength}},max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minLength}}{{^maxLength}} @Size(min={{minLength}}){{/maxLength}}{{/minLength}}{{^minLength}}{{#maxLength}} @Size(max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minItems}}{{#maxItems}} @Size(min={{minItems}},max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minItems}}{{^maxItems}} @Size(min={{minItems}}){{/maxItems}}{{/minItems}}{{^minItems}}{{#maxItems}} @Size(max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minimum}}/* @Min({{minimum}}) */{{/minimum}}{{#maximum}}/* @Max({{maximum}}) */{{/maximum}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/enumOuterClass.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/enumOuterClass.mustache new file mode 100644 index 00000000000..85de81431b6 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/enumOuterClass.mustache @@ -0,0 +1,43 @@ +{{#jackson}} +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +{{/jackson}} + +/** + * {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} + */ +public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} { + {{#gson}} + {{#allowableValues}}{{#enumVars}} + @SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) + {{{name}}}({{{value}}}){{^-last}}, + {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} + {{/gson}} + {{^gson}} + {{#allowableValues}}{{#enumVars}} + {{{name}}}({{{value}}}){{^-last}}, + {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} + {{/gson}} + + private {{{dataType}}} value; + + {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { + for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } +} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/formParams.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/formParams.mustache index c129a925e94..f4988929e52 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/formParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/formParams.mustache @@ -1,2 +1 @@ -{{#isFormParam}}{{#notFile}}@Multipart(value = "{{paramName}}"{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}} @Multipart(value = "{{paramName}}"{{^required}}, required = false{{/required}}) InputStream {{paramName}}InputStream, - @Multipart(value = "{{paramName}}" {{^required}}, required = false{{/required}}) Attachment {{paramName}}Detail{{/isFile}}{{/isFormParam}} \ No newline at end of file +{{#isFormParam}}{{#notFile}}@Multipart(value = "{{paramName}}"{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}} @Multipart(value = "{{paramName}}" {{^required}}, required = false{{/required}}) Attachment {{paramName}}Detail{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/formParamsImpl.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/formParamsImpl.mustache new file mode 100644 index 00000000000..e8c0e77c156 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/formParamsImpl.mustache @@ -0,0 +1 @@ +{{#isFormParam}}{{#notFile}}{{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}} Attachment {{paramName}}Detail{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/headerParamsImpl.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/headerParamsImpl.mustache new file mode 100644 index 00000000000..bd03573d196 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/headerParamsImpl.mustache @@ -0,0 +1 @@ +{{#isHeaderParam}}{{{dataType}}} {{paramName}}{{/isHeaderParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/model.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/model.mustache index aa3501d796e..0030cf7dd0c 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/model.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/model.mustache @@ -9,7 +9,7 @@ import javax.validation.constraints.*; {{#models}} {{#model}} {{#isEnum}} -{{>enumClass}} +{{>enumOuterClass}} {{/isEnum}} {{^isEnum}} {{>pojo}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pathParamsImpl.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pathParamsImpl.mustache new file mode 100644 index 00000000000..6829cf8c7a6 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pathParamsImpl.mustache @@ -0,0 +1 @@ +{{#isPathParam}}{{{dataType}}} {{paramName}}{{/isPathParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache index 9f00536089c..b959ce17c15 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache @@ -7,12 +7,14 @@ import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; +{{#useJaxbAnnotations}} @XmlAccessorType(XmlAccessType.FIELD) {{#hasVars}} @XmlType(name = "{{classname}}", propOrder = { {{#vars}}"{{name}}"{{^-last}}, {{/-last}}{{/vars}} }){{/hasVars}} {{^hasVars}}@XmlType(name = "{{classname}}"){{/hasVars}} {{^parent}}@XmlRootElement(name="{{classname}}"){{/parent}} +{{/useJaxbAnnotations}} {{#description}} @ApiModel(description="{{{description}}}") {{/description}} @@ -22,8 +24,9 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { {{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}} {{>enumClass}}{{/items}}{{/items.isEnum}} - +{{#useJaxbAnnotations}} @XmlElement(name="{{baseName}}") +{{/useJaxbAnnotations}} @ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/queryParams.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/queryParams.mustache index 6b16d47e340..ef3bf519c43 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/queryParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/queryParams.mustache @@ -1 +1 @@ -{{#isQueryParam}}@QueryParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{/isQueryParam}} \ No newline at end of file +{{#isQueryParam}}@QueryParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{/isQueryParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/server/ApplicationContext.xml.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/server/ApplicationContext.xml.mustache index 2cb4720da8c..b4cdc5b6cfd 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/server/ApplicationContext.xml.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/server/ApplicationContext.xml.mustache @@ -11,8 +11,6 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd"> - - @@ -23,18 +21,27 @@ {{/useMultipartFeature}} +{{#useSpringAnnotationConfig}} + + +{{/useSpringAnnotationConfig}} +{{^useSpringAnnotationConfig}} {{#apiInfo}} {{#apis}} {{/apis}} {{/apiInfo}} +{{/useSpringAnnotationConfig}} {{#useSwaggerFeature}} {{! http://cxf.apache.org/docs/swagger2feature.html }} - +{{#useSwaggerUI}} + +{{/useSwaggerUI}} + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + + + + io.swagger + swagger-jaxrs + compile + ${swagger-core-version} + + + ch.qos.logback + logback-classic + ${logback-version} + compile + + + ch.qos.logback + logback-core + ${logback-version} + compile + + + junit + junit + ${junit-version} + test + + + + org.apache.cxf + cxf-rt-rs-client + ${cxf-version} + test + + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf-version} + compile + + + org.apache.cxf + cxf-rt-rs-service-description + ${cxf-version} + compile + + + org.apache.cxf + cxf-rt-ws-policy + ${cxf-version} + compile + + + org.apache.cxf + cxf-rt-wsdl + ${cxf-version} + compile + + + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + true + + + + + 1.7 + ${java.version} + ${java.version} + 1.5.9 + 9.2.9.v20150224 + 2.22.2 + 4.12 + 1.1.7 + 2.5 + 3.1.6 + UTF-8 + + diff --git a/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java new file mode 100644 index 00000000000..4ff1aa826dc --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java @@ -0,0 +1,78 @@ +package io.swagger.api; + +import io.swagger.model.Pet; +import io.swagger.model.ModelApiResponse; +import java.io.File; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.MediaType; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +@Path("/") +@Api(value = "/", description = "") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public interface PetApi { + + @POST + @Path("/pet") + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Add a new pet to the store", tags={ }) + public void addPet(Pet body); + + @DELETE + @Path("/pet/{petId}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Deletes a pet", tags={ }) + public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey); + + @GET + @Path("/pet/findByStatus") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Finds Pets by status", tags={ }) + public List findPetsByStatus(@QueryParam("status")List status); + + @GET + @Path("/pet/findByTags") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Finds Pets by tags", tags={ }) + public List findPetsByTags(@QueryParam("tags")List tags); + + @GET + @Path("/pet/{petId}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Find pet by ID", tags={ }) + public Pet getPetById(@PathParam("petId") Long petId); + + @PUT + @Path("/pet") + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Update an existing pet", tags={ }) + public void updatePet(Pet body); + + @POST + @Path("/pet/{petId}") + @Consumes({ "application/x-www-form-urlencoded" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Updates a pet in the store with form data", tags={ }) + public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status); + + @POST + @Path("/pet/{petId}/uploadImage") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @ApiOperation(value = "uploads an image", tags={ }) + public ModelApiResponse uploadFile(@PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file", required = false) InputStream fileInputStream, + @Multipart(value = "file" , required = false) Attachment fileDetail); +} + diff --git a/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java new file mode 100644 index 00000000000..dca146745e8 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java @@ -0,0 +1,47 @@ +package io.swagger.api; + +import io.swagger.model.Order; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.MediaType; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +@Path("/") +@Api(value = "/", description = "") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public interface StoreApi { + + @DELETE + @Path("/store/order/{orderId}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Delete purchase order by ID", tags={ }) + public void deleteOrder(@PathParam("orderId") String orderId); + + @GET + @Path("/store/inventory") + @Produces({ "application/json" }) + @ApiOperation(value = "Returns pet inventories by status", tags={ }) + public Map getInventory(); + + @GET + @Path("/store/order/{orderId}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Find purchase order by ID", tags={ }) + public Order getOrderById(@PathParam("orderId") Long orderId); + + @POST + @Path("/store/order") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Place an order for a pet", tags={ }) + public Order placeOrder(Order body); +} + diff --git a/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java new file mode 100644 index 00000000000..e3e77a12361 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java @@ -0,0 +1,71 @@ +package io.swagger.api; + +import io.swagger.model.User; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.MediaType; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +@Path("/") +@Api(value = "/", description = "") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public interface UserApi { + + @POST + @Path("/user") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Create user", tags={ }) + public void createUser(User body); + + @POST + @Path("/user/createWithArray") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Creates list of users with given input array", tags={ }) + public void createUsersWithArrayInput(List body); + + @POST + @Path("/user/createWithList") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Creates list of users with given input array", tags={ }) + public void createUsersWithListInput(List body); + + @DELETE + @Path("/user/{username}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Delete user", tags={ }) + public void deleteUser(@PathParam("username") String username); + + @GET + @Path("/user/{username}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Get user by user name", tags={ }) + public User getUserByName(@PathParam("username") String username); + + @GET + @Path("/user/login") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Logs user into the system", tags={ }) + public String loginUser(@QueryParam("username")String username, @QueryParam("password")String password); + + @GET + @Path("/user/logout") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Logs out current logged in user session", tags={ }) + public void logoutUser(); + + @PUT + @Path("/user/{username}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Updated user", tags={ }) + public void updateUser(@PathParam("username") String username, User body); +} + diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Category.java similarity index 82% rename from samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java rename to samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Category.java index ecd7630f6a7..591a6e22a69 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java +++ b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Category.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; @@ -10,33 +11,28 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; -@XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "Category", propOrder = - { "id", "name" -}) - -@XmlRootElement(name="Category") +@ApiModel(description="A category for a pet") public class Category { - - @XmlElement(name="id") + @ApiModelProperty(example = "null", value = "") private Long id = null; - - @XmlElement(name="name") + @ApiModelProperty(example = "null", value = "") private String name = null; - /** - **/ - + /** + * Get id + * @return id + **/ public Long getId() { return id; } public void setId(Long id) { this.id = id; } - /** - **/ - + /** + * Get name + * @return name + **/ public String getName() { return name; } diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/ModelApiResponse.java b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ModelApiResponse.java similarity index 79% rename from samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/ModelApiResponse.java rename to samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ModelApiResponse.java index dc8a57cf13a..f3c6f56cfc4 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/ModelApiResponse.java +++ b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ModelApiResponse.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; @@ -10,45 +11,40 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; -@XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "ModelApiResponse", propOrder = - { "code", "type", "message" -}) - -@XmlRootElement(name="ModelApiResponse") +@ApiModel(description="Describes the result of uploading an image resource") public class ModelApiResponse { - - @XmlElement(name="code") + @ApiModelProperty(example = "null", value = "") private Integer code = null; - - @XmlElement(name="type") + @ApiModelProperty(example = "null", value = "") private String type = null; - - @XmlElement(name="message") + @ApiModelProperty(example = "null", value = "") private String message = null; - /** - **/ - + /** + * Get code + * @return code + **/ public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } - /** - **/ - + /** + * Get type + * @return type + **/ public String getType() { return type; } public void setType(String type) { this.type = type; } - /** - **/ - + /** + * Get message + * @return message + **/ public String getMessage() { return message; } diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Order.java similarity index 81% rename from samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java rename to samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Order.java index ec2140e1b4d..af6f5e0e38e 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java +++ b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Order.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; @@ -10,25 +11,16 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; -@XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "Order", propOrder = - { "id", "petId", "quantity", "shipDate", "status", "complete" -}) - -@XmlRootElement(name="Order") +@ApiModel(description="An order for a pets from the pet store") public class Order { - - @XmlElement(name="id") + @ApiModelProperty(example = "null", value = "") private Long id = null; - - @XmlElement(name="petId") + @ApiModelProperty(example = "null", value = "") private Long petId = null; - - @XmlElement(name="quantity") + @ApiModelProperty(example = "null", value = "") private Integer quantity = null; - - @XmlElement(name="shipDate") + @ApiModelProperty(example = "null", value = "") private javax.xml.datatype.XMLGregorianCalendar shipDate = null; @XmlType(name="StatusEnum") @@ -63,62 +55,65 @@ public static StatusEnum fromValue(String v) { } } - - @XmlElement(name="status") + @ApiModelProperty(example = "null", value = "Order Status") private StatusEnum status = null; - - @XmlElement(name="complete") + @ApiModelProperty(example = "null", value = "") private Boolean complete = false; - /** - **/ - + /** + * Get id + * @return id + **/ public Long getId() { return id; } public void setId(Long id) { this.id = id; } - /** - **/ - + /** + * Get petId + * @return petId + **/ public Long getPetId() { return petId; } public void setPetId(Long petId) { this.petId = petId; } - /** - **/ - + /** + * Get quantity + * @return quantity + **/ public Integer getQuantity() { return quantity; } public void setQuantity(Integer quantity) { this.quantity = quantity; } - /** - **/ - + /** + * Get shipDate + * @return shipDate + **/ public javax.xml.datatype.XMLGregorianCalendar getShipDate() { return shipDate; } public void setShipDate(javax.xml.datatype.XMLGregorianCalendar shipDate) { this.shipDate = shipDate; } - /** + /** * Order Status - **/ - + * @return status + **/ public StatusEnum getStatus() { return status; } public void setStatus(StatusEnum status) { this.status = status; } - /** - **/ - + /** + * Get complete + * @return complete + **/ public Boolean getComplete() { return complete; } diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Pet.java similarity index 81% rename from samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java rename to samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Pet.java index 5a636e92c33..0cfc0a30ee0 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java +++ b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Pet.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; +import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; @@ -14,28 +15,18 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; -@XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "Pet", propOrder = - { "id", "category", "name", "photoUrls", "tags", "status" -}) - -@XmlRootElement(name="Pet") +@ApiModel(description="A pet for sale in the pet store") public class Pet { - - @XmlElement(name="id") + @ApiModelProperty(example = "null", value = "") private Long id = null; - - @XmlElement(name="category") + @ApiModelProperty(example = "null", value = "") private Category category = null; - - @XmlElement(name="name") + @ApiModelProperty(example = "doggie", required = true, value = "") private String name = null; - - @XmlElement(name="photoUrls") + @ApiModelProperty(example = "null", required = true, value = "") private List photoUrls = new ArrayList(); - - @XmlElement(name="tags") + @ApiModelProperty(example = "null", value = "") private List tags = new ArrayList(); @XmlType(name="StatusEnum") @@ -70,59 +61,63 @@ public static StatusEnum fromValue(String v) { } } - - @XmlElement(name="status") + @ApiModelProperty(example = "null", value = "pet status in the store") private StatusEnum status = null; - /** - **/ - + /** + * Get id + * @return id + **/ public Long getId() { return id; } public void setId(Long id) { this.id = id; } - /** - **/ - + /** + * Get category + * @return category + **/ public Category getCategory() { return category; } public void setCategory(Category category) { this.category = category; } - /** - **/ - + /** + * Get name + * @return name + **/ public String getName() { return name; } public void setName(String name) { this.name = name; } - /** - **/ - + /** + * Get photoUrls + * @return photoUrls + **/ public List getPhotoUrls() { return photoUrls; } public void setPhotoUrls(List photoUrls) { this.photoUrls = photoUrls; } - /** - **/ - + /** + * Get tags + * @return tags + **/ public List getTags() { return tags; } public void setTags(List tags) { this.tags = tags; } - /** + /** * pet status in the store - **/ - + * @return status + **/ public StatusEnum getStatus() { return status; } diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Tag.java similarity index 82% rename from samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java rename to samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Tag.java index 848da3841f0..4eb99ad2fc1 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java +++ b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Tag.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; @@ -10,33 +11,28 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; -@XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "Tag", propOrder = - { "id", "name" -}) - -@XmlRootElement(name="Tag") +@ApiModel(description="A tag for a pet") public class Tag { - - @XmlElement(name="id") + @ApiModelProperty(example = "null", value = "") private Long id = null; - - @XmlElement(name="name") + @ApiModelProperty(example = "null", value = "") private String name = null; - /** - **/ - + /** + * Get id + * @return id + **/ public Long getId() { return id; } public void setId(Long id) { this.id = id; } - /** - **/ - + /** + * Get name + * @return name + **/ public String getName() { return name; } diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/User.java similarity index 75% rename from samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java rename to samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/User.java index e08637a5777..005d9aa8c74 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java +++ b/samples/client/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/User.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; @@ -10,106 +11,100 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; -@XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "User", propOrder = - { "id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus" -}) - -@XmlRootElement(name="User") +@ApiModel(description="A User who is purchasing from the pet store") public class User { - - @XmlElement(name="id") + @ApiModelProperty(example = "null", value = "") private Long id = null; - - @XmlElement(name="username") + @ApiModelProperty(example = "null", value = "") private String username = null; - - @XmlElement(name="firstName") + @ApiModelProperty(example = "null", value = "") private String firstName = null; - - @XmlElement(name="lastName") + @ApiModelProperty(example = "null", value = "") private String lastName = null; - - @XmlElement(name="email") + @ApiModelProperty(example = "null", value = "") private String email = null; - - @XmlElement(name="password") + @ApiModelProperty(example = "null", value = "") private String password = null; - - @XmlElement(name="phone") + @ApiModelProperty(example = "null", value = "") private String phone = null; - - @XmlElement(name="userStatus") + @ApiModelProperty(example = "null", value = "User Status") private Integer userStatus = null; - /** - **/ - + /** + * Get id + * @return id + **/ public Long getId() { return id; } public void setId(Long id) { this.id = id; } - /** - **/ - + /** + * Get username + * @return username + **/ public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } - /** - **/ - + /** + * Get firstName + * @return firstName + **/ public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } - /** - **/ - + /** + * Get lastName + * @return lastName + **/ public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } - /** - **/ - + /** + * Get email + * @return email + **/ public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } - /** - **/ - + /** + * Get password + * @return password + **/ public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } - /** - **/ - + /** + * Get phone + * @return phone + **/ public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } - /** + /** * User Status - **/ - + * @return userStatus + **/ public Integer getUserStatus() { return userStatus; } diff --git a/samples/client/petstore/jaxrs-cxf/src/test/java/io/swagger/api/PetApiTest.java b/samples/client/petstore/jaxrs-cxf/src/test/java/io/swagger/api/PetApiTest.java new file mode 100644 index 00000000000..9d4a9de9901 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf/src/test/java/io/swagger/api/PetApiTest.java @@ -0,0 +1,205 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package io.swagger.api; + +import io.swagger.model.Pet; +import io.swagger.model.ModelApiResponse; +import java.io.File; +import org.junit.Test; +import org.junit.Before; +import static org.junit.Assert.*; + +import javax.ws.rs.core.Response; +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.apache.cxf.jaxrs.client.ClientConfiguration; +import org.apache.cxf.jaxrs.client.WebClient; + + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + + + +/** + * API tests for PetApi + */ +public class PetApiTest { + + + private PetApi api; + + @Before + public void setup() { + JacksonJsonProvider provider = new JacksonJsonProvider(); + List providers = new ArrayList(); + providers.add(provider); + + api = JAXRSClientFactory.create("http://petstore.swagger.io/v2", PetApi.class, providers); + org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); + + ClientConfiguration config = WebClient.getConfig(client); + } + + + /** + * Add a new pet to the store + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void addPetTest() { + Pet body = null; + // response = api.addPet(body); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Deletes a pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deletePetTest() { + Long petId = null; + String apiKey = null; + // response = api.deletePet(petId, apiKey); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void findPetsByStatusTest() { + List status = null; + //List response = api.findPetsByStatus(status); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void findPetsByTagsTest() { + List tags = null; + //List response = api.findPetsByTags(tags); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Find pet by ID + * + * Returns a single pet + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getPetByIdTest() { + Long petId = null; + //Pet response = api.getPetById(petId); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Update an existing pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updatePetTest() { + Pet body = null; + // response = api.updatePet(body); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Updates a pet in the store with form data + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updatePetWithFormTest() { + Long petId = null; + String name = null; + String status = null; + // response = api.updatePetWithForm(petId, name, status); + //assertNotNull(response); + // TODO: test validations + } + + /** + * uploads an image + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void uploadFileTest() { + Long petId = null; + String additionalMetadata = null; + File file = null; + //ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file); + //assertNotNull(response); + // TODO: test validations + } + +} diff --git a/samples/client/petstore/jaxrs-cxf/src/test/java/io/swagger/api/StoreApiTest.java b/samples/client/petstore/jaxrs-cxf/src/test/java/io/swagger/api/StoreApiTest.java new file mode 100644 index 00000000000..81053a82b29 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf/src/test/java/io/swagger/api/StoreApiTest.java @@ -0,0 +1,133 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package io.swagger.api; + +import io.swagger.model.Order; +import org.junit.Test; +import org.junit.Before; +import static org.junit.Assert.*; + +import javax.ws.rs.core.Response; +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.apache.cxf.jaxrs.client.ClientConfiguration; +import org.apache.cxf.jaxrs.client.WebClient; + + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + + + +/** + * API tests for StoreApi + */ +public class StoreApiTest { + + + private StoreApi api; + + @Before + public void setup() { + JacksonJsonProvider provider = new JacksonJsonProvider(); + List providers = new ArrayList(); + providers.add(provider); + + api = JAXRSClientFactory.create("http://petstore.swagger.io/v2", StoreApi.class, providers); + org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); + + ClientConfiguration config = WebClient.getConfig(client); + } + + + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deleteOrderTest() { + String orderId = null; + // response = api.deleteOrder(orderId); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getInventoryTest() { + //Map response = api.getInventory(); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getOrderByIdTest() { + Long orderId = null; + //Order response = api.getOrderById(orderId); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Place an order for a pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void placeOrderTest() { + Order body = null; + //Order response = api.placeOrder(body); + //assertNotNull(response); + // TODO: test validations + } + +} diff --git a/samples/client/petstore/jaxrs-cxf/src/test/java/io/swagger/api/UserApiTest.java b/samples/client/petstore/jaxrs-cxf/src/test/java/io/swagger/api/UserApiTest.java new file mode 100644 index 00000000000..126c7018935 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf/src/test/java/io/swagger/api/UserApiTest.java @@ -0,0 +1,199 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package io.swagger.api; + +import io.swagger.model.User; +import org.junit.Test; +import org.junit.Before; +import static org.junit.Assert.*; + +import javax.ws.rs.core.Response; +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.apache.cxf.jaxrs.client.ClientConfiguration; +import org.apache.cxf.jaxrs.client.WebClient; + + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + + + +/** + * API tests for UserApi + */ +public class UserApiTest { + + + private UserApi api; + + @Before + public void setup() { + JacksonJsonProvider provider = new JacksonJsonProvider(); + List providers = new ArrayList(); + providers.add(provider); + + api = JAXRSClientFactory.create("http://petstore.swagger.io/v2", UserApi.class, providers); + org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); + + ClientConfiguration config = WebClient.getConfig(client); + } + + + /** + * Create user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUserTest() { + User body = null; + // response = api.createUser(body); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Creates list of users with given input array + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithArrayInputTest() { + List body = null; + // response = api.createUsersWithArrayInput(body); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Creates list of users with given input array + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithListInputTest() { + List body = null; + // response = api.createUsersWithListInput(body); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Delete user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deleteUserTest() { + String username = null; + // response = api.deleteUser(username); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Get user by user name + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getUserByNameTest() { + String username = null; + //User response = api.getUserByName(username); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Logs user into the system + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void loginUserTest() { + String username = null; + String password = null; + //String response = api.loginUser(username, password); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Logs out current logged in user session + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void logoutUserTest() { + // response = api.logoutUser(); + //assertNotNull(response); + // TODO: test validations + } + + /** + * Updated user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updateUserTest() { + String username = null; + User body = null; + // response = api.updateUser(username, body); + //assertNotNull(response); + // TODO: test validations + } + +} diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java deleted file mode 100644 index 9e459c248dd..00000000000 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java +++ /dev/null @@ -1,60 +0,0 @@ -package io.swagger.api; - -import io.swagger.model.Pet; -import java.io.File; -import io.swagger.model.ModelApiResponse; - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; -import javax.ws.rs.*; -import javax.ws.rs.core.Response; - -import org.apache.cxf.jaxrs.ext.multipart.*; - -@Path("/v2") -public interface PetApi { - @POST - @Path("/pet") - @Consumes({ "application/json", "application/xml" }) - @Produces({ "application/xml", "application/json" }) - Response addPet(Pet body); - @DELETE - @Path("/pet/{petId}") - - @Produces({ "application/xml", "application/json" }) - Response deletePet(@PathParam("petId") Long petId,@HeaderParam("api_key") String apiKey); - @GET - @Path("/pet/findByStatus") - - @Produces({ "application/xml", "application/json" }) - Response findPetsByStatus(@QueryParam("status") List status); - @GET - @Path("/pet/findByTags") - - @Produces({ "application/xml", "application/json" }) - Response findPetsByTags(@QueryParam("tags") List tags); - @GET - @Path("/pet/{petId}") - - @Produces({ "application/xml", "application/json" }) - Response getPetById(@PathParam("petId") Long petId); - @PUT - @Path("/pet") - @Consumes({ "application/json", "application/xml" }) - @Produces({ "application/xml", "application/json" }) - Response updatePet(Pet body); - @POST - @Path("/pet/{petId}") - @Consumes({ "application/x-www-form-urlencoded" }) - @Produces({ "application/xml", "application/json" }) - Response updatePetWithForm(@PathParam("petId") Long petId,@Multipart(value = "name", required = false) String name,@Multipart(value = "status", required = false) String status); - @POST - @Path("/pet/{petId}/uploadImage") - @Consumes({ "multipart/form-data" }) - @Produces({ "application/json" }) - Response uploadFile(@PathParam("petId") Long petId,@Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file", required = false) InputStream fileInputStream, - @Multipart(value = "file" , required = false) Attachment fileDetail); -} - diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java deleted file mode 100644 index 2bdd151ec3f..00000000000 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.swagger.api; - -import java.util.Map; -import io.swagger.model.Order; - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; -import javax.ws.rs.*; -import javax.ws.rs.core.Response; - -import org.apache.cxf.jaxrs.ext.multipart.*; - -@Path("/v2") -public interface StoreApi { - @DELETE - @Path("/store/order/{orderId}") - - @Produces({ "application/xml", "application/json" }) - Response deleteOrder(@PathParam("orderId") String orderId); - @GET - @Path("/store/inventory") - - @Produces({ "application/json" }) - Response getInventory(); - @GET - @Path("/store/order/{orderId}") - - @Produces({ "application/xml", "application/json" }) - Response getOrderById(@PathParam("orderId") Long orderId); - @POST - @Path("/store/order") - - @Produces({ "application/xml", "application/json" }) - Response placeOrder(Order body); -} - diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/UserApi.java deleted file mode 100644 index f93523bf947..00000000000 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/UserApi.java +++ /dev/null @@ -1,58 +0,0 @@ -package io.swagger.api; - -import io.swagger.model.User; -import java.util.List; - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; -import javax.ws.rs.*; -import javax.ws.rs.core.Response; - -import org.apache.cxf.jaxrs.ext.multipart.*; - -@Path("/v2") -public interface UserApi { - @POST - @Path("/user") - - @Produces({ "application/xml", "application/json" }) - Response createUser(User body); - @POST - @Path("/user/createWithArray") - - @Produces({ "application/xml", "application/json" }) - Response createUsersWithArrayInput(List body); - @POST - @Path("/user/createWithList") - - @Produces({ "application/xml", "application/json" }) - Response createUsersWithListInput(List body); - @DELETE - @Path("/user/{username}") - - @Produces({ "application/xml", "application/json" }) - Response deleteUser(@PathParam("username") String username); - @GET - @Path("/user/{username}") - - @Produces({ "application/xml", "application/json" }) - Response getUserByName(@PathParam("username") String username); - @GET - @Path("/user/login") - - @Produces({ "application/xml", "application/json" }) - Response loginUser(@QueryParam("username") String username,@QueryParam("password") String password); - @GET - @Path("/user/logout") - - @Produces({ "application/xml", "application/json" }) - Response logoutUser(); - @PUT - @Path("/user/{username}") - - @Produces({ "application/xml", "application/json" }) - Response updateUser(@PathParam("username") String username,User body); -} - diff --git a/samples/server/petstore/jaxrs-cxf/pom.xml b/samples/server/petstore/jaxrs-cxf/pom.xml index 24ae04f9d19..cdf3a68ed8f 100644 --- a/samples/server/petstore/jaxrs-cxf/pom.xml +++ b/samples/server/petstore/jaxrs-cxf/pom.xml @@ -82,7 +82,7 @@ maven-war-plugin 2.1.1 - true + false @@ -165,13 +165,13 @@ 1.7 ${java.version} ${java.version} - 1.5.9 + 1.5.10 9.2.9.v20150224 2.22.2 4.12 1.1.7 2.5 - 3.1.7 + 3.1.8 UTF-8 diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java new file mode 100644 index 00000000000..608b51f96d8 --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java @@ -0,0 +1,77 @@ +package io.swagger.api; + +import io.swagger.model.Pet; +import io.swagger.model.ModelApiResponse; +import java.io.File; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.MediaType; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +@Path("/") +@Api(value = "/", description = "") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public interface PetApi { + + @POST + @Path("/pet") + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Add a new pet to the store", tags={ "pet", }) + public void addPet(Pet body); + + @DELETE + @Path("/pet/{petId}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Deletes a pet", tags={ "pet", }) + public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey); + + @GET + @Path("/pet/findByStatus") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Finds Pets by status", tags={ "pet", }) + public Pet findPetsByStatus(@QueryParam("status")List status); + + @GET + @Path("/pet/findByTags") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Finds Pets by tags", tags={ "pet", }) + public Pet findPetsByTags(@QueryParam("tags")List tags); + + @GET + @Path("/pet/{petId}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Find pet by ID", tags={ "pet", }) + public Pet getPetById(@PathParam("petId") Long petId); + + @PUT + @Path("/pet") + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Update an existing pet", tags={ "pet", }) + public void updatePet(Pet body); + + @POST + @Path("/pet/{petId}") + @Consumes({ "application/x-www-form-urlencoded" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Updates a pet in the store with form data", tags={ "pet", }) + public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status); + + @POST + @Path("/pet/{petId}/uploadImage") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @ApiOperation(value = "uploads an image", tags={ "pet" }) + public ModelApiResponse uploadFile(@PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file" , required = false) Attachment fileDetail); +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java new file mode 100644 index 00000000000..87a583b8712 --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java @@ -0,0 +1,48 @@ +package io.swagger.api; + +import java.util.Map; +import io.swagger.model.Order; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.MediaType; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +@Path("/") +@Api(value = "/", description = "") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public interface StoreApi { + + @DELETE + @Path("/store/order/{orderId}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Delete purchase order by ID", tags={ "store", }) + public void deleteOrder(@PathParam("orderId") String orderId); + + @GET + @Path("/store/inventory") + @Produces({ "application/json" }) + @ApiOperation(value = "Returns pet inventories by status", tags={ "store", }) + public Integer getInventory(); + + @GET + @Path("/store/order/{orderId}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Find purchase order by ID", tags={ "store", }) + public Order getOrderById(@PathParam("orderId") Long orderId); + + @POST + @Path("/store/order") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Place an order for a pet", tags={ "store" }) + public Order placeOrder(Order body); +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java new file mode 100644 index 00000000000..528af584f46 --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java @@ -0,0 +1,72 @@ +package io.swagger.api; + +import io.swagger.model.User; +import java.util.List; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.MediaType; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +@Path("/") +@Api(value = "/", description = "") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public interface UserApi { + + @POST + @Path("/user") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Create user", tags={ "user", }) + public void createUser(User body); + + @POST + @Path("/user/createWithArray") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Creates list of users with given input array", tags={ "user", }) + public void createUsersWithArrayInput(List body); + + @POST + @Path("/user/createWithList") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Creates list of users with given input array", tags={ "user", }) + public void createUsersWithListInput(List body); + + @DELETE + @Path("/user/{username}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Delete user", tags={ "user", }) + public void deleteUser(@PathParam("username") String username); + + @GET + @Path("/user/{username}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Get user by user name", tags={ "user", }) + public User getUserByName(@PathParam("username") String username); + + @GET + @Path("/user/login") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Logs user into the system", tags={ "user", }) + public String loginUser(@QueryParam("username")String username, @QueryParam("password")String password); + + @GET + @Path("/user/logout") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Logs out current logged in user session", tags={ "user", }) + public void logoutUser(); + + @PUT + @Path("/user/{username}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Updated user", tags={ "user" }) + public void updateUser(@PathParam("username") String username, User body); +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Category.java new file mode 100644 index 00000000000..591a6e22a69 --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Category.java @@ -0,0 +1,65 @@ +package io.swagger.model; + +import io.swagger.annotations.ApiModel; + +import io.swagger.annotations.ApiModelProperty; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; + +@ApiModel(description="A category for a pet") +public class Category { + + @ApiModelProperty(example = "null", value = "") + private Long id = null; + @ApiModelProperty(example = "null", value = "") + private String name = null; + + /** + * Get id + * @return id + **/ + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + /** + * Get name + * @return name + **/ + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ModelApiResponse.java new file mode 100644 index 00000000000..f3c6f56cfc4 --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ModelApiResponse.java @@ -0,0 +1,78 @@ +package io.swagger.model; + +import io.swagger.annotations.ApiModel; + +import io.swagger.annotations.ApiModelProperty; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; + +@ApiModel(description="Describes the result of uploading an image resource") +public class ModelApiResponse { + + @ApiModelProperty(example = "null", value = "") + private Integer code = null; + @ApiModelProperty(example = "null", value = "") + private String type = null; + @ApiModelProperty(example = "null", value = "") + private String message = null; + + /** + * Get code + * @return code + **/ + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + /** + * Get type + * @return type + **/ + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + /** + * Get message + * @return message + **/ + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Order.java new file mode 100644 index 00000000000..af6f5e0e38e --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Order.java @@ -0,0 +1,150 @@ +package io.swagger.model; + +import io.swagger.annotations.ApiModel; + +import io.swagger.annotations.ApiModelProperty; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; + +@ApiModel(description="An order for a pets from the pet store") +public class Order { + + @ApiModelProperty(example = "null", value = "") + private Long id = null; + @ApiModelProperty(example = "null", value = "") + private Long petId = null; + @ApiModelProperty(example = "null", value = "") + private Integer quantity = null; + @ApiModelProperty(example = "null", value = "") + private javax.xml.datatype.XMLGregorianCalendar shipDate = null; + +@XmlType(name="StatusEnum") +@XmlEnum(String.class) +public enum StatusEnum { + + @XmlEnumValue("placed") PLACED(String.valueOf("placed")), @XmlEnumValue("approved") APPROVED(String.valueOf("approved")), @XmlEnumValue("delivered") DELIVERED(String.valueOf("delivered")); + + + private String value; + + StatusEnum (String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String v) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(v)) { + return b; + } + } + return null; + } +} + + @ApiModelProperty(example = "null", value = "Order Status") + private StatusEnum status = null; + @ApiModelProperty(example = "null", value = "") + private Boolean complete = false; + + /** + * Get id + * @return id + **/ + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + /** + * Get petId + * @return petId + **/ + public Long getPetId() { + return petId; + } + public void setPetId(Long petId) { + this.petId = petId; + } + /** + * Get quantity + * @return quantity + **/ + public Integer getQuantity() { + return quantity; + } + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + /** + * Get shipDate + * @return shipDate + **/ + public javax.xml.datatype.XMLGregorianCalendar getShipDate() { + return shipDate; + } + public void setShipDate(javax.xml.datatype.XMLGregorianCalendar shipDate) { + this.shipDate = shipDate; + } + /** + * Order Status + * @return status + **/ + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + /** + * Get complete + * @return complete + **/ + public Boolean getComplete() { + return complete; + } + public void setComplete(Boolean complete) { + this.complete = complete; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Pet.java new file mode 100644 index 00000000000..0cfc0a30ee0 --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Pet.java @@ -0,0 +1,154 @@ +package io.swagger.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.model.Category; +import io.swagger.model.Tag; +import java.util.ArrayList; +import java.util.List; + +import io.swagger.annotations.ApiModelProperty; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; + +@ApiModel(description="A pet for sale in the pet store") +public class Pet { + + @ApiModelProperty(example = "null", value = "") + private Long id = null; + @ApiModelProperty(example = "null", value = "") + private Category category = null; + @ApiModelProperty(example = "doggie", required = true, value = "") + private String name = null; + @ApiModelProperty(example = "null", required = true, value = "") + private List photoUrls = new ArrayList(); + @ApiModelProperty(example = "null", value = "") + private List tags = new ArrayList(); + +@XmlType(name="StatusEnum") +@XmlEnum(String.class) +public enum StatusEnum { + + @XmlEnumValue("available") AVAILABLE(String.valueOf("available")), @XmlEnumValue("pending") PENDING(String.valueOf("pending")), @XmlEnumValue("sold") SOLD(String.valueOf("sold")); + + + private String value; + + StatusEnum (String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String v) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(v)) { + return b; + } + } + return null; + } +} + + @ApiModelProperty(example = "null", value = "pet status in the store") + private StatusEnum status = null; + + /** + * Get id + * @return id + **/ + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + /** + * Get category + * @return category + **/ + public Category getCategory() { + return category; + } + public void setCategory(Category category) { + this.category = category; + } + /** + * Get name + * @return name + **/ + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + /** + * Get photoUrls + * @return photoUrls + **/ + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + /** + * Get tags + * @return tags + **/ + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + /** + * pet status in the store + * @return status + **/ + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Tag.java new file mode 100644 index 00000000000..4eb99ad2fc1 --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Tag.java @@ -0,0 +1,65 @@ +package io.swagger.model; + +import io.swagger.annotations.ApiModel; + +import io.swagger.annotations.ApiModelProperty; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; + +@ApiModel(description="A tag for a pet") +public class Tag { + + @ApiModelProperty(example = "null", value = "") + private Long id = null; + @ApiModelProperty(example = "null", value = "") + private String name = null; + + /** + * Get id + * @return id + **/ + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + /** + * Get name + * @return name + **/ + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/User.java new file mode 100644 index 00000000000..005d9aa8c74 --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/User.java @@ -0,0 +1,143 @@ +package io.swagger.model; + +import io.swagger.annotations.ApiModel; + +import io.swagger.annotations.ApiModelProperty; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; + +@ApiModel(description="A User who is purchasing from the pet store") +public class User { + + @ApiModelProperty(example = "null", value = "") + private Long id = null; + @ApiModelProperty(example = "null", value = "") + private String username = null; + @ApiModelProperty(example = "null", value = "") + private String firstName = null; + @ApiModelProperty(example = "null", value = "") + private String lastName = null; + @ApiModelProperty(example = "null", value = "") + private String email = null; + @ApiModelProperty(example = "null", value = "") + private String password = null; + @ApiModelProperty(example = "null", value = "") + private String phone = null; + @ApiModelProperty(example = "null", value = "User Status") + private Integer userStatus = null; + + /** + * Get id + * @return id + **/ + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + /** + * Get username + * @return username + **/ + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + /** + * Get firstName + * @return firstName + **/ + public String getFirstName() { + return firstName; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + /** + * Get lastName + * @return lastName + **/ + public String getLastName() { + return lastName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } + /** + * Get email + * @return email + **/ + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + /** + * Get password + * @return password + **/ + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + /** + * Get phone + * @return phone + **/ + public String getPhone() { + return phone; + } + public void setPhone(String phone) { + this.phone = phone; + } + /** + * User Status + * @return userStatus + **/ + public Integer getUserStatus() { + return userStatus; + } + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java new file mode 100644 index 00000000000..9c952820070 --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java @@ -0,0 +1,71 @@ +package io.swagger.api.impl; + +import io.swagger.api.*; +import io.swagger.model.Pet; +import io.swagger.model.ModelApiResponse; +import java.io.File; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import org.apache.cxf.jaxrs.model.wadl.Description; +import org.apache.cxf.jaxrs.model.wadl.DocTarget; + +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; + +public class PetApiServiceImpl implements PetApi { + public void addPet(Pet body) { + // TODO: Implement... + + + } + + public void deletePet(Long petId, String apiKey) { + // TODO: Implement... + + + } + + public Pet findPetsByStatus(List status) { + // TODO: Implement... + + return null; + } + + public Pet findPetsByTags(List tags) { + // TODO: Implement... + + return null; + } + + public Pet getPetById(Long petId) { + // TODO: Implement... + + return null; + } + + public void updatePet(Pet body) { + // TODO: Implement... + + + } + + public void updatePetWithForm(Long petId, String name, String status) { + // TODO: Implement... + + + } + + public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Attachment fileDetail) { + // TODO: Implement... + + return null; + } + +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java new file mode 100644 index 00000000000..cbcc2de9e2a --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java @@ -0,0 +1,46 @@ +package io.swagger.api.impl; + +import io.swagger.api.*; +import java.util.Map; +import io.swagger.model.Order; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import org.apache.cxf.jaxrs.model.wadl.Description; +import org.apache.cxf.jaxrs.model.wadl.DocTarget; + +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; + +public class StoreApiServiceImpl implements StoreApi { + public void deleteOrder(String orderId) { + // TODO: Implement... + + + } + + public Integer getInventory() { + // TODO: Implement... + + return null; + } + + public Order getOrderById(Long orderId) { + // TODO: Implement... + + return null; + } + + public Order placeOrder(Order body) { + // TODO: Implement... + + return null; + } + +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java new file mode 100644 index 00000000000..8fac5414a23 --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java @@ -0,0 +1,70 @@ +package io.swagger.api.impl; + +import io.swagger.api.*; +import io.swagger.model.User; +import java.util.List; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import org.apache.cxf.jaxrs.model.wadl.Description; +import org.apache.cxf.jaxrs.model.wadl.DocTarget; + +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; + +public class UserApiServiceImpl implements UserApi { + public void createUser(User body) { + // TODO: Implement... + + + } + + public void createUsersWithArrayInput(List body) { + // TODO: Implement... + + + } + + public void createUsersWithListInput(List body) { + // TODO: Implement... + + + } + + public void deleteUser(String username) { + // TODO: Implement... + + + } + + public User getUserByName(String username) { + // TODO: Implement... + + return null; + } + + public String loginUser(String username, String password) { + // TODO: Implement... + + return null; + } + + public void logoutUser() { + // TODO: Implement... + + + } + + public void updateUser(String username, User body) { + // TODO: Implement... + + + } + +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/PetApiTest.java b/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/PetApiTest.java new file mode 100644 index 00000000000..44cf564dec1 --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/PetApiTest.java @@ -0,0 +1,221 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package io.swagger.api; + +import io.swagger.model.Pet; +import io.swagger.model.ModelApiResponse; +import java.io.File; +import org.junit.Test; +import org.junit.Before; +import static org.junit.Assert.*; + +import javax.ws.rs.core.Response; +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.apache.cxf.jaxrs.client.ClientConfiguration; +import org.apache.cxf.jaxrs.client.WebClient; + + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + + + +/** + * API tests for PetApi + */ +public class PetApiTest { + + + private PetApi api; + + @Before + public void setup() { + JacksonJsonProvider provider = new JacksonJsonProvider(); + List providers = new ArrayList(); + providers.add(provider); + + api = JAXRSClientFactory.create("http://petstore.swagger.io/v2", PetApi.class, providers); + org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); + + ClientConfiguration config = WebClient.getConfig(client); + } + + + /** + * Add a new pet to the store + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void addPetTest() { + Pet body = null; + //api.addPet(body); + + // TODO: test validations + + + } + + /** + * Deletes a pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deletePetTest() { + Long petId = null; + String apiKey = null; + //api.deletePet(petId, apiKey); + + // TODO: test validations + + + } + + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void findPetsByStatusTest() { + List status = null; + //Pet response = api.findPetsByStatus(status); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void findPetsByTagsTest() { + List tags = null; + //Pet response = api.findPetsByTags(tags); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Find pet by ID + * + * Returns a single pet + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getPetByIdTest() { + Long petId = null; + //Pet response = api.getPetById(petId); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Update an existing pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updatePetTest() { + Pet body = null; + //api.updatePet(body); + + // TODO: test validations + + + } + + /** + * Updates a pet in the store with form data + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updatePetWithFormTest() { + Long petId = null; + String name = null; + String status = null; + //api.updatePetWithForm(petId, name, status); + + // TODO: test validations + + + } + + /** + * uploads an image + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void uploadFileTest() { + Long petId = null; + String additionalMetadata = null; + org.apache.cxf.jaxrs.ext.multipart.Attachment file = null; + //ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file); + //assertNotNull(response); + // TODO: test validations + + + } + +} diff --git a/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/StoreApiTest.java b/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/StoreApiTest.java new file mode 100644 index 00000000000..e54e33f0fbc --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/StoreApiTest.java @@ -0,0 +1,142 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package io.swagger.api; + +import java.util.Map; +import io.swagger.model.Order; +import org.junit.Test; +import org.junit.Before; +import static org.junit.Assert.*; + +import javax.ws.rs.core.Response; +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.apache.cxf.jaxrs.client.ClientConfiguration; +import org.apache.cxf.jaxrs.client.WebClient; + + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + + + +/** + * API tests for StoreApi + */ +public class StoreApiTest { + + + private StoreApi api; + + @Before + public void setup() { + JacksonJsonProvider provider = new JacksonJsonProvider(); + List providers = new ArrayList(); + providers.add(provider); + + api = JAXRSClientFactory.create("http://petstore.swagger.io/v2", StoreApi.class, providers); + org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); + + ClientConfiguration config = WebClient.getConfig(client); + } + + + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deleteOrderTest() { + String orderId = null; + //api.deleteOrder(orderId); + + // TODO: test validations + + + } + + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getInventoryTest() { + //Integer response = api.getInventory(); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getOrderByIdTest() { + Long orderId = null; + //Order response = api.getOrderById(orderId); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Place an order for a pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void placeOrderTest() { + Order body = null; + //Order response = api.placeOrder(body); + //assertNotNull(response); + // TODO: test validations + + + } + +} diff --git a/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/UserApiTest.java b/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/UserApiTest.java new file mode 100644 index 00000000000..2285f3c70cf --- /dev/null +++ b/samples/server/petstore/jaxrs-cxf/src/test/java/io/swagger/api/UserApiTest.java @@ -0,0 +1,216 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package io.swagger.api; + +import io.swagger.model.User; +import java.util.List; +import org.junit.Test; +import org.junit.Before; +import static org.junit.Assert.*; + +import javax.ws.rs.core.Response; +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.apache.cxf.jaxrs.client.ClientConfiguration; +import org.apache.cxf.jaxrs.client.WebClient; + + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + + + +/** + * API tests for UserApi + */ +public class UserApiTest { + + + private UserApi api; + + @Before + public void setup() { + JacksonJsonProvider provider = new JacksonJsonProvider(); + List providers = new ArrayList(); + providers.add(provider); + + api = JAXRSClientFactory.create("http://petstore.swagger.io/v2", UserApi.class, providers); + org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); + + ClientConfiguration config = WebClient.getConfig(client); + } + + + /** + * Create user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUserTest() { + User body = null; + //api.createUser(body); + + // TODO: test validations + + + } + + /** + * Creates list of users with given input array + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithArrayInputTest() { + List body = null; + //api.createUsersWithArrayInput(body); + + // TODO: test validations + + + } + + /** + * Creates list of users with given input array + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithListInputTest() { + List body = null; + //api.createUsersWithListInput(body); + + // TODO: test validations + + + } + + /** + * Delete user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deleteUserTest() { + String username = null; + //api.deleteUser(username); + + // TODO: test validations + + + } + + /** + * Get user by user name + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getUserByNameTest() { + String username = null; + //User response = api.getUserByName(username); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Logs user into the system + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void loginUserTest() { + String username = null; + String password = null; + //String response = api.loginUser(username, password); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Logs out current logged in user session + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void logoutUserTest() { + //api.logoutUser(); + + // TODO: test validations + + + } + + /** + * Updated user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updateUserTest() { + String username = null; + User body = null; + //api.updateUser(username, body); + + // TODO: test validations + + + } + +}