From 08f5466105c878cd568780b2d5dc170547af1d0f Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Wed, 16 Nov 2022 10:26:10 +0100 Subject: [PATCH] fix after merge --- apps/dnet-directindex-api/pom.xml | 2 +- .../directindex/DirectIndexApplication.java | 34 ++++++++----------- .../openaire/directindex/input/PidEntry.java | 12 +++---- .../directindex/input/ResultEntry.java | 31 +++++++++++------ 4 files changed, 42 insertions(+), 37 deletions(-) diff --git a/apps/dnet-directindex-api/pom.xml b/apps/dnet-directindex-api/pom.xml index 3531209b..a376e01d 100644 --- a/apps/dnet-directindex-api/pom.xml +++ b/apps/dnet-directindex-api/pom.xml @@ -6,7 +6,7 @@ eu.dnetlib.dhp apps - 3.2.1-SNAPSHOT + 3.3.3-SNAPSHOT ../ diff --git a/apps/dnet-directindex-api/src/main/java/eu/dnetlib/openaire/directindex/DirectIndexApplication.java b/apps/dnet-directindex-api/src/main/java/eu/dnetlib/openaire/directindex/DirectIndexApplication.java index 61128d11..93e1240d 100644 --- a/apps/dnet-directindex-api/src/main/java/eu/dnetlib/openaire/directindex/DirectIndexApplication.java +++ b/apps/dnet-directindex-api/src/main/java/eu/dnetlib/openaire/directindex/DirectIndexApplication.java @@ -3,26 +3,23 @@ package eu.dnetlib.openaire.directindex; import java.util.Properties; import org.apache.velocity.app.VelocityEngine; +import org.springdoc.core.GroupedOpenApi; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableScheduling; import eu.dnetlib.common.app.AbstractDnetApp; import eu.dnetlib.common.clients.ISLookupClientFactory; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; @SpringBootApplication -@EnableSwagger2 @EnableCaching @EnableScheduling +@ComponentScan(basePackages = "eu.dnetlib") public class DirectIndexApplication extends AbstractDnetApp { @Value("${openaire.service.islookup.wsdl}") @@ -32,20 +29,12 @@ public class DirectIndexApplication extends AbstractDnetApp { SpringApplication.run(DirectIndexApplication.class, args); } - @Override - protected void configSwagger(final Docket docket) { - docket.select() - .apis(RequestHandlerSelectors.any()) - .paths(p -> p.startsWith("/api/")) - .build() - .apiInfo(new ApiInfoBuilder() - .title("OpenAIRE DirectIndex API") - .description("APIs documentation") - .version("1.1") - .contact(ApiInfo.DEFAULT_CONTACT) - .license("Apache 2.0") - .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0") - .build()); + @Bean + public GroupedOpenApi publicApi() { + return GroupedOpenApi.builder() + .group("D-Net DirectIndex API") + .pathsToMatch("/api/**") + .build(); } @Bean @@ -64,4 +53,9 @@ public class DirectIndexApplication extends AbstractDnetApp { return ve; } + @Override + protected String swaggerTitle() { + return "OpenAIRE DirectIndex API"; + } + } diff --git a/apps/dnet-directindex-api/src/main/java/eu/dnetlib/openaire/directindex/input/PidEntry.java b/apps/dnet-directindex-api/src/main/java/eu/dnetlib/openaire/directindex/input/PidEntry.java index 1f2a04eb..e8a4e9aa 100644 --- a/apps/dnet-directindex-api/src/main/java/eu/dnetlib/openaire/directindex/input/PidEntry.java +++ b/apps/dnet-directindex-api/src/main/java/eu/dnetlib/openaire/directindex/input/PidEntry.java @@ -1,24 +1,25 @@ package eu.dnetlib.openaire.directindex.input; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; /** * Created by michele on 02/12/15. */ public class PidEntry { + @Schema(required = true, description = "E.g. doi, pmc, urn. See http://api.openaire.eu/vocabularies/dnet:pid_types") private String type; + + @Schema(required = true) private String value; - public PidEntry() { - } + public PidEntry() {} public PidEntry(final String type, final String value) { this.type = type; this.value = value; } - @ApiModelProperty(required = true, value = "E.g. doi, pmc, urn. See http://api.openaire.eu/vocabularies/dnet:pid_types") public String getType() { return type; } @@ -27,7 +28,6 @@ public class PidEntry { this.type = type; } - @ApiModelProperty(required = true) public String getValue() { return value; } @@ -35,4 +35,4 @@ public class PidEntry { public void setValue(final String value) { this.value = value; } -} \ No newline at end of file +} diff --git a/apps/dnet-directindex-api/src/main/java/eu/dnetlib/openaire/directindex/input/ResultEntry.java b/apps/dnet-directindex-api/src/main/java/eu/dnetlib/openaire/directindex/input/ResultEntry.java index dc6f5a17..b9083b26 100644 --- a/apps/dnet-directindex-api/src/main/java/eu/dnetlib/openaire/directindex/input/ResultEntry.java +++ b/apps/dnet-directindex-api/src/main/java/eu/dnetlib/openaire/directindex/input/ResultEntry.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import eu.dnetlib.openaire.directindex.DirectIndexApiException; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; /** * Created by michele on 02/12/15. @@ -20,28 +20,48 @@ public class ResultEntry { private String openaireId; private String originalId; + + @Schema(required = true) private String title; private List authors = new ArrayList<>(); private String publisher; private String description; + @Schema(description = "ISO Alpha-3 code. E.g. 'eng', 'ita'") private String language; private List pids = new ArrayList<>(); + + @Schema(required = false, allowableValues = { + "OPEN", "CLOSED", "RESTRICTED", "EMBARGO", "UNKNOWN", "OTHER", "OPEN SOURCE" + }) private String accessRightCode; private String embargoEndDate; + /** * One of publication, dataset, software, other. Default value is publication. */ + @Schema(allowableValues = { + "publication", "dataset", "software", "other" + }) private String type = "publication"; + + @Schema(required = true, description = "Use 001 for articles, 021 for datasets, 0029 for software. See: http://api.openaire.eu/vocabularies/dnet:publication_resource for all the available resource types.") private String resourceType; + + @Schema(required = true) private String url; + + @Schema(required = true, description = "Use opendoar___::2659 for Zenodo Publications; re3data_____::r3d100010468 for Zenodo datasets; infrastruct::openaire for OpenAIRE portal.") private String collectedFromId; private String hostedById; // String according to the EGI context profile, example: egi::classification::natsc::math + + @Schema(description = "E.g. fet, egi::classification::natsc::math::pure, egi::projects::EMI") private List contexts = new ArrayList<>(); // String according to openaire guidelines: // info:eu-repo/grantAgreement/Funder/FundingProgram/ProjectID/[Jurisdiction]/[ProjectName]/[ProjectAcronym] + @Schema(description = "E.g. info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus") private List linksToProjects = new ArrayList<>(); private static final Log log = LogFactory.getLog(ResultEntry.class); @@ -64,7 +84,6 @@ public class ResultEntry { this.originalId = originalId; } - @ApiModelProperty(required = true) public String getTitle() { return title; } @@ -97,7 +116,6 @@ public class ResultEntry { this.description = description; } - @ApiModelProperty(value = "ISO Alpha-3 code. E.g. 'eng', 'ita'") public String getLanguage() { return language; } @@ -119,7 +137,6 @@ public class ResultEntry { * * @return access rights code */ - @ApiModelProperty(required = false, allowableValues = "OPEN, CLOSED, RESTRICTED, EMBARGO, UNKNOWN, OTHER, OPEN SOURCE") public String getAccessRightCode() { return accessRightCode; } @@ -128,7 +145,6 @@ public class ResultEntry { this.accessRightCode = accessRightCode; } - @ApiModelProperty(required = true, value = "Use 001 for articles, 021 for datasets, 0029 for software. See: http://api.openaire.eu/vocabularies/dnet:publication_resource for all the available resource types.") public String getResourceType() { return resourceType; } @@ -137,7 +153,6 @@ public class ResultEntry { this.resourceType = resourceType; } - @ApiModelProperty(required = true) public String getUrl() { return url; } @@ -146,7 +161,6 @@ public class ResultEntry { this.url = url; } - @ApiModelProperty(required = true, value = "Use opendoar___::2659 for Zenodo Publications; re3data_____::r3d100010468 for Zenodo datasets; infrastruct::openaire for OpenAIRE portal.") public String getCollectedFromId() { return collectedFromId; } @@ -163,7 +177,6 @@ public class ResultEntry { this.hostedById = hostedById; } - @ApiModelProperty(value = "E.g. fet, egi::classification::natsc::math::pure, egi::projects::EMI") public List getContexts() { return contexts; } @@ -172,7 +185,6 @@ public class ResultEntry { this.contexts = contexts; } - @ApiModelProperty(value = "E.g. info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus") public List getLinksToProjects() { return linksToProjects; } @@ -181,7 +193,6 @@ public class ResultEntry { this.linksToProjects = linksToProjects; } - @ApiModelProperty(allowableValues = "publication, dataset, software, other") public String getType() { return type; }