modify query_params and path_params class names
Is there a way to change how the query_params and path_params class names are generated without modifying the parser?
I would like them to be named with the camelcase endpoint name plus the suffix.
Example of what I get now:
def get_field_values(
self,
path_params: FieldNamePathParams,
query_params: XmlNodeNameParameter1Parameter2Parameter3QueryParams
) -> GetFieldValuesResponse:
"""Get Field Values"""
return self.get(Endpoints.get_field_values, query_params)
what I want:
def get_field_values(
self,
path_params: GetFieldValuesPathParams,
query_params: GetFieldValuesQueryParams
) -> GetFieldValuesResponse:
"""Get Field Values"""
return self.get(Endpoints.get_field_values, query_params)
This is how I get it now but would rather not modify the library.
Change https://github.com/mom1/apiclient-pydantic-generator/blob/master/apiclient_pydantic_generator/parser.py#L320
operation_name = re.sub('(?i)response$', '', self._temporary_operation.get('response'))
original_name = self._get_model_name(operation_name, '', suffix=suffix)
Thank you for your interest in the project.
I think the method using response is not very good.
In my case response = List[Pet] the result will be List[Pet]QueryParams.
What do you think of this method?
original_name = self._get_model_name(path[1], '', suffix=suffix)
endpoint = pet/findByStatus
models_name = PetFindByStatusQueryParams
@mom1 I will test tomorrow and let you know. Thanks for looking at this.
@mom1 That almost works but need only the last part of a path like /api/v1/get_field_values/. Something like:
original_name = self._get_model_name(f"{pathlib.Path(path[1]).name}/", '', suffix=suffix)
Still getting the leading underscore for endpoints with path parameters
I think the other problem with using the path name is that you could have a GET, POST, and PUT endpoint all with the same path name but each could have different query_params. I think using the operation name is probably the best way to avoid this as they all need to be unique.
That's right, but here I need to investigate where to get the operation_id