spatie / schema-org

A fluent builder Schema.org types and ld+json generator
https://freek.dev/2016/12/package-fluently-generate-schema-org-markup/
MIT License
1.34k stars 135 forks source link

Make generator extensible for other Schema definitions #25

Closed agemmell closed 4 years ago

agemmell commented 7 years ago

Not so much an issue, just a question.

I'd love to use this package but without the health-lifesci.schema.org extension I might need to roll my own. Is there a way for me to add schema extensions so I can benefit from using the MedicalOrganization type "Physician"?

Is it possible to somehow run your generator against that health-lifesci schema extension and generate a library of files in my project to augment your core files?

sebastiandedeyne commented 7 years ago

Hmm right now not without forking this... Is there an RDFa file available though? That's what's used to generate the classes here, not sure if there are files like that available for extensions. If there is, I'd be willing to look into making the generator a bit more open for extension if it isn't too much overhead.

greatislander commented 7 years ago

There's this: https://github.com/schemaorg/schemaorg/blob/master/data/releases/3.3/ext-health-lifesci.rdf

Related, we would be really interested in looking into a way to include the bib.schema.org extensions:

https://github.com/schemaorg/schemaorg/blob/master/data/releases/3.3/ext-bib.rdf

If extension support is a broader feature you'd consider, I'd be delighted to help with testing if needed.

sebastiandedeyne commented 7 years ago

I'll look into making this extensible for other rdf files, but it won't be before the end of this month.

greatislander commented 6 years ago

@sebastiandedeyne I've been looking into this and I'd like to submit a PR to allow generating classes for Schema extensions. However I want to make sure my approach works for you before I do so.

Notes

Proposed Approach

So, to generate core types + bibliographic extension, one would run:

php generate.php generate https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/schema.rdfa,https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/ext/bib/bsdo-1.0.rdfa

Let me know what you think.

Edit: The generate command could also be updated to generate core types plus all extensions by default. See here.

Something like:

-     const SOURCE = 'https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/schema.rdfa';
+     const SOURCES = [
+          'https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/schema.rdfa',
+          'https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/ext/auto/auto.rdfa',
+          'https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/ext/bib/bsdo-1.0.rdfa',
+          'https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/ext/health-lifesci/med-health-core.rdfa',
+          'https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/ext/health-lifesci/physical-activity-and-exercise.rdfa'
+     ];
sebastiandedeyne commented 6 years ago

I'd rather only have the core types generated in this package. I don't mind maintaining a generate command that has the option of generating more types though, I'd accept a PR that adds this.

I'm currently rewriting part of the generator to give it a huge speed boost though, so if the changes are significant you might want to wait, or do it before I've made substantial progress ๐Ÿ˜„

greatislander commented 6 years ago

Changes arenโ€™t that significant; Iโ€™ll try to submit a PR today.

greatislander commented 6 years ago

Sorry, won't get a chance to do this today. I'll wait on your upstream changes and then submit, unless you can accept the PR later this week.

sebastiandedeyne commented 6 years ago

No hurry, not sure when I'll be getting to my changes yet either :)

sebastiandedeyne commented 6 years ago

Pretty far in the refactor. If you hate debugging with the long build times, you might want to wait on this, generating the code has gone down to 8 seconds from 150+ ๐Ÿ˜…

Gummibeer commented 6 years ago

@greatislander will you find time? Or is this now, like labeled, help wanted and the community can/should solve this.

greatislander commented 6 years ago

I still plan on doing this at some point.

nolros commented 6 years ago

@greatislander I'm interested why support for RDF vs JSON-ld. Google has been very pro-active in promoting JSON-LD-schema.org these past couple or three years. I see very little support for inline or any other vocabulary approach. Is it some further vocabulary extension like b2b or commerce of something else that is required by RDFa?

Gummibeer commented 6 years ago

@nolros they contain the same data just different file-formats. And the generated code is json-ld.

greatislander commented 6 years ago

Finally getting back to looking at this.

Gummibeer commented 4 years ago

relates to #133

mallardduck commented 4 years ago

@agemmell I think this issue is essentially resolved by the recent changes in #140. The Physician class is now being generated which seemed to be the specific concern mentioned. So give things a look and potentially this issue could be marked as resolved.

If there are any Schema types you think are missing still it's possible they were still Pending in the 8.0 release for schema. In that case then you may need to check back once the repo is updated to use the Schema 9.0 release. Which shouldn't be too hard to create. From what I saw in testing on that, it added a LOT more medical related Schema types.

Gummibeer commented 4 years ago

I'm working right now on v9 release - it will contain everything including all pending and extension types. I think that it will be released late today or tomorrow and as soon as it's released I will close this issue. ๐Ÿ˜Š

mallardduck commented 4 years ago

Nice! In my testing it was a lot more similar to v8 but had a handful of changes it needed. Mainly it seems that they're adding some internationalization of some sort. For instance I found some strings are now wrapped in an object identifying their locale.

Gummibeer commented 4 years ago

https://github.com/spatie/schema-org/releases/tag/3.0.0

agemmell commented 4 years ago

@mallardduck I'm afraid I cannot test this as I am no longer involved in this space. However, I appreciate the hard work OSS contributors like yourself put in to make improvements like this! So thank you.