From b34f63b571fbb8a5423a3335cc5acc14a913be7d Mon Sep 17 00:00:00 2001 From: Noa Flaherty Date: Fri, 22 Nov 2024 14:08:17 -0500 Subject: [PATCH 1/4] fix(python): Fix Reference Tracking for `Class` and `Method` AST Nodes (#5254) * Fix class reference tracking * Fix method reference tracking --- generators/python-v2/ast/src/Class.ts | 4 ++++ generators/python-v2/ast/src/Method.ts | 14 ++++++++++++++ .../python-v2/ast/src/__test__/Class.test.ts | 1 + .../python-v2/ast/src/__test__/Method.test.ts | 13 +++++++++++++ 4 files changed, 32 insertions(+) diff --git a/generators/python-v2/ast/src/Class.ts b/generators/python-v2/ast/src/Class.ts index 8c0407b4bc9..21444f51c36 100644 --- a/generators/python-v2/ast/src/Class.ts +++ b/generators/python-v2/ast/src/Class.ts @@ -35,6 +35,10 @@ export class Class extends AstNode { this.extends_.forEach((parentClassReference) => { this.inheritReferences(parentClassReference); }); + + this.decorators.forEach((decorator) => { + this.inheritReferences(decorator); + }); } public write(writer: Writer): void { diff --git a/generators/python-v2/ast/src/Method.ts b/generators/python-v2/ast/src/Method.ts index 734a4ab36e0..c26a628343a 100644 --- a/generators/python-v2/ast/src/Method.ts +++ b/generators/python-v2/ast/src/Method.ts @@ -50,6 +50,20 @@ export class Method extends AstNode { this.type = type; this.decorators = decorators ?? []; this.static_ = static_ ?? false; + + this.parameters.forEach((parameter) => { + this.inheritReferences(parameter); + }); + + this.inheritReferences(this.return); + + this.decorators.forEach((decorator) => { + this.inheritReferences(decorator); + }); + + this.statements.forEach((statements) => { + this.inheritReferences(statements); + }); } public addStatement(statement: AstNode): void { diff --git a/generators/python-v2/ast/src/__test__/Class.test.ts b/generators/python-v2/ast/src/__test__/Class.test.ts index ca0939785f0..029befcf5cd 100644 --- a/generators/python-v2/ast/src/__test__/Class.test.ts +++ b/generators/python-v2/ast/src/__test__/Class.test.ts @@ -75,6 +75,7 @@ describe("class", () => { }); clazz.write(writer); expect(await writer.toStringFormatted()).toMatchSnapshot(); + expect(clazz.getReferences().length).toBe(1); }); it("should generate a class with local classes", async () => { diff --git a/generators/python-v2/ast/src/__test__/Method.test.ts b/generators/python-v2/ast/src/__test__/Method.test.ts index 2e46f51d6ff..66c7f817dde 100644 --- a/generators/python-v2/ast/src/__test__/Method.test.ts +++ b/generators/python-v2/ast/src/__test__/Method.test.ts @@ -18,6 +18,7 @@ describe("Method", () => { }); method.write(writer); expect(await writer.toStringFormatted()).toMatchSnapshot(); + expect(method.getReferences().length).toBe(0); }); it("should generate an instance method", async () => { @@ -28,6 +29,7 @@ describe("Method", () => { }); method.write(writer); expect(await writer.toStringFormatted()).toMatchSnapshot(); + expect(method.getReferences().length).toBe(0); }); it("should generate a class method", async () => { @@ -38,6 +40,7 @@ describe("Method", () => { }); method.write(writer); expect(await writer.toStringFormatted()).toMatchSnapshot(); + expect(method.getReferences().length).toBe(0); }); it("should generate a method with one argument", async () => { @@ -47,6 +50,7 @@ describe("Method", () => { }); method.write(writer); expect(await writer.toStringFormatted()).toMatchSnapshot(); + expect(method.getReferences().length).toBe(0); }); it("should generate a method with multiple arguments", async () => { @@ -59,6 +63,7 @@ describe("Method", () => { }); method.write(writer); expect(await writer.toStringFormatted()).toMatchSnapshot(); + expect(method.getReferences().length).toBe(0); }); it("should generate a method with a specified return type", async () => { @@ -69,6 +74,7 @@ describe("Method", () => { }); method.write(writer); expect(await writer.toStringFormatted()).toMatchSnapshot(); + expect(method.getReferences().length).toBe(0); }); it("should generate a method without a specified return type", async () => { @@ -78,6 +84,7 @@ describe("Method", () => { }); method.write(writer); expect(await writer.toStringFormatted()).toMatchSnapshot(); + expect(method.getReferences().length).toBe(0); }); it("should generate a method with a body", async () => { @@ -88,6 +95,7 @@ describe("Method", () => { method.addStatement(python.codeBlock("return True")); method.write(writer); expect(await writer.toStringFormatted()).toMatchSnapshot(); + expect(method.getReferences().length).toBe(0); }); it("should generate a method without a body", async () => { @@ -97,6 +105,7 @@ describe("Method", () => { }); method.write(writer); expect(await writer.toStringFormatted()).toMatchSnapshot(); + expect(method.getReferences().length).toBe(0); }); it("should generate a method with a docstring", async () => { @@ -107,6 +116,7 @@ describe("Method", () => { }); method.write(writer); expect(await writer.toStringFormatted()).toMatchSnapshot(); + expect(method.getReferences().length).toBe(0); }); it("should generate a method without a docstring", async () => { @@ -116,6 +126,7 @@ describe("Method", () => { }); method.write(writer); expect(await writer.toStringFormatted()).toMatchSnapshot(); + expect(method.getReferences().length).toBe(0); }); it("should generate a method with a decorator", async () => { @@ -133,6 +144,7 @@ describe("Method", () => { }); method.write(writer); expect(await writer.toStringFormatted()).toMatchSnapshot(); + expect(method.getReferences().length).toBe(1); }); it("should generate a method with local classes", async () => { @@ -163,6 +175,7 @@ describe("Method", () => { method.write(writer); expect(await writer.toStringFormatted()).toMatchSnapshot(); + expect(method.getReferences().length).toBe(1); }); }); }); From 3ad9fbe11ae4c82604698151fd3f6e17e241ee0e Mon Sep 17 00:00:00 2001 From: Danny Sheridan <83524670+dannysheridan@users.noreply.github.com> Date: Fri, 22 Nov 2024 15:22:56 -0500 Subject: [PATCH 2/4] feat(docs): OAS compatibility (#5256) * Update overview.mdx * add link to OAS versions --- fern/pages/api-definition/openapi/overview.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/fern/pages/api-definition/openapi/overview.mdx b/fern/pages/api-definition/openapi/overview.mdx index 3c3a2815d76..725c5d7fe68 100644 --- a/fern/pages/api-definition/openapi/overview.mdx +++ b/fern/pages/api-definition/openapi/overview.mdx @@ -5,6 +5,7 @@ subtitle: OpenAPI is a standard for documenting REST APIs The OpenAPI Specification (OAS) is a framework used by developers to document REST APIs. The specification written in JSON or YAML and contains all of your endpoints, parameters, schemas, and authentication schemes. +Fern is compatible with the latest OAS release, which is currently [v3.1.1](https://spec.openapis.org/#openapi-specification). Considering options to generate an OpenAPI spec? Get live support [here](https://fern-community.slack.com/join/shared_invite/zt-2dpftfmif-MuAegl8AfP_PK8s2tx350Q%EF%BB%BF#/shared-invite/email) From df3f3fb20adf800b14f5b7e36b5098a1d034f132 Mon Sep 17 00:00:00 2001 From: Noa Flaherty Date: Fri, 22 Nov 2024 17:12:59 -0500 Subject: [PATCH 3/4] fix(python): IMprove DevExp of `AstNode` and `Reference` (#5257) * Make reference attrs public * Export AstNode --- generators/python-v2/ast/src/Reference.ts | 4 ++-- generators/python-v2/ast/src/python.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/generators/python-v2/ast/src/Reference.ts b/generators/python-v2/ast/src/Reference.ts index 85b923b1e8d..c3fed7fd680 100644 --- a/generators/python-v2/ast/src/Reference.ts +++ b/generators/python-v2/ast/src/Reference.ts @@ -24,9 +24,9 @@ export declare namespace Reference { export class Reference extends AstNode { public readonly name: string; public readonly modulePath: ModulePath; - private readonly genericTypes: AstNode[]; + public readonly genericTypes: AstNode[]; public readonly alias: string | undefined; - private readonly attribute: AttrPath; + public readonly attribute: AttrPath; constructor({ name, modulePath, genericTypes, alias, attribute }: Reference.Args) { super(); diff --git a/generators/python-v2/ast/src/python.ts b/generators/python-v2/ast/src/python.ts index 67d6795a5c9..749b6fa95be 100644 --- a/generators/python-v2/ast/src/python.ts +++ b/generators/python-v2/ast/src/python.ts @@ -11,6 +11,7 @@ import { PythonFile } from "./PythonFile"; import { Decorator } from "./Decorator"; import { Operator } from "./Operator"; +export { AstNode } from "./core/AstNode"; export { Class } from "./Class"; export { Field } from "./Field"; export { Reference } from "./Reference"; From a3a4c2f438aeb04894efc3ece66ba23adc443400 Mon Sep 17 00:00:00 2001 From: Rohin Bhargava Date: Fri, 22 Nov 2024 18:08:21 -0500 Subject: [PATCH 4/4] fix(cli): remove default float min max (#5258) * use convertDouble for float conversion * update snapshot tests * update cli version * chore: update changelog --------- Co-authored-by: fern-bot --- fern/pages/changelogs/cli/2024-11-22.mdx | 4 ++ packages/cli/cli/versions.yml | 7 ++++ .../csharp-grpc-proto-exhaustive.json | 40 ++++--------------- .../__snapshots__/csharp-grpc-proto.json | 10 +---- .../__test__/__snapshots__/object.json | 5 +-- .../ir-to-fdr-converter/convertTypeShape.ts | 7 +--- 6 files changed, 23 insertions(+), 50 deletions(-) create mode 100644 fern/pages/changelogs/cli/2024-11-22.mdx diff --git a/fern/pages/changelogs/cli/2024-11-22.mdx b/fern/pages/changelogs/cli/2024-11-22.mdx new file mode 100644 index 00000000000..9b452701ba4 --- /dev/null +++ b/fern/pages/changelogs/cli/2024-11-22.mdx @@ -0,0 +1,4 @@ +## 0.45.0-rc54 +**`(internal):`** Removes errant minimum and maximums for 'float' types for docs. + + diff --git a/packages/cli/cli/versions.yml b/packages/cli/cli/versions.yml index ebad321e126..0cf25f2d321 100644 --- a/packages/cli/cli/versions.yml +++ b/packages/cli/cli/versions.yml @@ -1,3 +1,10 @@ +- changelogEntry: + - summary: | + Removes errant minimum and maximums for 'float' types for docs. + type: internal + irVersion: 53 + version: 0.45.0-rc54 + - changelogEntry: - summary: | Add support for the `smart-casing` flags in the IR commands. diff --git a/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/csharp-grpc-proto-exhaustive.json b/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/csharp-grpc-proto-exhaustive.json index 86c8f3a7075..634f816b847 100644 --- a/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/csharp-grpc-proto-exhaustive.json +++ b/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/csharp-grpc-proto-exhaustive.json @@ -22,10 +22,7 @@ "itemType": { "type": "primitive", "value": { - "type": "double", - "minimum": 2.2250738585072014e-308, - "maximum": 1.7976931348623157e+308, - "default": 0 + "type": "double" } } } @@ -111,10 +108,7 @@ "itemType": { "type": "primitive", "value": { - "type": "double", - "minimum": 2.2250738585072014e-308, - "maximum": 1.7976931348623157e+308, - "default": 0 + "type": "double" } } } @@ -215,10 +209,7 @@ "itemType": { "type": "primitive", "value": { - "type": "double", - "minimum": 2.2250738585072014e-308, - "maximum": 1.7976931348623157e+308, - "default": 0 + "type": "double" } } } @@ -371,10 +362,7 @@ "itemType": { "type": "primitive", "value": { - "type": "double", - "minimum": 2.2250738585072014e-308, - "maximum": 1.7976931348623157e+308, - "default": 0 + "type": "double" } } } @@ -548,10 +536,7 @@ "itemType": { "type": "primitive", "value": { - "type": "double", - "minimum": 2.2250738585072014e-308, - "maximum": 1.7976931348623157e+308, - "default": 0 + "type": "double" } } } @@ -565,10 +550,7 @@ "itemType": { "type": "primitive", "value": { - "type": "double", - "minimum": 2.2250738585072014e-308, - "maximum": 1.7976931348623157e+308, - "default": 0 + "type": "double" } } } @@ -1507,10 +1489,7 @@ "itemType": { "type": "primitive", "value": { - "type": "double", - "minimum": 2.2250738585072014e-308, - "maximum": 1.7976931348623157e+308, - "default": 0 + "type": "double" } } } @@ -1701,10 +1680,7 @@ "itemType": { "type": "primitive", "value": { - "type": "double", - "minimum": 2.2250738585072014e-308, - "maximum": 1.7976931348623157e+308, - "default": 0 + "type": "double" } } } diff --git a/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/csharp-grpc-proto.json b/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/csharp-grpc-proto.json index 16a7d804025..c8de10bcf11 100644 --- a/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/csharp-grpc-proto.json +++ b/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/csharp-grpc-proto.json @@ -71,10 +71,7 @@ "itemType": { "type": "primitive", "value": { - "type": "double", - "minimum": 2.2250738585072014e-308, - "maximum": 1.7976931348623157e+308, - "default": 0 + "type": "double" } } } @@ -244,10 +241,7 @@ "itemType": { "type": "primitive", "value": { - "type": "double", - "minimum": 2.2250738585072014e-308, - "maximum": 1.7976931348623157e+308, - "default": 0 + "type": "double" } } } diff --git a/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/object.json b/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/object.json index 36bc6e5b4e6..aaa0e393f32 100644 --- a/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/object.json +++ b/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/object.json @@ -246,10 +246,7 @@ "valueType": { "type": "primitive", "value": { - "type": "double", - "minimum": 2.2250738585072014e-308, - "maximum": 1.7976931348623157e+308, - "default": 0 + "type": "double" } } }, diff --git a/packages/cli/register/src/ir-to-fdr-converter/convertTypeShape.ts b/packages/cli/register/src/ir-to-fdr-converter/convertTypeShape.ts index 91a24768e80..476327f9eb0 100644 --- a/packages/cli/register/src/ir-to-fdr-converter/convertTypeShape.ts +++ b/packages/cli/register/src/ir-to-fdr-converter/convertTypeShape.ts @@ -196,12 +196,7 @@ export function convertTypeReference(irTypeReference: Ir.types.TypeReference): F float: () => { // TODO: Add support for float types in FDR. We render them as double for now // (they have the same JSON representation). - return { - type: "double", - minimum: 2.2250738585072014e-308, - maximum: 1.7976931348623157e308, - default: 0.0 - }; + return convertDouble(primitive.v2); }, double: () => { return convertDouble(primitive.v2);