Generating types | schema-org-go | Spatie       

 SPATIE  

schema-org-go
=============

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Schema-org-go](https://spatie.be/docs/schema-org-go/v1)  Generating types

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/schema-org-go/v1) 

  Generating types    
- [ Introduction ](https://spatie.be/docs/schema-org-go/v1/introduction)
- [ Installation and setup ](https://spatie.be/docs/schema-org-go/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/schema-org-go/v1/usage)
- [ Advanced usage ](https://spatie.be/docs/schema-org-go/v1/advanced-usage)
- [ Graph - multiple items ](https://spatie.be/docs/schema-org-go/v1/graphs)
- [ Multi typed entities ](https://spatie.be/docs/schema-org-go/v1/multi-typed-entities)
- [ Generating types ](https://spatie.be/docs/schema-org-go/v1/generating-types)
- [ Testing ](https://spatie.be/docs/schema-org-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/schema-org-go/v1/releasing)
- [ Changelog ](https://spatie.be/docs/schema-org-go/v1/changelog)
- [ Support us ](https://spatie.be/docs/schema-org-go/v1/support-us)

 Generating types
================

The Python standard-library generator reads the [Schema.org 30.0 JSON-LD definitions](https://raw.githubusercontent.com/schemaorg/schemaorg/main/data/releases/30.0/schemaorg-all-https.jsonld), the same version pinned by the PHP package and Rust port. A copy is committed under `generator/`, so normal regeneration works offline with Python 3 and `gofmt`.

```
python3 generator/generate.py
```

This writes `vocabulary_generated.go` and `vocabulary_generated_test.go`. It generates 925 type constructors, 1,529 property setters, 536 enumeration constants and accessors on `Graph` and `MultiTypedEntity`. Every setter is available on every builder, including inherited and extension properties. Use `SetProperty` for properties outside the vocabulary.

Names are exported Go identifiers, such as `LocalBusiness`, `URL` and `ContentURL`. Enumeration constants include the parent type, such as `BookFormatTypeHardcover`. `ThreeDimensionalModel` is the Go constructor for `3DModel`. The JSON-LD output and string-based graph lookups keep the original name `3DModel`.

Primitive data types use Go values, not constructors. `TypeNames()` returns a copy of all generated names, and `IsType` tests membership. The generated API does not enforce Schema.org property ranges or validate Google's rich-result requirements.

To download the pinned upstream file again, run `python3 generator/generate.py --refresh`. To adopt a newer vocabulary, change the source URL and version in the generator, refresh, regenerate and review the diff. CI regenerates and rejects drift. Generated tests exercise each constructor, property mapping, enum URL and collection accessor.

The vocabulary and generator approach follow [spatie/schema-org](https://github.com/spatie/schema-org) at `5c67fb7b7fcbd0dfa0a7a5a4febe440f21d88c30` and [spatie/schema-org-rust](https://github.com/spatie/schema-org-rust) at `3e338ae0d5e329933081420803b7209ebd2b4a53`. Go tests also preserve the corrected `3DModel` wire name from the Rust port.

The vendored vocabulary is from Schema.org under the Apache 2.0 license, included at `generator/LICENSE-schemaorg`. The Go implementation is MIT licensed.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
