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

feat: new scalarParse translation function #1418

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tmastrom
Copy link
Member

@tmastrom tmastrom commented Apr 11, 2024

This PR adds scalarParse to oas-utils to convert the output of the parser into a more usable data object for rendering. The translation layer dereferences and groups fields for rendering as well as creates new zod schemas for parsing incoming data. We want to allow malformed data as much as possible to render what we can.

The parse.ts function is removed from @scalar/api-reference and replaced with the new scalarParse function

Todo

  • decide on critical error handling
    • we can implement custom errors, refinements, and preprocessing in zod schemas as well as safe parsing data to give a good sense of what data is available
  • don't blow up the bundle size - what to do with testing yaml files?
  • proper yaml import process for testing

@tmastrom tmastrom requested a review from marclave as a code owner April 11, 2024 06:37
Copy link

changeset-bot bot commented Apr 11, 2024

⚠️ No Changeset found

Latest commit: 7905777

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

relativeci bot commented Apr 12, 2024

Job #959: Bundle Size — 1.97MiB (+2.77%).

8e5beeb(current) vs 3d4d83e main#954(baseline)

Warning

Bundle contains 4 duplicate packages – View duplicate packages

Warning

Bundle introduced one new package: zod – View changed packages

Bundle metrics  Change 3 changes Regression 2 regressions
                 Current
Job #959
     Baseline
Job #954
Regression  Initial JS 1.97MiB(+2.77%) 1.92MiB
No change  Initial CSS 0B 0B
No change  Cache Invalidation 100% 100%
No change  Chunks 1 1
No change  Assets 1 1
Change  Modules 1044(+0.19%) 1042
No change  Duplicate Modules 0 0
No change  Duplicate Code 0% 0%
Regression  Packages 159(+0.63%) 158
No change  Duplicate Packages 4 4
Bundle size by type  Change 1 change Regression 1 regression
                 Current
Job #959
     Baseline
Job #954
Regression  JS 1.97MiB (+2.77%) 1.92MiB

View job #959 reportView tom/doc-1637-scalarparse branch activityView project dashboard

Copy link
Contributor

Choose a reason for hiding this comment

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

We should break all the test files out into a separate repo so it can just be installed as a dev depedency and keep the spec files out of the main repo.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved these test files to the CDN for now while we figure out the best way to break out the test files

@hanspagel
Copy link
Member

Great work already! Shouldn’t we keep this in @scalar/api-reference, though? It’s not useful for other people, transformResult is just too specific to our needs. 🤔

@hanspagel hanspagel marked this pull request as draft April 30, 2024 12:10
@tmastrom
Copy link
Member Author

Great work already! Shouldn’t we keep this in @scalar/api-reference, though? It’s not useful for other people, transformResult is just too specific to our needs. 🤔

The only downside I see to this is adding a dependency to @scalar/api-reference but I would defer to @marclave and @geoffgscott for this decision.

@hanspagel
Copy link
Member

Dumb question: What dependency do we need to add to @scalar/api-reference? 😳

@tmastrom
Copy link
Member Author

tmastrom commented May 6, 2024

@scalar/api-reference would need to import oas-utils to use this new translation function with the current package setup @hanspagel but it looks like it is already using this package so there would actually be no change.

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.

None yet

3 participants