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

Cleanup schema explorer override code for polymorphic discriminators #75

Merged
merged 1 commit into from
Jan 28, 2024

Conversation

gnidan
Copy link
Member

@gnidan gnidan commented Jan 28, 2024

Background: I previously added some janky code for detecting this format's conventional use of polymorphic discriminators (using allOf with if: { properties: { const: ... } }, the idea being to render these in a custom manner (different than docusaurus-json-schema-plugin's default allOf rendering).

This PR cleans up that code (which currently just lives in a swizzled AllOfSchema component), so that it has its own module with a detectDiscriminator() function and well-typed components, etc.

I'm making this change so that it won't get so bad when this project finds other schema conventions that make sense and we want to be able to custom-detect our use of the convention and render it properly.

This PR adds json-schema-typed to the web package and also enables strict: true, so this PR contains a few other fixes I noticed along the way.

... and a few other matters

Primarily:
- Move discriminator detection and rendering to own .tsx module
- Cleanup naming and types to be more precise

Also:
- Start using json-schema-typed in web
- Fix a broken type import (why were we not alerted?)
- Enable TypeScript's strict: true in web
- Fix strictness and other mistake in CreateNodesWrapper
  - Define type for props to reflect use of `[internalIdKey]` symbol
  - Pass original `props.schema` to @theme-original's <CreateNodes />,
    rather than the mistaken partial ...rest
@gnidan gnidan merged commit a3f90bc into main Jan 28, 2024
4 checks passed
@gnidan gnidan deleted the convention-cleanup branch January 28, 2024 06:06
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.

1 participant