Protocol buffer models for the MTGJSON data set
Explore the docs »
Jira Board
·
Report Bug
Table of Contents
MTGJSON-Protobufs are a set of protocol buffers modeling the original MTGJSON data set. These were originally developed for use within the MTGJSON API, however they can be used and integrated with any language. The models have been altered slightly to ensure that user ownership of objects (like decks) within the API can be implemented, please see model description below.
MTGJSON Protobufs is unofficial Fan Content permitted under the Fan Content Policy. Not approved/endorsed by Wizards of the Coast. Portions of the materials used are property of Wizards of the Coast. © Wizards of the Coast LLC.
MTGJSON Protobufs is not officially endorsed by MTGJSON
To be able to generate models for your selected language, you will need the protobuf compiler installed. You can follow the instructions below for installing this
- Debian Based Linux Distribution:
apt-get update && apt install -y protobuf-compiler
- MacOS:
brew update && brew install protobuf
If you need additional tags to be injected into the generated models (specifically for use within Go) then protoc-go-inject-tag should be installed as well
- Install protoc-go-inject-tag:
go install github.com/favadi/protoc-go-inject-tag@latest
Generating protobuf models is incredibly simple and can be completed with a single command. The below example shows how to generate them for Go lang, however they can be generated for any other language that protoc support simply by changing the --go_out
flag
to which ever flag best suits your language:
- Generate Protobuf's:
protoc -I=mtgjson-proto/ --go_out=<OUTPUT_DIRECTORY> --go_opt=paths=source_relative mtgjson-proto/*/*.proto
Please be aware that if you are generating these for a go-lang project that is seperate from the MTGJSON-API, then you will need to change the go_package
option statement that is defined at the top of each protobuf model. Currently, this is set to: github.com/stevezaluk/mtgjson-models/<package>
to ensure that
the models will be properly generated for the MTGJSON-API
Additionally, please make note that the paths=source_relative
option is currently set to ensure that protoc does not recreate the directory structure according to the go_package
option. Remove this if you would like this functionality
If you are generating these for go, and you need additional struct tags injected into the models then you should run the following command post-generation to inject the tags. You can define the additional tags that you want to inject using the following comment structure: // @gotags: key=val
.
Comments injecting additional BSON tags have been provided already:
- Inject Tags:
cd mtgjson-models && protoc-go-inject-tag -input="*/*.pb.go"
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under Apache License 2.0. See LICENSE.txt
for more information.
Steven A. Zaluk - @steve_zaluk - [email protected]
Project Link: https://github.com/stevezaluk/mtgjson-proto\n