-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenAPI different default content type for pojo return and primitives #36198
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.quarkus.smallrye.openapi.test.jaxrs; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
@Path("/greeting") | ||
public class NoDefaultSecurityResource { | ||
|
||
@GET | ||
@Path("/hello") | ||
public Greeting hello() { | ||
return new Greeting("Hello there"); | ||
} | ||
|
||
@POST | ||
@Path("/hello") | ||
public Greeting hello(Greeting greeting) { | ||
return greeting; | ||
} | ||
|
||
@GET | ||
@Path("/goodbye") | ||
@Produces(MediaType.APPLICATION_XML) | ||
public Greeting byebye() { | ||
return new Greeting("Good Bye !"); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.quarkus.smallrye.openapi.test.jaxrs; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class NoDefaultSecurityTest { | ||
private static final String OPEN_API_PATH = "/q/openapi"; | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(NoDefaultSecurityResource.class, Greeting.class)); | ||
|
||
@Test | ||
public void testOpenApiNoSecurity() { | ||
RestAssured.given().queryParam("format", "JSON") | ||
.when().get(OPEN_API_PATH) | ||
.then() | ||
.body("components.securitySchemes.SecurityScheme.type", Matchers.nullValue()); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package io.quarkus.vertx.http.deployment; | ||
|
||
import static io.quarkus.arc.processor.DotNames.APPLICATION_SCOPED; | ||
import static org.jboss.jandex.AnnotationTarget.Kind.CLASS; | ||
|
||
import java.security.Permission; | ||
import java.util.HashMap; | ||
|
@@ -216,7 +215,9 @@ SyntheticBeanBuildItem initBasicAuth( | |
&& !buildTimeConfig.auth.basic.orElse(false)) { | ||
//if not explicitly enabled we make this a default bean, so it is the fallback if nothing else is defined | ||
configurator.defaultBean(); | ||
securityInformationProducer.produce(SecurityInformationBuildItem.BASIC()); | ||
if (buildTimeConfig.auth.basic.isPresent() && buildTimeConfig.auth.basic.get()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line 215
while line 218 says
so in order to have produced @phillip-kruger I don't know what was intention of this condition, can you please fix it? Thank you |
||
securityInformationProducer.produce(SecurityInformationBuildItem.BASIC()); | ||
} | ||
} | ||
|
||
return configurator.done(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
"text/plain"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #36247