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
|
@NoArgsConstructor
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
public class PDFFile {
|
public class PDFFile {
|
||||||
@Schema(
|
@Schema(description = "The input PDF file", format = "binary")
|
||||||
description = "The input PDF file",
|
|
||||||
contentMediaType = "application/pdf",
|
|
||||||
format = "binary")
|
|
||||||
private MultipartFile fileInput;
|
private MultipartFile fileInput;
|
||||||
|
|
||||||
@Schema(
|
@Schema(
|
||||||
|
@ -52,7 +52,7 @@ public class OpenApiConfig {
|
|||||||
.email("contact@stirlingpdf.com"))
|
.email("contact@stirlingpdf.com"))
|
||||||
.description(DEFAULT_DESCRIPTION);
|
.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
|
// Add server configuration from environment variable
|
||||||
String swaggerServerUrl = System.getenv("SWAGGER_SERVER_URL");
|
String swaggerServerUrl = System.getenv("SWAGGER_SERVER_URL");
|
||||||
|
@ -21,9 +21,6 @@ import com.fasterxml.jackson.databind.JsonMappingException;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
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 io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -59,38 +56,6 @@ public class PipelineController {
|
|||||||
"This endpoint processes multiple PDF files through a configurable pipeline of operations. "
|
"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. "
|
+ "Users provide files and a JSON configuration defining the sequence of operations to perform. "
|
||||||
+ "Input:PDF Output:PDF/ZIP Type:MIMO")
|
+ "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)
|
public ResponseEntity<byte[]> handleData(@ModelAttribute HandleDataRequest request)
|
||||||
throws JsonMappingException, JsonProcessingException {
|
throws JsonMappingException, JsonProcessingException {
|
||||||
MultipartFile[] files = request.getFileInput();
|
MultipartFile[] files = request.getFileInput();
|
||||||
|
@ -13,8 +13,9 @@ public class EditTableOfContentsRequest extends PDFFile {
|
|||||||
|
|
||||||
@Schema(
|
@Schema(
|
||||||
description = "Bookmark structure in JSON format",
|
description = "Bookmark structure in JSON format",
|
||||||
|
type = "string",
|
||||||
example =
|
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;
|
private String bookmarkData;
|
||||||
|
|
||||||
@Schema(
|
@Schema(
|
||||||
|
@ -15,8 +15,11 @@ public class HandleDataRequest {
|
|||||||
private MultipartFile[] fileInput;
|
private MultipartFile[] fileInput;
|
||||||
|
|
||||||
@Schema(
|
@Schema(
|
||||||
description = "JSON String",
|
description =
|
||||||
defaultValue = "{}",
|
"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)
|
requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private String json;
|
private String json;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ public class BookletImpositionRequest extends PDFFile {
|
|||||||
@Schema(
|
@Schema(
|
||||||
description = "The number of pages to fit onto a single sheet in the output PDF.",
|
description = "The number of pages to fit onto a single sheet in the output PDF.",
|
||||||
type = "integer",
|
type = "integer",
|
||||||
defaultValue = "2",
|
|
||||||
requiredMode = Schema.RequiredMode.REQUIRED,
|
requiredMode = Schema.RequiredMode.REQUIRED,
|
||||||
allowableValues = {"2", "4"})
|
allowableValues = {"2", "4"})
|
||||||
private int pagesPerSheet = 2;
|
private int pagesPerSheet = 2;
|
||||||
|
@ -14,10 +14,9 @@ public class MergeMultiplePagesRequest extends PDFFile {
|
|||||||
@Schema(
|
@Schema(
|
||||||
description = "The number of pages to fit onto a single sheet in the output PDF.",
|
description = "The number of pages to fit onto a single sheet in the output PDF.",
|
||||||
type = "integer",
|
type = "integer",
|
||||||
defaultValue = "2",
|
|
||||||
requiredMode = Schema.RequiredMode.REQUIRED,
|
requiredMode = Schema.RequiredMode.REQUIRED,
|
||||||
allowableValues = {"2", "3", "4", "9", "16"})
|
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")
|
@Schema(description = "Boolean for if you wish to add border around the pages")
|
||||||
private Boolean addBorder;
|
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.",
|
"The angle by which to rotate the PDF file. This should be a multiple of 90.",
|
||||||
type = "integer",
|
type = "integer",
|
||||||
requiredMode = Schema.RequiredMode.REQUIRED,
|
requiredMode = Schema.RequiredMode.REQUIRED,
|
||||||
allowableValues = {"0", "90", "180", "270"},
|
allowableValues = {"0", "90", "180", "270"})
|
||||||
defaultValue = "90")
|
private Integer angle = 90;
|
||||||
private Integer angle;
|
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,8 @@ public class AddPageNumbersRequest extends PDFWithPageNums {
|
|||||||
+ " 7=bottom-left, 8=bottom-center, 9=bottom-right)",
|
+ " 7=bottom-left, 8=bottom-center, 9=bottom-right)",
|
||||||
type = "integer",
|
type = "integer",
|
||||||
allowableValues = {"1", "2", "3", "4", "5", "6", "7", "8", "9"},
|
allowableValues = {"1", "2", "3", "4", "5", "6", "7", "8", "9"},
|
||||||
defaultValue = "8",
|
|
||||||
requiredMode = RequiredMode.REQUIRED)
|
requiredMode = RequiredMode.REQUIRED)
|
||||||
private int position;
|
private int position = 8;
|
||||||
|
|
||||||
@Schema(
|
@Schema(
|
||||||
description = "Starting number for page numbering",
|
description = "Starting number for page numbering",
|
||||||
|
@ -56,9 +56,8 @@ public class AddStampRequest extends PDFWithPageNums {
|
|||||||
+ " 7: top-left, 8: top-center, 9: top-right)",
|
+ " 7: top-left, 8: top-center, 9: top-right)",
|
||||||
type = "integer",
|
type = "integer",
|
||||||
allowableValues = {"1", "2", "3", "4", "5", "6", "7", "8", "9"},
|
allowableValues = {"1", "2", "3", "4", "5", "6", "7", "8", "9"},
|
||||||
defaultValue = "5",
|
|
||||||
requiredMode = Schema.RequiredMode.REQUIRED)
|
requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private int position;
|
private int position = 5;
|
||||||
|
|
||||||
@Schema(
|
@Schema(
|
||||||
description =
|
description =
|
||||||
|
@ -16,10 +16,9 @@ public class OptimizePdfRequest extends PDFFile {
|
|||||||
"The level of optimization to apply to the PDF file. Higher values indicate"
|
"The level of optimization to apply to the PDF file. Higher values indicate"
|
||||||
+ " greater compression but may reduce quality.",
|
+ " greater compression but may reduce quality.",
|
||||||
type = "integer",
|
type = "integer",
|
||||||
defaultValue = "5",
|
|
||||||
requiredMode = Schema.RequiredMode.REQUIRED,
|
requiredMode = Schema.RequiredMode.REQUIRED,
|
||||||
allowableValues = {"1", "2", "3", "4", "5", "6", "7", "8", "9"})
|
allowableValues = {"1", "2", "3", "4", "5", "6", "7", "8", "9"})
|
||||||
private Integer optimizeLevel;
|
private Integer optimizeLevel = 5;
|
||||||
|
|
||||||
@Schema(
|
@Schema(
|
||||||
description = "The expected output size, e.g. '100MB', '25KB', etc.",
|
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",
|
description = "The length of the encryption key",
|
||||||
type = "integer",
|
type = "integer",
|
||||||
allowableValues = {"40", "128", "256"},
|
allowableValues = {"40", "128", "256"},
|
||||||
defaultValue = "256",
|
|
||||||
requiredMode = Schema.RequiredMode.REQUIRED)
|
requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private int keyLength = 256;
|
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
|
# Set the URL of the OpenAPI JSON for the Swagger UI
|
||||||
springdoc.swagger-ui.url=/v1/api-docs
|
springdoc.swagger-ui.url=/v1/api-docs
|
||||||
springdoc.swagger-ui.path=/index.html
|
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.api.key=phc_fiR65u5j6qmXTYL56MNrLZSWqLaDW74OrZH0Insd2xq
|
||||||
posthog.host=https://eu.i.posthog.com
|
posthog.host=https://eu.i.posthog.com
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ import java.io.Serializable;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
@ -30,6 +32,7 @@ public class Team implements Serializable {
|
|||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "team", cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(mappedBy = "team", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
|
@JsonIgnore
|
||||||
private Set<User> users = new HashSet<>();
|
private Set<User> users = new HashSet<>();
|
||||||
|
|
||||||
public void addUser(User user) {
|
public void addUser(User user) {
|
||||||
|
@ -4,6 +4,8 @@ import java.io.Serializable;
|
|||||||
|
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
@ -33,6 +35,7 @@ public class Authority implements GrantedAuthority, Serializable {
|
|||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "user_id")
|
@JoinColumn(name = "user_id")
|
||||||
|
@JsonIgnore
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
public Authority() {}
|
public Authority() {}
|
||||||
|
@ -9,6 +9,8 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@ -62,6 +64,7 @@ public class User implements UserDetails, Serializable {
|
|||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "team_id")
|
@JoinColumn(name = "team_id")
|
||||||
|
@JsonIgnore
|
||||||
private Team team;
|
private Team team;
|
||||||
|
|
||||||
@ElementCollection
|
@ElementCollection
|
||||||
|
Loading…
x
Reference in New Issue
Block a user