onshape-public / onshape-clients

All Onshape clients for interacting with the Onshape API.
MIT License
34 stars 29 forks source link

body_type case mismatch in Python API #59

Open koliyo opened 4 years ago

koliyo commented 4 years ago

I am trying to use the client.assemblies_api.get_assembly_definition function in the Python client API but get this error message:

onshape_client.oas.exceptions.ApiValueError: Invalid value for `body_type` (solid), must be one of ['SOLID', 'SHEET', 'WIRE', 'POINT', 'MATE_CONNECTOR', 'COMPOSITE', 'UNKNOWN']

I have tried the most recent pypi package as well as the master from this repository.

koliyo commented 4 years ago

This is the declaration in the Python API

    allowed_values = {
        ("body_type",): {
            "SOLID": "SOLID",
            "SHEET": "SHEET",
            "WIRE": "WIRE",
            "POINT": "POINT",
            "MATE_CONNECTOR": "MATE_CONNECTOR",
            "COMPOSITE": "COMPOSITE",
            "UNKNOWN": "UNKNOWN",
        },
    }

And checked using

    these_allowed_values = list(allowed_values[input_variable_path].values())
    ...
    elif (
        not isinstance(input_values, (list, dict))
        and input_values not in these_allowed_values
    ):
        raise ApiValueError(
            "Invalid value for `%s` (%s), must be one of %s"
            % (input_variable_path[0], input_values, these_allowed_values)
        )

The JSON response from the server contains

    "bodyType" : "solid",

So there seems to be an issue with case sensitive validation mismatch

rsinnet commented 2 years ago

I found this same issue. I replaced the uppercase with lowercase in the generated client and that works.