fern-api / fern

Input OpenAPI. Output SDKs and Docs.
https://buildwithfern.com
Apache License 2.0
2.68k stars 152 forks source link

[Bug] Global path-parameters are not considered by OpenAPI generator #4664

Open Koubek opened 2 months ago

Koubek commented 2 months ago

Describe the Bug

When using global path-parameters in the api.yml file, the Fern OpenAPI Generator does not respect these global parameters. As a result, the generated OpenAPI specification does not include the global path-parameters. This issue leads to missing parameters in the final URL when importing the specification into tools such as Postman.

Information to Reproduce

CLI Version

0.41.13

Generator Version

fernapi/fern-openapi version 0.0.31

Fern Definition

The minimal fern definition required to reproduce the bug.

# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json

types:
  Company:
    properties:
      id: uuid
      systemVersion: string
      name: string
      displayName: string

  Companies:
    properties:
      value: list<Company>

service:
  auth: true
  base-path: /companies
  endpoints: 
    getCompanies:
      display-name: Get all companies
      docs: Get list of all companies in the selected environment. More information how to work with companies can be found [here](/systemservices/companies).
      path: ""
      method: GET
      response: Companies
      examples:
        - path-parameters:
            saasguid: c35fabce-d6b1-4e2f-b539-dabc68f0e7bb
            saasenv: sandbox01
          response:
            body:
              value:
                - id: "17ff1351-d07d-4b85-8957-b4b585f47aad"
                  systemVersion: "24.0.16410.18056"
                  name: "CRONUS International Ltd."
                  displayName: ""
                - id: "872336d7-5183-4c0b-9b47-755f3d6d77e7"
                  systemVersion: "24.0.16410.18056"
                  name: "TestCompany"
                  displayName: "TestCompany"

Actual OpenAPI

The buggy OpenAPI document that is produced:

openapi: 3.0.1
info:
  title: companies
  version: ''
paths:
  /companies:
    get:
      description: >-
        Get list of all companies in the selected environment. More information
        how to work with companies can be found
        [here](/systemservices/companies).
      operationId: companies_getCompanies
      tags:
        - Companies
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Companies'
              examples:
                Example1:
                  value:
                    value:
                      - id: 17ff1351-d07d-4b85-8957-b4b585f47aad
                        systemVersion: 24.0.16410.18056
                        name: CRONUS International Ltd.
                        displayName: ''
                      - id: 872336d7-5183-4c0b-9b47-755f3d6d77e7
                        systemVersion: 24.0.16410.18056
                        name: TestCompany
                        displayName: TestCompany
        '400':
          description: ''
        '401':
          description: ''
        '402':
          description: ''
        '403':
          description: ''
        '404':
          description: ''
        '409':
          description: ''
        '429':
          description: ''
      summary: Get all companies
      security:
        - BearerAuth: []
components:
  schemas:
    Company:
      title: Company
      type: object
      properties:
        id:
          type: string
          format: uuid
        systemVersion:
          type: string
        name:
          type: string
        displayName:
          type: string
      required:
        - id
        - systemVersion
        - name
        - displayName
    Companies:
      title: Companies
      type: object
      properties:
        value:
          type: array
          items:
            $ref: '#/components/schemas/Company'
      required:
        - value
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
servers:
  - url: https://mydomain.com
    description: Production

Additional Context

I commented with @dsinghvi via Slack yesterday, he confirmed there was a bug.

dsinghvi commented 1 month ago

@Koubek https://github.com/fern-api/fern/pull/4734 PR in flight

dsinghvi commented 1 month ago

@Koubek we've merged a PR that releases 0.0.32 of the OpenAPI generator. The new version will be published in 30 minutes, can you confirm that this is fixed for you?

Koubek commented 1 month ago

Hi, great @dsinghvi. We have detected that it contains the global path parameters but the examples (the values) are still not referenced. Compared with the Postman generator, the Postman generator contains examples.