Skip to content

Commit ae9a4f0

Browse files
committed
fix oas 3.1 parameter resolving
1 parent fd61120 commit ae9a4f0

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/DefaultParameterExtension.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ public ResolvedParameter extractParameters(List<Annotation> annotations,
140140
components,
141141
classConsumes == null ? new String[0] : classConsumes.value(),
142142
methodConsumes == null ? new String[0] : methodConsumes.value(),
143-
jsonViewAnnotation);
143+
jsonViewAnnotation,
144+
openapi31);
144145
if (processedParameter != null) {
145146
extractParametersResult.parameters.add(processedParameter);
146147
}

modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/ReaderTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import io.swagger.v3.jaxrs2.petstore31.PetResource;
1717
import io.swagger.v3.jaxrs2.petstore31.TagResource;
1818
import io.swagger.v3.jaxrs2.resources.Misc31Resource;
19+
import io.swagger.v3.jaxrs2.resources.ParameterMaximumValueResource;
1920
import io.swagger.v3.jaxrs2.resources.ResponseReturnTypeResource;
2021
import io.swagger.v3.jaxrs2.resources.SchemaPropertiesResource;
2122
import io.swagger.v3.jaxrs2.resources.SiblingPropResource;
@@ -3940,4 +3941,32 @@ public void test4446CyclicProp() {
39403941
" $ref: '#/components/schemas/MyPojo'\n";
39413942
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
39423943
}
3944+
3945+
@Test
3946+
public void testParameterMaximumValue() {
3947+
Reader reader = new Reader(new SwaggerConfiguration().openAPI(new OpenAPI()).openAPI31(true));
3948+
3949+
OpenAPI openAPI = reader.read(ParameterMaximumValueResource.class);
3950+
String yaml = "openapi: 3.1.0\n" +
3951+
"paths:\n" +
3952+
" /test/{petId}:\n" +
3953+
" get:\n" +
3954+
" operationId: getPetById\n" +
3955+
" parameters:\n" +
3956+
" - name: petId\n" +
3957+
" in: path\n" +
3958+
" description: ID of pet that needs to be fetched\n" +
3959+
" required: true\n" +
3960+
" schema:\n" +
3961+
" type: integer\n" +
3962+
" format: int64\n" +
3963+
" exclusiveMaximum: 10\n" +
3964+
" exclusiveMinimum: 1\n" +
3965+
" responses:\n" +
3966+
" default:\n" +
3967+
" description: default response\n" +
3968+
" content:\n" +
3969+
" '*/*': {}\n";
3970+
SerializationMatchers.assertEqualsToYaml31(openAPI, yaml);
3971+
}
39433972
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package io.swagger.v3.jaxrs2.resources;
2+
3+
import io.swagger.v3.oas.annotations.Operation;
4+
import io.swagger.v3.oas.annotations.Parameter;
5+
import io.swagger.v3.oas.annotations.media.Content;
6+
import io.swagger.v3.oas.annotations.media.Schema;
7+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
8+
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
9+
10+
import javax.validation.constraints.Max;
11+
import javax.validation.constraints.Min;
12+
import javax.ws.rs.DefaultValue;
13+
import javax.ws.rs.GET;
14+
import javax.ws.rs.Path;
15+
import javax.ws.rs.PathParam;
16+
import javax.ws.rs.QueryParam;
17+
import javax.ws.rs.core.Response;
18+
import java.util.List;
19+
20+
@Path("/test")
21+
public class ParameterMaximumValueResource {
22+
23+
@GET
24+
@Path("/{petId}")
25+
public Response getPetById(
26+
@Parameter(
27+
description = "ID of pet that needs to be fetched",
28+
schema = @Schema(
29+
type = "integer",
30+
format = "int64",
31+
exclusiveMinimumValue = 1,
32+
exclusiveMaximumValue = 10
33+
),
34+
required = true)
35+
@PathParam("petId") Long petId) {
36+
return null;
37+
}
38+
}

0 commit comments

Comments
 (0)