Skip to content

Commit

Permalink
fix: remove reserved properties from function signatures (#4205)
Browse files Browse the repository at this point in the history
  • Loading branch information
armandobelardo authored Aug 5, 2024
1 parent abb1f37 commit 21c5779
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ export const FieldsetProperty = new Property({
type: GenericClassReference,
isOptional: true
});

export declare namespace SerializableObject {
export type Init = Omit<Class_.Init, "functions" | "includeInitializer" | "expressions">;
}
export class SerializableObject extends Class_ {
public static INTERNAL_FIELDS = [AdditionalPropertiesProperty.name, FieldsetProperty.name];

constructor(init: SerializableObject.Init) {
super({
...init,
Expand Down
4 changes: 4 additions & 0 deletions generators/ruby/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [0.8.2] - 2024-08-05

- Fix: The generated endpoint functions no long include object utilities such as `_field_set` or `additional_properties`.

## [0.8.1] - 2024-07-22

- Fix: Nested `hash` types are recursively resolved in `from_json` such that they come back as true hashes, as opposed to structs
Expand Down
2 changes: 1 addition & 1 deletion generators/ruby/sdk/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.1
0.8.2
6 changes: 6 additions & 0 deletions generators/ruby/sdk/src/utils/EndpointGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
LiteralClassReference,
Parameter,
Property,
SerializableObject,
StringClassReference,
Variable,
VariableType,
Expand Down Expand Up @@ -273,6 +274,11 @@ export class EndpointGenerator {
}
});

// Remove reserved properties from the function signature
this.bodyAsProperties = this.bodyAsProperties.filter(
(prop) => !SerializableObject.INTERNAL_FIELDS.includes(prop.name)
);

this.streamProcessingBlock = this.isStreamingResponse()
? new Parameter({
name: "on_data",
Expand Down
15 changes: 2 additions & 13 deletions seed/ruby-sdk/extends/lib/fern_extends.rb

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

0 comments on commit 21c5779

Please sign in to comment.