Skip to content

Conversation

@HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Sep 16, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a public beta Search API (GET /search) to discover models, collections, and documentation. Supports a required query and optional limit, returning structured results with collections, models (plus metadata), pages, and the original query.
    • Clear error responses for invalid queries (400) and service issues (500).
    • Added an “official” flag on models to indicate Replicate-maintained models, enabling easier filtering and trust signals.

@coderabbitai
Copy link

coderabbitai bot commented Sep 16, 2025

Walkthrough

Adds a new public GET /search endpoint (beta) with query and limit parameters, corresponding 200/400/500 responses, and new schemas for search results (collections, models with metadata, pages). Updates schemas_model_response to include an is_official boolean flag. All changes are in src/libs/Replicate/openapi.yaml.

Changes

Cohort / File(s) Summary
OpenAPI: Search endpoint and schema updates
src/libs/Replicate/openapi.yaml
Added GET /search (operationId: search) with query and limit parameters; defined 200/400/500 responses; introduced schemas_search_response, schemas_search_collection_response, schemas_search_model_metadata_response, schemas_page_response; extended schemas_model_response with is_official; included response examples for /search.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as Client
  participant A as API (OpenAPI-defined)
  participant S as Search Service

  U->>A: GET /search?query=...&limit=...
  alt Valid request
    A->>S: search(query, limit)
    S-->>A: results {collections, models{metadata, model}, pages, query}
    A-->>U: 200 OK (schemas_search_response)
  else Missing/invalid query
    A-->>U: 400 Bad Request
  else Internal error
    A->>S: search(...)
    S-->>A: error
    A-->>U: 500 Internal Server Error
  end

  note over A,S: models include is_official in schemas_model_response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I twitch my ears at /search’s debut,
Hop through models, pages too.
Collections clover, tags in dew,
An official stamp—is_official—woo!
With query crumbs and limits set,
I find the carrots on the net. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The provided title "feat:@coderabbitai" is vague and appears to be a contributor/tag token rather than a concise summary of the changes; it does not describe the primary work in this PR (adding a public GET /search endpoint, associated search schemas, and an is_official model flag) and therefore does not help a reviewer scanning history. Please replace the title with a short, descriptive sentence that highlights the main change, for example "feat(replicate): add public GET /search endpoint and search schemas" or "feat(api): add /search for models, collections, and docs (beta)"; keep it concise and focused so the PR intent is clear at a glance.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bot/update-openapi_202509160105

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@HavenDV HavenDV enabled auto-merge (squash) September 16, 2025 01:06
@HavenDV HavenDV merged commit 0ee5a2a into main Sep 16, 2025
3 of 4 checks passed
@HavenDV HavenDV deleted the bot/update-openapi_202509160105 branch September 16, 2025 01:07
@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:Add beta GET /search, new search schemas, is_official in model Sep 16, 2025
Copy link

@coderabbitai coderabbitai bot left a 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 (9)
src/libs/Replicate/openapi.yaml (9)

910-915: Align operationId naming and mark beta via vendor extension.

  • Use the repo’s dotted operationId convention for consistency (e.g., search.get).
  • Add an explicit vendor extension to flag beta status.

Apply:

-      operationId: search
+      operationId: search.get
+      x-beta: true

916-932: Tighten parameter validation and clarify intent.

  • Add minLength (and optionally maxLength) to query.
  • Current limit text says “model results”; that’s good—keep it explicit.
         - name: query
           in: query
           description: The search query string
           required: true
           schema:
             type: string
+            minLength: 1
+            maxLength: 512
             example: nano banana

933-976: Make nulls explicit in 200 example to avoid generator ambiguity.

YAML parsers differ on bare empty scalars. Use null explicitly for optional URI fields and default_example.

-                      default_example: 
+                      default_example: null
-                      github_url: 
+                      github_url: null
-                      license_url: 
+                      license_url: null
-                      paper_url: 
+                      paper_url: null

977-995: Use RFC 7807 content type for error responses (consistent with other endpoints).

Other endpoints here already use application/problem+json. Switch 400/500 to match.

         '400':
           description: Bad Request - Missing or invalid query parameter
           content:
-            application/json:
+            application/problem+json:
               schema:
                 type: object
                 properties:
                   detail:
                     type: string
                     example: Query parameter "query" is required
         '500':
           description: Internal Server Error - Search service error
           content:
-            application/json:
+            application/problem+json:
               schema:
                 type: object
                 properties:
                   detail:
                     type: string
                     example: Search service error

1255-1257: Mark is_official as readOnly.

This is server-derived metadata and should not be client-settable.

         is_official:
           type: boolean
           description: 'Boolean indicating whether the model is officially maintained by Replicate. Official models are always on, have stable API interfaces, and predictable pricing.'
+          readOnly: true

1292-1302: Constrain page hrefs to path-like values.

Add format and a simple leading-slash pattern.

         href:
           type: string
           description: URL path to the page
+          format: uri-reference
+          pattern: '^/.*'

1492-1514: Validate model identifiers in collections.

Ensure owner/name form with a lightweight regex.

         models:
           type: array
           items:
             type: string
             description: Model name in owner/name format
+            pattern: '^[^/]+/[^/]+$'
           description: Array of model names in the collection
           nullable: true

1515-1530: Optional: add example and bounds for tags/score.

Small polish to guide SDKs and docs.

         score:
           type: number
           description: Search relevance score
           nullable: true
+          example: 0.87
         tags:
           type: array
           items:
             type: string
           description: Array of descriptive tags for the model
+          example: ["image-editing", "text-to-image"]

1531-1564: Schema shape looks good; consider freezing fields.

If you want a tighter contract, add additionalProperties: false to the wrapper object and model items. Non-blocking.

     schemas_search_response:
       required:
         - query
         - models
         - collections
         - pages
       type: object
+      additionalProperties: false
       properties:
         models:
           type: array
           items:
             required:
               - model
               - metadata
             type: object
+            additionalProperties: false
             properties:
               metadata:
                 $ref: '#/components/schemas/schemas_search_model_metadata_response'
               model:
                 $ref: '#/components/schemas/schemas_model_response'
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f480e15 and 2a15e78.

⛔ Files ignored due to path filters (18)
  • src/libs/Replicate/Generated/Replicate.IReplicateApi.Search.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.JsonSerializerContextTypes.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SchemasModelResponse.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SchemasPageResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SchemasPageResponse.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SchemasSearchCollectionResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SchemasSearchCollectionResponse.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SchemasSearchModelMetadataResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SchemasSearchModelMetadataResponse.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SchemasSearchResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SchemasSearchResponse.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SchemasSearchResponseModel.Json.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SchemasSearchResponseModel.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SearchResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SearchResponse.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SearchResponse2.Json.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.SearchResponse2.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.ReplicateApi.Search.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/Replicate/openapi.yaml (4 hunks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants