Skip to content

Commit

Permalink
improvement: allow header auth extension to specify auth prefix (#3303)
Browse files Browse the repository at this point in the history
  • Loading branch information
armandobelardo authored Apr 1, 2024
1 parent 4405e01 commit 984f4e9
Show file tree
Hide file tree
Showing 8 changed files with 607 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ components:
x-fern-header:
name: header
env: MY_HEADER_ENVVAR
prefix: "Token " # Optional
```

This adds a header of the form `X-API-Key: Token <value>` to the request.

## Global headers
At times, your API will leverage certain headers for every endpoint, or the majority of them, we call these "global headers". For convenience, generated Fern SDKs expose "global headers" to easily be updated on API calls. Take for example an API key, if we declare the API key as a global header, a user will be able to plug theirs in easily:

Expand All @@ -106,7 +109,7 @@ import os
class Client:
def __init__(self, *, apiKey: str)
def __init__(self, *, apiKey: str):
```

To configure global headers, Fern will automatically pull out headers that are used in every request, or the majority of requests, and mark them as global.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2108,7 +2108,9 @@ exports[`generate IR 1`] = `
},
"typeId": "type_types:UnionWithBaseProperties",
},
"referencedTypes": [],
"referencedTypes": [
"type_types:Foo",
],
"shape": {
"_type": "union",
"baseProperties": [
Expand Down Expand Up @@ -2275,6 +2277,97 @@ exports[`generate IR 1`] = `
},
},
},
{
"discriminantValue": {
"name": {
"camelCase": {
"safeName": "foo",
"unsafeName": "foo",
},
"originalName": "foo",
"pascalCase": {
"safeName": "Foo",
"unsafeName": "Foo",
},
"screamingSnakeCase": {
"safeName": "FOO",
"unsafeName": "FOO",
},
"snakeCase": {
"safeName": "foo",
"unsafeName": "foo",
},
},
"wireValue": "foo",
},
"docs": null,
"shape": {
"_type": "samePropertiesAsObject",
"fernFilepath": {
"allParts": [
{
"camelCase": {
"safeName": "types",
"unsafeName": "types",
},
"originalName": "types",
"pascalCase": {
"safeName": "Types",
"unsafeName": "Types",
},
"screamingSnakeCase": {
"safeName": "TYPES",
"unsafeName": "TYPES",
},
"snakeCase": {
"safeName": "types",
"unsafeName": "types",
},
},
],
"file": {
"camelCase": {
"safeName": "types",
"unsafeName": "types",
},
"originalName": "types",
"pascalCase": {
"safeName": "Types",
"unsafeName": "Types",
},
"screamingSnakeCase": {
"safeName": "TYPES",
"unsafeName": "TYPES",
},
"snakeCase": {
"safeName": "types",
"unsafeName": "types",
},
},
"packagePath": [],
},
"name": {
"camelCase": {
"safeName": "foo",
"unsafeName": "foo",
},
"originalName": "Foo",
"pascalCase": {
"safeName": "Foo",
"unsafeName": "Foo",
},
"screamingSnakeCase": {
"safeName": "FOO",
"unsafeName": "FOO",
},
"snakeCase": {
"safeName": "foo",
"unsafeName": "foo",
},
},
"typeId": "type_types:Foo",
},
},
],
},
},
Expand Down
Loading

0 comments on commit 984f4e9

Please sign in to comment.