Skip to content
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

wrong code generated for API playground sample #5563

Open
cwcowell opened this issue Jan 8, 2025 · 2 comments
Open

wrong code generated for API playground sample #5563

cwcowell opened this issue Jan 8, 2025 · 2 comments
Labels
bug Issues reporting bugs. product/docs Fern Docs which builds and hosts a developer documentation site

Comments

@cwcowell
Copy link
Contributor

cwcowell commented Jan 8, 2025

CLI Version (from fern.config.json)

0.46.22

Minimal API Specification

openapi: 3.0.0
info:
  title: AI Hub API
  version: "0.1"
paths:
  /v2/conversations/{conversation_id}/documents:
    post:
      operationId: addDocumentsToConversation
      x-fern-audiences:
        - public
      tags:
        - conversations
      summary: Add documents to a conversation
      parameters:
        - $ref: '#/components/parameters/conversation_id'
        - $ref: '#/components/parameters/ib_context'
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                files:
                  type: array
                  items:
                    type: string
                    format: binary
                  description: foo
                process_files:
                  type: boolean
                  description: foo
                  default: true
              required:
                - files
      responses:
        '201':
          description: foo
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/documentUploadResponse'
        default:
          description: foo
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
      x-fern-examples:
        - code-samples:
            - sdk: curl
              code: |
                  curl "${API_ROOT}/v2/conversations/<CONVERSATION-ID>/documents" \
                    -H "Authorization: Bearer ${API_TOKEN}" \
                    -H "IB-Context: ${IB_CONTEXT}"\
                    -F files="@/path/to/test.pdf" \
                    -F files="@/path/to/test2.pdf"
            - sdk: python
              code: |
                  # AI Hub Python SDK example
                  from aihub import AIHub

                  client = AIHub(api_root="<API-ROOT>",
                                 api_key="<API-TOKEN>",
                                 ib_context="<IB-CONTEXT>")
                  status = client.conversations.add_documents('<CONVERSATION-ID>',
                                                              files=['test.pdf', 'test2.pdf'])
components:
  parameters:
    ib_context:
      in: header
      name: IB-Context
      schema:
        type: string
      required: false
      description: foo
    conversation_id:
      in: path
      name: conversation_id
      required: true
      schema:
        type: string
      description: bar
  schemas:
    error:
      type: object
      properties:
        message:
          type: string
    documentUploadResponse:
      type: object
      properties:
        upload_status:
          type: object
          properties:
            success:
              type: array
              items:
                type: object
                properties:
                  name:
                    type: string
                    description: foo
            failure:
              type: array
              items:
                type: object
                properties:
                  name:
                    type: string
                    description: foo
                  reason:
                    type: string
                    description: foo
          description: foo

Actual UI Behavior

The sample code that Fern autogenerates for the playground doesn’t work correctly.

The code that Fern autogenerates and shows in the Playground’s sample code box includes this:

files={
    'files': [
        ("test_api.py", open("/Users/prakhar/Downloads/test_api.py", "rb")),
    ],
},

Expected UI Behavior

In order to work, the code shown above should instead look like this:

files=[
    ("files", ("test_api.py", open("/Users/prakhar/Downloads/test_api.py", "rb"))),
],

There might be other discrepancies between the autogenerated code and working code, but we’ve disabled the Playground feature so I can’t retrieve the autogenerated code anymore to check it.

Steps to Reproduce

  1. Serve the docs locally
  2. load http://localhost:3000/api-sdk/api-reference/conversations/add-documents-to-conversation
  3. Click Play

Environment Details

Safari 18.2, macOS 15.2

@cwcowell cwcowell added bug Issues reporting bugs. product/docs Fern Docs which builds and hosts a developer documentation site labels Jan 8, 2025
@cwcowell
Copy link
Contributor Author

cwcowell commented Jan 8, 2025

This is high priority for us. We have disabled the playground feature (which we otherwise like a lot) until this is fixed, so it doesn’t show incorrect info to customers.

@cwcowell
Copy link
Contributor Author

cwcowell commented Jan 8, 2025

This is one example of incorrect autogenerated code, but there might be others. Since the playground is disabled and since it doesn’t appear when the pages are served locally, I can’t check any other pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues reporting bugs. product/docs Fern Docs which builds and hosts a developer documentation site
Development

No branches or pull requests

1 participant