Skip to content

Commit

Permalink
Tests to check content type between services and openapi
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Kruger <phillip.kruger@gmail.com>
  • Loading branch information
phillip-kruger committed Oct 25, 2023
1 parent 12ef71e commit b3857b5
Show file tree
Hide file tree
Showing 63 changed files with 7,559 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<smallrye-config.version>3.4.1</smallrye-config.version>
<smallrye-health.version>4.0.4</smallrye-health.version>
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
<smallrye-open-api.version>3.6.2</smallrye-open-api.version>
<smallrye-open-api.version>3.6.3-SNAPSHOT</smallrye-open-api.version>
<smallrye-graphql.version>2.5.1</smallrye-graphql.version>
<smallrye-opentracing.version>3.0.3</smallrye-opentracing.version>
<smallrye-fault-tolerance.version>6.2.6</smallrye-fault-tolerance.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ public class SmallRyeOpenApiProcessor {
private static final String VERT_X = "Vert.x";

static {
System.setProperty(io.smallrye.openapi.api.constants.OpenApiConstants.DEFAULT_PRODUCES_STREAMING,
"application/octet-stream");
System.setProperty(io.smallrye.openapi.api.constants.OpenApiConstants.DEFAULT_CONSUMES_STREAMING,
"application/octet-stream");
System.setProperty(io.smallrye.openapi.api.constants.OpenApiConstants.DEFAULT_PRODUCES, "application/json");
System.setProperty(io.smallrye.openapi.api.constants.OpenApiConstants.DEFAULT_CONSUMES, "application/json");
System.setProperty(io.smallrye.openapi.api.constants.OpenApiConstants.DEFAULT_PRODUCES_PRIMITIVES, "text/plain");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ public void testOpenApiPathAccessResource() {
Matchers.containsString("#/components/schemas/Greeting"));

}
}
}
171 changes: 171 additions & 0 deletions integration-tests/openapi/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quarkus-integration-tests-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-integration-test-openapi</artifactId>
<name>Quarkus - Integration Tests - OpenAPI</name>
<description>The openapi integration tests module</description>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-reactive-routes</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-web</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-component</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<!-- Minimal test dependencies to *-deployment artifacts for consistent build order -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-reactive-routes-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-jackson-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-spring-web-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<runOrder>alphabetical</runOrder>
</configuration>
</plugin>
</plugins>
</build>

<profiles>

<profile>
<id>native-image</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<!-- add some custom config, the rest comes from parent -->
<properties>
<quarkus.native.add-all-charsets>true</quarkus.native.add-all-charsets>
</properties>
</profile>

<profile>
<id>no-native</id>
<activation>
<property>
<name>!native</name>
</property>
</activation>
<!-- these properties must not be defined in the general properties,
otherwise the native profile in the parent pom is not able to override them -->
<properties>
<quarkus.package.type>uber-jar</quarkus.package.type>
</properties>
</profile>

</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.quarkus.it.openapi;

public class Greeting {
private int id;
private String salutation;

public Greeting() {

}

public Greeting(int id, String salutation) {
this.id = id;
this.salutation = salutation;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getSalutation() {
return salutation;
}

public void setSalutation(String salutation) {
this.salutation = salutation;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package io.quarkus.it.openapi.jaxrs;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;

import org.jboss.resteasy.reactive.RestResponse;

import io.smallrye.mutiny.Uni;

@Path("/jax-rs/defaultContentType")
public class BigDecimalResource {
@GET
@Path("/justBigDecimal")
public BigDecimal justBigDecimal() {
return new BigDecimal("0");
}

@POST
@Path("/justBigDecimal")
public BigDecimal justBigDecimal(BigDecimal body) {
return body;
}

@GET
@Path("/restResponseBigDecimal")
public RestResponse<BigDecimal> restResponseBigDecimal() {
return RestResponse.ok(new BigDecimal("0"));
}

@POST
@Path("/restResponseBigDecimal")
public RestResponse<BigDecimal> restResponseBigDecimal(BigDecimal body) {
return RestResponse.ok(body);
}

@GET
@Path("/optionalBigDecimal")
public Optional<BigDecimal> optionalBigDecimal() {
return Optional.of(new BigDecimal("0"));
}

@POST
@Path("/optionalBigDecimal")
public Optional<BigDecimal> optionalBigDecimal(Optional<BigDecimal> body) {
return body;
}

@GET
@Path("/uniBigDecimal")
public Uni<BigDecimal> uniBigDecimal() {
return Uni.createFrom().item(new BigDecimal("0"));
}

@GET
@Path("/completionStageBigDecimal")
public CompletionStage<BigDecimal> completionStageBigDecimal() {
return CompletableFuture.completedStage(new BigDecimal("0"));
}

@GET
@Path("/completedFutureBigDecimal")
public CompletableFuture<BigDecimal> completedFutureBigDecimal() {
return CompletableFuture.completedFuture(new BigDecimal("0"));
}

@GET
@Path("/listBigDecimal")
public List<BigDecimal> listBigDecimal() {
return Arrays.asList(new BigDecimal[] { new BigDecimal("0") });
}

@POST
@Path("/listBigDecimal")
public List<BigDecimal> listBigDecimal(List<BigDecimal> body) {
return body;
}

@GET
@Path("/arrayBigDecimal")
public BigDecimal[] arrayBigDecimal() {
return new BigDecimal[] { new BigDecimal("0") };
}

@POST
@Path("/arrayBigDecimal")
public BigDecimal[] arrayBigDecimal(BigDecimal[] body) {
return body;
}

}
Loading

0 comments on commit b3857b5

Please sign in to comment.