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

Enums camel case serialization #2056

Merged
merged 18 commits into from
Dec 13, 2023
Merged

Conversation

squadgazzz
Copy link
Contributor

@squadgazzz squadgazzz commented Nov 14, 2023

Description

Copied from the original PR:

Replaced all occurrences of #[serde(rename_all = "lowercase")] with `#[serde(rename_all = "camelCase")].
Ensured that the changes maintain the readability and functionality of the code.
This pull request addresses the concern raised about enum variant readability and serialisation. The changes improve the codebase's consistency and enhance its clarity.
Please review the changes, and I'm open to any feedback or adjustments to ensure the code's quality and maintainability. Thank you for your time and consideration.

Related PRs

#2020

fixes: #2016

Copy link

github-actions bot commented Nov 14, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@squadgazzz
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@squadgazzz squadgazzz marked this pull request as ready for review November 14, 2023 17:53
@squadgazzz squadgazzz requested a review from a team as a code owner November 14, 2023 17:53
Copy link
Contributor

@MartinquaXD MartinquaXD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you!

BTW if you write fixes: #SOME_ISSUE_NUMBER in the PR description it will auto-close that issue when the PR gets merged. I believe this will not happen if you only list it in the related issues section.

Copy link
Contributor

@sunce86 sunce86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
I see a few more occurrences of lowercase in our codebase. Can we substitute those also (with the exception of the ones related to database)?

@sunce86
Copy link
Contributor

sunce86 commented Nov 15, 2023

@anxolin can someone from the frontend team check if this PR breaks the API? namely changes around signingScheme

Copy link
Contributor

@fleupold fleupold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should only rename the "new" APIs where we currently still control both sides of the communication. We shouldn't make any breaking changes to the public facing orderbook API (it's not worth the effort of rolling this out) and also not to the APIs we are consuming.

Let's not change the crates/model, crates/orderbook and any infra where the upstream is not one of our services.

@@ -169,7 +169,7 @@ pub struct SimulationRequest {
}

#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't control the API, so this may break.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted

@@ -9,7 +9,7 @@ use {
};

#[derive(Debug, Serialize)]
#[serde(rename_all = "lowercase")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this API is also maintained by balancer and thus may break (but given the non compound words, it may not be an issue here)

@@ -88,7 +88,7 @@ async fn sell() {
}])
.await;

let engine = tests::SolverEngine::new("zeroex", zeroex::config(&api.address)).await;
let engine = tests::SolverEngine::new("zeroEx", zeroex::config(&api.address)).await;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we don't really need to change this, do we?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted

@@ -148,7 +148,7 @@ async fn sell() {
])
.await;

let engine = tests::SolverEngine::new("paraswap", paraswap::config(&api.address)).await;
let engine = tests::SolverEngine::new("paraSwap", paraswap::config(&api.address)).await;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also no need to change this (I think we at some point decided to have all solver names lower case).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted

@squadgazzz squadgazzz force-pushed the enums-camel-case-serialization branch from 569b619 to 1a33c98 Compare November 20, 2023 11:25
Copy link

@anxolin anxolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anxolin can someone from the frontend team check if this PR breaks the API? namely changes around signingScheme

@sunce86 We would need a bit more of context to test this. Is this really a breaking change? (or it doesn't affect to the requests we are doing and is just affecting the swagger types?

Also, i don't see any change in the swagger for the normal API, but i see changes in the one for solvers. Is it possible you forgot to generate the swagger? @mfw78 do we generate it dynamically or is still manual?

@fleupold
Copy link
Contributor

It shouldn't be a breaking change (this is what we need to test).
I think the right way to test this is to run cowswap and the orderbook locally and make sure we can still get quotes and place orders. @squadgazzz do you think you can do this? We will then still have time to see issues in barn before this goes into prod.

@anxolin
Copy link

anxolin commented Nov 22, 2023

Here are some instructions on how to point the web to your local API https://github.com/cowprotocol/cowswap#orderbook-api-endpoints

@mfw78
Copy link
Contributor

mfw78 commented Nov 22, 2023

Also, i don't see any change in the swagger for the normal API, but i see changes in the one for solvers. Is it possible you forgot to generate the swagger? @mfw78 do we generate it dynamically or is still manual?

Still manual as far as I'm aware.

@squadgazzz
Copy link
Contributor Author

I think the right way to test this is to run cowswap and the orderbook locally and make sure we can still get quotes and place orders. @squadgazzz do you think you can do this? We will then still have time to see issues in barn before this goes into prod.

Tested locally with cowswap and explorer, didn't encounter an issue.

@squadgazzz squadgazzz enabled auto-merge (squash) December 13, 2023 15:34
@squadgazzz squadgazzz merged commit a843533 into main Dec 13, 2023
8 checks passed
@squadgazzz squadgazzz deleted the enums-camel-case-serialization branch December 13, 2023 15:39
@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore: Serialize enums as CamelCase
7 participants