-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat:Add /files API resource with CRUD and download endpoints to OpenAPI spec #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughA new Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API
Client->>API: GET /files
API-->>Client: List of file objects
Client->>API: POST /files (multipart/form-data)
API-->>Client: File object or 413 error
Client->>API: GET /files/{file_id}
API-->>Client: File metadata or 404
Client->>API: DELETE /files/{file_id}
API-->>Client: 204 No Content or 404
Client->>API: GET /files/{file_id}/download?owner&expiry&signature
API-->>Client: File binary data or 404
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (6)
src/libs/Replicate/openapi.yaml (6)
272-297: Add pagination query parameters to the list endpoint
CurrentlyGET /filesreturnsnext/previousURLs but does not accept any query parameters such aslimitorcursor. This makes client‐side paging rely solely on the returned URLs.Consider adding parameters consistent with other list endpoints (e.g.,
limit,cursor):/files: get: parameters: - name: limit in: query description: Maximum number of files to return. schema: type: integer default: 100 - name: cursor in: query description: Cursor for pagination. schema: type: string ...This will give clients more flexibility when fetching pages.
298-343: Align the form field nametypewith the response schema
The create endpoint’s multipart form schema uses atypefield for the MIME type, but the file resource schema usescontent_type. Renaming the form field tocontent_typeimproves consistency and reduces confusion. You can still accepttypeas an alias if needed.Example diff:
requestBody: content: multipart/form-data: schema: required: - content - - filename + - filename type: object properties: content: type: string format: binary filename: maxLength: 255 type: string description: The filename - type: - type: string - description: The content / MIME type for the file - default: application/octet-stream + content_type: + type: string + description: The content / MIME type for the file + default: application/octet-stream metadata: type: object description: User-provided metadata associated with the file
345-369: Mark thedetailfield as required in the 404 error schema
In the 404 response forDELETE /files/{file_id}, thedetailproperty is defined but not listed underrequired. It’s best practice to explicitly mark required fields in error schemas.Example diff:
responses: '404': description: File not found content: application/problem+json: schema: - type: object - properties: + type: object + required: + - detail + properties: detail: type: string example: File not found
371-399: Provide an example response for the GET file endpoint
GET /files/{file_id}returnsschemas_file_responsebut lacks an example. Including an example under the200response will help API consumers understand the resource shape.responses: '200': description: Success content: application/json: schema: $ref: '#/components/schemas/schemas_file_response' + example: + id: cneqzikepnug6xezperrr4z55o + urls: + get: https://api.replicate.com/v1/files/cneqzikepnug6xezperrr4z55o + content_type: application/zip + size: 69420 + checksums: + sha256: f047f8e745f9996c6e386064e06cb2007b8e6bc0a968a334fc0d2b2d64012066 + metadata: + customer_reference_id: 123 + created_at: '2024-02-21T12:54:18.5787610+00:00' + expires_at: '2024-02-21T13:54:18.5787610+00:00'
399-448: Include aContent-Dispositionheader in the download response
ForGET /files/{file_id}/download, adding aContent-Dispositionheader helps clients determine the download filename.Example diff:
responses: '200': description: Success content: application/octet-stream: schema: type: string format: binary + headers: + Content-Disposition: + description: Suggests a default filename for download (e.g., `attachment; filename="example.zip"`). + schema: + type: string
1032-1088: Enhanceschemas_file_responsewith a default formetadata
Themetadataproperty isrequiredbut has no default. It’s common to default this to an empty object to clarify expectations.Example diff:
schemas_file_response: required: - id - urls - content_type - size - checksums - metadata - created_at - expires_at type: object properties: metadata: type: object description: Metadata provided by user when the file was created + default: {} example: customer_reference_id: 123You might also consider adding a top‐level example to the schema.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (33)
src/libs/Replicate/Generated/JsonSerializerContextTypes.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.IReplicateApi.FilesCreate.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.IReplicateApi.FilesDelete.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.IReplicateApi.FilesDownload.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.IReplicateApi.FilesGet.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.IReplicateApi.FilesList.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.FilesCreateRequest.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.FilesCreateRequest.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.FilesCreateRequestMetadata.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.FilesCreateRequestMetadata.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.FilesCreateResponse.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.FilesCreateResponse.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.FilesDeleteResponse.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.FilesDeleteResponse.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.FilesDownloadResponse.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.FilesDownloadResponse.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.FilesGetResponse.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.FilesGetResponse.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.FilesListResponse.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.FilesListResponse.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasFileResponse.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasFileResponse.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasFileResponseChecksums.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasFileResponseChecksums.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasFileResponseMetadata.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasFileResponseMetadata.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasFileResponseUrls.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasFileResponseUrls.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.FilesCreate.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.FilesDelete.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.FilesDownload.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.FilesGet.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.FilesList.g.csis excluded by!**/generated/**
📒 Files selected for processing (1)
src/libs/Replicate/openapi.yaml(2 hunks)
Summary by CodeRabbit