add better description to swagger

This commit is contained in:
2025-06-02 00:12:40 +02:00
parent c8b8e76345
commit 153b8548ba
6 changed files with 150 additions and 87 deletions

View File

@@ -22,14 +22,14 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
// Enum for the file type // Enum representing the supported file types for processing.
type FileType int32 type FileType int32
const ( const (
FileType_FILE_TYPE_UNSPECIFIED FileType = 0 // Default value for unspecified file type FileType_FILE_TYPE_UNSPECIFIED FileType = 0 // Default value when file type is not specified.
FileType_IMAGE FileType = 1 // Image file FileType_IMAGE FileType = 1 // Represents an image file type.
FileType_VIDEO FileType = 2 // Video file FileType_VIDEO FileType = 2 // Represents a video file type.
FileType_PDF FileType = 3 // PDF file FileType_PDF FileType = 3 // Represents a PDF file type.
) )
// Enum value maps for FileType. // Enum value maps for FileType.
@@ -75,13 +75,17 @@ func (FileType) EnumDescriptor() ([]byte, []int) {
return file_thumbnail_proto_rawDescGZIP(), []int{0} return file_thumbnail_proto_rawDescGZIP(), []int{0}
} }
// Request message for generating thumbnails // Request message for thumbnail generation.
//
// The file_content must be a base64-encoded file (image, video, or PDF).
// Optional max_width and max_height can be provided to resize the thumbnail
// (values of 0 mean no resizing constraints).
type ThumbnailRequest struct { type ThumbnailRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
FileContent []byte `protobuf:"bytes,1,opt,name=file_content,json=fileContent,proto3" json:"file_content,omitempty"` // File content as bytes FileContent []byte `protobuf:"bytes,1,opt,name=file_content,json=fileContent,proto3" json:"file_content,omitempty"` // Base64-encoded bytes of the file to process.
FileType FileType `protobuf:"varint,2,opt,name=file_type,json=fileType,proto3,enum=thumbnail_service.FileType" json:"file_type,omitempty"` // File type (image, video, pdf) FileType FileType `protobuf:"varint,2,opt,name=file_type,json=fileType,proto3,enum=thumbnail_service.FileType" json:"file_type,omitempty"` // Specifies the type of the file.
MaxWidth int32 `protobuf:"varint,3,opt,name=max_width,json=maxWidth,proto3" json:"max_width,omitempty"` // Optional max width for resizing (0 means no limit) MaxWidth int32 `protobuf:"varint,3,opt,name=max_width,json=maxWidth,proto3" json:"max_width,omitempty"` // Maximum width of the generated thumbnail; 0 means no limit.
MaxHeight int32 `protobuf:"varint,4,opt,name=max_height,json=maxHeight,proto3" json:"max_height,omitempty"` // Optional max height for resizing (0 means no limit) MaxHeight int32 `protobuf:"varint,4,opt,name=max_height,json=maxHeight,proto3" json:"max_height,omitempty"` // Maximum height of the generated thumbnail; 0 means no limit.
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@@ -144,11 +148,13 @@ func (x *ThumbnailRequest) GetMaxHeight() int32 {
return 0 return 0
} }
// Response message for the thumbnail generation // Response message for thumbnail generation.
//
// Contains a status message and the generated thumbnail as base64-encoded bytes.
type ThumbnailResponse struct { type ThumbnailResponse struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // Message indicating success or failure Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // Status or informational message about the thumbnail generation.
ThumbnailContent []byte `protobuf:"bytes,2,opt,name=thumbnail_content,json=thumbnailContent,proto3" json:"thumbnail_content,omitempty"` // Thumbnail content as bytes ThumbnailContent []byte `protobuf:"bytes,2,opt,name=thumbnail_content,json=thumbnailContent,proto3" json:"thumbnail_content,omitempty"` // Base64-encoded bytes of the generated thumbnail image.
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@@ -197,12 +203,16 @@ func (x *ThumbnailResponse) GetThumbnailContent() []byte {
return nil return nil
} }
// create a ocred version of a document // Request message for OCR processing.
//
// The file_content must be a base64-encoded file.
// The cleanUp flag indicates if whitespace normalization and character cleanup
// should be applied to the extracted text.
type OCRFileRequest struct { type OCRFileRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
FileContent []byte `protobuf:"bytes,1,opt,name=file_content,json=fileContent,proto3" json:"file_content,omitempty"` //file FileContent []byte `protobuf:"bytes,1,opt,name=file_content,json=fileContent,proto3" json:"file_content,omitempty"` // Base64-encoded bytes of the file to OCR.
FileType FileType `protobuf:"varint,2,opt,name=file_type,json=fileType,proto3,enum=thumbnail_service.FileType" json:"file_type,omitempty"` //file type for future adding of maybe other stuff? FileType FileType `protobuf:"varint,2,opt,name=file_type,json=fileType,proto3,enum=thumbnail_service.FileType" json:"file_type,omitempty"` // Type of the file for future extensibility.
CleanUp bool `protobuf:"varint,3,opt,name=cleanUp,proto3" json:"cleanUp,omitempty"` // if whitespace should be normalized and cleaned from "useless chars" CleanUp bool `protobuf:"varint,3,opt,name=cleanUp,proto3" json:"cleanUp,omitempty"` // Whether to normalize whitespace and remove unnecessary characters.
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@@ -258,12 +268,15 @@ func (x *OCRFileRequest) GetCleanUp() bool {
return false return false
} }
// Response message of ocred document // Response message for OCR processing.
//
// Contains a status message, the OCRed file content as bytes, and
// the extracted text content as a string.
type OCRFileResponse struct { type OCRFileResponse struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // Status Message Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // Status message about the OCR operation.
OcrContent []byte `protobuf:"bytes,2,opt,name=ocr_content,json=ocrContent,proto3" json:"ocr_content,omitempty"` //data of the ocred file OcrContent []byte `protobuf:"bytes,2,opt,name=ocr_content,json=ocrContent,proto3" json:"ocr_content,omitempty"` // Base64-encoded bytes of the OCR processed file.
TextContent string `protobuf:"bytes,3,opt,name=text_content,json=textContent,proto3" json:"text_content,omitempty"` //text of the file TextContent string `protobuf:"bytes,3,opt,name=text_content,json=textContent,proto3" json:"text_content,omitempty"` // Extracted text content from the file.
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }

View File

@@ -27,9 +27,13 @@ const (
// //
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
// //
// Service definition // Service providing thumbnail generation and OCR functionalities.
type ThumbnailServiceClient interface { type ThumbnailServiceClient interface {
// Generates a thumbnail image from a given file.
// Accepts a ThumbnailRequest and returns a ThumbnailResponse.
GenerateThumbnail(ctx context.Context, in *ThumbnailRequest, opts ...grpc.CallOption) (*ThumbnailResponse, error) GenerateThumbnail(ctx context.Context, in *ThumbnailRequest, opts ...grpc.CallOption) (*ThumbnailResponse, error)
// Performs OCR (Optical Character Recognition) on a provided file.
// Accepts an OCRFileRequest and returns an OCRFileResponse.
OcrFile(ctx context.Context, in *OCRFileRequest, opts ...grpc.CallOption) (*OCRFileResponse, error) OcrFile(ctx context.Context, in *OCRFileRequest, opts ...grpc.CallOption) (*OCRFileResponse, error)
} }
@@ -65,9 +69,13 @@ func (c *thumbnailServiceClient) OcrFile(ctx context.Context, in *OCRFileRequest
// All implementations must embed UnimplementedThumbnailServiceServer // All implementations must embed UnimplementedThumbnailServiceServer
// for forward compatibility. // for forward compatibility.
// //
// Service definition // Service providing thumbnail generation and OCR functionalities.
type ThumbnailServiceServer interface { type ThumbnailServiceServer interface {
// Generates a thumbnail image from a given file.
// Accepts a ThumbnailRequest and returns a ThumbnailResponse.
GenerateThumbnail(context.Context, *ThumbnailRequest) (*ThumbnailResponse, error) GenerateThumbnail(context.Context, *ThumbnailRequest) (*ThumbnailResponse, error)
// Performs OCR (Optical Character Recognition) on a provided file.
// Accepts an OCRFileRequest and returns an OCRFileResponse.
OcrFile(context.Context, *OCRFileRequest) (*OCRFileResponse, error) OcrFile(context.Context, *OCRFileRequest) (*OCRFileResponse, error)
mustEmbedUnimplementedThumbnailServiceServer() mustEmbedUnimplementedThumbnailServiceServer()
} }

View File

@@ -22,14 +22,14 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
// Enum for the file type // Enum representing the supported file types for processing.
type FileType int32 type FileType int32
const ( const (
FileType_FILE_TYPE_UNSPECIFIED FileType = 0 // Default value for unspecified file type FileType_FILE_TYPE_UNSPECIFIED FileType = 0 // Default value when file type is not specified.
FileType_IMAGE FileType = 1 // Image file FileType_IMAGE FileType = 1 // Represents an image file type.
FileType_VIDEO FileType = 2 // Video file FileType_VIDEO FileType = 2 // Represents a video file type.
FileType_PDF FileType = 3 // PDF file FileType_PDF FileType = 3 // Represents a PDF file type.
) )
// Enum value maps for FileType. // Enum value maps for FileType.
@@ -75,13 +75,17 @@ func (FileType) EnumDescriptor() ([]byte, []int) {
return file_thumbnail_proto_rawDescGZIP(), []int{0} return file_thumbnail_proto_rawDescGZIP(), []int{0}
} }
// Request message for generating thumbnails // Request message for thumbnail generation.
//
// The file_content must be a base64-encoded file (image, video, or PDF).
// Optional max_width and max_height can be provided to resize the thumbnail
// (values of 0 mean no resizing constraints).
type ThumbnailRequest struct { type ThumbnailRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
FileContent []byte `protobuf:"bytes,1,opt,name=file_content,json=fileContent,proto3" json:"file_content,omitempty"` // File content as bytes FileContent []byte `protobuf:"bytes,1,opt,name=file_content,json=fileContent,proto3" json:"file_content,omitempty"` // Base64-encoded bytes of the file to process.
FileType FileType `protobuf:"varint,2,opt,name=file_type,json=fileType,proto3,enum=thumbnail_service.FileType" json:"file_type,omitempty"` // File type (image, video, pdf) FileType FileType `protobuf:"varint,2,opt,name=file_type,json=fileType,proto3,enum=thumbnail_service.FileType" json:"file_type,omitempty"` // Specifies the type of the file.
MaxWidth int32 `protobuf:"varint,3,opt,name=max_width,json=maxWidth,proto3" json:"max_width,omitempty"` // Optional max width for resizing (0 means no limit) MaxWidth int32 `protobuf:"varint,3,opt,name=max_width,json=maxWidth,proto3" json:"max_width,omitempty"` // Maximum width of the generated thumbnail; 0 means no limit.
MaxHeight int32 `protobuf:"varint,4,opt,name=max_height,json=maxHeight,proto3" json:"max_height,omitempty"` // Optional max height for resizing (0 means no limit) MaxHeight int32 `protobuf:"varint,4,opt,name=max_height,json=maxHeight,proto3" json:"max_height,omitempty"` // Maximum height of the generated thumbnail; 0 means no limit.
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@@ -144,11 +148,13 @@ func (x *ThumbnailRequest) GetMaxHeight() int32 {
return 0 return 0
} }
// Response message for the thumbnail generation // Response message for thumbnail generation.
//
// Contains a status message and the generated thumbnail as base64-encoded bytes.
type ThumbnailResponse struct { type ThumbnailResponse struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // Message indicating success or failure Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // Status or informational message about the thumbnail generation.
ThumbnailContent []byte `protobuf:"bytes,2,opt,name=thumbnail_content,json=thumbnailContent,proto3" json:"thumbnail_content,omitempty"` // Thumbnail content as bytes ThumbnailContent []byte `protobuf:"bytes,2,opt,name=thumbnail_content,json=thumbnailContent,proto3" json:"thumbnail_content,omitempty"` // Base64-encoded bytes of the generated thumbnail image.
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@@ -197,12 +203,16 @@ func (x *ThumbnailResponse) GetThumbnailContent() []byte {
return nil return nil
} }
// create a ocred version of a document // Request message for OCR processing.
//
// The file_content must be a base64-encoded file.
// The cleanUp flag indicates if whitespace normalization and character cleanup
// should be applied to the extracted text.
type OCRFileRequest struct { type OCRFileRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
FileContent []byte `protobuf:"bytes,1,opt,name=file_content,json=fileContent,proto3" json:"file_content,omitempty"` //file FileContent []byte `protobuf:"bytes,1,opt,name=file_content,json=fileContent,proto3" json:"file_content,omitempty"` // Base64-encoded bytes of the file to OCR.
FileType FileType `protobuf:"varint,2,opt,name=file_type,json=fileType,proto3,enum=thumbnail_service.FileType" json:"file_type,omitempty"` //file type for future adding of maybe other stuff? FileType FileType `protobuf:"varint,2,opt,name=file_type,json=fileType,proto3,enum=thumbnail_service.FileType" json:"file_type,omitempty"` // Type of the file for future extensibility.
CleanUp bool `protobuf:"varint,3,opt,name=cleanUp,proto3" json:"cleanUp,omitempty"` // if whitespace should be normalized and cleaned from "useless chars" CleanUp bool `protobuf:"varint,3,opt,name=cleanUp,proto3" json:"cleanUp,omitempty"` // Whether to normalize whitespace and remove unnecessary characters.
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@@ -258,12 +268,15 @@ func (x *OCRFileRequest) GetCleanUp() bool {
return false return false
} }
// Response message of ocred document // Response message for OCR processing.
//
// Contains a status message, the OCRed file content as bytes, and
// the extracted text content as a string.
type OCRFileResponse struct { type OCRFileResponse struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // Status Message Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // Status message about the OCR operation.
OcrContent []byte `protobuf:"bytes,2,opt,name=ocr_content,json=ocrContent,proto3" json:"ocr_content,omitempty"` //data of the ocred file OcrContent []byte `protobuf:"bytes,2,opt,name=ocr_content,json=ocrContent,proto3" json:"ocr_content,omitempty"` // Base64-encoded bytes of the OCR processed file.
TextContent string `protobuf:"bytes,3,opt,name=text_content,json=textContent,proto3" json:"text_content,omitempty"` //text of the file TextContent string `protobuf:"bytes,3,opt,name=text_content,json=textContent,proto3" json:"text_content,omitempty"` // Extracted text content from the file.
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }

View File

@@ -27,9 +27,13 @@ const (
// //
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
// //
// Service definition // Service providing thumbnail generation and OCR functionalities.
type ThumbnailServiceClient interface { type ThumbnailServiceClient interface {
// Generates a thumbnail image from a given file.
// Accepts a ThumbnailRequest and returns a ThumbnailResponse.
GenerateThumbnail(ctx context.Context, in *ThumbnailRequest, opts ...grpc.CallOption) (*ThumbnailResponse, error) GenerateThumbnail(ctx context.Context, in *ThumbnailRequest, opts ...grpc.CallOption) (*ThumbnailResponse, error)
// Performs OCR (Optical Character Recognition) on a provided file.
// Accepts an OCRFileRequest and returns an OCRFileResponse.
OcrFile(ctx context.Context, in *OCRFileRequest, opts ...grpc.CallOption) (*OCRFileResponse, error) OcrFile(ctx context.Context, in *OCRFileRequest, opts ...grpc.CallOption) (*OCRFileResponse, error)
} }
@@ -65,9 +69,13 @@ func (c *thumbnailServiceClient) OcrFile(ctx context.Context, in *OCRFileRequest
// All implementations must embed UnimplementedThumbnailServiceServer // All implementations must embed UnimplementedThumbnailServiceServer
// for forward compatibility. // for forward compatibility.
// //
// Service definition // Service providing thumbnail generation and OCR functionalities.
type ThumbnailServiceServer interface { type ThumbnailServiceServer interface {
// Generates a thumbnail image from a given file.
// Accepts a ThumbnailRequest and returns a ThumbnailResponse.
GenerateThumbnail(context.Context, *ThumbnailRequest) (*ThumbnailResponse, error) GenerateThumbnail(context.Context, *ThumbnailRequest) (*ThumbnailResponse, error)
// Performs OCR (Optical Character Recognition) on a provided file.
// Accepts an OCRFileRequest and returns an OCRFileResponse.
OcrFile(context.Context, *OCRFileRequest) (*OCRFileResponse, error) OcrFile(context.Context, *OCRFileRequest) (*OCRFileResponse, error)
mustEmbedUnimplementedThumbnailServiceServer() mustEmbedUnimplementedThumbnailServiceServer()
} }

View File

@@ -18,6 +18,7 @@
"paths": { "paths": {
"/v1/ocr": { "/v1/ocr": {
"post": { "post": {
"summary": "Performs OCR (Optical Character Recognition) on a provided file.\nAccepts an OCRFileRequest and returns an OCRFileResponse.",
"operationId": "ThumbnailService_OcrFile", "operationId": "ThumbnailService_OcrFile",
"responses": { "responses": {
"200": { "200": {
@@ -36,6 +37,7 @@
"parameters": [ "parameters": [
{ {
"name": "body", "name": "body",
"description": "Request message for OCR processing.\n\nThe file_content must be a base64-encoded file.\nThe cleanUp flag indicates if whitespace normalization and character cleanup\nshould be applied to the extracted text.",
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "schema": {
@@ -50,6 +52,7 @@
}, },
"/v1/thumbnail": { "/v1/thumbnail": {
"post": { "post": {
"summary": "Generates a thumbnail image from a given file.\nAccepts a ThumbnailRequest and returns a ThumbnailResponse.",
"operationId": "ThumbnailService_GenerateThumbnail", "operationId": "ThumbnailService_GenerateThumbnail",
"responses": { "responses": {
"200": { "200": {
@@ -68,6 +71,7 @@
"parameters": [ "parameters": [
{ {
"name": "body", "name": "body",
"description": "Request message for thumbnail generation.\n\nThe file_content must be a base64-encoded file (image, video, or PDF).\nOptional max_width and max_height can be provided to resize the thumbnail\n(values of 0 mean no resizing constraints).",
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "schema": {
@@ -119,8 +123,7 @@
"PDF" "PDF"
], ],
"default": "FILE_TYPE_UNSPECIFIED", "default": "FILE_TYPE_UNSPECIFIED",
"description": "- FILE_TYPE_UNSPECIFIED: Default value for unspecified file type\n - IMAGE: Image file\n - VIDEO: Video file\n - PDF: PDF file", "description": "Enum representing the supported file types for processing.\n\n - FILE_TYPE_UNSPECIFIED: Default value when file type is not specified.\n - IMAGE: Represents an image file type.\n - VIDEO: Represents a video file type.\n - PDF: Represents a PDF file type."
"title": "Enum for the file type"
}, },
"thumbnail_serviceOCRFileRequest": { "thumbnail_serviceOCRFileRequest": {
"type": "object", "type": "object",
@@ -128,37 +131,37 @@
"fileContent": { "fileContent": {
"type": "string", "type": "string",
"format": "byte", "format": "byte",
"title": "file" "description": "Base64-encoded bytes of the file to OCR."
}, },
"fileType": { "fileType": {
"$ref": "#/definitions/thumbnail_serviceFileType", "$ref": "#/definitions/thumbnail_serviceFileType",
"title": "file type for future adding of maybe other stuff?" "description": "Type of the file for future extensibility."
}, },
"cleanUp": { "cleanUp": {
"type": "boolean", "type": "boolean",
"title": "if whitespace should be normalized and cleaned from \"useless chars\"" "description": "Whether to normalize whitespace and remove unnecessary characters."
} }
}, },
"title": "create a ocred version of a document" "description": "Request message for OCR processing.\n\nThe file_content must be a base64-encoded file.\nThe cleanUp flag indicates if whitespace normalization and character cleanup\nshould be applied to the extracted text."
}, },
"thumbnail_serviceOCRFileResponse": { "thumbnail_serviceOCRFileResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"message": { "message": {
"type": "string", "type": "string",
"title": "Status Message" "description": "Status message about the OCR operation."
}, },
"ocrContent": { "ocrContent": {
"type": "string", "type": "string",
"format": "byte", "format": "byte",
"title": "data of the ocred file" "description": "Base64-encoded bytes of the OCR processed file."
}, },
"textContent": { "textContent": {
"type": "string", "type": "string",
"title": "text of the file" "description": "Extracted text content from the file."
} }
}, },
"title": "Response message of ocred document" "description": "Response message for OCR processing.\n\nContains a status message, the OCRed file content as bytes, and\nthe extracted text content as a string."
}, },
"thumbnail_serviceThumbnailRequest": { "thumbnail_serviceThumbnailRequest": {
"type": "object", "type": "object",
@@ -166,39 +169,39 @@
"fileContent": { "fileContent": {
"type": "string", "type": "string",
"format": "byte", "format": "byte",
"title": "File content as bytes" "description": "Base64-encoded bytes of the file to process."
}, },
"fileType": { "fileType": {
"$ref": "#/definitions/thumbnail_serviceFileType", "$ref": "#/definitions/thumbnail_serviceFileType",
"title": "File type (image, video, pdf)" "description": "Specifies the type of the file."
}, },
"maxWidth": { "maxWidth": {
"type": "integer", "type": "integer",
"format": "int32", "format": "int32",
"title": "Optional max width for resizing (0 means no limit)" "description": "Maximum width of the generated thumbnail; 0 means no limit."
}, },
"maxHeight": { "maxHeight": {
"type": "integer", "type": "integer",
"format": "int32", "format": "int32",
"title": "Optional max height for resizing (0 means no limit)" "description": "Maximum height of the generated thumbnail; 0 means no limit."
} }
}, },
"title": "Request message for generating thumbnails" "description": "Request message for thumbnail generation.\n\nThe file_content must be a base64-encoded file (image, video, or PDF).\nOptional max_width and max_height can be provided to resize the thumbnail\n(values of 0 mean no resizing constraints)."
}, },
"thumbnail_serviceThumbnailResponse": { "thumbnail_serviceThumbnailResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"message": { "message": {
"type": "string", "type": "string",
"title": "Message indicating success or failure" "description": "Status or informational message about the thumbnail generation."
}, },
"thumbnailContent": { "thumbnailContent": {
"type": "string", "type": "string",
"format": "byte", "format": "byte",
"title": "Thumbnail content as bytes" "description": "Base64-encoded bytes of the generated thumbnail image."
} }
}, },
"title": "Response message for the thumbnail generation" "description": "Response message for thumbnail generation.\n\nContains a status message and the generated thumbnail as base64-encoded bytes."
} }
} }
} }

View File

@@ -6,22 +6,27 @@ option go_package = "./proto";
import "google/api/annotations.proto"; import "google/api/annotations.proto";
// Enum for the file type // Enum representing the supported file types for processing.
enum FileType { enum FileType {
FILE_TYPE_UNSPECIFIED = 0; // Default value for unspecified file type FILE_TYPE_UNSPECIFIED = 0; // Default value when file type is not specified.
IMAGE = 1; // Image file IMAGE = 1; // Represents an image file type.
VIDEO = 2; // Video file VIDEO = 2; // Represents a video file type.
PDF = 3; // PDF file PDF = 3; // Represents a PDF file type.
} }
// Service definition // Service providing thumbnail generation and OCR functionalities.
service ThumbnailService { service ThumbnailService {
// Generates a thumbnail image from a given file.
// Accepts a ThumbnailRequest and returns a ThumbnailResponse.
rpc GenerateThumbnail(ThumbnailRequest) returns (ThumbnailResponse) { rpc GenerateThumbnail(ThumbnailRequest) returns (ThumbnailResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/v1/thumbnail" post: "/v1/thumbnail"
body: "*" body: "*"
}; };
} }
// Performs OCR (Optical Character Recognition) on a provided file.
// Accepts an OCRFileRequest and returns an OCRFileResponse.
rpc OcrFile(OCRFileRequest) returns (OCRFileResponse) { rpc OcrFile(OCRFileRequest) returns (OCRFileResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/v1/ocr" post: "/v1/ocr"
@@ -30,30 +35,43 @@ service ThumbnailService {
} }
} }
// Request message for generating thumbnails // Request message for thumbnail generation.
//
// The file_content must be a base64-encoded file (image, video, or PDF).
// Optional max_width and max_height can be provided to resize the thumbnail
// (values of 0 mean no resizing constraints).
message ThumbnailRequest { message ThumbnailRequest {
bytes file_content = 1; // File content as bytes bytes file_content = 1; // Base64-encoded bytes of the file to process.
FileType file_type = 2; // File type (image, video, pdf) FileType file_type = 2; // Specifies the type of the file.
int32 max_width = 3; // Optional max width for resizing (0 means no limit) int32 max_width = 3; // Maximum width of the generated thumbnail; 0 means no limit.
int32 max_height = 4; // Optional max height for resizing (0 means no limit) int32 max_height = 4; // Maximum height of the generated thumbnail; 0 means no limit.
} }
// Response message for the thumbnail generation // Response message for thumbnail generation.
//
// Contains a status message and the generated thumbnail as base64-encoded bytes.
message ThumbnailResponse { message ThumbnailResponse {
string message = 1; // Message indicating success or failure string message = 1; // Status or informational message about the thumbnail generation.
bytes thumbnail_content = 2; // Thumbnail content as bytes bytes thumbnail_content = 2; // Base64-encoded bytes of the generated thumbnail image.
} }
//create a ocred version of a document // Request message for OCR processing.
//
// The file_content must be a base64-encoded file.
// The cleanUp flag indicates if whitespace normalization and character cleanup
// should be applied to the extracted text.
message OCRFileRequest { message OCRFileRequest {
bytes file_content = 1; //file bytes file_content = 1; // Base64-encoded bytes of the file to OCR.
FileType file_type = 2; //file type for future adding of maybe other stuff? FileType file_type = 2; // Type of the file for future extensibility.
bool cleanUp = 3; // if whitespace should be normalized and cleaned from "useless chars" bool cleanUp = 3; // Whether to normalize whitespace and remove unnecessary characters.
} }
//Response message of ocred document // Response message for OCR processing.
//
// Contains a status message, the OCRed file content as bytes, and
// the extracted text content as a string.
message OCRFileResponse { message OCRFileResponse {
string message = 1; // Status Message string message = 1; // Status message about the OCR operation.
bytes ocr_content = 2; //data of the ocred file bytes ocr_content = 2; // Base64-encoded bytes of the OCR processed file.
string text_content = 3; //text of the file string text_content = 3; // Extracted text content from the file.
} }