forked from smallrye/smallrye-open-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prefer parameter order from
@Parameters
annotation
Closes smallrye#1165 Signed-off-by: Michael Edgar <michael@xlate.io>
- Loading branch information
Showing
8 changed files
with
279 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...rc/test/java/test/io/smallrye/openapi/runtime/scanner/jakarta/ParameterOrderResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package test.io.smallrye.openapi.runtime.scanner.jakarta; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.json.JsonObject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.QueryParam; | ||
import jakarta.ws.rs.core.Application; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.Components; | ||
import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition; | ||
import org.eclipse.microprofile.openapi.annotations.enums.ParameterIn; | ||
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; | ||
import org.eclipse.microprofile.openapi.annotations.info.Info; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; | ||
import org.eclipse.microprofile.openapi.annotations.parameters.Parameters; | ||
|
||
public class ParameterOrderResource { | ||
|
||
public static final Class<?>[] CLASSES = { | ||
Application1.class, | ||
Resource1.class | ||
}; | ||
|
||
@OpenAPIDefinition(info = @Info(title = "Parameter Order", version = "1.0.0"), components = @Components(parameters = { | ||
@Parameter(name = "namespace", schema = @Schema(type = SchemaType.STRING)), | ||
@Parameter(name = "collection", schema = @Schema(type = SchemaType.STRING)), | ||
@Parameter(name = "where", schema = @Schema(type = SchemaType.OBJECT)), | ||
@Parameter(name = "fields", schema = @Schema(implementation = String[].class)), | ||
@Parameter(name = "page-state", schema = @Schema(type = SchemaType.BOOLEAN)), | ||
@Parameter(name = "profile", schema = @Schema(type = SchemaType.BOOLEAN)), | ||
@Parameter(name = "raw", schema = @Schema(type = SchemaType.BOOLEAN)) | ||
})) | ||
static class Application1 extends Application { | ||
} | ||
|
||
@Path("/1") | ||
static class Resource1 { | ||
@Parameters(value = { | ||
@Parameter(ref = "namespace"), | ||
@Parameter(name = "collection", ref = "collection"), | ||
@Parameter(name = "where", ref = "where"), | ||
@Parameter(ref = "fields"), | ||
@Parameter(name = "page-size", in = ParameterIn.QUERY, description = "The max number of results to return.", schema = @Schema(implementation = Integer.class, defaultValue = "3", minimum = "1", maximum = "20")), | ||
@Parameter(name = "page-state", ref = "page-state"), | ||
@Parameter(name = "profile", ref = "profile"), | ||
@Parameter(name = "raw", ref = "raw"), | ||
}) | ||
@GET | ||
public String get( | ||
// Order purposefully different than parameters listed in `@Parameters` on method | ||
@QueryParam("raw") boolean raw, | ||
@QueryParam("collection") String collection, | ||
@QueryParam("fields") List<String> fields, | ||
@QueryParam("namespace") String namespace, | ||
@QueryParam("page-size") int pageSize, | ||
@QueryParam("page-state") boolean pageState, | ||
@QueryParam("profile") boolean profile, | ||
@QueryParam("where") JsonObject where) { | ||
return null; | ||
} | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
...test/resources/io/smallrye/openapi/runtime/scanner/params.annotation-preferred-order.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
{ | ||
"openapi": "3.0.3", | ||
"info": { | ||
"title": "Parameter Order", | ||
"version": "1.0.0" | ||
}, | ||
"paths": { | ||
"/1": { | ||
"get": { | ||
"parameters": [ | ||
{ | ||
"$ref": "#/components/parameters/namespace" | ||
}, | ||
{ | ||
"$ref": "#/components/parameters/collection" | ||
}, | ||
{ | ||
"$ref": "#/components/parameters/where" | ||
}, | ||
{ | ||
"$ref": "#/components/parameters/fields" | ||
}, | ||
{ | ||
"name": "page-size", | ||
"in": "query", | ||
"description": "The max number of results to return.", | ||
"schema": { | ||
"format": "int32", | ||
"default": 3, | ||
"maximum": 20, | ||
"minimum": 1, | ||
"type": "integer" | ||
} | ||
}, | ||
{ | ||
"$ref": "#/components/parameters/page-state" | ||
}, | ||
{ | ||
"$ref": "#/components/parameters/profile" | ||
}, | ||
{ | ||
"$ref": "#/components/parameters/raw" | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"content": { | ||
"*/*": { | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"parameters": { | ||
"collection": { | ||
"name": "collection", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
"fields": { | ||
"name": "fields", | ||
"schema": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"namespace": { | ||
"name": "namespace", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
"page-state": { | ||
"name": "page-state", | ||
"schema": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"profile": { | ||
"name": "profile", | ||
"schema": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"raw": { | ||
"name": "raw", | ||
"schema": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"where": { | ||
"name": "where", | ||
"schema": { | ||
"type": "object" | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.