forked from loafle/openapi-generator-original
[Java] remove samples & replace them with file asserts (#11773)
This commit is contained in:
parent
00ec168536
commit
3656ec5260
2
.github/workflows/samples-jaxrs.yaml
vendored
2
.github/workflows/samples-jaxrs.yaml
vendored
@ -34,11 +34,9 @@ jobs:
|
||||
- samples/server/petstore/jaxrs-resteasy/eap-joda
|
||||
- samples/server/petstore/jaxrs-resteasy/eap-java8
|
||||
- samples/server/petstore/jaxrs-resteasy/joda
|
||||
- samples/server/petstore/jaxrs-resteasy/default-value
|
||||
- samples/server/petstore/jaxrs-cxf
|
||||
- samples/server/petstore/jaxrs-cxf-annotated-base-path
|
||||
- samples/server/petstore/jaxrs-cxf-cdi
|
||||
- samples/server/petstore/jaxrs-cxf-cdi-default-value
|
||||
- samples/server/petstore/jaxrs-cxf-non-spring-app
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
@ -1,7 +0,0 @@
|
||||
generatorName: jaxrs-cxf-cdi
|
||||
outputDir: samples/server/petstore/jaxrs-cxf-cdi-default-value
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/issue_8535.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
artifactId: jaxrs-cxf-cdi-default-value
|
@ -1,7 +0,0 @@
|
||||
generatorName: jaxrs-resteasy
|
||||
outputDir: samples/server/petstore/jaxrs-resteasy/default-value
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/issue_8535.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
artifactId: jaxrs-resteasy-default-value
|
@ -1,5 +1,6 @@
|
||||
package org.openapitools.codegen.java.assertions;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -8,8 +9,11 @@ import java.util.stream.Collectors;
|
||||
import org.assertj.core.api.ListAssert;
|
||||
|
||||
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||
import com.github.javaparser.ast.expr.MemberValuePair;
|
||||
import com.github.javaparser.ast.expr.MarkerAnnotationExpr;
|
||||
import com.github.javaparser.ast.expr.NormalAnnotationExpr;
|
||||
import com.github.javaparser.ast.expr.SingleMemberAnnotationExpr;
|
||||
import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
public abstract class AbstractAnnotationAssert<ACTUAL extends AbstractAnnotationAssert<ACTUAL>> extends ListAssert<AnnotationExpr> {
|
||||
|
||||
@ -37,10 +41,19 @@ public abstract class AbstractAnnotationAssert<ACTUAL extends AbstractAnnotation
|
||||
}
|
||||
|
||||
private static boolean hasAttributes(final AnnotationExpr annotation, final Map<String, String> expectedAttributesToContains) {
|
||||
final Map<String, String> actualAttributes = annotation.getChildNodes().stream()
|
||||
.filter(MemberValuePair.class::isInstance)
|
||||
.map(MemberValuePair.class::cast)
|
||||
final Map<String, String> actualAttributes;
|
||||
if (annotation instanceof SingleMemberAnnotationExpr) {
|
||||
actualAttributes = ImmutableMap.of(
|
||||
"value", ((SingleMemberAnnotationExpr) annotation).getMemberValue().toString()
|
||||
);
|
||||
} else if (annotation instanceof NormalAnnotationExpr) {
|
||||
actualAttributes = ((NormalAnnotationExpr) annotation).getPairs().stream()
|
||||
.collect(Collectors.toMap(NodeWithSimpleName::getNameAsString, pair -> pair.getValue().toString()));
|
||||
} else if (annotation instanceof MarkerAnnotationExpr) {
|
||||
actualAttributes = new HashMap<>();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unexpected annotation expression type for: " + annotation);
|
||||
}
|
||||
|
||||
return expectedAttributesToContains.entrySet().stream()
|
||||
.allMatch(expected -> Objects.equals(actualAttributes.get(expected.getKey()), expected.getValue()));
|
||||
|
@ -1,10 +1,12 @@
|
||||
package org.openapitools.codegen.java.assertions;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import org.assertj.core.api.Assertions;
|
||||
@ -33,6 +35,14 @@ public class JavaFileAssert extends AbstractAssert<JavaFileAssert, CompilationUn
|
||||
}
|
||||
}
|
||||
|
||||
public static JavaFileAssert assertThat(final File file) {
|
||||
try {
|
||||
return new JavaFileAssert(StaticJavaParser.parse(file));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Exception while reading file: " + file, e);
|
||||
}
|
||||
}
|
||||
|
||||
public MethodAssert assertMethod(final String methodName, final String... paramTypes) {
|
||||
List<MethodDeclaration> methods = paramTypes.length == 0
|
||||
? actual.getType(0).getMethodsByName(methodName)
|
||||
@ -71,6 +81,20 @@ public class JavaFileAssert extends AbstractAssert<JavaFileAssert, CompilationUn
|
||||
return this;
|
||||
}
|
||||
|
||||
public JavaFileAssert fileContains(final String... lines) {
|
||||
final String actualBody = actual.getTokenRange()
|
||||
.orElseThrow(() -> new IllegalStateException("Empty file"))
|
||||
.toString();
|
||||
Assertions.assertThat(actualBody)
|
||||
.withFailMessage(
|
||||
"File should contains lines\n====\n%s\n====\nbut actually was\n====\n%s\n====",
|
||||
Arrays.stream(lines).collect(Collectors.joining(System.lineSeparator())), actualBody
|
||||
)
|
||||
.contains(lines);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public TypeAnnotationAssert assertTypeAnnotations() {
|
||||
return new TypeAnnotationAssert(this, actual.getType(0).getAnnotations());
|
||||
}
|
||||
|
@ -1,23 +1,30 @@
|
||||
package org.openapitools.codegen.java.assertions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import org.assertj.core.api.Assertions;
|
||||
|
||||
import com.github.javaparser.ast.Node;
|
||||
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
|
||||
import com.github.javaparser.ast.body.MethodDeclaration;
|
||||
import com.github.javaparser.ast.body.Parameter;
|
||||
import com.github.javaparser.ast.nodeTypes.NodeWithName;
|
||||
|
||||
public class MethodAssert extends AbstractAssert<MethodAssert, MethodDeclaration> {
|
||||
|
||||
private final JavaFileAssert fileAssert;
|
||||
private final String methodSignature;
|
||||
|
||||
MethodAssert(final JavaFileAssert fileAssert, final MethodDeclaration methodDeclaration) {
|
||||
super(methodDeclaration, MethodAssert.class);
|
||||
this.fileAssert = fileAssert;
|
||||
this.methodSignature = methodDeclaration.getDeclarationAsString();
|
||||
}
|
||||
|
||||
public JavaFileAssert and() {
|
||||
public JavaFileAssert toFileAssert() {
|
||||
return fileAssert;
|
||||
}
|
||||
|
||||
@ -34,9 +41,83 @@ public class MethodAssert extends AbstractAssert<MethodAssert, MethodDeclaration
|
||||
public ParameterAssert hasParameter(final String paramName) {
|
||||
final Optional<Parameter> parameter = actual.getParameterByName(paramName);
|
||||
Assertions.assertThat(parameter)
|
||||
.withFailMessage("Method %s should have parameter %s, but it doesn't", actual.getNameAsString(), paramName)
|
||||
.withFailMessage("Method %s should have parameter %s, but it doesn't", methodSignature, paramName)
|
||||
.isPresent();
|
||||
return new ParameterAssert(this, parameter.get());
|
||||
}
|
||||
|
||||
public MethodAssert doesNotHaveParameter(final String paramName) {
|
||||
Assertions.assertThat(actual.getParameterByName(paramName))
|
||||
.withFailMessage("Method %s shouldn't have parameter %s, but it does", methodSignature, paramName)
|
||||
.isEmpty();
|
||||
return this;
|
||||
}
|
||||
|
||||
public MethodAssert bodyContainsLines(final String... lines) {
|
||||
Assertions.assertThat(isWithImplementation())
|
||||
.withFailMessage("Method %s is abstract", methodSignature)
|
||||
.isTrue();
|
||||
final String actualBody = actual.getTokenRange()
|
||||
.orElseThrow(() -> new IllegalStateException("Not-abstract method doesn't have body"))
|
||||
.toString();
|
||||
Assertions.assertThat(actualBody)
|
||||
.withFailMessage(
|
||||
"Method's %s body should contains lines\n====\n%s\n====\nbut actually was\n====\n%s\n====",
|
||||
methodSignature, Arrays.stream(lines).collect(Collectors.joining(System.lineSeparator())), actualBody
|
||||
)
|
||||
.contains(lines);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public MethodAssert doesNotHaveImplementation() {
|
||||
Assertions.assertThat(isWithImplementation())
|
||||
.withFailMessage("Method %s should be abstract", methodSignature)
|
||||
.isFalse();
|
||||
return this;
|
||||
}
|
||||
|
||||
public MethodAssert doesNotHaveComment() {
|
||||
Assertions.assertThat(actual.getJavadocComment())
|
||||
.withFailMessage("Method %s shouldn't contains comment, but it does", methodSignature)
|
||||
.isEmpty();
|
||||
return this;
|
||||
}
|
||||
|
||||
public MethodAssert commentContainsLines(final String... lines) {
|
||||
Assertions.assertThat(actual.getJavadocComment())
|
||||
.withFailMessage("Method %s should contains comment, but it doesn't", methodSignature)
|
||||
.isPresent();
|
||||
final String actualComment = actual.getJavadocComment().get().getContent();
|
||||
Assertions.assertThat(actualComment)
|
||||
.withFailMessage(
|
||||
"Method's %s comment should contains lines\n====\n%s\n====\nbut actually was\n====%s\n====",
|
||||
methodSignature, Arrays.stream(lines).collect(Collectors.joining(System.lineSeparator())), actualComment
|
||||
)
|
||||
.contains(lines);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public MethodAssert noneOfParameterHasAnnotation(final String annotationName) {
|
||||
actual.getParameters()
|
||||
.forEach(
|
||||
param -> Assertions.assertThat(param.getAnnotations())
|
||||
.withFailMessage("Parameter %s contains annotation %s while it shouldn't", param.getNameAsString(), annotationName)
|
||||
.extracting(NodeWithName::getNameAsString)
|
||||
.doesNotContain(annotationName)
|
||||
);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private boolean isWithImplementation() {
|
||||
final boolean isInterface = actual.getParentNode()
|
||||
.filter(ClassOrInterfaceDeclaration.class::isInstance)
|
||||
.map(ClassOrInterfaceDeclaration.class::cast)
|
||||
.map(ClassOrInterfaceDeclaration::isInterface)
|
||||
.orElse(false);
|
||||
return !(actual.isAbstract() || (isInterface && !actual.isDefault()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,24 @@
|
||||
package org.openapitools.codegen.java.jaxrs;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
import org.openapitools.codegen.java.assertions.JavaFileAssert;
|
||||
import org.openapitools.codegen.languages.JavaJAXRSCXFCDIServerCodegen;
|
||||
import org.openapitools.codegen.languages.features.CXFServerFeatures;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
|
||||
public class JavaJAXRSCXFCDIServerCodegenTest extends JavaJaxrsBaseTest {
|
||||
|
||||
@ -9,4 +26,76 @@ public class JavaJAXRSCXFCDIServerCodegenTest extends JavaJaxrsBaseTest {
|
||||
public void beforeMethod() {
|
||||
codegen = new JavaJAXRSCXFCDIServerCodegen();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleDefaultValue_issue8535() throws Exception {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/3_0/issue_8535.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true");
|
||||
|
||||
ClientOptInput input = new ClientOptInput()
|
||||
.openAPI(openAPI)
|
||||
.config(codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
Map<String, File> files = generator.opts(input).generate().stream()
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
|
||||
JavaFileAssert.assertThat(files.get("TestHeadersApi.java"))
|
||||
.assertMethod("headersTest")
|
||||
.hasParameter("headerNumber").withType("BigDecimal")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"11.2\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerString").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringQuotes").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringQuotesWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerBoolean").withType("Boolean")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"true\""));
|
||||
|
||||
JavaFileAssert.assertThat(files.get("TestQueryParamsApi.java"))
|
||||
.assertMethod("queryParamsTest")
|
||||
.hasParameter("queryNumber").withType("BigDecimal")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"11.2\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryString").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringQuotes").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringQuotesWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryBoolean").withType("Boolean")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"true\""));
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,10 @@ import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.java.assertions.JavaFileAssert;
|
||||
import org.openapitools.codegen.languages.AbstractJavaCodegen;
|
||||
import org.openapitools.codegen.languages.AbstractJavaJAXRSServerCodegen;
|
||||
import org.openapitools.codegen.languages.JavaCXFExtServerCodegen;
|
||||
@ -13,14 +16,9 @@ import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
@ -184,33 +182,6 @@ public class JavaJAXRSCXFExtServerCodegenTest extends JavaJaxrsBaseTest {
|
||||
codegen = new JavaCXFExtServerCodegenTester();
|
||||
}
|
||||
|
||||
private void checkFile(Path path, boolean fileShouldExist, String... regexes) {
|
||||
if (!fileShouldExist) {
|
||||
assertFalse(path.toFile().exists());
|
||||
return;
|
||||
}
|
||||
|
||||
assertTrue(path.toFile().exists());
|
||||
|
||||
String contents = null;
|
||||
try {
|
||||
contents = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
fail("Unable to evaluate file contents");
|
||||
}
|
||||
|
||||
for (String regex : regexes)
|
||||
assertTrue(Pattern.compile(regex).matcher(contents).find());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<CodegenOperation> getOperationsList(Map<String, Object> templateData) {
|
||||
assertTrue(templateData.get("operations") instanceof Map);
|
||||
Map<String, Object> operations = (Map<String, Object>) templateData.get("operations");
|
||||
assertTrue(operations.get("operation") instanceof List);
|
||||
return (List<CodegenOperation>) operations.get("operation");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAdditionalPropertiesPutForConfigValues() throws Exception {
|
||||
JavaCXFExtServerCodegenTester testerCodegen = (JavaCXFExtServerCodegenTester) this.codegen;
|
||||
@ -379,29 +350,25 @@ public class JavaJAXRSCXFExtServerCodegenTest extends JavaJaxrsBaseTest {
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
generator.opts(input).generate();
|
||||
|
||||
String reGetPetById = "(?s)(?m)public Pet getPetById\\(Long petId\\) \\{" // split
|
||||
+ ".*" // split
|
||||
+ "Pet response = new Pet\\(\\);" // split
|
||||
+ ".*" // split
|
||||
+ "return response;\\s+" // split
|
||||
+ "\\}"; // split
|
||||
checkFile(Paths.get(outputPath + "/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java"), true,
|
||||
reGetPetById);
|
||||
JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java"))
|
||||
.assertMethod("getPetById")
|
||||
.bodyContainsLines(
|
||||
"Pet response = new Pet();",
|
||||
"return response;"
|
||||
);
|
||||
|
||||
String reFindPetsByStatusTest = "(?s)(?m)public void findPetsByStatusTest\\(\\) throws Exception \\{\\s+"
|
||||
+ ".*" // split
|
||||
+ "List<String> status = new ArrayList<>\\(\\);" // split
|
||||
+ ".*" // split
|
||||
+ "List<Pet> response = api\\.findPetsByStatus\\(status\\);" // split
|
||||
+ ".*" // split
|
||||
+ "validate\\(response\\);\\s+" // split
|
||||
+ "\\}";
|
||||
checkFile(Paths.get(outputPath + "/src/test/java/org/openapitools/api/PetApiTest.java"), true,
|
||||
reFindPetsByStatusTest);
|
||||
JavaFileAssert.assertThat(Paths.get(outputPath + "/src/test/java/org/openapitools/api/PetApiTest.java"))
|
||||
.assertMethod("findPetsByStatusTest")
|
||||
.bodyContainsLines(
|
||||
"List<String> status = new ArrayList<>();",
|
||||
"// List<Pet> response = api.findPetsByStatus(status);",
|
||||
"// validate(response);"
|
||||
);
|
||||
|
||||
checkFile(Paths.get(outputPath + "/src/main/resources/test-data.json"), false);
|
||||
|
||||
checkFile(Paths.get(outputPath + "/test-data-control.json"), false);
|
||||
Assertions.assertThat(Paths.get(outputPath + "/src/main/resources/test-data.json"))
|
||||
.doesNotExist();
|
||||
Assertions.assertThat(Paths.get(outputPath + "/test-data-control.json"))
|
||||
.doesNotExist();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -424,28 +391,34 @@ public class JavaJAXRSCXFExtServerCodegenTest extends JavaJaxrsBaseTest {
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
generator.opts(input).generate();
|
||||
|
||||
String reInitCache = "(?s)(?m)\\{\\s+" + "try \\{\\s+"
|
||||
+ "File cacheFile = new File\\(System\\.getProperty\\(\"jaxrs\\.test\\.server\\.json\",\\s+\"(.+)\"\\)\\);\\s+"
|
||||
+ "cache = JsonCache\\.Factory\\.instance\\.get\\(\"test-data\"\\)\\.load\\(cacheFile\\)\\.child\\(\"/org\\.openapitools\\.api/PetApi\"\\);";
|
||||
String reGetPetById = "(?s)(?m)public Pet getPetById\\(Long petId\\) \\{.*" // split
|
||||
+ "try \\{\\s*" // split
|
||||
+ "Pet response = cache\\.getObject\\(\"/getPetById/response\", Pet\\.class\\);";
|
||||
checkFile(Paths.get(outputPath + "/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java"), true,
|
||||
reInitCache, reGetPetById);
|
||||
JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java"))
|
||||
.fileContains(
|
||||
"File cacheFile = new File(System.getProperty(\"jaxrs.test.server.json\"",
|
||||
"cache = JsonCache.Factory.instance.get(\"test-data\").load(cacheFile).child(\"/org.openapitools.api/PetApi\");"
|
||||
)
|
||||
.assertMethod("getPetById")
|
||||
.bodyContainsLines(
|
||||
"Pet response = cache.getObject(\"/getPetById/response\", Pet.class);"
|
||||
);
|
||||
|
||||
reInitCache = "(?s)(?m)public static void beforeClass\\(\\) throws Exception \\{\\s+"
|
||||
+ "File cacheFile = new File\\(System\\.getProperty\\(\"jaxrs\\.test\\.client\\.json\",\\s+"
|
||||
+ "\".*src(?:\\\\\\\\|/)main(?:\\\\\\\\|/)resources(?:\\\\\\\\|/)test-data\\.json\"\\)\\);\\s+"
|
||||
+ "cache = JsonCache\\.Factory\\.instance.get\\(\"test-data\"\\)\\.load\\(cacheFile\\)"
|
||||
+ "\\.child\\(\"/org\\.openapitools\\.api/PetApi\"\\);";
|
||||
String reAddPetTest = "public void addPetTest\\(\\) throws Exception \\{\\s+"
|
||||
+ "Pet pet = cache\\.getObject\\(\"/addPet/pet\", Pet\\.class\\);";
|
||||
checkFile(Paths.get(outputPath + "/src/test/java/org/openapitools/api/PetApiTest.java"), true, reInitCache,
|
||||
reAddPetTest);
|
||||
|
||||
checkFile(Paths.get(outputPath + "/src/main/resources/test-data.json"), true);
|
||||
JavaFileAssert.assertThat(Paths.get(outputPath + "/src/test/java/org/openapitools/api/PetApiTest.java"))
|
||||
.assertMethod("beforeClass")
|
||||
.bodyContainsLines(
|
||||
"File cacheFile = new File(System.getProperty(\"jaxrs.test.client.json\",",
|
||||
"cache = JsonCache.Factory.instance.get(\"test-data\").load(cacheFile).child(\"/org.openapitools.api/PetApi\");",
|
||||
"validator = Validation.buildDefaultValidatorFactory().getValidator();"
|
||||
)
|
||||
.toFileAssert()
|
||||
.assertMethod("addPetTest")
|
||||
.bodyContainsLines(
|
||||
"Pet pet = cache.getObject(\"/addPet/pet\", Pet.class);"
|
||||
);
|
||||
|
||||
checkFile(Paths.get(outputPath + "/test-data-control.json"), true);
|
||||
Assertions.assertThat(Paths.get(outputPath + "/src/main/resources/test-data.json"))
|
||||
.exists();
|
||||
Assertions.assertThat(Paths.get(outputPath + "/test-data-control.json"))
|
||||
.exists();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -8,6 +8,7 @@ import io.swagger.v3.oas.models.servers.Server;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.config.CodegenConfigurator;
|
||||
import org.openapitools.codegen.java.assertions.JavaFileAssert;
|
||||
import org.openapitools.codegen.languages.AbstractJavaJAXRSServerCodegen;
|
||||
import org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen;
|
||||
import org.openapitools.codegen.languages.features.CXFServerFeatures;
|
||||
@ -23,6 +24,8 @@ import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.openapitools.codegen.TestUtils.assertFileContains;
|
||||
import static org.openapitools.codegen.TestUtils.validateJavaSourceFiles;
|
||||
@ -32,6 +35,8 @@ import static org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen.RETU
|
||||
import static org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen.SUPPORT_ASYNC;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
* Unit-Test for {@link org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen}.
|
||||
*
|
||||
@ -610,4 +615,76 @@ public class JavaJAXRSSpecServerCodegenTest extends JavaJaxrsBaseTest {
|
||||
TestUtils.ensureContainsFile(files, output, "src/gen/java/org/openapitools/model/Options.java");
|
||||
TestUtils.assertFileContains(output.toPath().resolve("src/gen/java/org/openapitools/model/Options.java"), "List< @Pattern(regexp=\"^[A-Z].*\")String> getA()");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleDefaultValue_issue8535() throws Exception {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/3_0/issue_8535.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true");
|
||||
|
||||
ClientOptInput input = new ClientOptInput()
|
||||
.openAPI(openAPI)
|
||||
.config(codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
Map<String, File> files = generator.opts(input).generate().stream()
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
|
||||
JavaFileAssert.assertThat(files.get("TestHeadersApi.java"))
|
||||
.assertMethod("headersTest")
|
||||
.hasParameter("headerNumber").withType("BigDecimal")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"11.2\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerString").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringQuotes").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringQuotesWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerBoolean").withType("Boolean")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"true\""));
|
||||
|
||||
JavaFileAssert.assertThat(files.get("TestQueryParamsApi.java"))
|
||||
.assertMethod("queryParamsTest")
|
||||
.hasParameter("queryNumber").withType("BigDecimal")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"11.2\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryString").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringQuotes").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringQuotesWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryBoolean").withType("Boolean")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"true\""));
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,21 @@
|
||||
package org.openapitools.codegen.java.jaxrs;
|
||||
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.MapSchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
import org.openapitools.codegen.TestUtils;
|
||||
import org.openapitools.codegen.java.assertions.JavaFileAssert;
|
||||
import org.openapitools.codegen.languages.JavaResteasyServerCodegen;
|
||||
import org.openapitools.codegen.languages.features.CXFServerFeatures;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@ -16,6 +23,14 @@ import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
public class JavaJaxrsResteasyServerCodegenModelTest extends JavaJaxrsBaseTest {
|
||||
|
||||
@BeforeMethod
|
||||
@ -60,4 +75,76 @@ public class JavaJaxrsResteasyServerCodegenModelTest extends JavaJaxrsBaseTest {
|
||||
Assert.assertEquals(floatParam.defaultValue, floatVal);
|
||||
Assert.assertEquals(doubleParam.defaultValue, doubleVal);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleDefaultValue_issue8535() throws Exception {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/3_0/issue_8535.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true");
|
||||
|
||||
ClientOptInput input = new ClientOptInput()
|
||||
.openAPI(openAPI)
|
||||
.config(codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
Map<String, File> files = generator.opts(input).generate().stream()
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
|
||||
JavaFileAssert.assertThat(files.get("TestHeadersApi.java"))
|
||||
.assertMethod("headersTest")
|
||||
.hasParameter("headerNumber").withType("BigDecimal")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"11.2\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerString").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringQuotes").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringQuotesWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerBoolean").withType("Boolean")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"true\""));
|
||||
|
||||
JavaFileAssert.assertThat(files.get("TestQueryParamsApi.java"))
|
||||
.assertMethod("queryParamsTest")
|
||||
.hasParameter("queryNumber").withType("BigDecimal")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"11.2\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryString").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringQuotes").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringQuotesWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryBoolean").withType("Boolean")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DefaultValue", ImmutableMap.of("value", "\"true\""));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.openapitools.codegen.java.jaxrs;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
@ -12,6 +13,7 @@ import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.TestUtils;
|
||||
import org.openapitools.codegen.java.assertions.JavaFileAssert;
|
||||
import org.openapitools.codegen.languages.JavaJerseyServerCodegen;
|
||||
import org.openapitools.codegen.languages.features.CXFServerFeatures;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
@ -29,6 +31,7 @@ import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class JavaJerseyServerCodegenTest extends JavaJaxrsBaseTest {
|
||||
@ -169,4 +172,76 @@ public class JavaJerseyServerCodegenTest extends JavaJaxrsBaseTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleDefaultValue_issue8535() throws Exception {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/3_0/issue_8535.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true");
|
||||
|
||||
ClientOptInput input = new ClientOptInput()
|
||||
.openAPI(openAPI)
|
||||
.config(codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
Map<String, File> files = generator.opts(input).generate().stream()
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
|
||||
JavaFileAssert.assertThat(files.get("TestHeadersApi.java"))
|
||||
.assertMethod("headersTest")
|
||||
.hasParameter("headerNumber").withType("BigDecimal")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"11.2\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerString").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringQuotes").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringQuotesWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerBoolean").withType("Boolean")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"true\""));
|
||||
|
||||
JavaFileAssert.assertThat(files.get("TestQueryParamsApi.java"))
|
||||
.assertMethod("queryParamsTest")
|
||||
.hasParameter("queryNumber").withType("BigDecimal")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"11.2\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryString").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringQuotes").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringQuotesWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryBoolean").withType("Boolean")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("defaultValue", "\"true\""));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,7 +39,10 @@ import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.openapitools.codegen.java.assertions.JavaFileAssert;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
@ -127,11 +130,10 @@ public class SpringCodegenTest {
|
||||
.containsWithNameAndAttributes("RequestParam", ImmutableMap.of("required", "false", "value", "\"limit\""))
|
||||
.toParameter()
|
||||
.toMethod()
|
||||
.hasParameter("animalParams").withType("AnimalParams");
|
||||
|
||||
// todo: to remove
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ZebrasApi.java"),
|
||||
"AnimalParams");
|
||||
.hasParameter("animalParams").withType("AnimalParams")
|
||||
.toMethod()
|
||||
.commentContainsLines("GET /zebras", "@param limit (optional)")
|
||||
.bodyContainsLines("return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)");
|
||||
|
||||
JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/model/AnimalParams.java"))
|
||||
.hasImports("org.springframework.format.annotation.DateTimeFormat")
|
||||
@ -142,15 +144,11 @@ public class SpringCodegenTest {
|
||||
.toType()
|
||||
.hasProperty("lastSeen").withType("OffsetDateTime")
|
||||
.assertPropertyAnnotations()
|
||||
.containsWithNameAndAttributes("DateTimeFormat", ImmutableMap.of("iso", "DateTimeFormat.ISO.DATE_TIME"));
|
||||
|
||||
// todo: to remove
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/AnimalParams.java"),
|
||||
"@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)", "@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)");
|
||||
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/AnimalParams.java"),
|
||||
"import org.springframework.format.annotation.DateTimeFormat;"
|
||||
);
|
||||
.containsWithNameAndAttributes("DateTimeFormat", ImmutableMap.of("iso", "DateTimeFormat.ISO.DATE_TIME"))
|
||||
.toProperty().toType()
|
||||
.assertMethod("born", "LocalDate")
|
||||
.bodyContainsLines("this.born = born")
|
||||
.doesNotHaveComment();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -179,9 +177,22 @@ public class SpringCodegenTest {
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
|
||||
generator.opts(input).generate();
|
||||
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ElephantsApi.java"), "@CookieValue");
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ZebrasApi.java"), "@CookieValue");
|
||||
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/BirdsApi.java"), "@CookieValue");
|
||||
JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ElephantsApi.java"))
|
||||
.assertMethod("getElephants", "String", "BigDecimal")
|
||||
.hasParameter("userToken")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("CookieValue", ImmutableMap.of("name", "\"userToken\""));
|
||||
|
||||
JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ZebrasApi.java"))
|
||||
.assertMethod("getZebras", "String")
|
||||
.hasParameter("userToken")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("CookieValue", ImmutableMap.of("name", "\"userToken\""));
|
||||
|
||||
JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/api/BirdsApi.java"))
|
||||
.assertMethod("getBirds", "BigDecimal")
|
||||
.doesNotHaveParameter("userToken")
|
||||
.noneOfParameterHasAnnotation("CookieValue");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -276,22 +287,19 @@ public class SpringCodegenTest {
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
|
||||
generator.opts(input).generate();
|
||||
|
||||
assertFileContains(
|
||||
Paths.get(outputPath + "/src/main/java/org/openapitools/api/ElephantsApi.java"),
|
||||
"import org.springframework.format.annotation.DateTimeFormat;"
|
||||
);
|
||||
assertFileContains(
|
||||
Paths.get(outputPath + "/src/main/java/org/openapitools/api/ElephantsApi.java"),
|
||||
"@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)"
|
||||
);
|
||||
assertFileContains(
|
||||
Paths.get(outputPath + "/src/main/java/org/openapitools/api/ZebrasApi.java"),
|
||||
"import org.springframework.format.annotation.DateTimeFormat;"
|
||||
);
|
||||
assertFileContains(
|
||||
Paths.get(outputPath + "/src/main/java/org/openapitools/api/ZebrasApi.java"),
|
||||
"@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)"
|
||||
);
|
||||
JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ElephantsApi.java"))
|
||||
.hasImports("org.springframework.format.annotation.DateTimeFormat")
|
||||
.assertMethod("getElephants", "LocalDate")
|
||||
.hasParameter("startDate")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DateTimeFormat", ImmutableMap.of("iso", "DateTimeFormat.ISO.DATE"));
|
||||
|
||||
JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ZebrasApi.java"))
|
||||
.hasImports("org.springframework.format.annotation.DateTimeFormat")
|
||||
.assertMethod("getZebras", "OffsetDateTime")
|
||||
.hasParameter("startDateTime")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("DateTimeFormat", ImmutableMap.of("iso", "DateTimeFormat.ISO.DATE_TIME"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -339,9 +347,15 @@ public class SpringCodegenTest {
|
||||
|
||||
generator.opts(input).generate();
|
||||
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ExampleApi.java"),
|
||||
"@RequestParam(value = \"format\"",
|
||||
"@RequestParam(value = \"query\"");
|
||||
JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ExampleApi.java"))
|
||||
.assertMethod("exampleApiGet", "String", "Format")
|
||||
.hasParameter("query")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestParam", ImmutableMap.of("value", "\"query\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("format")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestParam", ImmutableMap.of("value", "\"format\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -371,8 +385,12 @@ public class SpringCodegenTest {
|
||||
|
||||
generator.opts(input).generate();
|
||||
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ExampleApi.java"),
|
||||
"@RequestParam(value = \"start\"");
|
||||
JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ExampleApi.java"))
|
||||
.assertMethod("exampleApiGet", "OffsetDateTime")
|
||||
.hasParameter("start")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestParam", ImmutableMap.of("value", "\"start\""))
|
||||
.containsWithNameAndAttributes("DateTimeFormat", ImmutableMap.of("iso", "DateTimeFormat.ISO.DATE_TIME"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -496,6 +514,12 @@ public class SpringCodegenTest {
|
||||
|
||||
generator.opts(input).generate();
|
||||
|
||||
JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ExampleApi.java"))
|
||||
.assertMethod("exampleApiPost", "InlineObject")
|
||||
.hasParameter("inlineObject")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestBody", ImmutableMap.of("required", "false"));
|
||||
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ExampleApi.java"),
|
||||
"@RequestBody(required = false");
|
||||
}
|
||||
@ -536,14 +560,17 @@ public class SpringCodegenTest {
|
||||
final Map<String, File> files = generateFiles(codegen, "src/test/resources/3_0/form-multipart-binary-array.yaml");
|
||||
|
||||
// Check that the delegate handles the array
|
||||
final File multipartArrayApiDelegate = files.get("MultipartArrayApiDelegate.java");
|
||||
assertFileContains(multipartArrayApiDelegate.toPath(), "List<MultipartFile> files");
|
||||
JavaFileAssert.assertThat(files.get("MultipartArrayApiDelegate.java"))
|
||||
.assertMethod("multipartArray", "List<MultipartFile>")
|
||||
.hasParameter("files").withType("List<MultipartFile>");
|
||||
|
||||
// Check that the api handles the array
|
||||
final File multipartArrayApi = files.get("MultipartArrayApi.java");
|
||||
assertFileContains(multipartArrayApi.toPath(), "List<MultipartFile> files",
|
||||
"@ApiParam(value = \"Many files\")",
|
||||
"@RequestPart(value = \"files\", required = false)");
|
||||
JavaFileAssert.assertThat(files.get("MultipartArrayApi.java"))
|
||||
.assertMethod("multipartArray", "List<MultipartFile>")
|
||||
.hasParameter("files").withType("List<MultipartFile>")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("value", "\"Many files\""))
|
||||
.containsWithNameAndAttributes("RequestPart", ImmutableMap.of("value", "\"files\"", "required", "false"));
|
||||
|
||||
// UPDATE: the following test has been ignored due to https://github.com/OpenAPITools/openapi-generator/pull/11081/
|
||||
// We will contact the contributor of the following test to see if the fix will break their use cases and
|
||||
@ -553,17 +580,29 @@ public class SpringCodegenTest {
|
||||
// assertFileContains(multipartSingleApiDelegate.toPath(), "MultipartFile file");
|
||||
|
||||
// Check that the api handles the single file
|
||||
final File multipartSingleApi = files.get("MultipartSingleApi.java");
|
||||
assertFileContains(multipartSingleApi.toPath(), "MultipartFile file",
|
||||
"@ApiParam(value = \"One file\")",
|
||||
"@RequestPart(value = \"file\", required = false)");
|
||||
JavaFileAssert.assertThat(files.get("MultipartSingleApi.java"))
|
||||
.assertMethod("multipartSingle", "MultipartFile")
|
||||
.hasParameter("file").withType("MultipartFile")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("value", "\"One file\""))
|
||||
.containsWithNameAndAttributes("RequestPart", ImmutableMap.of("value", "\"file\"", "required", "false"));
|
||||
|
||||
// Check that api validates mixed multipart request
|
||||
final File multipartMixedApi = files.get("MultipartMixedApi.java");
|
||||
assertFileContains(multipartMixedApi.toPath(), "MultipartFile file",
|
||||
"@Valid @RequestParam(value = \"status\", required = true)",
|
||||
"@RequestPart(value = \"file\", required = true)",
|
||||
"@Valid @RequestParam(value = \"marker\", required = false)");
|
||||
JavaFileAssert.assertThat(files.get("MultipartMixedApi.java"))
|
||||
.assertMethod("multipartMixed", "MultipartMixedStatus", "MultipartFile", "MultipartMixedMarker")
|
||||
.hasParameter("status").withType("MultipartMixedStatus")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithName("Valid")
|
||||
.containsWithNameAndAttributes("ApiParam", ImmutableMap.of("value", "\"\""))
|
||||
.containsWithNameAndAttributes("RequestParam", ImmutableMap.of("value", "\"status\"", "required", "true"))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("file").withType("MultipartFile")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestPart", ImmutableMap.of("value", "\"file\"", "required", "true"))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("marker").withType("MultipartMixedMarker")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestParam", ImmutableMap.of("value", "\"marker\"", "required", "false"));
|
||||
}
|
||||
|
||||
// Helper function, intended to reduce boilerplate
|
||||
@ -1015,4 +1054,114 @@ public class SpringCodegenTest {
|
||||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Address.java"),
|
||||
"@JsonValue", "import com.fasterxml.jackson.annotation.JsonValue;");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldPurAdditionalModelTypesOverAllModels() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/3_0/petstore.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
SpringCodegen codegen = new SpringCodegen();
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
codegen.additionalProperties().put(SpringCodegen.ADDITIONAL_MODEL_TYPE_ANNOTATIONS, "@path.Annotation(param1 = \"test1\", param2 = 3);@path.Annotation2;@custom.Annotation");
|
||||
|
||||
ClientOptInput input = new ClientOptInput();
|
||||
input.openAPI(openAPI);
|
||||
input.config(codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "false");
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
|
||||
generator.opts(input).generate();
|
||||
|
||||
File[] generatedModels = new File(outputPath + "/src/main/java/org/openapitools/model").listFiles();
|
||||
Assertions.assertThat(generatedModels).isNotEmpty();
|
||||
|
||||
for (File modelPath : generatedModels) {
|
||||
JavaFileAssert.assertThat(modelPath)
|
||||
.assertTypeAnnotations()
|
||||
.containsWithName("custom.Annotation")
|
||||
.containsWithName("path.Annotation2")
|
||||
.containsWithNameAndAttributes("path.Annotation", ImmutableMap.of("param1", "\"test1\"", "param2", "3"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleDefaultValue_issue8535() throws Exception {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/3_0/issue_8535.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
SpringCodegen codegen = new SpringCodegen();
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true");
|
||||
|
||||
ClientOptInput input = new ClientOptInput()
|
||||
.openAPI(openAPI)
|
||||
.config(codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
Map<String, File> files = generator.opts(input).generate().stream()
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
|
||||
JavaFileAssert.assertThat(files.get("TestHeadersApi.java"))
|
||||
.assertMethod("headersTest")
|
||||
.hasParameter("headerNumber").withType("BigDecimal")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestHeader", ImmutableMap.of("defaultValue", "\"11.2\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerString").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestHeader", ImmutableMap.of("defaultValue", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestHeader", ImmutableMap.of("defaultValue", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringQuotes").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestHeader", ImmutableMap.of("defaultValue", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerStringQuotesWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestHeader", ImmutableMap.of("defaultValue", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("headerBoolean").withType("Boolean")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestHeader", ImmutableMap.of("defaultValue", "\"true\""));
|
||||
|
||||
JavaFileAssert.assertThat(files.get("TestQueryParamsApi.java"))
|
||||
.assertMethod("queryParamsTest")
|
||||
.hasParameter("queryNumber").withType("BigDecimal")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestParam", ImmutableMap.of("defaultValue", "\"11.2\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryString").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestParam", ImmutableMap.of("defaultValue", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestParam", ImmutableMap.of("defaultValue", "\"qwerty\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringQuotes").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestParam", ImmutableMap.of("defaultValue", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryStringQuotesWrapped").withType("String")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestParam", ImmutableMap.of("defaultValue", "\"qwerty\\\"with quotes\\\" test\""))
|
||||
.toParameter().toMethod()
|
||||
.hasParameter("queryBoolean").withType("Boolean")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("RequestParam", ImmutableMap.of("defaultValue", "\"true\""));
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -1,10 +0,0 @@
|
||||
pom.xml
|
||||
src/gen/java/org/openapitools/api/TestHeadersApi.java
|
||||
src/gen/java/org/openapitools/api/TestHeadersApiService.java
|
||||
src/gen/java/org/openapitools/api/TestQueryParamsApi.java
|
||||
src/gen/java/org/openapitools/api/TestQueryParamsApiService.java
|
||||
src/gen/java/org/openapitools/model/TestResponse.java
|
||||
src/main/java/org/openapitools/api/RestApplication.java
|
||||
src/main/java/org/openapitools/api/impl/TestHeadersApiServiceImpl.java
|
||||
src/main/java/org/openapitools/api/impl/TestQueryParamsApiServiceImpl.java
|
||||
src/main/webapp/WEB-INF/beans.xml
|
@ -1 +0,0 @@
|
||||
6.0.0-SNAPSHOT
|
@ -1,121 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>jaxrs-cxf-cdi-default-value</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>jaxrs-cxf-cdi-default-value</name>
|
||||
<version>1.0.0</version>
|
||||
|
||||
|
||||
<build>
|
||||
<!-- Main source directory -->
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<fork>true</fork>
|
||||
<meminitial>128m</meminitial>
|
||||
<maxmem>512m</maxmem>
|
||||
<compilerArgs>
|
||||
<arg>-Xlint:all</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Add src/gen/java to compilation -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.9.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>src/gen/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Java EE 7 doesn't need a web.xml -->
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/javax/javaee-api -->
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
<version>7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxrs -->
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||
<!-- Version is just a guess -->
|
||||
<!-- Require at lease CXF 3.1.2 since HTTP PATCH support was added on this version -->
|
||||
<version>3.1.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||
<version>[2.8.3,2.12.1]</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger annotations -->
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>[1.5.3,1.5.16]</version>
|
||||
</dependency>
|
||||
|
||||
<!-- @Nullable annotation -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
<version>${beanvalidation-version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.10.13</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<beanvalidation-version>2.0.2</beanvalidation-version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -1,49 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.model.TestResponse;
|
||||
import org.openapitools.api.TestHeadersApiService;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.cxf.jaxrs.ext.PATCH;
|
||||
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
|
||||
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.*;
|
||||
@Path("/test-headers")
|
||||
@RequestScoped
|
||||
|
||||
@Api(description = "the test-headers API")
|
||||
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSCXFCDIServerCodegen")
|
||||
|
||||
public class TestHeadersApi {
|
||||
|
||||
@Context SecurityContext securityContext;
|
||||
|
||||
@Inject TestHeadersApiService delegate;
|
||||
|
||||
|
||||
@GET
|
||||
|
||||
|
||||
@Produces({ "application/json" })
|
||||
@ApiOperation(value = "test headers", notes = "desc", response = TestResponse.class, tags={ "verify-default-value" })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "default response", response = TestResponse.class) })
|
||||
public Response headersTest( @ApiParam(value = "" , defaultValue="11.2")@HeaderParam("headerNumber") BigDecimal headerNumber, @ApiParam(value = "" , defaultValue="qwerty")@HeaderParam("headerString") String headerString, @ApiParam(value = "" , defaultValue="qwerty")@HeaderParam("headerStringWrapped") String headerStringWrapped, @ApiParam(value = "" , defaultValue="qwerty\"with quotes\" test")@HeaderParam("headerStringQuotes") String headerStringQuotes, @ApiParam(value = "" , defaultValue="qwerty\"with quotes\" test")@HeaderParam("headerStringQuotesWrapped") String headerStringQuotesWrapped, @ApiParam(value = "" , defaultValue="true")@HeaderParam("headerBoolean") Boolean headerBoolean) {
|
||||
return delegate.headersTest(headerNumber, headerString, headerStringWrapped, headerStringQuotes, headerStringQuotesWrapped, headerBoolean, securityContext);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.openapitools.api.*;
|
||||
import org.openapitools.model.*;
|
||||
|
||||
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
|
||||
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.model.TestResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSCXFCDIServerCodegen")
|
||||
public interface TestHeadersApiService {
|
||||
public Response headersTest(BigDecimal headerNumber, String headerString, String headerStringWrapped, String headerStringQuotes, String headerStringQuotesWrapped, Boolean headerBoolean, SecurityContext securityContext);
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.model.TestResponse;
|
||||
import org.openapitools.api.TestQueryParamsApiService;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.cxf.jaxrs.ext.PATCH;
|
||||
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
|
||||
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.*;
|
||||
@Path("/test-query-params")
|
||||
@RequestScoped
|
||||
|
||||
@Api(description = "the test-query-params API")
|
||||
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSCXFCDIServerCodegen")
|
||||
|
||||
public class TestQueryParamsApi {
|
||||
|
||||
@Context SecurityContext securityContext;
|
||||
|
||||
@Inject TestQueryParamsApiService delegate;
|
||||
|
||||
|
||||
@GET
|
||||
|
||||
|
||||
@Produces({ "application/json" })
|
||||
@ApiOperation(value = "test query params", notes = "desc", response = TestResponse.class, tags={ "verify-default-value" })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "default response", response = TestResponse.class) })
|
||||
public Response queryParamsTest(@ApiParam(value = "", defaultValue="11.2") @DefaultValue("11.2") @QueryParam("queryNumber") BigDecimal queryNumber, @ApiParam(value = "", defaultValue="qwerty") @DefaultValue("qwerty") @QueryParam("queryString") String queryString, @ApiParam(value = "", defaultValue="qwerty") @DefaultValue("qwerty") @QueryParam("queryStringWrapped") String queryStringWrapped, @ApiParam(value = "", defaultValue="qwerty\"with quotes\" test") @DefaultValue("qwerty\"with quotes\" test") @QueryParam("queryStringQuotes") String queryStringQuotes, @ApiParam(value = "", defaultValue="qwerty\"with quotes\" test") @DefaultValue("qwerty\"with quotes\" test") @QueryParam("queryStringQuotesWrapped") String queryStringQuotesWrapped, @ApiParam(value = "", defaultValue="true") @DefaultValue("true") @QueryParam("queryBoolean") Boolean queryBoolean) {
|
||||
return delegate.queryParamsTest(queryNumber, queryString, queryStringWrapped, queryStringQuotes, queryStringQuotesWrapped, queryBoolean, securityContext);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.openapitools.api.*;
|
||||
import org.openapitools.model.*;
|
||||
|
||||
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
|
||||
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.model.TestResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSCXFCDIServerCodegen")
|
||||
public interface TestQueryParamsApiService {
|
||||
public Response queryParamsTest(BigDecimal queryNumber, String queryString, String queryStringWrapped, String queryStringQuotes, String queryStringQuotesWrapped, Boolean queryBoolean, SecurityContext securityContext);
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
|
||||
public class TestResponse {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String stringField = "asd";
|
||||
|
||||
private BigDecimal numberField = new BigDecimal("11");
|
||||
|
||||
private Boolean booleanField = true;
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
public TestResponse id(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@JsonProperty("id")
|
||||
@NotNull
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
public TestResponse stringField(String stringField) {
|
||||
this.stringField = stringField;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@JsonProperty("stringField")
|
||||
@NotNull
|
||||
public String getStringField() {
|
||||
return stringField;
|
||||
}
|
||||
public void setStringField(String stringField) {
|
||||
this.stringField = stringField;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
public TestResponse numberField(BigDecimal numberField) {
|
||||
this.numberField = numberField;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@JsonProperty("numberField")
|
||||
@NotNull
|
||||
public BigDecimal getNumberField() {
|
||||
return numberField;
|
||||
}
|
||||
public void setNumberField(BigDecimal numberField) {
|
||||
this.numberField = numberField;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
public TestResponse booleanField(Boolean booleanField) {
|
||||
this.booleanField = booleanField;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@JsonProperty("booleanField")
|
||||
@NotNull
|
||||
public Boolean getBooleanField() {
|
||||
return booleanField;
|
||||
}
|
||||
public void setBooleanField(Boolean booleanField) {
|
||||
this.booleanField = booleanField;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
TestResponse testResponse = (TestResponse) o;
|
||||
return Objects.equals(id, testResponse.id) &&
|
||||
Objects.equals(stringField, testResponse.stringField) &&
|
||||
Objects.equals(numberField, testResponse.numberField) &&
|
||||
Objects.equals(booleanField, testResponse.booleanField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, stringField, numberField, booleanField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class TestResponse {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" stringField: ").append(toIndentedString(stringField)).append("\n");
|
||||
sb.append(" numberField: ").append(toIndentedString(numberField)).append("\n");
|
||||
sb.append(" booleanField: ").append(toIndentedString(booleanField)).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 String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import javax.ws.rs.ApplicationPath;
|
||||
import javax.ws.rs.core.Application;
|
||||
|
||||
@ApplicationPath("")
|
||||
public class RestApplication extends Application {
|
||||
// Add implementation-specific details here
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package org.openapitools.api.impl;
|
||||
|
||||
import org.openapitools.api.*;
|
||||
import org.openapitools.model.*;
|
||||
|
||||
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.model.TestResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
|
||||
@RequestScoped
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSCXFCDIServerCodegen")
|
||||
public class TestHeadersApiServiceImpl implements TestHeadersApiService {
|
||||
@Override
|
||||
public Response headersTest(BigDecimal headerNumber, String headerString, String headerStringWrapped, String headerStringQuotes, String headerStringQuotesWrapped, Boolean headerBoolean, SecurityContext securityContext) {
|
||||
// do some magic!
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package org.openapitools.api.impl;
|
||||
|
||||
import org.openapitools.api.*;
|
||||
import org.openapitools.model.*;
|
||||
|
||||
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.model.TestResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
|
||||
@RequestScoped
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSCXFCDIServerCodegen")
|
||||
public class TestQueryParamsApiServiceImpl implements TestQueryParamsApiService {
|
||||
@Override
|
||||
public Response queryParamsTest(BigDecimal queryNumber, String queryString, String queryStringWrapped, String queryStringQuotes, String queryStringQuotesWrapped, Boolean queryBoolean, SecurityContext securityContext) {
|
||||
// do some magic!
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="
|
||||
http://java.sun.com/xml/ns/javaee
|
||||
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
|
||||
|
||||
<!--
|
||||
This is just an empty file so that CDI archive scanning kicks in when
|
||||
implicit archive scanning is disabled (such as on IBM Bluemix)
|
||||
-->
|
||||
|
||||
</beans>
|
@ -1,23 +0,0 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -1,21 +0,0 @@
|
||||
README.md
|
||||
build.gradle
|
||||
pom.xml
|
||||
settings.gradle
|
||||
src/gen/java/org/openapitools/api/ApiException.java
|
||||
src/gen/java/org/openapitools/api/ApiOriginFilter.java
|
||||
src/gen/java/org/openapitools/api/ApiResponseMessage.java
|
||||
src/gen/java/org/openapitools/api/JacksonConfig.java
|
||||
src/gen/java/org/openapitools/api/NotFoundException.java
|
||||
src/gen/java/org/openapitools/api/RFC3339DateFormat.java
|
||||
src/gen/java/org/openapitools/api/RestApplication.java
|
||||
src/gen/java/org/openapitools/api/StringUtil.java
|
||||
src/gen/java/org/openapitools/api/TestHeadersApi.java
|
||||
src/gen/java/org/openapitools/api/TestHeadersApiService.java
|
||||
src/gen/java/org/openapitools/api/TestQueryParamsApi.java
|
||||
src/gen/java/org/openapitools/api/TestQueryParamsApiService.java
|
||||
src/gen/java/org/openapitools/model/TestResponse.java
|
||||
src/main/java/org/openapitools/api/impl/TestHeadersApiServiceImpl.java
|
||||
src/main/java/org/openapitools/api/impl/TestQueryParamsApiServiceImpl.java
|
||||
src/main/webapp/WEB-INF/jboss-web.xml
|
||||
src/main/webapp/WEB-INF/web.xml
|
@ -1 +0,0 @@
|
||||
6.0.0-SNAPSHOT
|
@ -1,24 +0,0 @@
|
||||
# JAX-RS/RESTEasy server with OpenAPI
|
||||
|
||||
## Overview
|
||||
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using an
|
||||
[OpenAPI-Spec](https://openapis.org), you can easily generate a server stub.
|
||||
|
||||
This is an example of building a OpenAPI-enabled JAX-RS server.
|
||||
This example uses the [JAX-RS](https://jax-rs-spec.java.net/) framework.
|
||||
RESTEasy is used as JAX-RS implementation library and is defined as dependency.
|
||||
|
||||
To run the server, please execute the following:
|
||||
|
||||
```
|
||||
mvn -Djetty.http.port=8080 package org.eclipse.jetty:jetty-maven-plugin:run
|
||||
```
|
||||
|
||||
You can then view the OpenAPI v2 specification here:
|
||||
|
||||
```
|
||||
http://localhost:8080/swagger.json
|
||||
```
|
||||
|
||||
Note that if you have configured the `host` to be something other than localhost, the calls through
|
||||
swagger-ui will be directed to that host and not localhost!
|
@ -1,36 +0,0 @@
|
||||
apply plugin: 'war'
|
||||
|
||||
project.version = "1.0.0"
|
||||
project.group = "org.openapitools"
|
||||
|
||||
repositories {
|
||||
maven { url "https://repo1.maven.org/maven2" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
providedCompile 'org.jboss.resteasy:resteasy-jaxrs:3.0.11.Final'
|
||||
providedCompile 'org.jboss.resteasy:jaxrs-api:3.0.11.Final'
|
||||
providedCompile 'org.jboss.resteasy:resteasy-validator-provider-11:3.0.11.Final'
|
||||
providedCompile 'org.jboss.resteasy:resteasy-multipart-provider:3.0.11.Final'
|
||||
providedCompile 'jakarta.annotation:jakarta.annotation-api:1.3.5'
|
||||
providedCompile 'javax:javaee-api:7.0'
|
||||
providedCompile 'org.jboss.spec.javax.servlet:jboss-servlet-api_3.0_spec:1.0.0.Final'
|
||||
compile 'io.swagger:swagger-annotations:1.5.22'
|
||||
compile 'org.jboss.resteasy:resteasy-jackson2-provider:3.0.11.Final'
|
||||
providedCompile 'jakarta.validation:jakarta.validation-api:2.0.2'
|
||||
compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.9.9'
|
||||
compile 'joda-time:joda-time:2.7'
|
||||
//TODO: swaggerFeature
|
||||
compile 'io.swagger:swagger-jaxrs:1.5.12'
|
||||
|
||||
testCompile 'junit:junit:4.13.2',
|
||||
'org.hamcrest:hamcrest-core:1.3'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir 'src/gen/java'
|
||||
}
|
||||
}
|
||||
}
|
@ -1,198 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>jaxrs-resteasy-default-value</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>jaxrs-resteasy-default-value</name>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.9.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>
|
||||
src/gen/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/javax/javaee-api -->
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
<version>7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>${swagger-core-version}</version>
|
||||
</dependency>
|
||||
<!-- @Nullable annotation -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>${slf4j-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.servlet</groupId>
|
||||
<artifactId>jakarta.servlet-api</artifactId>
|
||||
<version>${servlet-api-version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
<version>${resteasy-version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>jaxrs-api</artifactId>
|
||||
<version>3.0.12.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-validator-provider-11</artifactId>
|
||||
<version>3.6.3.SP1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-multipart-provider</artifactId>
|
||||
<version>${resteasy-version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jackson2-provider</artifactId>
|
||||
<version>${resteasy-version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.annotation</groupId>
|
||||
<artifactId>jakarta.annotation-api</artifactId>
|
||||
<version>${jakarta-annotation-version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-jaxrs</artifactId>
|
||||
<version>${swagger-core-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>6.8.8</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>junit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<groupId>org.yaml</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bsh</artifactId>
|
||||
<groupId>org.beanshell</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
<version>${beanvalidation-version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.10.13</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<swagger-core-version>1.5.22</swagger-core-version>
|
||||
<jackson-version>2.11.2</jackson-version>
|
||||
<jetty-version>9.2.9.v20150224</jetty-version>
|
||||
<resteasy-version>3.13.0.Final</resteasy-version>
|
||||
<slf4j-version>1.6.3</slf4j-version>
|
||||
<junit-version>4.13.2</junit-version>
|
||||
<servlet-api-version>4.0.4</servlet-api-version>
|
||||
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
||||
<beanvalidation-version>2.0.2</beanvalidation-version>
|
||||
</properties>
|
||||
</project>
|
@ -1 +0,0 @@
|
||||
rootProject.name = "jaxrs-resteasy-default-value"
|
@ -1,32 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
/**
|
||||
* The exception that can be used to store the HTTP status code returned by an API response.
|
||||
*/
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen")
|
||||
public class ApiException extends Exception {
|
||||
|
||||
/** The HTTP status code. */
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param code The HTTP status code.
|
||||
* @param msg The error message.
|
||||
*/
|
||||
public ApiException(int code, String msg) {
|
||||
super(msg);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP status code.
|
||||
*
|
||||
* @return The HTTP status code.
|
||||
*/
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen")
|
||||
public class ApiOriginFilter implements javax.servlet.Filter {
|
||||
public void doFilter(ServletRequest request, ServletResponse response,
|
||||
FilterChain chain) throws IOException, ServletException {
|
||||
HttpServletResponse res = (HttpServletResponse) response;
|
||||
res.addHeader("Access-Control-Allow-Origin", "*");
|
||||
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
|
||||
res.addHeader("Access-Control-Allow-Headers", "Content-Type");
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
|
||||
public void destroy() {}
|
||||
|
||||
public void init(FilterConfig filterConfig) throws ServletException {}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
@javax.xml.bind.annotation.XmlRootElement
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen")
|
||||
public class ApiResponseMessage {
|
||||
public static final int ERROR = 1;
|
||||
public static final int WARNING = 2;
|
||||
public static final int INFO = 3;
|
||||
public static final int OK = 4;
|
||||
public static final int TOO_BUSY = 5;
|
||||
|
||||
int code;
|
||||
String type;
|
||||
String message;
|
||||
|
||||
public ApiResponseMessage(){}
|
||||
|
||||
public ApiResponseMessage(int code, String message){
|
||||
this.code = code;
|
||||
switch(code){
|
||||
case ERROR:
|
||||
setType("error");
|
||||
break;
|
||||
case WARNING:
|
||||
setType("warning");
|
||||
break;
|
||||
case INFO:
|
||||
setType("info");
|
||||
break;
|
||||
case OK:
|
||||
setType("ok");
|
||||
break;
|
||||
case TOO_BUSY:
|
||||
setType("too busy");
|
||||
break;
|
||||
default:
|
||||
setType("unknown");
|
||||
break;
|
||||
}
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@XmlTransient
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
|
||||
import javax.ws.rs.ext.ContextResolver;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
import java.io.IOException;
|
||||
|
||||
@Provider
|
||||
public class JacksonConfig implements ContextResolver<ObjectMapper> {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public JacksonConfig() throws Exception {
|
||||
|
||||
objectMapper = new ObjectMapper()
|
||||
.registerModule(new JavaTimeModule())
|
||||
.setDateFormat(new RFC3339DateFormat());
|
||||
}
|
||||
|
||||
public ObjectMapper getContext(Class<?> arg0) {
|
||||
return objectMapper;
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen")
|
||||
public class NotFoundException extends ApiException {
|
||||
private int code;
|
||||
public NotFoundException (int code, String msg) {
|
||||
super(code, msg);
|
||||
this.code = code;
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.FieldPosition;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class RFC3339DateFormat extends DateFormat {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
|
||||
|
||||
private final StdDateFormat fmt = new StdDateFormat()
|
||||
.withTimeZone(TIMEZONE_Z)
|
||||
.withColonInTimeZone(true);
|
||||
|
||||
public RFC3339DateFormat() {
|
||||
this.calendar = new GregorianCalendar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date parse(String source, ParsePosition pos) {
|
||||
return fmt.parse(source, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
|
||||
return fmt.format(date, toAppendTo, fieldPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import javax.ws.rs.ApplicationPath;
|
||||
import javax.ws.rs.core.Application;
|
||||
|
||||
@ApplicationPath("")
|
||||
public class RestApplication extends Application {
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
*
|
||||
* @param array The array
|
||||
* @param value The value to search
|
||||
* @return true if the array contains the value
|
||||
*/
|
||||
public static boolean containsIgnoreCase(String[] array, String value) {
|
||||
for (String str : array) {
|
||||
if (value == null && str == null) return true;
|
||||
if (value != null && value.equalsIgnoreCase(str)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Join an array of strings with the given separator.
|
||||
* <p>
|
||||
* Note: This might be replaced by utility method from commons-lang or guava someday
|
||||
* if one of those libraries is added as dependency.
|
||||
* </p>
|
||||
*
|
||||
* @param array The array of strings
|
||||
* @param separator The separator
|
||||
* @return the resulting string
|
||||
*/
|
||||
public static String join(String[] array, String separator) {
|
||||
int len = array.length;
|
||||
if (len == 0) return "";
|
||||
|
||||
StringBuilder out = new StringBuilder();
|
||||
out.append(array[0]);
|
||||
for (int i = 1; i < len; i++) {
|
||||
out.append(separator).append(array[i]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.openapitools.model.*;
|
||||
import org.openapitools.api.TestHeadersApiService;
|
||||
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.jaxrs.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.model.TestResponse;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import org.openapitools.api.NotFoundException;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
import javax.ws.rs.*;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Path("/test-headers")
|
||||
|
||||
|
||||
@io.swagger.annotations.Api(description = "the test-headers API")
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen")
|
||||
public class TestHeadersApi {
|
||||
|
||||
@Inject TestHeadersApiService service;
|
||||
|
||||
@GET
|
||||
|
||||
|
||||
@Produces({ "application/json" })
|
||||
@io.swagger.annotations.ApiOperation(value = "test headers", notes = "desc", response = TestResponse.class, tags={ "verify-default-value", })
|
||||
@io.swagger.annotations.ApiResponses(value = {
|
||||
@io.swagger.annotations.ApiResponse(code = 200, message = "default response", response = TestResponse.class) })
|
||||
public Response headersTest( @ApiParam(value = "" , defaultValue="11.2") @HeaderParam("headerNumber") BigDecimal headerNumber, @ApiParam(value = "" , defaultValue="qwerty") @HeaderParam("headerString") String headerString, @ApiParam(value = "" , defaultValue="qwerty") @HeaderParam("headerStringWrapped") String headerStringWrapped, @ApiParam(value = "" , defaultValue="qwerty\"with quotes\" test") @HeaderParam("headerStringQuotes") String headerStringQuotes, @ApiParam(value = "" , defaultValue="qwerty\"with quotes\" test") @HeaderParam("headerStringQuotesWrapped") String headerStringQuotesWrapped, @ApiParam(value = "" , defaultValue="true") @HeaderParam("headerBoolean") Boolean headerBoolean,@Context SecurityContext securityContext)
|
||||
throws NotFoundException {
|
||||
return service.headersTest(headerNumber,headerString,headerStringWrapped,headerStringQuotes,headerStringQuotesWrapped,headerBoolean,securityContext);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.openapitools.api.*;
|
||||
import org.openapitools.model.*;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.model.TestResponse;
|
||||
|
||||
import java.util.List;
|
||||
import org.openapitools.api.NotFoundException;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen")
|
||||
public interface TestHeadersApiService {
|
||||
Response headersTest(BigDecimal headerNumber,String headerString,String headerStringWrapped,String headerStringQuotes,String headerStringQuotesWrapped,Boolean headerBoolean,SecurityContext securityContext)
|
||||
throws NotFoundException;
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.openapitools.model.*;
|
||||
import org.openapitools.api.TestQueryParamsApiService;
|
||||
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.jaxrs.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.model.TestResponse;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import org.openapitools.api.NotFoundException;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
import javax.ws.rs.*;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Path("/test-query-params")
|
||||
|
||||
|
||||
@io.swagger.annotations.Api(description = "the test-query-params API")
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen")
|
||||
public class TestQueryParamsApi {
|
||||
|
||||
@Inject TestQueryParamsApiService service;
|
||||
|
||||
@GET
|
||||
|
||||
|
||||
@Produces({ "application/json" })
|
||||
@io.swagger.annotations.ApiOperation(value = "test query params", notes = "desc", response = TestResponse.class, tags={ "verify-default-value", })
|
||||
@io.swagger.annotations.ApiResponses(value = {
|
||||
@io.swagger.annotations.ApiResponse(code = 200, message = "default response", response = TestResponse.class) })
|
||||
public Response queryParamsTest( @DefaultValue("11.2") @QueryParam("queryNumber") BigDecimal queryNumber, @DefaultValue("qwerty") @QueryParam("queryString") String queryString, @DefaultValue("qwerty") @QueryParam("queryStringWrapped") String queryStringWrapped, @DefaultValue("qwerty\"with quotes\" test") @QueryParam("queryStringQuotes") String queryStringQuotes, @DefaultValue("qwerty\"with quotes\" test") @QueryParam("queryStringQuotesWrapped") String queryStringQuotesWrapped, @DefaultValue("true") @QueryParam("queryBoolean") Boolean queryBoolean,@Context SecurityContext securityContext)
|
||||
throws NotFoundException {
|
||||
return service.queryParamsTest(queryNumber,queryString,queryStringWrapped,queryStringQuotes,queryStringQuotesWrapped,queryBoolean,securityContext);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.openapitools.api.*;
|
||||
import org.openapitools.model.*;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.model.TestResponse;
|
||||
|
||||
import java.util.List;
|
||||
import org.openapitools.api.NotFoundException;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen")
|
||||
public interface TestQueryParamsApiService {
|
||||
Response queryParamsTest(BigDecimal queryNumber,String queryString,String queryStringWrapped,String queryStringQuotes,String queryStringQuotesWrapped,Boolean queryBoolean,SecurityContext securityContext)
|
||||
throws NotFoundException;
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import javax.validation.constraints.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen")
|
||||
public class TestResponse {
|
||||
|
||||
private Integer id;
|
||||
private String stringField = "asd";
|
||||
private BigDecimal numberField = new BigDecimal("11");
|
||||
private Boolean booleanField = true;
|
||||
|
||||
/**
|
||||
**/
|
||||
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@JsonProperty("id")
|
||||
@NotNull
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@JsonProperty("stringField")
|
||||
@NotNull
|
||||
public String getStringField() {
|
||||
return stringField;
|
||||
}
|
||||
public void setStringField(String stringField) {
|
||||
this.stringField = stringField;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@JsonProperty("numberField")
|
||||
@NotNull
|
||||
public BigDecimal getNumberField() {
|
||||
return numberField;
|
||||
}
|
||||
public void setNumberField(BigDecimal numberField) {
|
||||
this.numberField = numberField;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@JsonProperty("booleanField")
|
||||
@NotNull
|
||||
public Boolean getBooleanField() {
|
||||
return booleanField;
|
||||
}
|
||||
public void setBooleanField(Boolean booleanField) {
|
||||
this.booleanField = booleanField;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
TestResponse testResponse = (TestResponse) o;
|
||||
return Objects.equals(id, testResponse.id) &&
|
||||
Objects.equals(stringField, testResponse.stringField) &&
|
||||
Objects.equals(numberField, testResponse.numberField) &&
|
||||
Objects.equals(booleanField, testResponse.booleanField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, stringField, numberField, booleanField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class TestResponse {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" stringField: ").append(toIndentedString(stringField)).append("\n");
|
||||
sb.append(" numberField: ").append(toIndentedString(numberField)).append("\n");
|
||||
sb.append(" booleanField: ").append(toIndentedString(booleanField)).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 String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
package org.openapitools.api.impl;
|
||||
|
||||
import org.openapitools.api.*;
|
||||
import org.openapitools.model.*;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.model.TestResponse;
|
||||
|
||||
import java.util.List;
|
||||
import org.openapitools.api.NotFoundException;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
|
||||
@RequestScoped
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen")
|
||||
public class TestHeadersApiServiceImpl implements TestHeadersApiService {
|
||||
public Response headersTest(BigDecimal headerNumber,String headerString,String headerStringWrapped,String headerStringQuotes,String headerStringQuotesWrapped,Boolean headerBoolean,SecurityContext securityContext)
|
||||
throws NotFoundException {
|
||||
// do some magic!
|
||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package org.openapitools.api.impl;
|
||||
|
||||
import org.openapitools.api.*;
|
||||
import org.openapitools.model.*;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.openapitools.model.TestResponse;
|
||||
|
||||
import java.util.List;
|
||||
import org.openapitools.api.NotFoundException;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
|
||||
@RequestScoped
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen")
|
||||
public class TestQueryParamsApiServiceImpl implements TestQueryParamsApiService {
|
||||
public Response queryParamsTest(BigDecimal queryNumber,String queryString,String queryStringWrapped,String queryStringQuotes,String queryStringQuotesWrapped,Boolean queryBoolean,SecurityContext securityContext)
|
||||
throws NotFoundException {
|
||||
// do some magic!
|
||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
<jboss-web>
|
||||
<context-root></context-root>
|
||||
</jboss-web>
|
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||
xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
|
||||
|
||||
<filter>
|
||||
<filter-name>ApiOriginFilter</filter-name>
|
||||
<filter-class>org.openapitools.api.ApiOriginFilter</filter-class>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>ApiOriginFilter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
</web-app>
|
Loading…
x
Reference in New Issue
Block a user