Skip to content

Commit

Permalink
feat(specification-storage): implement endpoint to fetch specifications
Browse files Browse the repository at this point in the history
Closes: MRSPECS-3
  • Loading branch information
psmagin committed Apr 29, 2024
1 parent ab0e3da commit fdf1300
Show file tree
Hide file tree
Showing 51 changed files with 1,347 additions and 59 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ USER root
RUN apk upgrade --no-cache
USER folio

ENV APP_FILE mod-record-specifications-fat.jar
ARG JAR_FILE=./mod-record-specifications-server/target/mod-record-specifications-server-1.0.0-SNAPSHOT.jar
ENV APP_FILE mod-record-specifications-server-fat.jar
ENV JAR_FILE=mod-record-specifications-server/target/${APP_FILE}
COPY ${JAR_FILE} ${JAVA_APP_DIR}/${APP_FILE}

EXPOSE 8081
6 changes: 6 additions & 0 deletions api/examples/response/unknownErrorResponse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
value:
errors:
- message: "Illegal argument error"
type: "IllegalArgumentException"
code: "unknown_error"
total_records: 1
10 changes: 10 additions & 0 deletions api/examples/response/validationErrorResponse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
value:
errors:
- message: "must not be null"
type: "MethodArgumentNotValidException"
code: "validation_error"
parameters:
- key: "parameter"
value: "null"
total_records: 1

26 changes: 4 additions & 22 deletions api/mod-record-specifications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,10 @@ servers:
- snapshot-2

tags:
- name: tag
description: Tag description
- name: specifications
description: Provides API for managing specifications.


paths:
/stub:
get:
summary: Stub
description: New endpoint
tags:
- tag
operationId: stub
responses:
'200':
description: New response
content:
application/json:
schema:
title: StubObject
type: object
properties:
id:
type: string
format: uuid

/specification-storage/specifications:
$ref: 'paths/specification-storage/get-specifications-path.yaml'
8 changes: 8 additions & 0 deletions api/parameters/limit-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
in: query
name: limit
description: Limit the number of elements returned in the response.
schema:
type: integer
minimum: 0
maximum: 500
default: 100
8 changes: 8 additions & 0 deletions api/parameters/offset-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
in: query
name: offset
description: Skip over a number of elements by specifying an offset value for the query.
schema:
type: integer
minimum: 0
maximum: 9999
default: 0
40 changes: 40 additions & 0 deletions api/paths/specification-storage/get-specifications-path.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
get:
summary: Get Specifications
description: Get a collection of specifications.
operationId: getSpecifications
tags:
- specifications
security:
- ApiKeyAuth: [ ]

Check warning on line 8 in api/paths/specification-storage/get-specifications-path.yaml

View workflow job for this annotation

GitHub Actions / Lint (push)

oas3-operation-security-defined

Operation "security" values must match a scheme defined in the "components.securitySchemes" object.
parameters:
- in: query
name: family
description: Filter by specification's family.
schema:
$ref: '../../schemas/family.yaml'
- in: query
name: profile
description: Filter by specification's family profile.
schema:
$ref: '../../schemas/familyProfile.yaml'
- in: query
name: include
description: Limit the number of elements returned in the response.
schema:
type: string
enum:
- all
- required-fields
- $ref: '../../parameters/limit-param.yaml'
- $ref: '../../parameters/offset-param.yaml'
responses:
'200':
description: Collection of specifications
content:
application/json:
schema:
$ref: '../../schemas/specificationCollection.yaml'
'400':
$ref: '../../responses/badRequestResponse.yaml'
'500':
$ref: '../../responses/internalServerErrorResponse.yaml'
8 changes: 8 additions & 0 deletions api/responses/badRequestResponse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
description: Validation errors
content:
application/json:
schema:
$ref: "../schemas/common/errorCollection.yaml"
examples:
validationErrorResponse:
$ref: "../examples/response/validationErrorResponse.yaml"
8 changes: 8 additions & 0 deletions api/responses/internalServerErrorResponse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
description: When unhandled exception occurred during code execution, e.g. NullPointerException.
content:
application/json:
schema:
$ref: "../schemas/common/errorCollection.yaml"
examples:
unknownError:
$ref: "../examples/response/unknownErrorResponse.yaml"
16 changes: 16 additions & 0 deletions api/schemas/common/error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
description: An error
type: object
properties:
message:
type: string
description: Error message text
type:
type: string
description: Error message type
code:
type: string
description: Error message code
parameters:
type: array
items:
$ref: 'parameter.yaml'
18 changes: 18 additions & 0 deletions api/schemas/common/errorCollection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
description: A List of errors
type: object
properties:
errors:
description: List of errors
type: array
items:
$ref: 'error.yaml'
totalRecords:
description: Total number of errors
type: integer
example:
errors:
- message: Illegal argument error
type: IllegalArgumentException
code: unknown_error
total_records: 1

17 changes: 17 additions & 0 deletions api/schemas/common/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
description: Creater, updater, creation date, last updated date
type: object
properties:
createdDate:
description: Date and time when the record was created
type: string
createdByUserId:
description: ID of the user who created the record (when available)
type: string
format: uuid
updatedDate:
description: Date and time when the record was last updated
type: string
updatedByUserId:
description: ID of the user who last updated the record (when available)
type: string
format: uuid
12 changes: 12 additions & 0 deletions api/schemas/common/parameter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
description: List of key/value parameters of an error
type: object
properties:
key:
description: Parameter key
type: string
value:
description: Parameter value
type: string
example:
key: source
value: null

Check failure on line 12 in api/schemas/common/parameter.yaml

View workflow job for this annotation

GitHub Actions / Lint (push)

oas3-valid-schema-example

"value" property type must be string
3 changes: 3 additions & 0 deletions api/schemas/family.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type: string
enum:
- MARC
4 changes: 4 additions & 0 deletions api/schemas/familyProfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type: string
enum:
- authority
- bibliographic
17 changes: 17 additions & 0 deletions api/schemas/specification.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
type: object
x-parent: "abstract"
properties:
id:
type: string
format: uuid
title:
type: string
family:
$ref: 'family.yaml'
profile:
$ref: 'familyProfile.yaml'
url:
type: string
format: url
metadata:
$ref: 'common/metadata.yaml'
10 changes: 10 additions & 0 deletions api/schemas/specificationCollection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type: object
properties:
specifications:
type: array
items:
oneOf:
- $ref: 'specification.yaml'
- $ref: 'specificationFull.yaml'
totalRecords:
type: integer
12 changes: 12 additions & 0 deletions api/schemas/specificationFull.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
allOf:
- $ref: 'specification.yaml'
- type: object
properties:
fields:
type: array
items:
type: object
rules:
type: array
items:
type: object
2 changes: 1 addition & 1 deletion descriptors/DeploymentDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"srvcId": "@artifactId@-@version@",
"nodeId": "localhost",
"descriptor": {
"exec": "java -Dport=%p -jar ../mod-record-specifications/target/mod-record-specifications-fat.jar -Dhttp.port=%p embed_postgres=true"
"exec": "java -Dport=%p -jar ../mod-record-specifications/mod-record-specifications-server/target/mod-record-specifications-fat.jar -Dhttp.port=%p"
}
}

28 changes: 28 additions & 0 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
"id": "@artifactId@-@version@",
"name": "Record Specifications",
"provides": [
{
"id": "specification-storage",
"version": "1.0",
"handlers": [
{
"methods": [
"GET"
],
"pathPattern": "/specification-storage/specifications",
"permissionsRequired": [
"specification-storage.specifications.collection.get"
]
}
]
},
{
"id": "_tenant",
"version": "2.0",
Expand All @@ -24,6 +39,19 @@
}
],
"permissionSets": [
{
"permissionName": "specification-storage.specifications.collection.get",
"displayName": "Specification Storage - Get specification collection",
"description": "Get specification collection"
},
{
"permissionName": "specification-storage.all",
"displayName": "Specification Storage - All permissions",
"description": "Entire set of permissions needed to manage specifications",
"subPermissions": [
"specification-storage.specifications.collection.get"
]
}
],
"launchDescriptor": {
"dockerImage": "@artifactId@:@version@",
Expand Down
19 changes: 6 additions & 13 deletions mod-record-specifications-dto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
<artifactId>jackson-databind-nullable</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator</artifactId>
Expand Down Expand Up @@ -66,21 +70,10 @@
<configOptions>
<library>spring-boot</library>
<useSpringBoot3>true</useSpringBoot3>
<sourceFolder>model</sourceFolder>
</configOptions>
</configuration>
</execution>
<execution>
<id>Client generation</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.parent.basedir}/${openapi.input.file}</inputSpec>
<output>${project.build.directory}/generated-sources</output>
<modelPackage>${project.groupId}.rspec.domain.dto</modelPackage>
<generatorName>mysql-schema</generatorName>
</configuration>
</execution>
</executions>
</plugin>

Expand All @@ -96,7 +89,7 @@
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/src/main/java</source>
<source>${project.build.directory}/generated-sources/model</source>
</sources>
</configuration>
</execution>
Expand Down
Loading

0 comments on commit fdf1300

Please sign in to comment.