swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

Option to disable validation in the API clients

Open wing328 opened this issue 8 years ago • 7 comments

Description

Currently, there's no way to disable validation in the API clients and therefore we cannot use the API clients to perform integration tests with the RESTful backend (e.g. the API client cannot send requests with incorrect values as the client validation rule will fail the operation)

We'll introduce an option (e.g. client_side_validation in the configuration object)

Swagger-codegen version

Latest master

Swagger declaration file content or url
Related issues

https://github.com/swagger-api/swagger-codegen/pull/5528 has been submitted for Ruby API client.

Suggest a Fix

If anyone wants to work on the enhancement, please reply to let us know.

wing328 avatar May 02 '17 11:05 wing328

Hey @arun-nalla, I would like to know how to disable client_side_validation in python? I went through your changes. The changes belonged to openapi-generator. I don't know how swagger-codegen uses openapi-generator. Is there a gflag or configuration param I can use to disable client_side_validation? I did try it as a param, but it shows as an unexpected keyword:

swagger_configuration = groups_client.Configuration(client_side_validation=False)

subtleseeker avatar May 24 '20 13:05 subtleseeker

@subtleseeker the PR for swagger codegen is not merged yet. https://github.com/swagger-api/swagger-codegen/pull/9719

ghost avatar May 24 '20 14:05 ghost

#9719 is merged - can this issue be closed?

ghost avatar Oct 18 '21 14:10 ghost

@sebastian-hatala-leanix it looks like this is fixed in master but not the 3.x branch. What's the procedure for tracking that?

apendleton avatar Oct 22 '21 04:10 apendleton

I tested this option out in the latest 2.x tag but was unable to make it work. Looking at the code, I don't think the Configuration object gets passed from the ApiClient to the instantiated model object. In this block of api_client.mustache, it instantiates the model object, passes kwargs into its constructor, but doesn't include self.configuration.

It's fixed by changing line 624 to: kwargs = {'_configuration': self.configuration}

I can create a PR, but I want to make sure I'm not being dumb and forgetting to set something. Has anyone else been able to disable the client-side validation?

spfjr avatar Nov 19 '21 01:11 spfjr

What's the status of this issue? I generated a python REST client via the swagger-codegen, but as stated by @spfjr, the configuration object is not passed to the models.

Is this the correct way doing it? kwargs = {'_configuration': self.configuration}

Dragonwilds avatar Apr 24 '22 22:04 Dragonwilds

Is this the correct way doing it? kwargs = {'_configuration': self.configuration}

This fix is needed and resolves the problems I have.

jimdigriz avatar Sep 10 '23 15:09 jimdigriz