square / square/wire

wire code gen extensions

Open
#1,867 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
4.4k
Forks
627
Avg merge
3d 15m
Merged PRs (30d)
20

Description

I'm not really sure how to name issue - more of a general question. I can open something more specific if this leads anywhere. I didn't see any similar issue, sorry if I missed something.

There's a specific use case I'm trying to satisfy and a potentially more general way of accomplishing that solution that would fit other needs. I don't think I'm trying to propose something as general as the protoc plugin model.

Very concretely, I'm curious about trying to leverage validation annotations like the ones in https://github.com/envoyproxy/protoc-gen-validate but rather than generate a Validator#validate(Message m) for each message type, I'd like to have the generated object apply its own validations and throw an exception when trying to create an invalid instance. eg. adding require checks to a kotlin init block or very similar to how Immutables Java does precondition checks https://immutables.github.io/immutable.html#precondition-check-method

This same mechanism could possibly extend to supporting field annotations like redacted to exclude the field from toString generation?

Maybe doing domain modeling like this in protos is just a foolish idea?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository files, tests, or entry points. Start by clarifying whether the goal is validation during generated-object construction, annotation-driven output changes such as redacted toString methods, or both; done requires an agreed scope and design before implementation can be located.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.