Skip to content

Commit

Permalink
chore: specify required fields in open api specs
Browse files Browse the repository at this point in the history
  • Loading branch information
younes-lnds committed Dec 17, 2024
1 parent 3c6969c commit 91edde6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package io.github.genomicdatainfrastructure.discovery.datasets.infrastructure.ckan.utils;

import io.github.genomicdatainfrastructure.discovery.model.DatasetSearchQuery;
import io.github.genomicdatainfrastructure.discovery.model.QueryOperator;
import lombok.experimental.UtilityClass;

@UtilityClass
Expand All @@ -13,7 +13,7 @@ public class CkanQueryOperatorMapper {
private final String AND = " AND ";
private final String OR = " OR ";

public String getOperator(DatasetSearchQuery.OperatorEnum operator) {
return DatasetSearchQuery.OperatorEnum.AND.equals(operator) ? AND : OR;
public String getOperator(QueryOperator operator) {
return QueryOperator.AND.equals(operator) ? AND : OR;
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0

package io.github.genomicdatainfrastructure.discovery.filters.infrastructure.ckan;

import io.github.genomicdatainfrastructure.discovery.filters.application.ports.FiltersRepository;
import io.github.genomicdatainfrastructure.discovery.filters.infrastructure.mapper.CkanFilterMapper;
import io.github.genomicdatainfrastructure.discovery.model.ValueLabel;
import io.github.genomicdatainfrastructure.discovery.remote.ckan.api.CkanQueryApi;
import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanFacet;
import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.PackageSearchRequest;
import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.PackagesSearchResult;
import jakarta.enterprise.context.ApplicationScoped;
import org.eclipse.microprofile.rest.client.inject.RestClient;

import java.util.List;
import java.util.Map;

import static java.util.Optional.ofNullable;

@ApplicationScoped
public class CkanFiltersRepository implements FiltersRepository {
Expand Down
37 changes: 22 additions & 15 deletions src/main/openapi/discovery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,7 @@ components:
operator:
title: Ckan query operator
type: string
enum:
- AND
- OR
$ref: "#/components/schemas/QueryOperator"
default: OR
DatasetSearchQueryFacet:
type: object
Expand All @@ -226,7 +224,7 @@ components:
entries:
type: array
items:
$ref: '#/components/schemas/QueryEntry'
$ref: "#/components/schemas/QueryEntry"
required:
- source
- type
Expand Down Expand Up @@ -258,6 +256,15 @@ components:
value:
type: string
title: value
required:
- key
- value
QueryOperator:
type: string
enum:
- OR
- AND
title: Query operator
SearchedDataset:
type: object
properties:
Expand Down Expand Up @@ -308,8 +315,6 @@ components:
- id
- title
- description
- catalogue
- modifiedAt
DatasetsSearchResponse:
type: object
properties:
Expand Down Expand Up @@ -407,8 +412,6 @@ components:
- id
- title
- description
- catalogue
- createdAt
RetrievedDistribution:
type: object
properties:
Expand Down Expand Up @@ -445,7 +448,6 @@ components:
- id
- title
- description
- createdAt
ValueLabel:
properties:
value:
Expand All @@ -471,9 +473,6 @@ components:
uri:
type: string
title: uri
identifier:
type: string
title: identifier
required:
- name
- email
Expand All @@ -494,9 +493,6 @@ components:
identifier:
type: string
title: identifier
uri:
type: string
title: uri
required:
- name
DatasetRelationEntry:
Expand Down Expand Up @@ -555,6 +551,11 @@ components:
items:
$ref: "#/components/schemas/FilterEntry"
title: entries
required:
- source
- type
- key
- label
FilterEntry:
properties:
key:
Expand All @@ -563,6 +564,9 @@ components:
label:
type: string
title: label
required:
- key
- label
ErrorResponse:
properties:
title:
Expand All @@ -574,3 +578,6 @@ components:
detail:
type: string
title: Error detail
required:
- title
- status
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.github.genomicdatainfrastructure.discovery.model.DatasetSearchQuery;
import io.github.genomicdatainfrastructure.discovery.datasets.infrastructure.ckan.persistence.CkanFacetsQueryBuilder;
import io.github.genomicdatainfrastructure.discovery.model.FilterType;
import io.github.genomicdatainfrastructure.discovery.model.QueryOperator;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.NullSource;
Expand Down Expand Up @@ -100,7 +101,7 @@ void canParse_withAndOperator(String value) {

var query = new DatasetSearchQuery();
query.setFacets(facets);
query.setOperator(DatasetSearchQuery.OperatorEnum.AND);
query.setOperator(QueryOperator.AND);

var expected = "field1:(\"value1\" AND \"value2\") AND field2:(\"value3\")";
var actual = CkanFacetsQueryBuilder.buildFacetQuery(query);
Expand Down Expand Up @@ -169,7 +170,7 @@ void canParse_withOrOperator(String value) {

var query = new DatasetSearchQuery();
query.setFacets(facets);
query.setOperator(DatasetSearchQuery.OperatorEnum.OR);
query.setOperator(QueryOperator.OR);

var expected = "field1:(\"value1\" OR \"value2\") AND field2:(\"value3\")";
var actual = CkanFacetsQueryBuilder.buildFacetQuery(query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,13 @@ void given_ckanPackage_should_be_mapped_to_expected_values() {
.email("email")
.url("url")
.type("type")
.uri("uri")
.build(),
Agent.builder()
.name("creatorName2")
.identifier("creatorIdentifier2")
.email("email2")
.url("url2")
.type("type2")
.uri("uri2")
.build()
))
.publishers(List.of(
Expand All @@ -105,15 +103,13 @@ void given_ckanPackage_should_be_mapped_to_expected_values() {
.email("email")
.url("url")
.type("type")
.uri("uri")
.build(),
Agent.builder()
.name("publisherName2")
.identifier("publisherIdentifier2")
.email("email2")
.url("url2")
.type("type2")
.uri("uri2")
.build()
))
.accessRights(ValueLabel.builder()
Expand Down Expand Up @@ -157,13 +153,11 @@ void given_ckanPackage_should_be_mapped_to_expected_values() {
ContactPoint.builder()
.name("Contact 1")
.email("contact1@example.com")
.identifier("contact-identifier-1")
.build(),
ContactPoint.builder()
.name("Contact 2")
.email("contact2@example.com")
.uri("http://example.com")
.identifier("contact-identifier-2")
.build()
))
.datasetRelationships(List.of(
Expand Down Expand Up @@ -309,15 +303,13 @@ private static SearchedDataset buildSearchedDataset() {
.email("email")
.url("url")
.identifier("publisherIdentifier")
.uri("uri")
.type("type")
.build(),
Agent.builder()
.name("publisherName2")
.email("email2")
.url("url2")
.identifier("publisherIdentifier2")
.uri("uri2")
.type("type2")
.build()))
.themes(List.of(ValueLabel.builder()
Expand Down

0 comments on commit 91edde6

Please sign in to comment.