Using now "application/pdf" as Media Type for PDFs

This commit is contained in:
dankito 2024-11-21 02:42:16 +01:00
parent 2b39bb8682
commit 67c58db9d7
1 changed files with 8 additions and 3 deletions

View File

@ -18,6 +18,11 @@ class InvoicingResource(
private val service: InvoicingService private val service: InvoicingService
) { ) {
companion object {
private const val MediaTypePdf = "application/pdf"
}
@Path("xrechnung") @Path("xrechnung")
@POST @POST
@Operation(summary = "Create a XRechnung XML") @Operation(summary = "Create a XRechnung XML")
@ -34,7 +39,7 @@ class InvoicingResource(
@Path("facturx/pdf") @Path("facturx/pdf")
@POST @POST
@Produces(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaTypePdf)
@Operation(summary = "Create a Factur-X / ZUGFeRD XML, transforms it to PDF and attaches before created XML to it") @Operation(summary = "Create a Factur-X / ZUGFeRD XML, transforms it to PDF and attaches before created XML to it")
@Tag(name = "Create") @Tag(name = "Create")
fun createFacturXPdf(invoice: Invoice): Response { fun createFacturXPdf(invoice: Invoice): Response {
@ -46,12 +51,12 @@ class InvoicingResource(
@Path("attach") @Path("attach")
@POST @POST
@Consumes(MediaType.MULTIPART_FORM_DATA) @Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaTypePdf)
@Operation(summary = "Attaches the invoice data as EN 16931 XML to a PDF file, combining them to a Factur-X / ZUGFeRD hybrid PDF with XML invoice file") @Operation(summary = "Attaches the invoice data as EN 16931 XML to a PDF file, combining them to a Factur-X / ZUGFeRD hybrid PDF with XML invoice file")
@Tag(name = "Create - Attach") @Tag(name = "Create - Attach")
fun attachInvoiceXmlToPdf( fun attachInvoiceXmlToPdf(
@RestForm @PartType(MediaType.APPLICATION_JSON) invoice: Invoice, @RestForm @PartType(MediaType.APPLICATION_JSON) invoice: Invoice,
@RestForm("pdf") pdf: FileUpload @RestForm("pdf") @PartType(MediaTypePdf) pdf: FileUpload
): Response { ): Response {
val pdfFile = service.attachInvoiceXmlToPdf(invoice, pdf.uploadedFile()) val pdfFile = service.attachInvoiceXmlToPdf(invoice, pdf.uploadedFile())