Skip to content

Commit

Permalink
fix oas 3.1 parameter resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
frantuma committed Jul 4, 2023
1 parent fd61120 commit ae9a4f0
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ public ResolvedParameter extractParameters(List<Annotation> annotations,
components,
classConsumes == null ? new String[0] : classConsumes.value(),
methodConsumes == null ? new String[0] : methodConsumes.value(),
jsonViewAnnotation);
jsonViewAnnotation,
openapi31);
if (processedParameter != null) {
extractParametersResult.parameters.add(processedParameter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.swagger.v3.jaxrs2.petstore31.PetResource;
import io.swagger.v3.jaxrs2.petstore31.TagResource;
import io.swagger.v3.jaxrs2.resources.Misc31Resource;
import io.swagger.v3.jaxrs2.resources.ParameterMaximumValueResource;
import io.swagger.v3.jaxrs2.resources.ResponseReturnTypeResource;
import io.swagger.v3.jaxrs2.resources.SchemaPropertiesResource;
import io.swagger.v3.jaxrs2.resources.SiblingPropResource;
Expand Down Expand Up @@ -3940,4 +3941,32 @@ public void test4446CyclicProp() {
" $ref: '#/components/schemas/MyPojo'\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}

@Test
public void testParameterMaximumValue() {
Reader reader = new Reader(new SwaggerConfiguration().openAPI(new OpenAPI()).openAPI31(true));

OpenAPI openAPI = reader.read(ParameterMaximumValueResource.class);
String yaml = "openapi: 3.1.0\n" +
"paths:\n" +
" /test/{petId}:\n" +
" get:\n" +
" operationId: getPetById\n" +
" parameters:\n" +
" - name: petId\n" +
" in: path\n" +
" description: ID of pet that needs to be fetched\n" +
" required: true\n" +
" schema:\n" +
" type: integer\n" +
" format: int64\n" +
" exclusiveMaximum: 10\n" +
" exclusiveMinimum: 1\n" +
" responses:\n" +
" default:\n" +
" description: default response\n" +
" content:\n" +
" '*/*': {}\n";
SerializationMatchers.assertEqualsToYaml31(openAPI, yaml);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.swagger.v3.jaxrs2.resources;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import java.util.List;

@Path("/test")
public class ParameterMaximumValueResource {

@GET
@Path("/{petId}")
public Response getPetById(
@Parameter(
description = "ID of pet that needs to be fetched",
schema = @Schema(
type = "integer",
format = "int64",
exclusiveMinimumValue = 1,
exclusiveMaximumValue = 10
),
required = true)
@PathParam("petId") Long petId) {
return null;
}
}

0 comments on commit ae9a4f0

Please sign in to comment.