private/apigen: Fix bug TypeScript optional class members

The TypesScript generator generates classes and checks for Go struct
field if the struct type is of a nullable type, however, it should check
if the field types is nullable because it doesn't make sense to check
that struct field for each field nor to assign to the field if it's
nullable or not depending on it.

Change-Id: Ia22a609a17752f520233c006cba17685fe142b32
This commit is contained in:
Ivan Fraixedes 2023-10-02 16:59:58 +02:00
parent bc7f621073
commit ac86eb397a
No known key found for this signature in database
GPG Key ID: FB6101AFB5CB5AD5
3 changed files with 16 additions and 16 deletions

View File

@ -17,7 +17,7 @@ export class GetResponseItem {
path: string;
date: Time;
metadata: Metadata;
last_retrievals: GetResponseItemLastretrievals;
last_retrievals?: GetResponseItemLastretrievals;
}
export class GetResponseItemLastretrievalsItem {
@ -27,7 +27,7 @@ export class GetResponseItemLastretrievalsItem {
export class Metadata {
owner: string;
tags: string[][];
tags?: string[][];
}
export class UpdateContentRequest {

View File

@ -174,7 +174,7 @@ func (types *Types) GenerateTypescriptDefinitions() string {
}
isOptional := ""
if isNillableType(t.Type) {
if isNillableType(field.Type) {
isOptional = "?"
}

View File

@ -8,13 +8,13 @@ export class APIKeyInfo {
id: UUID;
projectId: UUID;
projectPublicId: UUID;
userAgent: string;
userAgent?: string;
name: string;
createdAt: Time;
}
export class APIKeyPage {
apiKeys: APIKeyInfo[];
apiKeys?: APIKeyInfo[];
search: string;
limit: number;
order: number;
@ -46,7 +46,7 @@ export class CreateAPIKeyRequest {
export class CreateAPIKeyResponse {
key: string;
keyInfo: APIKeyInfo;
keyInfo?: APIKeyInfo;
}
export class Project {
@ -54,18 +54,18 @@ export class Project {
publicId: UUID;
name: string;
description: string;
userAgent: string;
userAgent?: string;
ownerId: UUID;
rateLimit: number;
burstLimit: number;
maxBuckets: number;
rateLimit?: number;
burstLimit?: number;
maxBuckets?: number;
createdAt: Time;
memberCount: number;
storageLimit: MemorySize;
bandwidthLimit: MemorySize;
userSpecifiedStorageLimit: MemorySize;
userSpecifiedBandwidthLimit: MemorySize;
segmentLimit: number;
storageLimit?: MemorySize;
bandwidthLimit?: MemorySize;
userSpecifiedStorageLimit?: MemorySize;
userSpecifiedBandwidthLimit?: MemorySize;
segmentLimit?: number;
defaultPlacement: number;
}
@ -74,7 +74,7 @@ export class ResponseUser {
fullName: string;
shortName: string;
email: string;
userAgent: string;
userAgent?: string;
projectLimit: number;
isProfessional: boolean;
position: string;