Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): Add OpenAPI tree-shaking setting #5168

Merged
merged 8 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 6 additions & 0 deletions fern/apis/generators-yml/definition/generators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ types:
message-naming:
type: optional<MessageNamingSettingsSchema>
docs: What version of message naming to use for AsyncAPI messages, this will grow over time. Defaults to v1.
only-include-referenced-schemas:
type: optional<boolean>
docs: Whether to only include schemas referenced by endpoints in the generated SDK (i.e. a form of tree-shaking). Defaults to false.

UnionSettingsSchema:
enum:
Expand Down Expand Up @@ -222,6 +225,9 @@ types:
respect-readonly-schemas:
type: optional<boolean>
docs: Enables exploring readonly schemas in OpenAPI specifications
only-include-referenced-schemas:
type: optional<boolean>
docs: Whether to only include schemas referenced by endpoints in the generated SDK (i.e. a form of tree-shaking). Defaults to false.

OpenAPISpecSchema:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface ParseOpenAPIOptions {
cooerceEnumsToLiterals: boolean;
/* Whether or not to respect readonly properties in schemas */
respectReadonlySchemas: boolean;
/* Whether or not to only include endpoint referenced schemas */
onlyIncludeReferencedSchemas: boolean;
}

export const DEFAULT_PARSE_OPENAPI_SETTINGS: ParseOpenAPIOptions = {
Expand All @@ -24,5 +26,6 @@ export const DEFAULT_PARSE_OPENAPI_SETTINGS: ParseOpenAPIOptions = {
audiences: undefined,
optionalAdditionalProperties: true,
cooerceEnumsToLiterals: true,
respectReadonlySchemas: false
respectReadonlySchemas: false,
onlyIncludeReferencedSchemas: false
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface SpecImportSettings {
cooerceEnumsToLiterals: boolean;
objectQueryParameters: boolean;
respectReadonlySchemas: boolean;
onlyIncludeReferencedSchemas: boolean;
}

export type Source = AsyncAPISource | OpenAPISource | ProtobufSource;
Expand Down Expand Up @@ -196,7 +197,11 @@ function getParseOptions({
respectReadonlySchemas:
overrides?.respectReadonlySchemas ??
specSettings?.respectReadonlySchemas ??
DEFAULT_PARSE_OPENAPI_SETTINGS.respectReadonlySchemas
DEFAULT_PARSE_OPENAPI_SETTINGS.respectReadonlySchemas,
onlyIncludeReferencedSchemas:
overrides?.onlyIncludeReferencedSchemas ??
specSettings?.onlyIncludeReferencedSchemas ??
DEFAULT_PARSE_OPENAPI_SETTINGS.onlyIncludeReferencedSchemas
};
}

Expand Down
Loading
Loading