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

[DNM, Dupe] fix(cli): namespacing no longer breaks when objects conflict across namespaces #4596

Closed
wants to merge 9 commits into from

Conversation

armandobelardo
Copy link
Contributor

For now, this just adds a repro of the namespace break, you can see in the ETE test, trains imports from neopets (a different namespace) when the objects share the same name

const declarationFile = getDeclarationFileForSchema(schema);
const typeDeclaration = buildTypeDeclaration({ schema, context, declarationFile });
const declarationFile = getDeclarationFileForSchema(schema);
const typeDeclaration = buildTypeDeclaration({ schema, context, declarationFile, namespace });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really only nesting the for loop into another for loop, the only actual change is passing in namespace here

x-fern-type-name: Pets
Error:
x-fern-type-name: Error
__no_namespace__:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not positive what would cause this

@armandobelardo armandobelardo changed the title [WIP] fix(cli): namespacing no longer breaks when objects conflict across namespaces fix(cli): namespacing no longer breaks when objects conflict across namespaces Sep 12, 2024
@armandobelardo armandobelardo marked this pull request as ready for review September 12, 2024 10:24
Copy link

gitguardian bot commented Sep 12, 2024

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
Once a secret has been leaked into a git repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

import { Namespace, SdkGroupName, EndpointSdkName } from "@fern-api/openapi-ir-sdk";

export function getNamespaceFromGroup(groupName: SdkGroupName): string | undefined {
return groupName.find((group): group is Namespace => typeof group !== "string" && group.type === "namespace")?.name;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this would be easier to read if we refactored the type guard outside of the lambda

The schemas are organized by namespace and schema name.
The schema name is the key in the inner map.
Note that this also includes un-namespaced schemas with a static sentinel key of `__no_namespace__`,
as even when namespacing we allow for root, unnamespaced APIs, and this allows for the most flexibility.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@armandobelardo armandobelardo changed the title fix(cli): namespacing no longer breaks when objects conflict across namespaces [DNM, Dupe] fix(cli): namespacing no longer breaks when objects conflict across namespaces Sep 17, 2024
@armandobelardo armandobelardo marked this pull request as draft September 17, 2024 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants