-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #820 from EBISPOT/add-v2-api-documentation
Add Swagger Documentation for V2 API
- Loading branch information
Showing
11 changed files
with
545 additions
and
139 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
56 changes: 56 additions & 0 deletions
56
backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v2/V2DefinedFieldsController.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,56 @@ | ||
package uk.ac.ebi.spot.ols.controller.api.v2; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import uk.ac.ebi.ols.shared.DefinedFields; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
@RestController | ||
public class V2DefinedFieldsController { | ||
|
||
@GetMapping("/api/v2/defined-fields") | ||
public List<DefinedFieldDto> getDefinedFields() { | ||
return Stream.of(DefinedFields.values()) | ||
.map(field -> new DefinedFieldDto( | ||
field.getText(), | ||
field.getOls3Text(), | ||
field.getDescription(), | ||
field.getType() | ||
)) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
// DTO class for serialization | ||
static class DefinedFieldDto { | ||
private String ols4FieldName; | ||
private String ols3FieldName; | ||
private String description; | ||
private String dataType; | ||
|
||
public DefinedFieldDto(String ols4FieldName, String ols3FieldName, String description, String dataType) { | ||
this.ols4FieldName = ols4FieldName; | ||
this.ols3FieldName = ols3FieldName; | ||
this.description = description; | ||
this.dataType = dataType; | ||
} | ||
|
||
public String getOls4FieldName() { | ||
return ols4FieldName; | ||
} | ||
|
||
public String getOls3FieldName() { | ||
return ols3FieldName; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public String getDataType() { | ||
return dataType; | ||
} | ||
} | ||
} |
Oops, something went wrong.