Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

chore: upgrade openapi-generator to latest release (v7.4.0) #88

Merged
merged 6 commits into from
Mar 13, 2024

Conversation

ctreatma
Copy link
Contributor

This updates the Makefile to stitch the API spec and generate the SDK code using the latest release of openapi-generator. Among other things, this fixes an issue where openapi-generator would occasionally add extra values to enum properties nested under oneOf schemas.

def type_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in ('vlan', 'vrf'):
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 is an example of the benefits of upgrading: previously, the type field could not be used to determine that a VrfVirtualCircuit is not a VlanVirtualCircuit because the VlanVirtualCircuit model accepted vrf as a valid value for type.

return method, url, header_params, body, post_params


def call_api(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Manual integration test run is failing with a bunch of errors like this:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: ApiClient.call_api() got multiple values for argument 'body'
fatal: [testhost]: FAILED! => {"changed": false, "msg": "Error in metal_project: ApiClient.call_api() got multiple values for argument 'body'"}

@t0mk
Copy link
Contributor

t0mk commented Mar 13, 2024

This is quite strange, the call to call_api in create_device_with_http_info is

        return self.api_client.call_api(
            '/projects/{id}/devices', 'POST',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
# order of params: [self], url, method, path_params, query_params, header_params, body

but client.call_api is defined as

    def call_api(
        self,
        method,
        url,
        header_params=None,
        body=None,
        post_params=None,
        _request_timeout=None
    ) -> rest.RESTResponse:

The order is different in functin call and in function definitoin. I suspect it's caused by our templating.

@ctreatma ctreatma force-pushed the upgrade-generator branch from c1be29f to 8f8733e Compare March 13, 2024 14:56
@ctreatma ctreatma force-pushed the upgrade-generator branch from 8f8733e to 83e072c Compare March 13, 2024 15:06
@ctreatma
Copy link
Contributor Author

Updated templates to match the v7.4.0 generator and regenerated the code, and now there's one integration test failure:

TASK [metal_connection : create connection for test] ***************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was:     For further information visit https://errors.pydantic.dev/2.6/v/string_type
fatal: [testhost]: FAILED! => {"changed": false, "msg": "Error in metal_connection: 1 validation error for DedicatedPortCreateInput\nspeed\n  Input should be a valid string [type=string_type, input_value=50000000, input_type=int]\n    For further information visit https://errors.pydantic.dev/2.6/v/string_type"}

I think this one is expected because there was a spec change for that field.

I'm still concerned that the integration test workflow isn't triggering automatically for this PR. It seems like it should, since this PR touches nearly every file in the repo.

@t0mk t0mk changed the title chore: upgrade openapi-generator to latest release chore: upgrade openapi-generator to latest release (v7.4.0) Mar 13, 2024
@t0mk
Copy link
Contributor

t0mk commented Mar 13, 2024

@ctreatma I tested with events and it seems that the all_pages listers are working fine!

@t0mk t0mk self-requested a review March 13, 2024 16:56
@ctreatma ctreatma merged commit 9ecb4ac into main Mar 13, 2024
3 of 4 checks passed
@ctreatma ctreatma deleted the upgrade-generator branch March 13, 2024 18:48
Copy link
Contributor

This PR is included in version 0.9.0 🎉

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.

2 participants