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

remover decorador RestApiBlueprint.validate de agave[chalice] #155

Open
felipao-mx opened this issue Feb 5, 2025 · 0 comments
Open

remover decorador RestApiBlueprint.validate de agave[chalice] #155

felipao-mx opened this issue Feb 5, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@felipao-mx
Copy link
Member

felipao-mx commented Feb 5, 2025

pydantic tiene una forma de validar parámetros de funciones con BaseModel con @validate_call. RestApiBlueprint.validate hace eso pero al definir un endpoint se ve redundante porque el parámetro de la función ya tiene el mismo tipo que el argumento de validate, por ejemplo:

@app.resource('/accounts')
class Account:
    # otros campos

    @staticmethod
    @app.validate(AccountRequest)
    def create(request: AccountRequest) -> Response:
        ...

al usar @validate_call al momento de inicializar RestApiBlueprint esta función no sería necesaria y visualmente podría homologarse a su versión con agave[fastapi]:

@app.resource('/accounts')
class Account:
    # otros campos

    @staticmethod
    def create(request: AccountRequest) -> Response:
        ...

https://github.com/cuenca-mx/agave/blob/main/agave/chalice/rest_api.py#L80

@felipao-mx felipao-mx added the enhancement New feature or request label Feb 5, 2025
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

1 participant