Skip to content

Commit

Permalink
Merge branch 'main' into eden/docs-schema-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eyw520 authored Nov 22, 2024
2 parents 31b7b46 + a3a4c2f commit d22ca3d
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 55 deletions.
1 change: 1 addition & 0 deletions fern/pages/api-definition/openapi/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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).

<Info> 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) </Info>

Expand Down
2 changes: 1 addition & 1 deletion fern/pages/changelogs/cli/2024-11-22.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 0.45.0-rc54
**`(fix):`** Docs generation now preserves original model schema names.
**`(internal):`** Removes errant minimum and maximums for 'float' types for docs.


4 changes: 4 additions & 0 deletions generators/python-v2/ast/src/Class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions generators/python-v2/ast/src/Method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions generators/python-v2/ast/src/Reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions generators/python-v2/ast/src/__test__/Class.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
13 changes: 13 additions & 0 deletions generators/python-v2/ast/src/__test__/Method.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand Down Expand Up @@ -163,6 +175,7 @@ describe("Method", () => {

method.write(writer);
expect(await writer.toStringFormatted()).toMatchSnapshot();
expect(method.getReferences().length).toBe(1);
});
});
});
1 change: 1 addition & 0 deletions generators/python-v2/ast/src/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- changelogEntry:
- summary: |
Docs generation now preserves original model schema names.
type: fix
Removes errant minimum and maximums for 'float' types for docs.
type: internal
irVersion: 53
version: 0.45.0-rc54

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
"itemType": {
"type": "primitive",
"value": {
"type": "double",
"minimum": 2.2250738585072014e-308,
"maximum": 1.7976931348623157e+308,
"default": 0
"type": "double"
}
}
}
Expand Down Expand Up @@ -111,10 +108,7 @@
"itemType": {
"type": "primitive",
"value": {
"type": "double",
"minimum": 2.2250738585072014e-308,
"maximum": 1.7976931348623157e+308,
"default": 0
"type": "double"
}
}
}
Expand Down Expand Up @@ -215,10 +209,7 @@
"itemType": {
"type": "primitive",
"value": {
"type": "double",
"minimum": 2.2250738585072014e-308,
"maximum": 1.7976931348623157e+308,
"default": 0
"type": "double"
}
}
}
Expand Down Expand Up @@ -371,10 +362,7 @@
"itemType": {
"type": "primitive",
"value": {
"type": "double",
"minimum": 2.2250738585072014e-308,
"maximum": 1.7976931348623157e+308,
"default": 0
"type": "double"
}
}
}
Expand Down Expand Up @@ -548,10 +536,7 @@
"itemType": {
"type": "primitive",
"value": {
"type": "double",
"minimum": 2.2250738585072014e-308,
"maximum": 1.7976931348623157e+308,
"default": 0
"type": "double"
}
}
}
Expand All @@ -565,10 +550,7 @@
"itemType": {
"type": "primitive",
"value": {
"type": "double",
"minimum": 2.2250738585072014e-308,
"maximum": 1.7976931348623157e+308,
"default": 0
"type": "double"
}
}
}
Expand Down Expand Up @@ -1507,10 +1489,7 @@
"itemType": {
"type": "primitive",
"value": {
"type": "double",
"minimum": 2.2250738585072014e-308,
"maximum": 1.7976931348623157e+308,
"default": 0
"type": "double"
}
}
}
Expand Down Expand Up @@ -1701,10 +1680,7 @@
"itemType": {
"type": "primitive",
"value": {
"type": "double",
"minimum": 2.2250738585072014e-308,
"maximum": 1.7976931348623157e+308,
"default": 0
"type": "double"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@
"itemType": {
"type": "primitive",
"value": {
"type": "double",
"minimum": 2.2250738585072014e-308,
"maximum": 1.7976931348623157e+308,
"default": 0
"type": "double"
}
}
}
Expand Down Expand Up @@ -244,10 +241,7 @@
"itemType": {
"type": "primitive",
"value": {
"type": "double",
"minimum": 2.2250738585072014e-308,
"maximum": 1.7976931348623157e+308,
"default": 0
"type": "double"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,7 @@
"valueType": {
"type": "primitive",
"value": {
"type": "double",
"minimum": 2.2250738585072014e-308,
"maximum": 1.7976931348623157e+308,
"default": 0
"type": "double"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d22ca3d

Please sign in to comment.