-
Notifications
You must be signed in to change notification settings - Fork 2
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
wip: foundation for OpenApi Parser #1814
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
📦 Next.js Bundle Analysis for fern-platform-monorepoThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
Playwright test resultsDetails 101 tests across 10 suites Flaky testschromium › forward-proxy/nextjs.spec.ts › capture the flag Skipped testschromium › posthog.spec.ts › Posthog loads successfully |
packages/parsers/openapi/shared/composable/availability.node.ts
Outdated
Show resolved
Hide resolved
packages/parsers/openapi/shared/interfaces/api.node.interface.ts
Outdated
Show resolved
Hide resolved
packages/parsers/openapi/shared/interfaces/api.node.interface.ts
Outdated
Show resolved
Hide resolved
packages/parsers/openapi/shared/interfaces/api.node.interface.ts
Outdated
Show resolved
Hide resolved
packages/parsers/openapi/shared/composable/availability.node.ts
Outdated
Show resolved
Hide resolved
packages/parsers/openapi/shared/interfaces/fdr.stage.interface.ts
Outdated
Show resolved
Hide resolved
packages/parsers/openapi/shared/composable/availability.node.ts
Outdated
Show resolved
Hide resolved
import { SchemaObject } from "../../../openapi/shared/openapi.types"; | ||
import { createMockContext } from "../../createMockContext.util"; | ||
|
||
describe("ObjectNode", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mega nit: i think it might be nicer to put these test files through out the code base as opposed to the top, that way you can see object.node.ts
and object.node.test.ts
side-by-side
|
||
if (input.allOf != null) { | ||
this.extends = input.allOf | ||
.map((type) => (isReferenceObject(type) ? FdrAPI.TypeId(type.$ref) : undefined)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: its going to be very important to handle non reference allOfs
|
||
if (input.allOf != null) { | ||
this.extends = input.allOf | ||
.map((type) => (isReferenceObject(type) ? FdrAPI.TypeId(type.$ref) : undefined)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a $ref
is #/components/schemas/Person
, ideally we store a TypeId that is Person
import { OpenAPIV3_1 } from "openapi-types"; | ||
import { ApiNodeContext, InputApiNode } from "../../../ApiNode"; | ||
|
||
export class EnumNode extends InputApiNode<OpenAPIV3_1.SchemaObject, FdrAPI.api.v1.read.PrimitiveType.Enum> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: think we should move enum outside of primitives folder
return; | ||
} | ||
|
||
if (!isOpenApiNumberTypeFormat(input.format)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think this actually needs to be the case, i.e. you can have numbers without formats
case "float": | ||
case "sf-decimal": | ||
case undefined: | ||
this.type = "double"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: we'll eventually want to update FDR to store the actual format
`Expected format for integer primitive, but got "${input.format}"`, | ||
accessPath, | ||
); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as flat, dont think this need to be a large failure
export class ErrorCollector { | ||
errors: ValidationError[] = []; | ||
|
||
addError(error: string, accessPath: string[]): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it also makes sense to collect warnings
+ errors
,
Could see an example of collector.warn()
and collector.error()
as the two methods on the ErrorCollector.
@@ -0,0 +1,3 @@ | |||
import { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from "openapi-types"; | |||
export type SchemaObject = OpenAPIV3_1.SchemaObject | OpenAPIV3.SchemaObject | OpenAPIV2.SchemaObject; | |||
export type ReferenceObject = OpenAPIV3_1.ReferenceObject | OpenAPIV3.ReferenceObject | OpenAPIV2.ReferenceObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we delete this (since we are only optimizing for OpenAPIV3_1 for now) ?
Note: Ignore any of the files in
temporary
, those are there so that boilerplate does not need to be implemented again.This PR introduces the base nodes that are necessary for parsing OpenApi Spec.
It introduces 3 abstractions:
The nodes created are:
Primitives:
String --> these correspond to any type: "string" nodes we encounter in OpenApi spec
Number --> these correspond to any type: "integer | number" nodes we encounter in OpenApi spec
Schema: An input node that helps us recognize schemas/references as we encounter them in OpenApi spec.
Reference: An input node that helps us to resolve references or pass them as Alias types.
Object (and all derivatives): An output node that helps us to parse any schema from OpenApi into the correct Fdr shapes.
Additionally, there are a few of types files introduced for cleaner organization: