-
-
Notifications
You must be signed in to change notification settings - Fork 414
feat: add jsonld schema support #1375
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 097b0bf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
This comment was marked as outdated.
This comment was marked as outdated.
6de32e5
to
2c0e0b7
Compare
This comment was marked as outdated.
This comment was marked as outdated.
@codex review |
@codex fix comments |
This comment was marked as off-topic.
This comment was marked as off-topic.
314f0e3
to
045fe31
Compare
@codex review |
@codex review |
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
private resolveProperty( | ||
key: string, | ||
value: any, | ||
context?: JsonLdContext, | ||
): any { | ||
// Basic type inference from value | ||
if (typeof value === "string") { | ||
return { type: "string" }; | ||
} | ||
if (typeof value === "number") { | ||
return { type: "number" }; | ||
} | ||
if (typeof value === "boolean") { | ||
return { type: "boolean" }; | ||
} | ||
if (Array.isArray(value)) { | ||
return { | ||
type: "array", | ||
items: | ||
value.length > 0 | ||
? this.resolveProperty(`${key}_item`, value[0], context) | ||
: { type: "string" }, | ||
}; | ||
} | ||
if (typeof value === "object" && value !== null) { | ||
if (this.isJsonLdSchema(value)) { | ||
return this.resolveJsonLdSchema(value); | ||
} | ||
return { | ||
type: "object", | ||
additionalProperties: true, | ||
}; |
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.
Preserve typed properties when normalizing JSON-LD schemas
The JSON-LD resolver replaces every object-valued property that doesn’t itself look like a JSON-LD schema with { type: "object", additionalProperties: true }
. Because the property loop assigns this result back to resolvedSchema.properties[key]
, ordinary JSON Schema definitions such as { type: "string", format: "email" }
are discarded and later become Record<string, any>
in the generated interfaces (see the snapshots where name
/email
lose their string types). This wipes out the original typing for JSON-LD entity fields and materially reduces accuracy. The resolver should leave non‑JSON‑LD property schemas intact (or copy them through) instead of blindly converting them to a generic object.
Useful? React with 👍 / 👎.
No description provided.