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

validation error with example #11

Open
brunnels opened this issue Mar 2, 2022 · 5 comments
Open

validation error with example #11

brunnels opened this issue Mar 2, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@brunnels
Copy link

brunnels commented Mar 2, 2022

Not certain if it's an issue with python 3.10 or not but I always get a validation error with your example and also the code that is generated from my openapi doc.

I copy/pasted from the README.md to create the PetStoreAPIClient.

    pet_client = PetStoreAPIClient(response_handler=JsonResponseHandler, request_formatter=JsonRequestFormatter)
    params = PetIdPathParams(petId="petid1")
    result = pet_client.show_pet_by_id(path_params=params)
    print(result)

(<class 'pydantic.error_wrappers.ValidationError'>, ValidationError(model='ParsingModel[PetIdPathParams]', errors=[{'loc': ('__root__', 'petId'), 'msg': 'field required', 'type': 'value_error.missing'}]), <traceback object at 0x7f2c6db4d980>)

Looks like it's happening around line 36 of https://github.com/mom1/api-client-pydantic/blob/main/apiclient_pydantic/serializers.py but I can't determine if I'm doing something wrong with the generated client, it's py 3.10 compatibility issue, or something is broken in the api-client-pydantic.

@brunnels
Copy link
Author

brunnels commented Mar 3, 2022

Seems it was me doing it wrong.

pet_client = PetStoreAPIClient(response_handler=JsonResponseHandler, request_formatter=JsonRequestFormatter)
result = pet_client.show_pet_by_id(petId="petid1")

Would it be a good idea to modify the template to add None, validator, and **kwargs so the IDE doesn't give warnings?

    def show_pet_by_id(self, path_params: PetIdPathParams = ..., **kwargs) -> Pets:
        """Info for a specific pet"""
        if not path_params:
            raise RuntimeError("path_params are required")
        return self.get(Endpoints.show_pet_by_id.format(**path_params))

@brunnels
Copy link
Author

brunnels commented Mar 3, 2022

@mom1
Copy link
Owner

mom1 commented Mar 3, 2022

I'm sorry, but I'm very busy this month. I'll be happy to look into this, but a little later.

@brunnels
Copy link
Author

brunnels commented Mar 3, 2022

@mom1 no worries. I have it working how I want with local library edits. I just wanted to ensure I was following best practices and try to get things working how I want without the edits.

@mom1 mom1 added the enhancement New feature or request label Mar 8, 2022
@mom1
Copy link
Owner

mom1 commented Mar 8, 2022

Looks like it needs to be parametrized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants