You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
but if we go to the Model it's referencing for FinancingOption, found in the generated FinancingOption.ts file, the values generated here for the fields are in camelCase,
classBaseModel(models.Model):
""" Base model that includes default created / updated timestamps. """created_at=models.DateTimeField(auto_now_add=True)
updated_at=models.DateTimeField(auto_now=True)
classMeta:
abstract=True
Because the interface FinancingOption is in camelCase but the interface FinanciersApiFinancingOptionCreateRequest is using Omit defined by snake_case variables, when I set up the parameters for the openapi request like so:
Type '{ financierFileAttachments: { [key: string]: string; }; projectId: number; team: number; }' is missing the following properties from type'Omit<FinancingOption, "id" | "created_at" | "updated_at" | "foo" | "bar">': createdAt, updatedAtts(2739)
FinanciersApi.ts(31, 3): The expected type comes from property 'financingOption' which is declared here on type'FinanciersApiFinancingOptionCreateRequest'
(property) FinanciersApiFinancingOptionCreateRequest.financingOption: Omit<FinancingOption, "id"|"created_at"|"updated_at"|"foo"|"bar">
openapi-generator version
7.8.0
OpenAPI declaration file content or url
Generation Details
typescript-fetch default settings
using a django stack with Django Rest Framework and DRF Spectacular
classBaseModel(models.Model):
""" Base model that includes default created / updated timestamps. """created_at=models.DateTimeField(auto_now_add=True)
updated_at=models.DateTimeField(auto_now=True)
classMeta:
abstract=True
And create this serializer as well in the same django app:
Navigate to the Api.ts file generated by the CLI, in my case it was called FinanciersApi.ts, and check to see if the Create class for this model (in my case it was interface FinanciersApiFinancingOptionCreateRequest) has the Omit class listing its parameters to be omitted as snake_case or camelCase.
Related issues/PRs
I searched around for this issue, and found things suggesting I try modifying the modelPropertyNaming config value, but that didn't change what I needed.
Suggest a fix
The clients generated need to list the interface values omitted as camelCase so they are consistent with the Model's themselves generated by the same api, which does list them as camelCase, because it needs to be camelCase to actually use the client calls, if snake_case were used it wouldn't actually be able to complete the calls.
The text was updated successfully, but these errors were encountered:
glitchwizard
changed the title
[BUG] Api has discrepency between generated models and API
[BUG] Api has parameter naming discrepency between generated models and API
Sep 12, 2024
Bug Report Checklist
Description
I have a django stack. When I run the command:
It will generate the following in the file
FinanciersApi.ts
, which usessnake_case
to define the omitted parameters:but if we go to the Model it's referencing for
FinancingOption
, found in the generatedFinancingOption.ts
file, the values generated here for the fields are incamelCase
,The django model it's generating from is this (created_at and updated_at are inherited from the
BaseModel
):And this is the serializer for this model:
Because the
interface FinancingOption
is incamelCase
but theinterface FinanciersApiFinancingOptionCreateRequest
is usingOmit
defined bysnake_case
variables, when I set up the parameters for the openapi request like so:I end up getting this typescript error:
openapi-generator version
7.8.0
OpenAPI declaration file content or url
Generation Details
typescript-fetch default settings
using a django stack with Django Rest Framework and DRF Spectacular
Steps to reproduce
Create a model with the following:
And create this serializer as well in the same django app:
Assuming you have the
openapi-generator-cli
installed in your terminal, run this commandNavigate to the Api.ts file generated by the CLI, in my case it was called
FinanciersApi.ts
, and check to see if theCreate
class for this model (in my case it wasinterface FinanciersApiFinancingOptionCreateRequest
) has theOmit
class listing its parameters to be omitted assnake_case
orcamelCase
.Related issues/PRs
I searched around for this issue, and found things suggesting I try modifying the
modelPropertyNaming
config value, but that didn't change what I needed.Suggest a fix
The clients generated need to list the interface values omitted as
camelCase
so they are consistent with the Model's themselves generated by the same api, which does list them ascamelCase
, because it needs to becamelCase
to actually use the client calls, ifsnake_case
were used it wouldn't actually be able to complete the calls.The text was updated successfully, but these errors were encountered: