lexiq-legal / pydantic_schemaorg

Schema.org classes in pydantic
MIT License
58 stars 17 forks source link

Allow (option for) str type for all property values #1

Closed m-alek closed 2 years ago

m-alek commented 2 years ago

Description Each schema.org object has properties that have expected values, which subsequently could be other schema.org objects.

E.g. 'https://schema.org/ScholarlyArticle' has property 'https://schema.org/publisherImprint', which has expected type 'https://schema.org/Organization'.

Problem Many times it is impractical to build an Organization object to put as a value for a some property, and instead you would like toenter a unique id that refers to this object, i.e. put in a value of type string.

Schema.org themselves anticipate that also: "We also expect that often, where we expect a property value of type Person, Place, Organization or some other subClassOf Thing, we will get a text string, even if our schemas don't formally document that expectation" (https://schema.org/docs/datamodel.html).

Solution Allow type string always for every property. Or have an option that strings are allowed when instantiating a pydantic model, such that you keep control over when you do and when you don't want to allow string types additionally.

crbaker89 commented 2 years ago

str type is added for all fields now, thanks!