Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Generate enum as enum for Java #248

Open
martin-martinez-thrive opened this issue May 11, 2022 · 0 comments
Open

Generate enum as enum for Java #248

martin-martinez-thrive opened this issue May 11, 2022 · 0 comments

Comments

@martin-martinez-thrive
Copy link

Hi 👋
using the following schema for a test event:
{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "labels": { "section": "auth" }, "description": "Testing Events with accepted values", "properties": { "context": { "id": "/properties/context" }, "traits": { "type": "object", "id": "/properties/traits" }, "properties": { "type": "object", "properties": { "backpack_contents": { "description": "What are you taking on your trip", "id": "/properties/properties/properties/backpack_contents", "properties": { "item_name": { "description": "Item name", "enum": [ "food", "raincoat", "salami", "tootbrush" ], "id": "/properties/properties/properties/backpack_contents/properties/item_name", "type": "string" }, "weight": { "description": "How heavy is the backpack", "id": "/properties/properties/properties/backpack_contents/properties/weight", "type": "integer" } }, "required": [], "type": "object" }, "heading": { "description": "Heading direction", "enum": [ "east", "north", "south", "west" ], "id": "/properties/properties/properties/heading", "type": "string" }, "trip_name": { "description": "A descriptive name for the trip, example: \"Road trip to Vegas\"", "id": "/properties/properties/properties/trip_name", "pattern": "([A-Z])\\w+", "type": "string" } }, "id": "/properties/properties" } } }

the generated code for Java, TestEvent.Builder takes heading as a String. Ideally this should be an enum with 4 options so clients shouldn't have these values hard-coded, which would also prevent other values to be added.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant