mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-18 01:19:24 +00:00
fixes and cleanups
This commit is contained in:
parent
073332b7a5
commit
da83e67017
@ -12,10 +12,7 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class PDFFile {
|
||||
@Schema(
|
||||
description = "The input PDF file",
|
||||
contentMediaType = "application/pdf",
|
||||
format = "binary")
|
||||
@Schema(description = "The input PDF file", format = "binary")
|
||||
private MultipartFile fileInput;
|
||||
|
||||
@Schema(
|
||||
|
@ -52,7 +52,7 @@ public class OpenApiConfig {
|
||||
.email("contact@stirlingpdf.com"))
|
||||
.description(DEFAULT_DESCRIPTION);
|
||||
|
||||
OpenAPI openAPI = new OpenAPI().info(info);
|
||||
OpenAPI openAPI = new OpenAPI().info(info).openapi("3.0.3");
|
||||
|
||||
// Add server configuration from environment variable
|
||||
String swaggerServerUrl = System.getenv("SWAGGER_SERVER_URL");
|
||||
|
@ -21,9 +21,6 @@ import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -59,38 +56,6 @@ public class PipelineController {
|
||||
"This endpoint processes multiple PDF files through a configurable pipeline of operations. "
|
||||
+ "Users provide files and a JSON configuration defining the sequence of operations to perform. "
|
||||
+ "Input:PDF Output:PDF/ZIP Type:MIMO")
|
||||
@RequestBody(
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "multipart/form-data",
|
||||
examples =
|
||||
@ExampleObject(
|
||||
name = "Email Preparation Pipeline",
|
||||
summary =
|
||||
"Repair, sanitize, and compress PDFs for email",
|
||||
value =
|
||||
"{\n"
|
||||
+ " \"name\": \"Prepare-pdfs-for-email\",\n"
|
||||
+ " \"pipeline\": [\n"
|
||||
+ " {\n"
|
||||
+ " \"operation\": \"/api/v1/misc/repair\",\n"
|
||||
+ " \"parameters\": {}\n"
|
||||
+ " },\n"
|
||||
+ " {\n"
|
||||
+ " \"operation\": \"/api/v1/security/sanitize-pdf\",\n"
|
||||
+ " \"parameters\": {\n"
|
||||
+ " \"removeJavaScript\": true,\n"
|
||||
+ " \"removeEmbeddedFiles\": false\n"
|
||||
+ " }\n"
|
||||
+ " },\n"
|
||||
+ " {\n"
|
||||
+ " \"operation\": \"/api/v1/misc/compress-pdf\",\n"
|
||||
+ " \"parameters\": {\n"
|
||||
+ " \"optimizeLevel\": 2\n"
|
||||
+ " }\n"
|
||||
+ " }\n"
|
||||
+ " ]\n"
|
||||
+ "}")))
|
||||
public ResponseEntity<byte[]> handleData(@ModelAttribute HandleDataRequest request)
|
||||
throws JsonMappingException, JsonProcessingException {
|
||||
MultipartFile[] files = request.getFileInput();
|
||||
|
@ -13,8 +13,9 @@ public class EditTableOfContentsRequest extends PDFFile {
|
||||
|
||||
@Schema(
|
||||
description = "Bookmark structure in JSON format",
|
||||
type = "string",
|
||||
example =
|
||||
"[{\"title\":\"Chapter 1\",\"pageNumber\":1,\"children\":[{\"title\":\"Section 1.1\",\"pageNumber\":2}]}]")
|
||||
"[{\\\"title\\\":\\\"Chapter 1\\\",\\\"pageNumber\\\":1,\\\"children\\\":[{\\\"title\\\":\\\"Section 1.1\\\",\\\"pageNumber\\\":2}]}]")
|
||||
private String bookmarkData;
|
||||
|
||||
@Schema(
|
||||
|
@ -15,8 +15,11 @@ public class HandleDataRequest {
|
||||
private MultipartFile[] fileInput;
|
||||
|
||||
@Schema(
|
||||
description = "JSON String",
|
||||
defaultValue = "{}",
|
||||
description =
|
||||
"Pipeline configuration in JSON format containing name and operations list",
|
||||
type = "string",
|
||||
example =
|
||||
"{\\\"name\\\":\\\"Prepare-pdfs-for-email\\\",\\\"pipeline\\\":[{\\\"operation\\\":\\\"/api/v1/misc/repair\\\",\\\"parameters\\\":{}},{\\\"operation\\\":\\\"/api/v1/security/sanitize-pdf\\\",\\\"parameters\\\":{\\\"removeJavaScript\\\":true,\\\"removeEmbeddedFiles\\\":false}},{\\\"operation\\\":\\\"/api/v1/misc/compress-pdf\\\",\\\"parameters\\\":{\\\"optimizeLevel\\\":2}}]}",
|
||||
requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String json;
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ public class BookletImpositionRequest extends PDFFile {
|
||||
@Schema(
|
||||
description = "The number of pages to fit onto a single sheet in the output PDF.",
|
||||
type = "integer",
|
||||
defaultValue = "2",
|
||||
requiredMode = Schema.RequiredMode.REQUIRED,
|
||||
allowableValues = {"2", "4"})
|
||||
private int pagesPerSheet = 2;
|
||||
|
@ -14,10 +14,9 @@ public class MergeMultiplePagesRequest extends PDFFile {
|
||||
@Schema(
|
||||
description = "The number of pages to fit onto a single sheet in the output PDF.",
|
||||
type = "integer",
|
||||
defaultValue = "2",
|
||||
requiredMode = Schema.RequiredMode.REQUIRED,
|
||||
allowableValues = {"2", "3", "4", "9", "16"})
|
||||
private int pagesPerSheet;
|
||||
private int pagesPerSheet = 2;
|
||||
|
||||
@Schema(description = "Boolean for if you wish to add border around the pages")
|
||||
private Boolean addBorder;
|
||||
|
@ -16,7 +16,6 @@ public class RotatePDFRequest extends PDFFile {
|
||||
"The angle by which to rotate the PDF file. This should be a multiple of 90.",
|
||||
type = "integer",
|
||||
requiredMode = Schema.RequiredMode.REQUIRED,
|
||||
allowableValues = {"0", "90", "180", "270"},
|
||||
defaultValue = "90")
|
||||
private Integer angle;
|
||||
allowableValues = {"0", "90", "180", "270"})
|
||||
private Integer angle = 90;
|
||||
}
|
||||
|
@ -39,9 +39,8 @@ public class AddPageNumbersRequest extends PDFWithPageNums {
|
||||
+ " 7=bottom-left, 8=bottom-center, 9=bottom-right)",
|
||||
type = "integer",
|
||||
allowableValues = {"1", "2", "3", "4", "5", "6", "7", "8", "9"},
|
||||
defaultValue = "8",
|
||||
requiredMode = RequiredMode.REQUIRED)
|
||||
private int position;
|
||||
private int position = 8;
|
||||
|
||||
@Schema(
|
||||
description = "Starting number for page numbering",
|
||||
|
@ -56,9 +56,8 @@ public class AddStampRequest extends PDFWithPageNums {
|
||||
+ " 7: top-left, 8: top-center, 9: top-right)",
|
||||
type = "integer",
|
||||
allowableValues = {"1", "2", "3", "4", "5", "6", "7", "8", "9"},
|
||||
defaultValue = "5",
|
||||
requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private int position;
|
||||
private int position = 5;
|
||||
|
||||
@Schema(
|
||||
description =
|
||||
|
@ -16,10 +16,9 @@ public class OptimizePdfRequest extends PDFFile {
|
||||
"The level of optimization to apply to the PDF file. Higher values indicate"
|
||||
+ " greater compression but may reduce quality.",
|
||||
type = "integer",
|
||||
defaultValue = "5",
|
||||
requiredMode = Schema.RequiredMode.REQUIRED,
|
||||
allowableValues = {"1", "2", "3", "4", "5", "6", "7", "8", "9"})
|
||||
private Integer optimizeLevel;
|
||||
private Integer optimizeLevel = 5;
|
||||
|
||||
@Schema(
|
||||
description = "The expected output size, e.g. '100MB', '25KB', etc.",
|
||||
|
@ -29,7 +29,6 @@ public class AddPasswordRequest extends PDFFile {
|
||||
description = "The length of the encryption key",
|
||||
type = "integer",
|
||||
allowableValues = {"40", "128", "256"},
|
||||
defaultValue = "256",
|
||||
requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private int keyLength = 256;
|
||||
|
||||
|
@ -49,6 +49,8 @@ springdoc.api-docs.path=/v1/api-docs
|
||||
# Set the URL of the OpenAPI JSON for the Swagger UI
|
||||
springdoc.swagger-ui.url=/v1/api-docs
|
||||
springdoc.swagger-ui.path=/index.html
|
||||
# Force OpenAPI 3.0 specification version
|
||||
springdoc.api-docs.version=OPENAPI_3_0
|
||||
posthog.api.key=phc_fiR65u5j6qmXTYL56MNrLZSWqLaDW74OrZH0Insd2xq
|
||||
posthog.host=https://eu.i.posthog.com
|
||||
|
||||
|
@ -4,6 +4,8 @@ import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import lombok.*;
|
||||
@ -30,6 +32,7 @@ public class Team implements Serializable {
|
||||
private String name;
|
||||
|
||||
@OneToMany(mappedBy = "team", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JsonIgnore
|
||||
private Set<User> users = new HashSet<>();
|
||||
|
||||
public void addUser(User user) {
|
||||
|
@ -4,6 +4,8 @@ import java.io.Serializable;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
@ -33,6 +35,7 @@ public class Authority implements GrantedAuthority, Serializable {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user_id")
|
||||
@JsonIgnore
|
||||
private User user;
|
||||
|
||||
public Authority() {}
|
||||
|
@ -9,6 +9,8 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -62,6 +64,7 @@ public class User implements UserDetails, Serializable {
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "team_id")
|
||||
@JsonIgnore
|
||||
private Team team;
|
||||
|
||||
@ElementCollection
|
||||
|
Loading…
x
Reference in New Issue
Block a user