-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openchallenges): create endpoint to search EDAM concepts (#2622)
- Loading branch information
1 parent
ad72df8
commit d503473
Showing
37 changed files
with
1,658 additions
and
5 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
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
90 changes: 90 additions & 0 deletions
90
...rc/main/java/org/sagebionetworks/openchallenges/challenge/service/api/EdamConceptApi.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,90 @@ | ||
/** | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (6.2.1). | ||
* https://openapi-generator.tech Do not edit the class manually. | ||
*/ | ||
package org.sagebionetworks.openchallenges.challenge.service.api; | ||
|
||
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.tags.Tag; | ||
import javax.annotation.Generated; | ||
import javax.validation.Valid; | ||
import javax.validation.constraints.*; | ||
import org.sagebionetworks.openchallenges.challenge.service.model.dto.BasicErrorDto; | ||
import org.sagebionetworks.openchallenges.challenge.service.model.dto.EdamConceptSearchQueryDto; | ||
import org.sagebionetworks.openchallenges.challenge.service.model.dto.EdamConceptsPageDto; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") | ||
@Validated | ||
@Tag(name = "EdamConcept", description = "Operations about EDAM concepts.") | ||
public interface EdamConceptApi { | ||
|
||
default EdamConceptApiDelegate getDelegate() { | ||
return new EdamConceptApiDelegate() {}; | ||
} | ||
|
||
/** | ||
* GET /edamConcepts : List EDAM concepts List EDAM concepts | ||
* | ||
* @param edamConceptSearchQuery The search query used to find EDAM concepts. (optional) | ||
* @return Success (status code 200) or Invalid request (status code 400) or The request cannot be | ||
* fulfilled due to an unexpected server error (status code 500) | ||
*/ | ||
@Operation( | ||
operationId = "listEdamConcepts", | ||
summary = "List EDAM concepts", | ||
tags = {"EdamConcept"}, | ||
responses = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "Success", | ||
content = { | ||
@Content( | ||
mediaType = "application/json", | ||
schema = @Schema(implementation = EdamConceptsPageDto.class)), | ||
@Content( | ||
mediaType = "application/problem+json", | ||
schema = @Schema(implementation = EdamConceptsPageDto.class)) | ||
}), | ||
@ApiResponse( | ||
responseCode = "400", | ||
description = "Invalid request", | ||
content = { | ||
@Content( | ||
mediaType = "application/json", | ||
schema = @Schema(implementation = BasicErrorDto.class)), | ||
@Content( | ||
mediaType = "application/problem+json", | ||
schema = @Schema(implementation = BasicErrorDto.class)) | ||
}), | ||
@ApiResponse( | ||
responseCode = "500", | ||
description = "The request cannot be fulfilled due to an unexpected server error", | ||
content = { | ||
@Content( | ||
mediaType = "application/json", | ||
schema = @Schema(implementation = BasicErrorDto.class)), | ||
@Content( | ||
mediaType = "application/problem+json", | ||
schema = @Schema(implementation = BasicErrorDto.class)) | ||
}) | ||
}) | ||
@RequestMapping( | ||
method = RequestMethod.GET, | ||
value = "/edamConcepts", | ||
produces = {"application/json", "application/problem+json"}) | ||
default ResponseEntity<EdamConceptsPageDto> listEdamConcepts( | ||
@Parameter( | ||
name = "edamConceptSearchQuery", | ||
description = "The search query used to find EDAM concepts.") | ||
@Valid | ||
EdamConceptSearchQueryDto edamConceptSearchQuery) { | ||
return getDelegate().listEdamConcepts(edamConceptSearchQuery); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...va/org/sagebionetworks/openchallenges/challenge/service/api/EdamConceptApiController.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,25 @@ | ||
package org.sagebionetworks.openchallenges.challenge.service.api; | ||
|
||
import java.util.Optional; | ||
import javax.annotation.Generated; | ||
import javax.validation.constraints.*; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") | ||
@Controller | ||
@RequestMapping("${openapi.openChallengesChallengeREST.base-path:/v1}") | ||
public class EdamConceptApiController implements EdamConceptApi { | ||
|
||
private final EdamConceptApiDelegate delegate; | ||
|
||
public EdamConceptApiController(@Autowired(required = false) EdamConceptApiDelegate delegate) { | ||
this.delegate = Optional.ofNullable(delegate).orElse(new EdamConceptApiDelegate() {}); | ||
} | ||
|
||
@Override | ||
public EdamConceptApiDelegate getDelegate() { | ||
return delegate; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...java/org/sagebionetworks/openchallenges/challenge/service/api/EdamConceptApiDelegate.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,52 @@ | ||
package org.sagebionetworks.openchallenges.challenge.service.api; | ||
|
||
import java.util.Optional; | ||
import javax.annotation.Generated; | ||
import org.sagebionetworks.openchallenges.challenge.service.model.dto.EdamConceptSearchQueryDto; | ||
import org.sagebionetworks.openchallenges.challenge.service.model.dto.EdamConceptsPageDto; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.context.request.NativeWebRequest; | ||
|
||
/** | ||
* A delegate to be called by the {@link EdamConceptApiController}}. Implement this interface with a | ||
* {@link org.springframework.stereotype.Service} annotated class. | ||
*/ | ||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") | ||
public interface EdamConceptApiDelegate { | ||
|
||
default Optional<NativeWebRequest> getRequest() { | ||
return Optional.empty(); | ||
} | ||
|
||
/** | ||
* GET /edamConcepts : List EDAM concepts List EDAM concepts | ||
* | ||
* @param edamConceptSearchQuery The search query used to find EDAM concepts. (optional) | ||
* @return Success (status code 200) or Invalid request (status code 400) or The request cannot be | ||
* fulfilled due to an unexpected server error (status code 500) | ||
* @see EdamConceptApi#listEdamConcepts | ||
*/ | ||
default ResponseEntity<EdamConceptsPageDto> listEdamConcepts( | ||
EdamConceptSearchQueryDto edamConceptSearchQuery) { | ||
getRequest() | ||
.ifPresent( | ||
request -> { | ||
for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { | ||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { | ||
String exampleString = "null"; | ||
ApiUtil.setExampleResponse(request, "application/json", exampleString); | ||
break; | ||
} | ||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/problem+json"))) { | ||
String exampleString = | ||
"Custom MIME type example not yet supported: application/problem+json"; | ||
ApiUtil.setExampleResponse(request, "application/problem+json", exampleString); | ||
break; | ||
} | ||
} | ||
}); | ||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
.../org/sagebionetworks/openchallenges/challenge/service/api/EdamConceptApiDelegateImpl.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,22 @@ | ||
package org.sagebionetworks.openchallenges.challenge.service.api; | ||
|
||
import org.sagebionetworks.openchallenges.challenge.service.model.dto.EdamConceptSearchQueryDto; | ||
import org.sagebionetworks.openchallenges.challenge.service.model.dto.EdamConceptsPageDto; | ||
import org.sagebionetworks.openchallenges.challenge.service.service.EdamConceptService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class EdamConceptApiDelegateImpl implements EdamConceptApiDelegate { | ||
|
||
private final EdamConceptService edamConceptService; | ||
|
||
public EdamConceptApiDelegateImpl(EdamConceptService edamConceptService) { | ||
this.edamConceptService = edamConceptService; | ||
} | ||
|
||
@Override | ||
public ResponseEntity<EdamConceptsPageDto> listEdamConcepts(EdamConceptSearchQueryDto query) { | ||
return ResponseEntity.ok(edamConceptService.listEdamConcepts(query)); | ||
} | ||
} |
Oops, something went wrong.