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

[Feature] Allow extensions in OpenAPI output #2979

Open
mstade opened this issue Feb 14, 2024 · 0 comments
Open

[Feature] Allow extensions in OpenAPI output #2979

mstade opened this issue Feb 14, 2024 · 0 comments

Comments

@mstade
Copy link

mstade commented Feb 14, 2024

Problem description

PR #1531 introduces the extensions field to object types, but it doesn't seem like this data even if specified is used for anything at the moment. At minimum, it'd be useful to have this data included in the generated OpenAPI spec.

Why would it be useful?

We use the OpenAPI spec to dynamically generate forms to interact with the APIs. Sometimes, we want to add additional metadata that's not strictly necessary for the API itself, but is useful to other tooling. An example of this might be the grouping of multiple properties into a fieldset, e.g. something like:

types:
  Person:
    properties:
      name: string
      age: number
      shoesize: number
      address: Address
    extensions: # <--
      fieldsets:
        - name: Personal information
          fields: [name, age, shoesize]
        - name: Contact information
          fields: [address]
  Address:
    properties:
      line1: string
      line2: optional<string>
      city: string
      state: string
      zip: string
      country: literal<"USA">

In this case, a downstream tool might look at the fieldsets extension and deduce that the fields name, age, and shoesize should belong to a fieldset called Personal information, and the field address should belong to another fieldset called Contact information. What a fieldset is, or how to interpret this schema, is entirely up to that tool and has nothing to do with Fern.

Describe the solution (optional)

The OpenAPI spec allows for schema objects to use specification extensions. I propose that the extensions object should (by default) generate corresponding specification extensions in the generated OpenAPI spec. In the aforementioned example, the generated OpenAPI spec might have something like the following in its schema:

x-fieldsets:
  - name: Personal information
    fields: [name, age, shoesize]
  - name: Contact information
    fields: [address]

So essentially, the data for each property is simply passed along verbatim, with the only transformation being to the property name such that it adheres to the x-{name} format required by the OpenAPI specification.

Additional context

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

No branches or pull requests

1 participant