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

Encoding numeric as string #3856

Closed
Tracked by #1179
lmazuel opened this issue Jul 16, 2024 · 2 comments · Fixed by #4020
Closed
Tracked by #1179

Encoding numeric as string #3856

lmazuel opened this issue Jul 16, 2024 · 2 comments · Fixed by #4020
Assignees
Labels
compiler:core Issues for @typespec/compiler design:accepted Proposal for design has been discussed and accepted. triaged:core
Milestone

Comments

@lmazuel
Copy link
Member

lmazuel commented Jul 16, 2024

Proposed changed signature for decorator

extern dec encode(
  target: Scalar | ModelProperty,
  encoding: string | EnumMember,
  encodedAs?: Scalar
);
extern dec encode2(target: Scalar | ModelProperty, encodedAs: Scalar);
extern dec encode2(
  target: Scalar | ModelProperty,
  encodingOrEncodedAs: string | EnumMember | Scalar,
  encodedAs?: Scalar
);

And then you can call

@encode(string) val: int64

restrict this overload format to only numeric scalar types and string as the encodeAs

Changes:

  • update decorator
  • update openapi3 emitter
  • add docs
@timotheeguerin
Copy link
Member

Would also be good to decide if string is the right key.

@MaryGao
Copy link
Member

MaryGao commented Jul 17, 2024

Similar issue with #2762

@timotheeguerin timotheeguerin added the design:needed A design request has been raised that needs a proposal label Jul 17, 2024
@timotheeguerin timotheeguerin changed the title Encode int as string TSP Author doc Encoding numeric as string Jul 17, 2024
@markcowl markcowl added compiler:core Issues for @typespec/compiler triaged:core labels Jul 22, 2024
@markcowl markcowl added this to the [2024] August milestone Jul 22, 2024
@timotheeguerin timotheeguerin added design:accepted Proposal for design has been discussed and accepted. and removed design:needed A design request has been raised that needs a proposal labels Jul 24, 2024
@timotheeguerin timotheeguerin self-assigned this Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:core Issues for @typespec/compiler design:accepted Proposal for design has been discussed and accepted. triaged:core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants