diff --git a/README.md b/README.md index 64c75007..862441fe 100644 --- a/README.md +++ b/README.md @@ -70,11 +70,11 @@ Details of few important APIs are provided below. ### Creating Work resources At present, API support creation of Work resource (with many other resource types included, like Instance). -Resources can be created by making a POST request to the `/resource` endpoint. +Resources can be created by making a POST request to the `/linked-data/resource` endpoint. Refer [src/main/resources/swagger.api/schema/resourceRequestDto.json](https://github.com/folio-org/mod-linked-data/blob/master/src/main/resources/swagger.api/schema/resourceRequestDto.json) for the schema of the request body. #### Example request for creating a Work resource: ```bash -curl --location '{{ base-uri }}/resource' \ +curl --location '{{ base-uri }}/linked-data/resource' \ --header 'x-okapi-tenant: {{ tenant identifier }}' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ @@ -252,13 +252,13 @@ curl --location '{{ base-uri }}/resource' \ }' ``` ### Updating resources -Resource can be updated by making a PUT request to the `/resource/{id}` endpoint. At present, only Work resources can be updated through the API. +Resource can be updated by making a PUT request to the `/linked-data/resource/{id}` endpoint. At present, only Work resources can be updated through the API. Refer [src/main/resources/swagger.api/schema/resourceRequestDto.json](https://github.com/folio-org/mod-linked-data/blob/master/src/main/resources/swagger.api/schema/resourceRequestDto.json) for the schema of the request body. ### Viewing a graph node -A graph node can be viewed by making a GET request to the `graph/resource/{id}` endpoint. Any kind of resources can be retrieved through this API. +A graph node can be viewed by making a GET request to the `/linked-data/resource/{id}/graph` endpoint. Any kind of resources can be retrieved through this API. ```bash -curl --location '{{ base-uri }}/graph/resource/{id}' \ +curl --location '{{ base-uri }}/linked-data/resource/{id}/graph' \ --header 'x-okapi-tenant: {tenant}' \ --header 'x-okapi-token: {token}' ``` diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 945f618b..12e05efd 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -3,12 +3,12 @@ "name": "Linked Data Module", "provides": [ { - "id": "resource", + "id": "linked-data", "version": "1.0", "handlers": [ { "methods": [ "POST" ], - "pathPattern": "/resource", + "pathPattern": "/linked-data/resource", "permissionsRequired": [ "linked-data.resources.bib.post" ], "modulePermissions": [ "mapping-metadata.get", @@ -40,19 +40,19 @@ }, { "methods": [ "GET" ], - "pathPattern": "/resource/{id}", + "pathPattern": "/linked-data/resource/{id}", "permissionsRequired": [ "linked-data.resources.bib.get" ], "modulePermissions": [] }, { "methods": [ "GET" ], - "pathPattern": "/resource/{id}/marc", + "pathPattern": "/linked-data/resource/{id}/marc", "permissionsRequired": [ "linked-data.resources.bib.marc.get" ], "modulePermissions": [] }, { "methods": [ "PUT" ], - "pathPattern": "/resource/{id}", + "pathPattern": "/linked-data/resource/{id}", "permissionsRequired": [ "linked-data.resources.bib.put" ], "modulePermissions": [ "mapping-metadata.get", @@ -78,31 +78,31 @@ }, { "methods": [ "DELETE" ], - "pathPattern": "/resource/{id}", + "pathPattern": "/linked-data/resource/{id}", "permissionsRequired": [ "linked-data.resources.bib.delete" ], "modulePermissions": [] }, { "methods": [ "GET" ], - "pathPattern": "/resource/metadata/{inventoryId}/id", + "pathPattern": "/linked-data/resource/metadata/{inventoryId}/id", "permissionsRequired": [ "linked-data.resources.bib.id.get" ], "modulePermissions": [] }, { "methods": [ "GET" ], - "pathPattern": "/resource/check/{inventoryId}/supported", + "pathPattern": "/linked-data/inventory-instance/{inventoryId}/import-supported", "permissionsRequired": [ "linked-data.resources.support-check.get" ], "modulePermissions": ["source-storage.records.formatted.item.get"] }, { "methods": [ "GET" ], - "pathPattern": "/resource/preview/{inventoryId}", + "pathPattern": "/linked-data/inventory-instance/{inventoryId}/preview", "permissionsRequired": [ "linked-data.resources.preview.get" ], "modulePermissions": ["source-storage.records.formatted.item.get"] }, { "methods": [ "POST" ], - "pathPattern": "/resource/import/{inventoryId}", + "pathPattern": "/linked-data/inventory-instance/{inventoryId}/import", "permissionsRequired": [ "linked-data.resources.import.post" ], "modulePermissions": [ "source-storage.records.formatted.item.get", @@ -121,6 +121,23 @@ "source-storage.records.post", "source-storage.records.put" ] + }, + { + "methods": [ "PUT" ], + "pathPattern": "/linked-data/reindex", + "permissionsRequired": [ "linked-data.resources.reindex.post" ], + "modulePermissions": [] + }, + { + "methods": [ "GET" ], + "pathPattern": "/linked-data/profile", + "permissionsRequired": [ "linked-data.profiles.get" ] + }, + { + "methods": [ "GET" ], + "pathPattern": "/linked-data/resource/{id}/graph", + "permissionsRequired": [ "linked-data.resources.graph.get" ], + "modulePermissions": [] } ] }, @@ -139,41 +156,6 @@ "pathPattern": "/_/tenant/{id}" } ] - }, - { - "id": "reindex", - "version": "1.0", - "handlers": [ - { - "methods": [ "PUT" ], - "pathPattern": "/reindex", - "permissionsRequired": [ "linked-data.resources.reindex.post" ], - "modulePermissions": [] - } - ] - }, - { - "id": "profile", - "version": "1.0", - "handlers": [ - { - "methods": [ "GET" ], - "pathPattern": "/profile", - "permissionsRequired": [ "linked-data.profiles.get" ] - } - ] - }, - { - "id": "graph", - "version": "1.0", - "handlers": [ - { - "methods": [ "GET" ], - "pathPattern": "/graph/resource/{id}", - "permissionsRequired": [ "linked-data.resources.graph.get" ], - "modulePermissions": [] - } - ] } ], "requires": [ diff --git a/pom.xml b/pom.xml index 8971b3cd..9a938032 100644 --- a/pom.xml +++ b/pom.xml @@ -434,6 +434,7 @@ ${project.basedir}/src/main/resources/swagger.api/templates true + true java true true diff --git a/src/main/java/org/folio/linked/data/controller/AuthorityAssignmentController.java b/src/main/java/org/folio/linked/data/controller/AuthorityAssignmentController.java index 45ff1caf..dcc34306 100644 --- a/src/main/java/org/folio/linked/data/controller/AuthorityAssignmentController.java +++ b/src/main/java/org/folio/linked/data/controller/AuthorityAssignmentController.java @@ -4,7 +4,7 @@ import lombok.RequiredArgsConstructor; import org.folio.linked.data.domain.dto.AssignmentCheckDto; -import org.folio.linked.data.rest.resource.LinkedDataApi; +import org.folio.linked.data.rest.resource.AuthorityApi; import org.folio.linked.data.service.resource.AssignAuthorityTarget; import org.folio.linked.data.service.resource.ResourceMarcAuthorityService; import org.springframework.http.ResponseEntity; @@ -12,7 +12,7 @@ @RestController @RequiredArgsConstructor -public class AuthorityAssignmentController implements LinkedDataApi { +public class AuthorityAssignmentController implements AuthorityApi { private final ResourceMarcAuthorityService resourceMarcAuthorityService; diff --git a/src/main/resources/swagger.api/mod-linked-data.yaml b/src/main/resources/swagger.api/mod-linked-data.yaml index 246076e2..2518d7f4 100644 --- a/src/main/resources/swagger.api/mod-linked-data.yaml +++ b/src/main/resources/swagger.api/mod-linked-data.yaml @@ -5,9 +5,11 @@ info: description: Linked Data service API paths: - /reindex: + /linked-data/reindex: put: operationId: reindex + tags: + - reindex description: Start the process of reindexing of resources in the database parameters: - $ref: '#/components/parameters/x-okapi-tenant-header' @@ -20,9 +22,11 @@ paths: '500': $ref: '#/components/responses/internalServerErrorResponse' - /resource: + /linked-data/resource: post: operationId: createResource + tags: + - resource description: Create a Resource parameters: - $ref: '#/components/parameters/x-okapi-tenant-header' @@ -43,9 +47,11 @@ paths: '500': $ref: '#/components/responses/internalServerErrorResponse' - /resource/{id}: + /linked-data/resource/{id}: get: operationId: getResourceById + tags: + - resource description: Get a resource by id parameters: - $ref: '#/components/parameters/x-okapi-tenant-header' @@ -65,6 +71,8 @@ paths: $ref: '#/components/responses/internalServerErrorResponse' put: operationId: updateResource + tags: + - resource description: Update a resource by id parameters: - $ref: '#/components/parameters/x-okapi-tenant-header' @@ -90,6 +98,8 @@ paths: $ref: '#/components/responses/internalServerErrorResponse' delete: operationId: deleteResource + tags: + - resource description: Delete a resource by id parameters: - $ref: '#/components/parameters/x-okapi-tenant-header' @@ -102,9 +112,11 @@ paths: '500': $ref: '#/components/responses/internalServerErrorResponse' - /resource/{id}/marc: + /linked-data/resource/{id}/marc: get: operationId: getResourceMarcViewById + tags: + - resource description: Get a marc view of resource by id parameters: - $ref: '#/components/parameters/x-okapi-tenant-header' @@ -123,9 +135,11 @@ paths: '500': $ref: '#/components/responses/internalServerErrorResponse' - /resource/metadata/{inventoryId}/id: + /linked-data/resource/metadata/{inventoryId}/id: get: operationId: getResourceIdByResourceInventoryId + tags: + - resource description: Get id of a resource by its inventory id parameters: - $ref: '#/components/parameters/x-okapi-tenant-header' @@ -140,9 +154,11 @@ paths: '404': description: No resource id is found by its inventory id - /resource/check/{inventoryId}/supported: + /linked-data/inventory-instance/{inventoryId}/import-supported: get: operationId: isSupportedByInventoryId + tags: + - resource description: Check if marc to bib conversion is supported parameters: - $ref: '#/components/parameters/inventoryId' @@ -159,9 +175,11 @@ paths: '500': $ref: '#/components/responses/internalServerErrorResponse' - /resource/preview/{inventoryId}: + /linked-data/inventory-instance/{inventoryId}/preview: get: operationId: getResourcePreviewByInventoryId + tags: + - resource description: Get the preview of a resource parameters: - $ref: '#/components/parameters/inventoryId' @@ -177,9 +195,11 @@ paths: '500': $ref: '#/components/responses/internalServerErrorResponse' - /resource/import/{inventoryId}: + /linked-data/inventory-instance/{inventoryId}/import: post: operationId: importMarcRecord + tags: + - resource description: Create a Resource derived from MARC record parameters: - $ref: '#/components/parameters/inventoryId' @@ -197,9 +217,11 @@ paths: '500': $ref: '#/components/responses/internalServerErrorResponse' - /profile: + /linked-data/profile: get: operationId: getProfile + tags: + - profile description: Get profile responses: '200': @@ -214,9 +236,11 @@ paths: '500': $ref: '#/components/responses/internalServerErrorResponse' - /graph/resource/{id}: + /linked-data/resource/{id}/graph: get: operationId: getResourceGraphById + tags: + - graph description: Get a resource graph by id parameters: - $ref: '#/components/parameters/x-okapi-tenant-header' @@ -238,6 +262,8 @@ paths: /linked-data/authority-assignment-check: post: operationId: authority-assignment-check + tags: + - authority description: Checks if authority can be assigned to work parameters: - $ref: '#/components/parameters/x-okapi-tenant-header' diff --git a/src/test/java/org/folio/linked/data/e2e/ProfileControllerIT.java b/src/test/java/org/folio/linked/data/e2e/ProfileControllerIT.java index 09dadf3b..c5a8b7a7 100644 --- a/src/test/java/org/folio/linked/data/e2e/ProfileControllerIT.java +++ b/src/test/java/org/folio/linked/data/e2e/ProfileControllerIT.java @@ -27,7 +27,7 @@ @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class ProfileControllerIT { - private static final String PROFILE_URL = "/profile"; + private static final String PROFILE_URL = "/linked-data/profile"; @Autowired private MockMvc mockMvc; diff --git a/src/test/java/org/folio/linked/data/e2e/ReIndexControllerIT.java b/src/test/java/org/folio/linked/data/e2e/ReIndexControllerIT.java index b11a18d3..fddf30aa 100644 --- a/src/test/java/org/folio/linked/data/e2e/ReIndexControllerIT.java +++ b/src/test/java/org/folio/linked/data/e2e/ReIndexControllerIT.java @@ -36,7 +36,7 @@ @IntegrationTest class ReIndexControllerIT { - public static final String INDEX_URL = "/reindex"; + public static final String INDEX_URL = "/linked-data/reindex"; @Autowired private MockMvc mockMvc; diff --git a/src/test/java/org/folio/linked/data/e2e/resource/ResourceControllerITBase.java b/src/test/java/org/folio/linked/data/e2e/resource/ResourceControllerITBase.java index 3734a16b..fdac7a03 100644 --- a/src/test/java/org/folio/linked/data/e2e/resource/ResourceControllerITBase.java +++ b/src/test/java/org/folio/linked/data/e2e/resource/ResourceControllerITBase.java @@ -199,7 +199,7 @@ public abstract class ResourceControllerITBase { public static final String LCCN_VALIDATION_NOT_AVAILABLE = "[Could not validate LCCN for duplicate] - reason: [Unable to reach search service]. Please try later."; - public static final String RESOURCE_URL = "/resource"; + public static final String RESOURCE_URL = "/linked-data/resource"; private static final String ROLES_PROPERTY = "roles"; private static final String NOTES_PROPERTY = "_notes"; private static final String ID_PROPERTY = "id"; diff --git a/src/test/java/org/folio/linked/data/e2e/resource/ResourceControllerValidationIT.java b/src/test/java/org/folio/linked/data/e2e/resource/ResourceControllerValidationIT.java index 44d4bfa1..0fc4f04b 100644 --- a/src/test/java/org/folio/linked/data/e2e/resource/ResourceControllerValidationIT.java +++ b/src/test/java/org/folio/linked/data/e2e/resource/ResourceControllerValidationIT.java @@ -30,7 +30,7 @@ @IntegrationTest class ResourceControllerValidationIT { - private static final String RESOURCE_URL = "/resource"; + private static final String RESOURCE_URL = "/linked-data/resource"; @Autowired private MockMvc mockMvc; diff --git a/src/test/java/org/folio/linked/data/e2e/resource/ResourceGraphControllerIT.java b/src/test/java/org/folio/linked/data/e2e/resource/ResourceGraphControllerIT.java index e1c4c9d2..e25d1c2d 100644 --- a/src/test/java/org/folio/linked/data/e2e/resource/ResourceGraphControllerIT.java +++ b/src/test/java/org/folio/linked/data/e2e/resource/ResourceGraphControllerIT.java @@ -110,7 +110,7 @@ void getResourceGraphById_shouldReturnResourceGraph() throws Exception { } private ResultActions performGet(Long resourceId) throws Exception { - var requestBuilder = get("/graph/resource/" + resourceId) + var requestBuilder = get("/linked-data/resource/" + resourceId + "/graph") .contentType(APPLICATION_JSON) .headers(defaultHeaders(env));