Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
armandobelardo committed Apr 19, 2024
2 parents 00cf7aa + 9e55cc7 commit c1eb6b4
Show file tree
Hide file tree
Showing 1,173 changed files with 39,459 additions and 452 deletions.
2 changes: 1 addition & 1 deletion fern/apis/fhir/generators.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
default-group: sdks
# default-group: sdks
groups:
sdks:
generators:
Expand Down
38 changes: 37 additions & 1 deletion fern/pages/overview/define-your-api/ferndef/api-yml.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,41 @@ auth-schemes:
```
</CodeBlock>

Custom authentication schemes include custom `OAuth` integrations, too. Simply hook up
your OAuth token endpoint and (optionally) configure token refresh like so:

<CodeBlock title="api.yml">
```yaml
name: api
imports:
auth: auth.yml
auth: OAuthScheme
auth-schemes:
OAuthScheme:
scheme: oauth
type: client-credentials
get-token:
endpoint: auth.getToken # Assumes the auth.yml file defines this endpoint.
response-properties:
access-token: $response.access_token
expires-in: $response.expires_in
refresh-token:
endpoint: auth.refreshToken # Assumes the auth.yml file defines this endpoint.
request-properties:
refresh-token: $request.refresh_token
response-properties:
access-token: $response.access_token
expires-in: $response.expires_in
refresh-token: $response.refresh_token
```
</CodeBlock>

The `request-properties` are the properties sent to the endpoint, whereas the `response-properties` are
used to identify and extract the OAuth access token details from the endpoint's response.

With this, all of the OAuth logic happens automatically in the generated SDKs. As long as you configure your
`client-id` and `client-secret`, your client will automatcally retrieve an access token and refresh it as needed.

## Global headers

You can specify headers that are meant to be included on every request:
Expand All @@ -98,7 +133,8 @@ path-parameters:

## Global query parameters

You cannot yet specify query parameters that are meant to be included on every request. If you'd like to see this feature, please upvote [this issue](https://github.com/fern-api/fern/issues/2930).
You cannot yet specify query parameters that are meant to be included on every request.
If you'd like to see this feature, please upvote [this issue](https://github.com/fern-api/fern/issues/2930).

## Environments

Expand Down
5 changes: 5 additions & 0 deletions generators/python/fastapi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [0.9.0-rc0]

- Feature: The generator now depends on v38 of Intermediate Representation which requires the latest
CLI.

- Improvement: Remove support for Python 3.7. In order to support newer versions of libraries we depend on (such as typing and typing-extensions), we must move on to Python 3.8. With this change we are also able to:
- Remove the `backports` dependency, as `cached_property` is now included within `functools`
- Remove the upper bound dependency on Pydantic which had dropped support for Python 3.7
Expand Down
2 changes: 1 addition & 1 deletion generators/python/fastapi/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.1-rc0
0.9.0-rc0
10 changes: 5 additions & 5 deletions generators/python/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion generators/python/pydantic/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## [0.9.0-rc0] - 2024-01-29

- Feature: The generator now depends on v38 of Intermediate Representation which requires the latest
CLI.

- Improvement: Remove support for Python 3.7. In order to support newer versions of libraries we depend on (such as typing and typing-extensions), we must move on to Python 3.8. With this change we are also able to:
- Remove the `backports` dependency, as `cached_property` is now included within `functools`
Expand Down
2 changes: 1 addition & 1 deletion generators/python/pydantic/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.1-rc0
0.9.0-rc0
2 changes: 1 addition & 1 deletion generators/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pydantic = "^1.9.2"
typer = {extras = ["all"], version = "^0.6.1"}
fern-fern-generator-exec-sdk = {version = "0.0.750", source = "fern-prod"}
ordered-set = "^4.1.0"
fern_fern_ir_v37 = "^0.0.3433"
fern-fern-fdr-sdk = {version = "0.0.5321", source = "fern-prod"}
fern_fern_ir_v38 = "^38.0.0"

[tool.poetry.dev-dependencies]
pytest = "^7.4.2"
Expand Down
8 changes: 8 additions & 0 deletions generators/python/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.0-rc2] - 2024-04-10
- Fix: The generator now correctly imports `json` when deserializing server sent events.

## [1.2.0-rc0] - 2024-04-10

- Feature: The generator now depends on v38 of Intermediate Representation which requires the latest
CLI. As part of this, the generator now supports server sent events using `httpx-sse`.

## [1.1.0-rc3] - 2024-04-04

- Fix: There are a number of fixes to the skip validation code as well as tests to reflect those updates.
Expand Down
2 changes: 1 addition & 1 deletion generators/python/sdk/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0-rc4
1.2.0-rc2
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .fastapi import FastAPI
from .functools import Functools
from .httpx import HttpX
from .httpx_sse import HttpxSSE
from .json import Json
from .pydantic import Pydantic, PydanticVersionCompatibility
from .starlette import Starlette
Expand All @@ -16,4 +17,5 @@
"Json",
"UrlLibParse",
"PydanticVersionCompatibility",
"HttpxSSE",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from fern_python.codegen import AST
from fern_python.codegen.ast.dependency.dependency import DependencyCompatibility

HTTPX_SSE = AST.Module.external(
module_path=("httpx_sse",),
dependency=AST.Dependency(
name="httpx-sse",
version="0.4.0",
compatibility=DependencyCompatibility.EXACT,
),
)


class HttpxSSE:

EVENT_SOURCE = AST.ClassReference(
qualified_name_excluding_import=("EventSource",),
import_=AST.ReferenceImport(module=HTTPX_SSE),
)
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ def get_referenced_types_of_type_declaration(
def get_referenced_types_of_type_reference(self, type_reference: ir_types.TypeReference) -> Set[ir_types.TypeId]:
return type_reference.visit(
container=lambda container: container.visit(
list=lambda item_type: self.get_referenced_types_of_type_reference(item_type),
set=lambda item_type: self.get_referenced_types_of_type_reference(item_type),
list_=lambda item_type: self.get_referenced_types_of_type_reference(item_type),
set_=lambda item_type: self.get_referenced_types_of_type_reference(item_type),
optional=lambda item_type: self.get_referenced_types_of_type_reference(item_type),
map=lambda map_type: (
map_=lambda map_type: (
self.get_referenced_types_of_type_reference(map_type.key_type).union(
self.get_referenced_types_of_type_reference(map_type.value_type)
)
Expand All @@ -120,10 +120,10 @@ def get_referenced_types_of_type_reference(self, type_reference: ir_types.TypeRe
def get_type_names_in_type_reference(self, type_reference: ir_types.TypeReference) -> Set[ir_types.TypeId]:
return type_reference.visit(
container=lambda container: container.visit(
list=lambda item_type: self.get_referenced_types_of_type_reference(item_type),
set=lambda item_type: self.get_referenced_types_of_type_reference(item_type),
list_=lambda item_type: self.get_referenced_types_of_type_reference(item_type),
set_=lambda item_type: self.get_referenced_types_of_type_reference(item_type),
optional=lambda item_type: self.get_referenced_types_of_type_reference(item_type),
map=lambda map_type: (
map_=lambda map_type: (
self.get_referenced_types_of_type_reference(map_type.key_type).union(
self.get_referenced_types_of_type_reference(map_type.value_type)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _get_type_hint_for_container(
in_endpoint: Optional[bool],
) -> AST.TypeHint:
return container.visit(
list=lambda wrapped_type: AST.TypeHint.sequence(
list_=lambda wrapped_type: AST.TypeHint.sequence(
self.get_type_hint_for_type_reference(
type_reference=wrapped_type,
must_import_after_current_declaration=must_import_after_current_declaration,
Expand All @@ -84,7 +84,7 @@ def _get_type_hint_for_container(
in_endpoint=in_endpoint,
)
),
map=lambda map_type: AST.TypeHint.dict(
map_=lambda map_type: AST.TypeHint.dict(
key_type=self.get_type_hint_for_type_reference(
type_reference=map_type.key_type,
must_import_after_current_declaration=must_import_after_current_declaration,
Expand All @@ -97,7 +97,7 @@ def _get_type_hint_for_container(
),
),
# Fern sets become Pydanic lists, since Pydantic models aren't hashable
set=lambda wrapped_type: wrapped_type.visit(
set_=lambda wrapped_type: wrapped_type.visit(
container=lambda type_reference: AST.TypeHint.sequence(
self._get_type_hint_for_container(
container=type_reference,
Expand Down Expand Up @@ -158,9 +158,9 @@ def _get_type_hint_for_primitive(self, primitive: ir_types.PrimitiveType) -> AST
double=AST.TypeHint.float_,
string=AST.TypeHint.str_,
boolean=AST.TypeHint.bool_,
long=AST.TypeHint.int_,
long_=AST.TypeHint.int_,
date_time=AST.TypeHint.datetime,
uuid=AST.TypeHint.uuid,
uuid_=AST.TypeHint.uuid,
date=AST.TypeHint.date,
base_64=AST.TypeHint.str_,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def generate(
def _get_builder_name(self, alias_of: ir_types.TypeReference) -> str:
return alias_of.visit(
container=lambda container: container.visit(
list=lambda x: "from_list",
map=lambda x: "from_map",
set=lambda x: "from_set",
list_=lambda x: "from_list",
map_=lambda x: "from_map",
set_=lambda x: "from_set",
optional=self._get_getter_name,
literal=lambda x: "from_string",
),
Expand All @@ -81,10 +81,10 @@ def _get_builder_name(self, alias_of: ir_types.TypeReference) -> str:
double=lambda: "from_float",
string=lambda: "from_str",
boolean=lambda: "from_bool",
long=lambda: "from_int",
long_=lambda: "from_int",
date_time=lambda: "from_datetime",
date=lambda: "from_date",
uuid=lambda: "from_uuid",
uuid_=lambda: "from_uuid",
base_64=lambda: "from_str",
),
unknown=lambda: "from_",
Expand All @@ -93,9 +93,9 @@ def _get_builder_name(self, alias_of: ir_types.TypeReference) -> str:
def _get_getter_name(self, alias_of: ir_types.TypeReference) -> str:
return alias_of.visit(
container=lambda container: container.visit(
list=lambda x: "get_as_list",
map=lambda x: "get_as_map",
set=lambda x: "get_as_set",
list_=lambda x: "get_as_list",
map_=lambda x: "get_as_map",
set_=lambda x: "get_as_set",
optional=self._get_getter_name,
literal=lambda x: "get_as_string",
),
Expand All @@ -105,10 +105,10 @@ def _get_getter_name(self, alias_of: ir_types.TypeReference) -> str:
double=lambda: "get_as_float",
string=lambda: "get_as_str",
boolean=lambda: "get_as_bool",
long=lambda: "get_as_int",
long_=lambda: "get_as_int",
date_time=lambda: "get_as_datetime",
date=lambda: "get_as_date",
uuid=lambda: "get_as_uuid",
uuid_=lambda: "get_as_uuid",
base_64=lambda: "get_as_str",
),
unknown=lambda: "get_value",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,11 @@ def _get_streaming_response_body_type(
return AST.TypeHint.iterator(streaming_data_event_type_hint)

def _get_streaming_response_data_type(self, streaming_response: ir_types.StreamingResponse) -> AST.TypeHint:
union = streaming_response.data_event_type.get_as_union()
union = streaming_response.get_as_union()
if union.type == "json":
return self._context.pydantic_generator_context.get_type_hint_for_type_reference(union.json_)
return self._context.pydantic_generator_context.get_type_hint_for_type_reference(union.payload)
if union.type == "sse":
return self._context.pydantic_generator_context.get_type_hint_for_type_reference(union.payload)
if union.type == "text":
return AST.TypeHint.str_()
raise RuntimeError(f"{union.type} streaming response is unsupported")
Expand Down Expand Up @@ -848,16 +850,16 @@ def visit_named_type(type_name: ir_types.DeclaredTypeName) -> bool:

return type_reference.visit(
container=lambda container: container.visit(
list=lambda x: False,
set=lambda x: False,
list_=lambda x: False,
set_=lambda x: False,
optional=lambda item_type: allow_optional
and self._does_type_reference_match_primitives(
item_type,
expected=expected,
allow_optional=True,
allow_enum=allow_enum,
),
map=lambda x: False,
map_=lambda x: False,
literal=lambda literal: literal.visit(
boolean=lambda x: ir_types.PrimitiveType.BOOLEAN in expected,
string=lambda x: ir_types.PrimitiveType.STRING in expected,
Expand Down
Loading

0 comments on commit c1eb6b4

Please sign in to comment.