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, typescript): Generarte API version scheme #4071

Merged
merged 9 commits into from
Jul 17, 2024

Conversation

amckinney
Copy link
Member

This adds support for generating an API version scheme in version.ts. Consider the following api.yml configuration:

version:
  header: X-API-Version
  default: "1.0.0"
  values:
    - "1.0.0-alpha"
    - "1.0.0-beta"
    - "1.0.0"

The following version.ts file is generated:

/**
 * This file was auto-generated by Fern from our API Definition.
 */

/** The version of the API, sent as the X-API-Version header. */
export type AcmeVersion = "1.0.0" | "2.0.0" | "latest";

If a default value is specified, it is set on every request but can be overridden in either the client-level Options or call-specific RequestOptions. If a default value is not specified, the value of the header is required on the generated Options.

An example call is shown below:

import { AcmeClient } from "acme";

const client = new AcmeClient({ apiKey: "YOUR_API_KEY", xApiVersion: "2.0.0" });
await client.users.create({
  firstName: "john",
  lastName: "doe"
});

@amckinney amckinney requested a review from dsinghvi as a code owner July 17, 2024 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants