Skip to content

Latest commit

 

History

History
150 lines (109 loc) · 6.96 KB

README.md

File metadata and controls

150 lines (109 loc) · 6.96 KB

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

MTGJSON-Protobufs

Protocol buffer models for the MTGJSON data set
Explore the docs »

Jira Board · Report Bug

Table of Contents
  1. About The Project
  2. Disclaimers
  3. Getting Started
  4. Contributing
  5. License
  6. Contact

About The Project

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.

Disclaimers

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

(back to top)

Getting Started

Prerequisites

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

Installation

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

Go-lang Generation Notes

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

Additional Go-lang Struct Tags

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"

(back to top)

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under Apache License 2.0. See LICENSE.txt for more information.

(back to top)

Contact

Steven A. Zaluk - @steve_zaluk - [email protected]

Project Link: https://github.com/stevezaluk/mtgjson-proto\n

(back to top)