Skip to content

Commit

Permalink
Merge branch 'main' into fix-openapi-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
grigoriev authored Jan 8, 2025
2 parents 0166816 + 3e7abb9 commit e58412d
Show file tree
Hide file tree
Showing 26 changed files with 165 additions and 122 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/openapi-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
with:
fetch-depth: 0
- name: 🧪 Validate OpenAPI definition
uses: swaggerexpert/swagger-editor-validate@e8e51dbc8c18e87f96b082b18a6a7cbd3c44abd8 # v1.4.2
uses: swaggerexpert/swagger-editor-validate@e8e51dbc8c18e87f96b082b18a6a7cbd3c44abd8 # v1.4.2
with:
definition-file: docs/openapi.json
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ repos:
- id: check-git-config-user-email
args: [--templates, ^\S+\.\S+@sbb\.ch$]
- repo: https://github.com/commitizen-tools/commitizen
rev: v4.0.0
rev: v4.1.0
hooks:
- id: commitizen
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ All good so far.

### Upgrade from version 7.x.x to 8.0.0

In version 8.0.0 support for Polarion 2404 and older has been dropped. This extensions supports only Polarion 2410.
In version 8.0.0 support for Polarion 2404 and older has been dropped. This extension supports only Polarion 2410.
Recommended version of WeasyPrint Service is 63.1.0.

### Upgrade from version 6.x.x to 7.0.0

Expand Down
95 changes: 32 additions & 63 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -886,11 +886,6 @@
"description": "Images deleted successfully"
}
},
"security": [
{
"bearerAuth": []
}
],
"summary": "Deletes images in SVN linked to specified cover page within specified scope (global or certain project)",
"tags": [
"Settings"
Expand All @@ -905,11 +900,6 @@
"description": "Template names retrieved successfully"
}
},
"security": [
{
"bearerAuth": []
}
],
"summary": "Get list of cover page predefined template names",
"tags": [
"Settings"
Expand Down Expand Up @@ -941,11 +931,6 @@
"description": "Template persisted successfully"
}
},
"security": [
{
"bearerAuth": []
}
],
"summary": "Persist content of cover page predefined template",
"tags": [
"Settings"
Expand Down Expand Up @@ -991,11 +976,6 @@
"description": "Localization file downloaded successfully"
}
},
"security": [
{
"bearerAuth": []
}
],
"summary": "Downloads localization values by name of localization settings",
"tags": [
"Settings"
Expand Down Expand Up @@ -1040,54 +1020,35 @@
"description": "Localization file uploaded successfully"
}
},
"security": [
{
"bearerAuth": []
}
],
"summary": "Uploads localization values",
"tags": [
"Settings"
]
}
},
"/api/settings/style-package/suitable-names": {
"get": {
"post": {
"operationId": "getSuitableStylePackageNames",
"parameters": [
{
"in": "query",
"name": "projectId",
"schema": {
"type": "string"
}
},
{
"in": "query",
"name": "spaceId",
"schema": {
"type": "string"
"requestBody": {
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/DocIdentifier"
},
"type": "array"
}
}
},
{
"in": "query",
"name": "documentName",
"schema": {
"type": "string"
}
}
],
"description": "List of document identifiers",
"required": true
},
"responses": {
"200": {
"description": "Successfully retrieved the list of style package names"
}
},
"security": [
{
"bearerAuth": []
}
],
"summary": "Get list of style packages suitable for a document",
"summary": "Get list of style packages suitable for the specified list of documents (sorted by weight)",
"tags": [
"Settings"
]
Expand All @@ -1110,11 +1071,6 @@
"description": "Successfully retrieved the list of style package names with the weight information"
}
},
"security": [
{
"bearerAuth": []
}
],
"summary": "Get full list of available style packages for the specific scope with the weight information",
"tags": [
"Settings"
Expand Down Expand Up @@ -1144,11 +1100,6 @@
"description": "default response"
}
},
"security": [
{
"bearerAuth": []
}
],
"summary": "Update weight information for the provided style packages",
"tags": [
"Settings"
Expand Down Expand Up @@ -1651,6 +1602,24 @@
},
"type": "object"
},
"DocIdentifier": {
"description": "Unique document identifier data",
"properties": {
"documentName": {
"description": "Document name",
"type": "string"
},
"projectId": {
"description": "Project ID",
"type": "string"
},
"spaceId": {
"description": "Space ID",
"type": "string"
}
},
"type": "object"
},
"DocumentCollectionEntry": {
"description": "Details about document from collection",
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<properties>
<pdfbox.version>3.0.3</pdfbox.version>
<okapi.xliff.version>1.47.0</okapi.xliff.version>
<byte-buddy.version>1.15.10</byte-buddy.version>
<byte-buddy.version>1.15.11</byte-buddy.version>

<slf4j.version>1.7.36</slf4j.version>
<testcontainers.version>1.20.4</testcontainers.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import ch.sbb.polarion.extension.pdf_exporter.rest.model.conversion.DocumentType;
import ch.sbb.polarion.extension.pdf_exporter.rest.model.conversion.ExportParams;
import ch.sbb.polarion.extension.pdf_exporter.rest.model.settings.localization.Language;
import ch.sbb.polarion.extension.pdf_exporter.rest.model.settings.stylepackage.DocIdentifier;
import ch.sbb.polarion.extension.pdf_exporter.rest.model.settings.stylepackage.StylePackageModel;
import ch.sbb.polarion.extension.pdf_exporter.service.PdfExporterPolarionService;
import ch.sbb.polarion.extension.pdf_exporter.service.PolarionBaselineExecutor;
Expand Down Expand Up @@ -173,7 +174,7 @@ private Collection<SettingName> getSuitableStylePackages(@NotNull IModule module
} else {
documentName = locationPath;
}
return polarionService.getSuitableStylePackages(module.getProject().getId(), spaceId, documentName);
return polarionService.getSuitableStylePackages(List.of(new DocIdentifier(module.getProject().getId(), spaceId, documentName)));
}

private Collection<SettingName> getSettingNames(@NotNull String featureName, @NotNull String scope) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ch.sbb.polarion.extension.generic.rest.filter.Secured;
import ch.sbb.polarion.extension.generic.service.PolarionService;
import ch.sbb.polarion.extension.generic.settings.SettingName;
import ch.sbb.polarion.extension.pdf_exporter.rest.model.settings.stylepackage.DocIdentifier;
import ch.sbb.polarion.extension.pdf_exporter.rest.model.settings.stylepackage.StylePackageWeightInfo;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;

Expand Down Expand Up @@ -44,8 +45,8 @@ public void deleteImages(String coverPageName, String scope) {
}

@Override
public Collection<SettingName> getSuitableStylePackageNames(String projectId, String spaceId, String documentName) {
return polarionService.callPrivileged(() -> super.getSuitableStylePackageNames(projectId, spaceId, documentName));
public Collection<SettingName> getSuitableStylePackageNames(List<DocIdentifier> docIdentifiers) {
return polarionService.callPrivileged(() -> super.getSuitableStylePackageNames(docIdentifiers));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ch.sbb.polarion.extension.generic.settings.SettingName;
import ch.sbb.polarion.extension.pdf_exporter.rest.model.settings.coverpage.CoverPageModel;
import ch.sbb.polarion.extension.pdf_exporter.rest.model.settings.localization.LocalizationModel;
import ch.sbb.polarion.extension.pdf_exporter.rest.model.settings.stylepackage.DocIdentifier;
import ch.sbb.polarion.extension.pdf_exporter.rest.model.settings.stylepackage.StylePackageWeightInfo;
import ch.sbb.polarion.extension.pdf_exporter.service.PdfExporterPolarionService;
import ch.sbb.polarion.extension.pdf_exporter.settings.CoverPageSettings;
Expand All @@ -16,7 +17,6 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import net.sf.okapi.lib.xliff2.reader.XLIFFReader;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
Expand Down Expand Up @@ -46,7 +46,6 @@
@Hidden
@Path("/internal")
@Tag(name = "Settings", description = "Operations related to PDF-exporter settings management")
@SecurityRequirement(name = "bearerAuth")
public class SettingsInternalController {

private final PdfExporterPolarionService pdfExporterPolarionService = new PdfExporterPolarionService();
Expand Down Expand Up @@ -145,20 +144,27 @@ public void deleteImages(@PathParam("name") String coverPageName, @QueryParam("s
new CoverPageSettings().deleteCoverPageImages(coverPageName, scope);
}

@GET
@POST
@Path("/settings/style-package/suitable-names")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Tag(name = "Settings")
@Operation(summary = "Get list of style packages suitable for a document",
@Operation(summary = "Get list of style packages suitable for the specified list of documents (sorted by weight)",
requestBody = @RequestBody(description = "List of document identifiers",
required = true,
content = @Content(array = @ArraySchema(schema = @Schema(implementation = DocIdentifier.class)),
mediaType = MediaType.APPLICATION_JSON
)
),
responses = {
@ApiResponse(responseCode = "200", description = "Successfully retrieved the list of style package names")
}
)
public Collection<SettingName> getSuitableStylePackageNames(@QueryParam("projectId") String projectId, @QueryParam("spaceId") String spaceId, @QueryParam("documentName") String documentName) {
if (spaceId == null || documentName == null) {
throw new BadRequestException("Parameters 'spaceId' and 'documentName' are required'");
public Collection<SettingName> getSuitableStylePackageNames(List<DocIdentifier> docIdentifiers) {
if (docIdentifiers.isEmpty()) {
throw new BadRequestException("At least one document identifier required");
}
return pdfExporterPolarionService.getSuitableStylePackages(projectId, spaceId, documentName);
return pdfExporterPolarionService.getSuitableStylePackages(docIdentifiers);
}

@GET
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ch.sbb.polarion.extension.pdf_exporter.rest.model.settings.stylepackage;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.jetbrains.annotations.NotNull;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ToString
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(description = "Unique document identifier data")
public class DocIdentifier {

@Schema(description = "Project ID")
private @NotNull String projectId;

@Schema(description = "Space ID")
private @NotNull String spaceId;

@Schema(description = "Document name")
private @NotNull String documentName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@
@JsonInclude(JsonInclude.Include.NON_NULL)
public class StylePackageWeightInfo {

@Schema(
description = "The name of the setting"
)
@Schema(description = "The name of the setting")
private String name;

@Schema(
description = "The scope of the setting"
)
@Schema(description = "The scope of the setting")
private String scope;

@Schema(
description = "The weight of the setting"
)
@Schema(description = "The weight of the setting")
private Float weight;

}
Loading

0 comments on commit e58412d

Please sign in to comment.