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

Operationのserialize方法を変える #17

Closed
shugo256 opened this issue Apr 27, 2021 · 2 comments
Closed

Operationのserialize方法を変える #17

shugo256 opened this issue Apr 27, 2021 · 2 comments

Comments

@shugo256
Copy link
Member

現状、GET routes/{id}をすると以下のようなレスポンスとなる

{"id":"7I5cHtC69mQ","name":"sample2","polyline":[{"latitude":0.0,"longitude":100.0},{"latitude":10.0,"longitude":110.0},{"latitude":20.0,"longitude":120.0}],"operation_history":{"op_list":[{"InitWithList":{"list":[{"latitude":10.0,"longitude":110.0},{"latitude":50.0,"longitude":150.0}]}},{"Add":{"pos":0,"coord":{"latitude":0.0,"longitude":100.0}}},{"Add":{"pos":2,"coord":{"latitude":20.0,"longitude":120.0}}},{"Remove":{"pos":3,"coord":{"latitude":50.0,"longitude":150.0}}},{"Clear":{"org_list":[{"latitude":0.0,"longitude":100.0},{"latitude":10.0,"longitude":110.0},{"latitude":20.0,"longitude":120.0}]}}],"pos":4}}

op_listの各要素のスキーマが適当(Addなどの操作名がkeyになってしまっている)なので、ちゃんとやる

各operationを一つのschemaにまとめる時にskip_serializing_ifというserdeのオプションが使えそう
serde-rs/serde#947

@shugo256
Copy link
Member Author

良さげなcrate見つけた
https://docs.rs/strum/0.20.0/strum/index.html

@shugo256
Copy link
Member Author

逆に俺も間違えた

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

1 participant