Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,16 @@ export class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGene
discriminantValue: FernIr.dynamic.NameAndWireValue;
}): python.Reference {
const unionClassName = this.getClassName(unionDeclaration.name);
const variantSuffix = discriminantValue.name.pascalCase.safeName;
const variantName = discriminantValue.name.pascalCase.safeName;
const modulePath = [
...this.getRootModulePath(),
...unionDeclaration.fernFilepath.allParts.map((part) => part.snakeCase.safeName)
];
return python.reference({ name: `${unionClassName}_${variantSuffix}`, modulePath });
const name =
this.customConfig.pydantic_config?.union_naming === "v1"
? `${variantName}${unionClassName}`
: `${unionClassName}_${variantName}`;
return python.reference({ name, modulePath });
}

public useTypedDictRequests(): boolean {
Expand Down
5 changes: 4 additions & 1 deletion generators/python-v2/sdk/src/wire-tests/WireTestGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ export class WireTestGenerator {
config: {
organization: context.config.organization,
workspaceName: context.config.workspaceName,
customConfig: context.customConfig
// Pass the raw customConfig (not the parsed SdkCustomConfigSchema) so that
// fields consumed by the dynamic snippets generator (e.g. pydantic_config)
// are preserved. SdkCustomConfigSchema.parse() strips unknown keys.
customConfig: context.config.customConfig
} as FernGeneratorExec.GeneratorConfig
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# yaml-language-server: $schema=../../../../../fern-changes-yml.schema.json

- summary: |
Fix generated wire tests and dynamic snippets to honor `pydantic_config.union_naming: v1`.
Previously, variant class names in wire tests and README/reference snippets were always
emitted with the v0 suffix style (e.g. `UnionName_Variant`), causing import errors when
the SDK types were generated with v1 prefix-style names (e.g. `VariantUnionName`).
type: fix
10 changes: 10 additions & 0 deletions generators/python/sdk/versions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# yaml-language-server: $schema=../../../fern-versions-yml.schema.json
- version: 5.5.2
changelogEntry:
- summary: |
Fix generated wire tests and dynamic snippets to honor `pydantic_config.union_naming: v1`.
Previously, variant class names in wire tests and README/reference snippets were always
emitted with the v0 suffix style (e.g. `UnionName_Variant`), causing import errors when
the SDK types were generated with v1 prefix-style names (e.g. `VariantUnionName`).
type: fix
createdAt: "2026-04-18"
irVersion: 66
- version: 5.5.1
changelogEntry:
- summary: |
Expand Down
12 changes: 12 additions & 0 deletions seed/python-sdk/seed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,12 @@ fixtures:
union_naming: v1
use_inheritance_for_extended_models: false
outputFolder: union-naming-v1
- customConfig:
enable_wire_tests: true
pydantic_config:
union_naming: v1
use_inheritance_for_extended_models: false
outputFolder: union-naming-v1-wire-tests
websocket:
- outputFolder: websocket-base
- customConfig:
Expand Down Expand Up @@ -475,3 +481,9 @@ allowedFailures:
- server-sent-event-examples:with-wire-tests # TODO: update wiretests geranation then remove it
- trace
- multi-url-environment-reference
# The unions API has two services (`union` and `bigunion`) that both expose
# `GET /{id}` on the root base-path, which causes a WireMock stub collision at
# test runtime. Code generation and imports are verified; one wire test
# assertion fails due to the colliding mocks. This is pre-existing and unrelated
# to the union_naming v1 fix this fixture regression-tests.
- unions:union-naming-v1-wire-tests

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

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

5 changes: 5 additions & 0 deletions seed/python-sdk/unions/union-naming-v1-wire-tests/.gitignore

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

164 changes: 164 additions & 0 deletions seed/python-sdk/unions/union-naming-v1-wire-tests/README.md

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

Loading
Loading