Skip to content

Conversation

@pcothenet
Copy link
Contributor

@pcothenet pcothenet commented Jul 29, 2022

What

  • Use 1.24.1 of the code generator to properly generate the classes for place_order without overriding manually
  • Uses the refactored swagger.json file to define the issued_to parameter (leading to better file name)

Why

  • The optional body parameter were not correctly handled
  • Make sure that all code is generated from templates

Notes

  • Only internal changes

SDK Release Checklist

  • Have you added an integration test for the changes?
  • Have you built the gem locally and made queries against it successfully?
  • Did you update the changelog?
  • Did you bump the package version in the code generator?
  • If endpoints were removed, did you manually remove the corresponding files? (this should be rare)
  • For breaking changes, did you plan for the release of the new SDK versions and deploy the API to production?

Comment on lines 168 to 171
def place_order(order_id, opts = {})
place_order_request = Patch::PlaceOrderRequest.new(opts)
opts[:place_order_request] = place_order_request
data, _status_code, _headers = place_order_with_http_info(order_id, opts)
def place_order(place_order_request = {}, opts = {})
_place_order_request = Patch::PlaceOrderRequest.new(place_order_request)
data, _status_code, _headers = place_order_with_http_info(_place_order_request, opts)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change should not be happening 😢

@pcothenet pcothenet changed the title Update swagger for issued_to Fix the generator for optional body parameters Jul 29, 2022

# Creates a GLEC air shipping estimate given freight mass and logistics
# Creates a GLEC air shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
# Creates a GLEC air shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed the bug in the template that was escaping those values.

Comment on lines -168 to 173
# @return [OrderResponse]
def place_order(order_id, opts = {})
place_order_request = Patch::PlaceOrderRequest.new(opts)
opts[:place_order_request] = place_order_request
data, _status_code, _headers = place_order_with_http_info(order_id, opts)
def place_order(id, opts = {})

data, _status_code, _headers = place_order_with_http_info(id, opts)
data
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This version had (most likely) be written manually. The new one is entirely generated by the templates.

let(:instance_hash) { { project_id: @instance.project_id, mass_g: @instance.mass_g, total_price_cents_usd: @instance.total_price_cents_usd, metadata: @instance.metadata } }
let(:nullable_properties) do
Set.new(%i[mass_g total_price_cents_usd project_id metadata state vintage_year total_price currency amount unit issued_to])
Set.new(%i[mass_g total_price_cents_usd project_id metadata state vintage_year total_price currency amount unit])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to change this line because of the new swagger file, but don't think this matters.

@pcothenet pcothenet marked this pull request as ready for review July 29, 2022 20:36

# Creates a GLEC air shipping estimate given freight mass and logistics
# Creates a GLEC air shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
# Creates a GLEC air shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also fixed this escaping in the generator.

@pcothenet pcothenet requested review from a team, holtbp and kleinjm July 29, 2022 21:02
@pcothenet pcothenet merged commit a3de184 into main Jul 29, 2022
@pcothenet pcothenet deleted the pc/issued_to branch July 29, 2022 21:42
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

Successfully merging this pull request may close these issues.

3 participants