Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.springdoc.core.converters.models;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Schema;

/**
* The Sort class as query param.
*
* @author ondrejkrpec
*/
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Parameter(in = ParameterIn.QUERY
, description = "Sorting criteria in the format: property,(asc|desc). "
+ "Default sort order is ascending. " + "Multiple sort criteria are supported."
, name = "sort"
, array = @ArraySchema(schema = @Schema(type = "string"))
)
public @interface SortAsQueryParam {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.springdoc.core.converters.models.PageableAsQueryParam;

import org.springdoc.core.converters.models.SortAsQueryParam;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -36,4 +37,10 @@ public String operation4() {
return "operation4";
}

@GetMapping("operation5")
@SortAsQueryParam
public String operation5() {
return "operation5";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,39 @@
}
],
"paths": {
"/demo/operation5": {
"get": {
"tags": [
"hello-controller"
],
"operationId": "operation5",
"parameters": [
{
"name": "sort",
"in": "query",
"description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.",
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
"/demo/operation4": {
"get": {
"tags": [
Expand Down