Skip to content
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

feat(REST API): Allow additional orderBy options when searching #5395

Merged
merged 1 commit into from
Oct 23, 2024
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
Expand Up @@ -1066,17 +1066,14 @@ public ArtifactSearchResultsDto searchArtifacts(Set<SearchFilter> filters, Order
case name:
orderByQuery.append(" ORDER BY coalesce(a.name, a.artifactId)");
break;
case artifactId:
orderByQuery.append(" ORDER BY a.artifactId");
case artifactType:
orderByQuery.append(" ORDER BY a.type");
break;
case groupId:
case artifactId:
case createdOn:
orderByQuery.append(" ORDER BY a.createdOn");
break;
case modifiedOn:
orderByQuery.append(" ORDER BY a.modifiedOn");
break;
case artifactType:
orderByQuery.append(" ORDER BY a.type");
orderByQuery.append(" ORDER BY a." + orderBy.name());
break;
default:
throw new RuntimeException("Sort by " + orderBy.name() + " not supported.");
Expand Down Expand Up @@ -1681,28 +1678,21 @@ public VersionSearchResultsDto searchVersions(Set<SearchFilter> filters, OrderBy
where.append(")");
}

// Add order by to artifact query
// Add order by to query
switch (orderBy) {
case globalId:
orderByQuery.append(" ORDER BY v.globalId");
case name:
orderByQuery.append(" ORDER BY coalesce(v.name, v.version)");
break;
case groupId:
orderByQuery.append(" ORDER BY v.groupId");
break;
case artifactId:
case version:
orderByQuery.append(" ORDER BY v.version");
break;
case name:
orderByQuery.append(" ORDER BY v.name");
break;
case globalId:
case createdOn:
orderByQuery.append(" ORDER BY v.createdOn");
break;
case modifiedOn:
orderByQuery.append(" ORDER BY v.modifiedOn");
orderByQuery.append(" ORDER BY v." + orderBy.name());
break;
default:
break;
throw new RuntimeException("Sort by " + orderBy.name() + " not supported.");
}
orderByQuery.append(" ").append(orderDirection.name());

Expand Down Expand Up @@ -2869,13 +2859,12 @@ public GroupSearchResultsDto searchGroups(Set<SearchFilter> filters, OrderBy ord
// Add order by to artifact query
switch (orderBy) {
case groupId:
orderByQuery.append(" ORDER BY g.groupId");
break;
case createdOn:
case modifiedOn:
orderByQuery.append(" ORDER BY g.").append(orderBy.name());
break;
default:
break;
throw new RuntimeException("Sort by " + orderBy.name() + " not supported.");
}
orderByQuery.append(" ").append(orderDirection.name());

Expand Down
6 changes: 5 additions & 1 deletion common/src/main/resources/META-INF/openapi.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{

Check warning on line 1 in common/src/main/resources/META-INF/openapi.json

View workflow job for this annotation

GitHub Actions / Validate

oas3-api-servers

Check warning on line 1 in common/src/main/resources/META-INF/openapi.json

View workflow job for this annotation

GitHub Actions / Validate

rhoas-servers-config
"openapi": "3.0.3",
"info": {
"title": "Apicurio Registry API [v3]",
Expand All @@ -14,7 +14,7 @@
"url": "https://www.apache.org/licenses/LICENSE-2.0"
}
},
"paths": {

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

View workflow job for this annotation

GitHub Actions / Validate

oas3-valid-media-example "value" property type must be string

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

View workflow job for this annotation

GitHub Actions / Validate

oas3-valid-media-example "value" property must have required property "title"

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

View workflow job for this annotation

GitHub Actions / Validate

oas3-valid-schema-example "version" property type must be string

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

View workflow job for this annotation

GitHub Actions / Validate

oas3-valid-schema-example "example" property must match pattern "^[a-zA-Z0-9._\-+]{1,256}$"

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

View workflow job for this annotation

GitHub Actions / Validate

oas3-valid-schema-example "example" property must be equal to one of the allowed values: "OUTBOUND", "INBOUND". Did you mean "INBOUND"?

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

View workflow job for this annotation

GitHub Actions / Validate

oas3-valid-schema-example "content" property must have required property "contentType"

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

View workflow job for this annotation

GitHub Actions / Validate

oas3-valid-schema-example "example" property must have required property "title"

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

View workflow job for this annotation

GitHub Actions / Validate

oas3-valid-schema-example "createdOn" property must match format "date-time"
"/ids/globalIds/{globalId}": {
"summary": "Access artifact content utilizing an artifact version's globally unique identifier.",
"get": {
Expand Down Expand Up @@ -3676,6 +3676,7 @@
"ArtifactSortBy": {
"description": "",
"enum": [
"groupId",
"artifactId",
"createdOn",
"modifiedOn",
Expand Down Expand Up @@ -5092,6 +5093,8 @@
"VersionSortBy": {
"description": "",
"enum": [
"groupId",
"artifactId",
"version",
"name",
"createdOn",
Expand All @@ -5104,7 +5107,8 @@
"description": "",
"enum": [
"groupId",
"createdOn"
"createdOn",
"modifiedOn"
],
"type": "string"
},
Expand Down
2 changes: 1 addition & 1 deletion go-sdk/pkg/registryclient-v3/kiota-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"descriptionHash": "D346A2A9A40F1B86E55F338BFB56645B0AE0D95EF3B3E66B14920108B20F119845B8EF22305D5C70D8DFDCC4BA0E39B5A78BD1F19D81AB90587F206B2470163D",
"descriptionHash": "6D428EDE13C8C05F3E9350ADBED7F44A1E6FFE2930A5F0EF8AF63340F89684254673F58AD88E237A968713F30D33CF09EB59BC3D3F08969CB79C3C4444A972C8",
"descriptionLocation": "../../v3.json",
"lockFileVersion": "1.0.0",
"kiotaVersion": "1.19.1",
Expand Down
9 changes: 6 additions & 3 deletions go-sdk/pkg/registryclient-v3/models/artifact_sort_by.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ package models
type ArtifactSortBy int

const (
ARTIFACTID_ARTIFACTSORTBY ArtifactSortBy = iota
GROUPID_ARTIFACTSORTBY ArtifactSortBy = iota
ARTIFACTID_ARTIFACTSORTBY
CREATEDON_ARTIFACTSORTBY
MODIFIEDON_ARTIFACTSORTBY
ARTIFACTTYPE_ARTIFACTSORTBY
NAME_ARTIFACTSORTBY
)

func (i ArtifactSortBy) String() string {
return []string{"artifactId", "createdOn", "modifiedOn", "artifactType", "name"}[i]
return []string{"groupId", "artifactId", "createdOn", "modifiedOn", "artifactType", "name"}[i]
}
func ParseArtifactSortBy(v string) (any, error) {
result := ARTIFACTID_ARTIFACTSORTBY
result := GROUPID_ARTIFACTSORTBY
switch v {
case "groupId":
result = GROUPID_ARTIFACTSORTBY
case "artifactId":
result = ARTIFACTID_ARTIFACTSORTBY
case "createdOn":
Expand Down
5 changes: 4 additions & 1 deletion go-sdk/pkg/registryclient-v3/models/group_sort_by.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ type GroupSortBy int
const (
GROUPID_GROUPSORTBY GroupSortBy = iota
CREATEDON_GROUPSORTBY
MODIFIEDON_GROUPSORTBY
)

func (i GroupSortBy) String() string {
return []string{"groupId", "createdOn"}[i]
return []string{"groupId", "createdOn", "modifiedOn"}[i]
}
func ParseGroupSortBy(v string) (any, error) {
result := GROUPID_GROUPSORTBY
Expand All @@ -17,6 +18,8 @@ func ParseGroupSortBy(v string) (any, error) {
result = GROUPID_GROUPSORTBY
case "createdOn":
result = CREATEDON_GROUPSORTBY
case "modifiedOn":
result = MODIFIEDON_GROUPSORTBY
default:
return nil, nil
}
Expand Down
12 changes: 9 additions & 3 deletions go-sdk/pkg/registryclient-v3/models/version_sort_by.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@ package models
type VersionSortBy int

const (
VERSION_VERSIONSORTBY VersionSortBy = iota
GROUPID_VERSIONSORTBY VersionSortBy = iota
ARTIFACTID_VERSIONSORTBY
VERSION_VERSIONSORTBY
NAME_VERSIONSORTBY
CREATEDON_VERSIONSORTBY
MODIFIEDON_VERSIONSORTBY
GLOBALID_VERSIONSORTBY
)

func (i VersionSortBy) String() string {
return []string{"version", "name", "createdOn", "modifiedOn", "globalId"}[i]
return []string{"groupId", "artifactId", "version", "name", "createdOn", "modifiedOn", "globalId"}[i]
}
func ParseVersionSortBy(v string) (any, error) {
result := VERSION_VERSIONSORTBY
result := GROUPID_VERSIONSORTBY
switch v {
case "groupId":
result = GROUPID_VERSIONSORTBY
case "artifactId":
result = ARTIFACTID_VERSIONSORTBY
case "version":
result = VERSION_VERSIONSORTBY
case "name":
Expand Down
Loading