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): Add ApiVersionSchema type #4068

Merged
merged 9 commits into from
Jul 16, 2024
Merged

(feature): Add ApiVersionSchema type #4068

merged 9 commits into from
Jul 16, 2024

Conversation

amckinney
Copy link
Member

@amckinney amckinney commented Jul 16, 2024

Feature

This proposes a new ApiVersionSchema type which is used to configure an API-wide version header enum. Users can configure this with the following:

# api.yml
version:
  header: X-API-Version
  default: "1.0.0"
  values:
    - "1.0.0-alpha"
    - "1.0.0-beta"
    - "1.0.0"

Implementation

Given that the version header has a few more restrictions than general HTTP headers and enum type declarations, this proposes a few new YAML schema types for the VersionDeclarationSchema. Regardless, these schemas are still capable of mapping into the same IR types (i.e. http.HttpHeader and types.EnumTypeDeclaration).

We also plan to support default values on enum type declarations and type references, so this defines the default value there.

Behavior

In TypeScript, the user will receive a special Version type like so:

// version.ts
type Version = "1.0.0-alpha" | "1.0.0-beta" | "1.0.0";

If a default value is configured, that X-API-Version header is sent on every request. Otherwise, the version header is treated as a required global header, which is specified on the client constructor.

@amckinney amckinney requested a review from dsinghvi as a code owner July 16, 2024 14:25
@amckinney amckinney changed the title (feature): Add VersionDeclaration type (feature): Add ApiVersionSchema type Jul 16, 2024
Copy link

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