-
Notifications
You must be signed in to change notification settings - Fork 35
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
Allow Role to be used for use cases like defining dates #143
Comments
Interesting. alumniOf is expected to be of type Organization. OrganizationRole is not an Organization. But schema.org shows examples of OrganizationRole being used in its place. I think the right answer is to open a bug against schema.org. Let's keep this open though, I'll link it |
You are right. I didn't notice that the schema was being fetched from https://schema.org/version/latest/schemaorg-current-https.nt and then processed by schema-dts I was implementing a PR based on the generated schema.d.ts. Didn't check the source code beforehand. I will pause the work on that PR. Thank you for opening the issue in the right repo. I will follow up there and come back here if I have new reasons. |
Schema.org conformance already allows "Text" and "URL" on more fields than what their schema says. Apparently, technically, Role is also allowed on most properties. I'll see what Richard says in the upstream bug, but we might additionally end up having something like |
With that approach, most cases will be covered. Maybe Role can be allowed in all types, as the conformance section says. One property of Role is that it has exactly a child node with the same name as the Role's parent. With that in mind, here is the idea I was pursuing. I don't know yet how to make it possible in the generator code, but this is how it would look in the generated schema.d.ts. Surely it will have to be adapted to what would be defined in upstream. Using Record and enforcing the string type will effectively allow restricting to only a child node with the same name as the Role's parent.
|
Yeah. I assume we could do something simpler, closer to:
or similar. I'd still be worried about it for a few reasons:
What is certainly true is that:
But you're right, even when the Schema.org Issue is addressed for the types you care about, we'll still need a way for role to support these excess properties very specifically. |
@SamuelEnglard if it's okay to skip type checking for just the Role sub-object, I'd probably just cast the role: ({
"@type": "Role",
// ...
} as {} as Organization) or similar, to the desired type. |
Hi @Eyas. I've been testing it today, and it has worked great so far. I hope it can be released as stable in the future. Thank you very much for the excellent work. |
fyi just published 0.11.0, still working on GitHub release notes. |
My use case is similar to the ones provided in the Example 2 for hasOccupation and in this use case for worksFor.
As stated in Schema.org hasOccupation definition: The Person's occupation. For past professions, use Role for expressing dates. In the case of
worksFor
is not stated explicitly but what I want is to represent additional information to a Person, as the original blog post suggests.I'm working on a PR to solve this but in the meantime I wanted to see if the idea is right for this project.
Here is an example taken from the Role webpage:
The text was updated successfully, but these errors were encountered: