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

feat: Remove duplicate information in the initiate negotiation api request #3549

Conversation

tuncaytunc-zf
Copy link
Contributor

What this PR changes/adds

Removes the duplicate information in the initiate negotiation api request

Why it does that

The offerId and the policy/@id have the same value, because they're representing the same information, so there's no point in offerId, as the policy is mandatory anyway.

Further notes

This introduces new api version of negotiation to avoid any braking changes

Linked Issue(s)

Closes #3395

Please be sure to take a look at the contributing guidelines and our etiquette for pull requests.

@tuncaytunc-zf tuncaytunc-zf added enhancement New feature or request api Feature related to the (REST) api labels Oct 18, 2023
@codecov-commenter
Copy link

Codecov Report

Attention: 68 lines in your changes are missing coverage. Please review.

Comparison is base (e30ca41) 72.45% compared to head (9c43497) 18.16%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3549       +/-   ##
===========================================
- Coverage   72.45%   18.16%   -54.30%     
===========================================
  Files         871      877        +6     
  Lines       17423    17566      +143     
  Branches      993      995        +2     
===========================================
- Hits        12624     3190     -9434     
- Misses       4382    14289     +9907     
+ Partials      417       87      -330     
Files Coverage Δ
...nt/contractnegotiation/ContractNegotiationApi.java 0.00% <ø> (ø)
...tnegotiation/ContractNegotiationApiController.java 100.00% <ø> (ø)
...gotiation/v3/ContractNegotiationApiController.java 100.00% <100.00%> (ø)
...ctnegotiation/ContractNegotiationApiExtension.java 0.00% <0.00%> (-92.86%) ⬇️
...ion/v3/validation/ContractRequestDtoValidator.java 0.00% <0.00%> (ø)
...contractnegotiation/v3/ContractNegotiationApi.java 0.00% <0.00%> (ø)
...ntractnegotiation/v3/model/ContractRequestDto.java 65.62% <65.62%> (ø)
...ontractRequestDtoToContractRequestTransformer.java 0.00% <0.00%> (ø)
...orm/JsonObjectToContractRequestDtoTransformer.java 0.00% <0.00%> (ø)

... and 568 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tuncaytunc-zf tuncaytunc-zf force-pushed the feat/negotiationApiRequestEnhancement branch from 79ecb8d to 5ec20a1 Compare October 18, 2023 15:14
Copy link
Member

@ndr-brt ndr-brt 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 there are two ways of doing this.
The way you followed brings in a Dto class, that we decided to remove some weeks ago.
Plus, a new Dto requires a two steps transformation (json -> dto -> model) that we don't really want.

I see that in this case they are needed because there is no way to define different validators and transformers for the same entity based on the controller they are used.

A new api version should be motivated for substantial changes, and I think the changes here are really little and they can be handled in the same version, as we did in the past in other APIs following this approach:

  • deprecate the properties on the schema
  • broaden the validator to accept the deprecated field as optional
  • in the transformer, check if the deprecated properties are used, in that case, print a warning log

to get a grasp, we did the same thing when we renamed providerUrl to counterPartyAddress in the CatalogRequest, please look at JsonObjectToCatalogRequestTransformer.

@tuncaytunc-zf
Copy link
Contributor Author

I think there are two ways of doing this. The way you followed brings in a Dto class, that we decided to remove some weeks ago. Plus, a new Dto requires a two steps transformation (json -> dto -> model) that we don't really want.

I see that in this case they are needed because there is no way to define different validators and transformers for the same entity based on the controller they are used.

A new api version should be motivated for substantial changes, and I think the changes here are really little and they can be handled in the same version, as we did in the past in other APIs following this approach:

  • deprecate the properties on the schema
  • broaden the validator to accept the deprecated field as optional
  • in the transformer, check if the deprecated properties are used, in that case, print a warning log

to get a grasp, we did the same thing when we renamed providerUrl to counterPartyAddress in the CatalogRequest, please look at JsonObjectToCatalogRequestTransformer.

After a short discussion with @wolf4ood we decided to go for a new Dto that's why I have implemented it like this. Unfortunately I was not aware about such a decision probably Enrico neither. But indeed introducing a new api version for such a small change would cause inconvenience. I will close this PR and implement the second way you described.

@wolf4ood
Copy link
Contributor

My two cents, it's fine to supports different fields on the same Object,
but in this case IMHO the shape of the input object changes substantially and the single transformer would basically handle two different shapes in one .
Having the DTO in the middle it's something that it's not wanted but in this case would be only a shim for the time being until the v2 is deprecated.

We did the same with Asset AP, by changing the shape cause the v3 :)

@ndr-brt
Copy link
Member

ndr-brt commented Oct 19, 2023

I'd propose compromise then: how do you see to add the Dto for the deprecated endpoint and have the new one without it? In that case the Dto will be removed when the deprecation will expire

@wolf4ood
Copy link
Contributor

For me it's fine also to have it in a deprecation way, as long as it will be deprecated soon 😂
and we should at least document well the behaviour of the combination of assetId + policy vs offer.

But i guess at this point as you wrote we could remove also the assetId and just use the policy?

In that case I'm fine with supporting only the policy field in addition and mark for deprecation offer :)

@paullatzelsperger paullatzelsperger removed their request for review October 19, 2023 15:24
@tuncaytunc-zf
Copy link
Contributor Author

If dto comes into consideration what would help to not frequently change the core model whenever an api schema changes, why then not keep it like implemented here and remove it when it gets deprecated instead of changing it now and remove it afterward 😂

@ndr-brt
Copy link
Member

ndr-brt commented Oct 19, 2023

If dto comes into consideration what would help to not frequently change the core model whenever an api schema changes, why then not keep it like implemented here and remove it when it gets deprecated instead of changing it now and remove it afterward 😂

because when someone takes care of removing deprecated stuff they just want to delete stuff that's marked as deprecated without having to do stuff that requires specific knowledge.

But i guess at this point as you wrote we could remove also the assetId and just use the policy?

In that case I'm fine with supporting only the policy field in addition and mark for deprecation offer :)

I agree with that, also the assetId field is not necessary as it is already pointed out by the policy (offer would be a better name for it but unfortunately it's already taken).

So, having an optional policy (or contractOffer or whathever) field instead of the deprecated offer would already solve the issue, without v3, dtos, additional validators and transformers.

@wolf4ood
Copy link
Contributor

So, having an optional policy (or contractOffer or whathever) field instead of the deprecated offer would already solve the issue, without v3, dtos, additional validators and transformers.

👍

@github-actions
Copy link

This pull request is stale because it has been open for 7 days with no activity.

@github-actions github-actions bot added the stale Open for x days with no activity label Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Feature related to the (REST) api enhancement New feature or request stale Open for x days with no activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

duplicate information in the initiate negotiation api request
4 participants