Skip to content

Commit

Permalink
fix(cli): add unions to settings. (#5532)
Browse files Browse the repository at this point in the history
  • Loading branch information
eyw520 authored Jan 6, 2025
1 parent ac6fb26 commit f6139da
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions fern/apis/generators-yml/definition/generators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ types:
title-as-schema-name: optional<boolean>
optional-additional-properties: optional<boolean>
coerce-enums-to-literals: optional<boolean>
prefer-undiscriminated-unions-with-literals:
type: optional<boolean>
docs: Whether to prefer undiscriminated unions with literals. Defaults to false.
object-query-parameters:
type: optional<boolean>
docs: Enables parsing deep object query parameters
Expand Down
10 changes: 10 additions & 0 deletions generators-yml.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,16 @@
}
]
},
"prefer-undiscriminated-unions-with-literals": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "null"
}
]
},
"object-query-parameters": {
"oneOf": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ async function parseApiConfigurationV2Schema({
audiences: [],
settings: {
shouldUseTitleAsName: spec.settings?.["title-as-schema-name"],
shouldUseUndiscriminatedUnionsWithLiterals: undefined,
shouldUseUndiscriminatedUnionsWithLiterals:
spec.settings?.["prefer-undiscriminated-unions-with-literals"] ?? false,
asyncApiMessageNaming: undefined,
onlyIncludeReferencedSchemas: spec.settings?.["only-include-referenced-schemas"],
shouldUseOptionalAdditionalProperties: spec.settings?.["optional-additional-properties"] ?? true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface OpenApiSettingsSchema {
"title-as-schema-name"?: boolean;
"optional-additional-properties"?: boolean;
"coerce-enums-to-literals"?: boolean;
/** Whether to prefer undiscriminated unions with literals. Defaults to false. */
"prefer-undiscriminated-unions-with-literals"?: boolean;
/** Enables parsing deep object query parameters */
"object-query-parameters"?: boolean;
/** Enables exploring readonly schemas in OpenAPI specifications */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const OpenApiSettingsSchema: core.serialization.ObjectSchema<
"title-as-schema-name": core.serialization.boolean().optional(),
"optional-additional-properties": core.serialization.boolean().optional(),
"coerce-enums-to-literals": core.serialization.boolean().optional(),
"prefer-undiscriminated-unions-with-literals": core.serialization.boolean().optional(),
"object-query-parameters": core.serialization.boolean().optional(),
"respect-readonly-schemas": core.serialization.boolean().optional(),
"only-include-referenced-schemas": core.serialization.boolean().optional(),
Expand All @@ -28,6 +29,7 @@ export declare namespace OpenApiSettingsSchema {
"title-as-schema-name"?: boolean | null;
"optional-additional-properties"?: boolean | null;
"coerce-enums-to-literals"?: boolean | null;
"prefer-undiscriminated-unions-with-literals"?: boolean | null;
"object-query-parameters"?: boolean | null;
"respect-readonly-schemas"?: boolean | null;
"only-include-referenced-schemas"?: boolean | null;
Expand Down
2 changes: 0 additions & 2 deletions pnpm-lock.yaml

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

0 comments on commit f6139da

Please sign in to comment.