Skip to content

Commit

Permalink
fix(cli): validating union examples takes into account base-properties (
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Oct 29, 2024
1 parent 85cc59e commit f25e5ea
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions generators/csharp/sdk/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- type: fix
summary: |
Fixes a bug where the ClientOptions would not compile due to incorrect Clone method generation.
irVersion: 53
- version: 1.8.1
irVersion: 53
createdAt: "2024-10-08"
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
- changelogEntry:
- summary: |
`fern check` handles validating unions that contain base properties.
type: feat
irVersion: 53
version: 0.45.0-rc26

- changelogEntry:
- summary: |
The Fern CLI temporarily does not support RBAC/Audiences (they will be added in again shortly).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,30 @@ export function validateUnionExample({
];
}

if (rawUnion["base-properties"] != null) {
const example = Object.fromEntries(
Object.entries(nonDiscriminantPropertyExamples).filter(
([key]) => rawUnion["base-properties"]?.[key] != null
)
);
const basePropertyViolations = validateObjectExample({
typeName,
typeNameForBreadcrumb: typeName,
rawObject: {
properties: rawUnion["base-properties"]
},
file,
example,
typeResolver,
exampleResolver,
workspace,
breadcrumbs
});
if (basePropertyViolations.length > 0) {
return basePropertyViolations;
}
}

const type =
typeof singleUnionTypeDefinition === "string" ? singleUnionTypeDefinition : singleUnionTypeDefinition.type;

Expand All @@ -79,12 +103,17 @@ export function validateUnionExample({
}

if (resolvedType._type === "named" && isRawObjectDefinition(resolvedType.declaration)) {
const example = Object.fromEntries(
Object.entries(nonDiscriminantPropertyExamples).filter(
([key]) => rawUnion["base-properties"]?.[key] == null
)
);
return validateObjectExample({
typeName,
typeNameForBreadcrumb: typeName,
rawObject: resolvedType.declaration,
file: resolvedType.file,
example: nonDiscriminantPropertyExamples,
example,
typeResolver,
exampleResolver,
workspace,
Expand Down

0 comments on commit f25e5ea

Please sign in to comment.