Skip to content

Fix remote schema maps #1212

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

Merged
merged 1 commit into from
Jul 7, 2023
Merged

Fix remote schema maps #1212

merged 1 commit into from
Jul 7, 2023

Conversation

drwpow
Copy link
Contributor

@drwpow drwpow commented Jul 7, 2023

Changes

Fixes #1131. There are likely some other bugs with deeply-nested remote schemas, but this fixes at least one.

The reason was in our getHint() logic that traverses the nodePath, it wasn’t keeping track of remote filenames, which is necessary for certain inferences (the hints are necessary because partial schemas could be anything and still be valid—the only way to know is by tracing from the root). There’s probably a better solution than this, but this will do for now.

How to Review

Tests should pass.

Checklist

  • Unit tests updated
  • README updated
  • examples/ directory updated (only applicable for openapi-typescript)

@changeset-bot
Copy link

changeset-bot bot commented Jul 7, 2023

🦋 Changeset detected

Latest commit: c25f227

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openapi-typescript Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@drwpow drwpow force-pushed the fix-remote-schema-maps branch from 4a71732 to 39916e0 Compare July 7, 2023 03:06
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jul 7, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: c25f227
Status: ✅  Deploy successful!
Preview URL: https://c751f852.openapi-ts.pages.dev
Branch Preview URL: https://fix-remote-schema-maps.openapi-ts.pages.dev

View logs

@@ -3965,7 +3965,160 @@ export interface external {
default: external["shared/responses/unexpected_error.yml"];
};
}
"resources/certificates/models/certificate_create.yml": unknown
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 probably a good sign

@drwpow drwpow force-pushed the fix-remote-schema-maps branch from 39916e0 to 4926934 Compare July 7, 2023 03:26
return getHintFromSchemaObject(path.slice(2), external); // skip array index at [1]
}
// if this is external, and the path is [filename, key], then the external schema is probably a SchemaMap
if (path.length === 2 && external) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very wacky logic, but it seems to check out 🤷

@drwpow drwpow force-pushed the fix-remote-schema-maps branch from 4926934 to 5d33b21 Compare July 7, 2023 03:27
@drwpow drwpow force-pushed the fix-remote-schema-maps branch from 5d33b21 to c25f227 Compare July 7, 2023 03:27
@drwpow drwpow merged commit e173ccf into main Jul 7, 2023
@drwpow drwpow deleted the fix-remote-schema-maps branch July 7, 2023 03:31
@github-actions github-actions bot mentioned this pull request Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generation of schema that references outside schema
1 participant