Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/api-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ name: api-doc

env:
API_TYPES: 'OAS'
API_DIRECTORIES: 'folio-spring-base/src/main/resources/swagger.api'
API_DIRECTORIES: 'folio-spring-tenant-settings/src/main/resources/swagger.api'
API_EXCLUDES: ''
OUTPUT_DIR: 'folio-api-docs'
AWS_S3_BUCKET: 'foliodocs'
Expand All @@ -31,7 +31,7 @@ on:
push:
branches: [ main, master ]
paths:
- 'folio-spring-base/src/main/resources/swagger.api/**'
- 'folio-spring-tenant-settings/src/main/resources/swagger.api/**'
tags: '[vV][0-9]+.[0-9]+.[0-9]+*'

jobs:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/api-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ name: api-lint

env:
API_TYPES: 'OAS'
API_DIRECTORIES: 'folio-spring-base/src/main/resources/swagger.api'
API_DIRECTORIES: 'folio-spring-tenant-settings/src/main/resources/swagger.api'
API_EXCLUDES: ''
API_WARNINGS: false

on:
push:
paths:
- 'folio-spring-base/src/main/resources/swagger.api/**'
- 'folio-spring-tenant-settings/src/main/resources/swagger.api/**'
pull_request:
paths:
- 'folio-spring-base/src/main/resources/swagger.api/**'
- 'folio-spring-tenant-settings/src/main/resources/swagger.api/**'

jobs:
api-lint:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/api-schema-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ name: api-schema-lint
# e.g. ''

env:
API_DIRECTORIES: 'folio-spring-base/src/main/resources/swagger.api'
API_DIRECTORIES: 'folio-spring-tenant-settings/src/main/resources/swagger.api'
API_EXCLUDES: ''

on:
push:
paths:
- 'folio-spring-base/src/main/resources/swagger.api/**'
- 'folio-spring-tenant-settings/src/main/resources/swagger.api/**'
pull_request:
paths:
- 'folio-spring-base/src/main/resources/swagger.api/**'
- 'folio-spring-tenant-settings/src/main/resources/swagger.api/**'

jobs:
api-schema-lint:
Expand Down
85 changes: 10 additions & 75 deletions folio-spring-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@
<artifactId>folio-spring-base</artifactId>
<description />

<properties>
<tenant.yaml.file>${project.basedir}/src/main/resources/swagger.api/tenant.yaml</tenant.yaml.file>
<sonar.exclusions>
src/main/java/org/folio/**/FolioLiquibaseConfiguration.java
</sonar.exclusions>
</properties>

<dependencies>

<dependency>
Expand Down Expand Up @@ -87,33 +80,25 @@
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>

<!-- OAS generation -->
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator</artifactId>
<version>${openapi-generator.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator.version}</version>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>

<dependency>
Expand All @@ -134,15 +119,6 @@
<version>${mapstruct.version}</version>
</dependency>

<dependency>
<!-- Fix XML External Entity (XXE) Injection: https://security.snyk.io/vuln/SNYK-JAVA-ORGMOZILLA-1314295
Remove this <dependecy> entry when org.openapitools:openapi-generator ships with a fixed version.
-->
<groupId>org.mozilla</groupId>
<artifactId>rhino</artifactId>
<version>${rhino.version}</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -195,45 +171,4 @@

</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<executions>
<execution>
<id>tenantApi</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${tenant.yaml.file}</inputSpec>
<output>${project.build.directory}/generated-sources</output>
<generatorName>spring</generatorName>
<modelPackage>${project.groupId}.tenant.domain.dto</modelPackage>
<apiPackage>${project.groupId}.tenant.rest.resource</apiPackage>
<generateApis>true</generateApis>
<generateApiTests>true</generateApiTests>
<generateApiDocumentation>true</generateApiDocumentation>
<generateModels>true</generateModels>
<modelsToGenerate>error,errors,parameter,metadata,tenantAttributes</modelsToGenerate>
<generateModelTests>false</generateModelTests>
<generateModelDocumentation>true</generateModelDocumentation>
<generateSupportingFiles>true</generateSupportingFiles>
<supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
<configOptions>
<java8>true</java8>
<dateLibrary>java</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useSpringBoot3>true</useSpringBoot3>
<useTags>true</useTags>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,6 @@ public class TenantController implements TenantApi {

private final TenantService tenantService;

@Override
public ResponseEntity<Void> deleteTenant(String operationId) {
/*
do nothing.
*/
return noContent().build();
}

@Override
public ResponseEntity<String> getTenant(String operationId) {
throw new NotImplementedException("Not implemented");
}

@Override
public ResponseEntity<Void> postTenant(@Valid TenantAttributes tenantAttributes) {
if (isDisableJob(tenantAttributes)) {
Expand All @@ -65,6 +52,19 @@ public ResponseEntity<Void> postTenant(@Valid TenantAttributes tenantAttributes)
return noContent().build();
}

@Override
public ResponseEntity<String> getTenant(String operationId) {
throw new NotImplementedException("Not implemented");
}

@Override
public ResponseEntity<Void> deleteTenant(String operationId) {
/*
do nothing.
*/
return noContent().build();
}

private Optional<String> getParameterValue(String paramName, List<Parameter> parameters) {
if (parameters.isEmpty()) {
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package org.folio.tenant.domain.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import jakarta.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jspecify.annotations.Nullable;

@Data
@NoArgsConstructor
@JsonTypeName("error")
public final class Error {

@JsonProperty("message")
private String message;

@JsonProperty("type")
private @Nullable String type;

@JsonProperty("code")
private @Nullable String code;

@Valid
@JsonProperty("parameters")
private List<@Valid Parameter> parameters = new ArrayList<>();

public Error(String message) {
this.message = message;
}

public Error message(String message) {
this.message = message;
return this;
}

public Error type(@Nullable String type) {
this.type = type;
return this;
}

public Error code(@Nullable String code) {
this.code = code;
return this;
}

public Error parameters(List<@Valid Parameter> parameters) {
this.parameters = parameters;
return this;
}

public Error addParametersItem(Parameter parametersItem) {
if (this.parameters == null) {
this.parameters = new ArrayList<>();
}
this.parameters.add(parametersItem);
return this;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.folio.tenant.domain.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import jakarta.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jspecify.annotations.Nullable;

@Data
@NoArgsConstructor
@JsonTypeName("errors")
public final class Errors {

@Valid
@JsonProperty("errors")
private List<@Valid Error> errors = new ArrayList<>();

Check warning on line 19 in folio-spring-base/src/main/java/org/folio/tenant/domain/dto/Errors.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename field "errors"

See more on https://sonarcloud.io/project/issues?id=org.folio%3Afolio-spring-support&issues=AZ5zmFDK4zARl5cMevD8&open=AZ5zmFDK4zARl5cMevD8&pullRequest=332

@JsonProperty("total_records")
private @Nullable Integer totalRecords;

public Errors errors(List<@Valid Error> errors) {
this.errors = errors;
return this;
}

public Errors addErrorsItem(Error errorsItem) {
if (this.errors == null) {
this.errors = new ArrayList<>();
}
this.errors.add(errorsItem);
return this;
}

public Errors totalRecords(@Nullable Integer totalRecords) {
this.totalRecords = totalRecords;
return this;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.folio.tenant.domain.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jspecify.annotations.Nullable;

@Data
@NoArgsConstructor
@JsonTypeName("parameter")
public final class Parameter {

@JsonProperty("key")
private String key;

@JsonProperty("value")
private @Nullable String value;

public Parameter(String key) {
this.key = key;
}

public Parameter key(String key) {
this.key = key;
return this;
}

public Parameter value(@Nullable String value) {
this.value = value;
return this;
}
}

Loading