{"id":13801596,"url":"https://github.com/malcolmgreaves/avro-codegen","last_synced_at":"2025-05-07T19:22:16.411Z","repository":{"id":145611437,"uuid":"98607570","full_name":"malcolmgreaves/avro-codegen","owner":"malcolmgreaves","description":"Scala code generator for Avro schemas.","archived":false,"fork":false,"pushed_at":"2020-05-29T21:59:56.000Z","size":84,"stargazers_count":9,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-22T13:32:37.875Z","etag":null,"topics":["avro","avro-schema","codegen","data","scala","serialization"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/malcolmgreaves.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-07-28T04:15:28.000Z","updated_at":"2022-09-23T09:04:52.000Z","dependencies_parsed_at":"2024-01-05T21:57:27.800Z","dependency_job_id":null,"html_url":"https://github.com/malcolmgreaves/avro-codegen","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malcolmgreaves%2Favro-codegen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malcolmgreaves%2Favro-codegen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malcolmgreaves%2Favro-codegen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malcolmgreaves%2Favro-codegen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/malcolmgreaves","download_url":"https://codeload.github.com/malcolmgreaves/avro-codegen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252941419,"owners_count":21828872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["avro","avro-schema","codegen","data","scala","serialization"],"created_at":"2024-08-04T00:01:24.786Z","updated_at":"2025-05-07T19:22:16.385Z","avatar_url":"https://github.com/malcolmgreaves.png","language":"Scala","readme":"avro-codegen\n============\n[![Build Status](https://travis-ci.org/malcolmgreaves/avro-codegen.svg?branch=master)](https://travis-ci.org/malcolmgreaves/avro-codegen) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/fe5fab0140fc4a05ad5bcef6972b0409)](https://www.codacy.com/app/greavesmalcolm/avro-codegen?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=malcolmgreaves/avro-codegen\u0026amp;utm_campaign=Badge_Grade) [![Gitter](https://badges.gitter.im/malcolmgreaves/avro-codegen.svg)](https://gitter.im/malcolmgreaves/avro-codegen?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge) [![Stories in Ready](https://badge.waffle.io/malcolmgreaves/avro-codegen.png?label=ready\u0026title=Ready)](https://waffle.io/malcolmgreaves/avro-codegen) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.malcolmgreaves/avro-codegen-runtime_2.12/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/io.malcolmgreaves/avro-codegen-runtime_2.12)\n\nScala code generation from Avro schemas. Generates code similar to [ScalaPB](https://github.com/trueaccord/ScalaPB).\n\nNotably, the generated code for data encapsulation is in the form of case classes. The data representation is completely immutable.\n\nAll generated code adheres to the `GeneratedMessageCompanion` type class. This ensures that there exists decode and encode functionality.\n\nworking code generation for types:\n* enums\n* records\n* scalar fields (for all types except for byte arrays)\n* union fields via shapeless coproducts (for unions not containing NULL)\n* optional union fields via shapeless coproducts (for unions containing more than 2 types, one of which is NULL)\n* optional fields (for unions containing 2 types, one of which is NULL)\n* arrays\n* maps\n* byte arrays\n\nfeatures:\n* generated `org.scalacheck.Gen[_]` instances for generated enums, records\n\nnot implemented:\n* fixed-length fields\n* Generating code from inter-dependent schemas defined in multiple files (currently only handles this case when everything is in the same file).\n\nSubprojects\n==================\n* runtime: runtime dependencies\n* codegen: generates `.scala` files from avro schemas. Currently hardcoded to generate `Out.scala` in sandbox from the avro schemas in the example directory.\n* proptest: generates random schemas, generates scala code for the schemas, tests the generated scala code by serializing and deserializing random message instances\n\nTo Use\n============\n\nThere are two ways to use this project. The first is in creating `case class` instances from Avro schemas. The second is in interacting with the generated code. In practice, it's common for a project to do a little bit of both.\n\nFor the first use case:\n\nadd this to `project/plugins.sbt`\n```\naddSbtPlugin(\"io.malcolmgreaves\" % \"avro-codegen-compiler\" % \"X.Y.Z\")\n```\n\nwhere `X.Y.Z` is the most recent version.\n\nAdd your avro schemas to `src/main/avro` with the `.avsc` extension. Generated scala classes will be created in `target/scala-2.12/src_managed/main/generated_avro_classes/`.\n\nFor the second use case:\n\nWhen using code generated by this plugin, it is necessary to include the runtime dependency (which includes lots of goodies -- notably the serialization type class `GeneratedMessage`). Therefore, include the following in your `build.sbt`\n\n```\nlibraryDependencies ++= Seq(\"io.malcolmgreaves\" %% \"avro-codegen-runtime\" % \"X.Y.Z\")\n```\n","funding_links":[],"categories":["Table of Contents"],"sub_categories":["Serialization"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalcolmgreaves%2Favro-codegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmalcolmgreaves%2Favro-codegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalcolmgreaves%2Favro-codegen/lists"}