Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Handle sum types in ingress encoder #1388

Closed
Tracked by #1248
worstell opened this issue May 2, 2024 · 2 comments
Closed
Tracked by #1248

Handle sum types in ingress encoder #1388

worstell opened this issue May 2, 2024 · 2 comments
Assignees

Comments

@worstell
Copy link
Contributor

worstell commented May 2, 2024

When decoding into a type enum schema.Enum, handle using the type registry

@github-actions github-actions bot added the triage Issue needs triaging label May 2, 2024
@alecthomas alecthomas mentioned this issue May 2, 2024
@alecthomas
Copy link
Collaborator

I'm thinking maybe we should just extend our existing encoding.Marshal/encoding.Unmarshal instead, but let's discuss in the standup.

@alecthomas
Copy link
Collaborator

Pros:

  1. omitempty in the stdlib doesn't support zero structs and thus doesn't support ftl.Optional resulting in teams using pointer fields
  2. lowerCamelCase and snake_case are very common in web APIs and Go's encoder has no way of specifying those cases easily, instead requiring every field to be tagged. Very tedious. We could support that easily.

Cons:

  1. Quite a lot of work.
  2. We'd need to support (perhaps optionally) encoding/json.Unmarshaler/Marshaler
  3. It's currently the internal encoding only, we might want to fork it instead.

This might be better as a separate open source project.

@worstell worstell added the next Work that will be be picked up next label May 2, 2024
@github-actions github-actions bot removed the triage Issue needs triaging label May 2, 2024
@worstell worstell changed the title Implement ingress encoder and handle sum types Handle sum types in ingress encoder May 3, 2024
@worstell worstell self-assigned this May 3, 2024
@github-actions github-actions bot removed the next Work that will be be picked up next label May 3, 2024
worstell added a commit that referenced this issue May 8, 2024
worstell added a commit that referenced this issue May 9, 2024
worstell added a commit that referenced this issue May 9, 2024
worstell added a commit that referenced this issue May 9, 2024
worstell added a commit that referenced this issue May 9, 2024
worstell added a commit that referenced this issue May 9, 2024
worstell added a commit that referenced this issue May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants