diff --git a/api/Planera.csproj b/api/Planera.csproj index 6b87d69..3c5a1f0 100644 --- a/api/Planera.csproj +++ b/api/Planera.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 enable enable Linux @@ -12,7 +12,7 @@ - + @@ -20,21 +20,21 @@ - - - - - - + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/api/Program.cs b/api/Program.cs index a6dfdfe..2a168e7 100644 --- a/api/Program.cs +++ b/api/Program.cs @@ -5,6 +5,8 @@ using Microsoft.IdentityModel.Tokens; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; +using NSwag.Generation; +using Planera; using Planera.Data; using Planera.Data.Files; using Planera.Hubs; @@ -52,6 +54,8 @@ options.SerializerSettings.ReferenceLoopHandling = serializerSettings.ReferenceLoopHandling; options.SerializerSettings.ContractResolver = serializerSettings.ContractResolver; }); + +builder.Services.AddOpenApiDocument(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); builder.Services.AddAuthorization(); @@ -72,36 +76,37 @@ }); builder.Services.AddDbContext(); -builder.Services.AddAuthentication(o => -{ - o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; - o.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; - o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; -}) -.AddJwtBearer(options => -{ - options.TokenValidationParameters = new TokenValidationParameters +builder.Services + .AddAuthentication(o => { - IssuerSigningKey = new SymmetricSecurityKey( - Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"] ?? string.Empty) - ), - ValidateIssuer = false, - ValidateAudience = false, - ValidateLifetime = false, - ValidateIssuerSigningKey = true, - }; - - options.Events = new JwtBearerEvents + o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; + o.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + }) + .AddJwtBearer(options => { - OnMessageReceived = context => + options.TokenValidationParameters = new TokenValidationParameters { - if (context.Request.Cookies.TryGetValue("token", out var jwtCookie)) - context.Token = jwtCookie; - - return Task.CompletedTask; - } - }; -}); + IssuerSigningKey = new SymmetricSecurityKey( + Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"] ?? string.Empty) + ), + ValidateIssuer = false, + ValidateAudience = false, + ValidateLifetime = false, + ValidateIssuerSigningKey = true, + }; + + options.Events = new JwtBearerEvents + { + OnMessageReceived = context => + { + if (context.Request.Cookies.TryGetValue("token", out var jwtCookie)) + context.Token = jwtCookie; + + return Task.CompletedTask; + } + }; + }); builder.Services.AddSignalR() .AddNewtonsoftJsonProtocol(options => { diff --git a/api/appsettings.Development.json b/api/appsettings.Development.json index 35c818c..4c84be1 100644 --- a/api/appsettings.Development.json +++ b/api/appsettings.Development.json @@ -8,7 +8,7 @@ "Postgres": { "Host": "localhost:5432", "User": "planera", - "Password": "", + "Password": "planera", "Database": "planera" }, "Jwt": { diff --git a/api/appsettings.json b/api/appsettings.json index f5169b2..f15e981 100644 --- a/api/appsettings.json +++ b/api/appsettings.json @@ -18,7 +18,7 @@ }, "Postgres": { "Host": "", - "Username": "", + "User": "", "Password": "", "Database": "" }, @@ -35,4 +35,4 @@ "Password": "", "Sender": "" } -} \ No newline at end of file +} diff --git a/api/nswag.json b/api/nswag.json index 8b702f4..c2b27cd 100644 --- a/api/nswag.json +++ b/api/nswag.json @@ -1,125 +1,124 @@ { - "runtime": "Net70", - "defaultVariables": null, - "documentGenerator": { - "webApiToOpenApi": { - "controllerNames": [], - "isAspNetCore": true, - "resolveJsonOptions": false, - "defaultUrlTemplate": "api/{controller}/{id?}", - "addMissingPathParameters": false, - "includedVersions": null, - "defaultPropertyNameHandling": "CamelCase", - "defaultReferenceTypeNullHandling": "Null", - "defaultDictionaryValueReferenceTypeNullHandling": "NotNull", - "defaultResponseReferenceTypeNullHandling": "NotNull", - "generateOriginalParameterNames": true, - "defaultEnumHandling": "Integer", - "flattenInheritanceHierarchy": false, - "generateKnownTypes": true, - "generateEnumMappingDescription": false, - "generateXmlObjects": false, - "generateAbstractProperties": false, - "generateAbstractSchemas": true, - "ignoreObsoleteProperties": false, - "allowReferencesWithProperties": false, - "useXmlDocumentation": true, - "resolveExternalXmlDocumentation": true, - "excludedTypeNames": [], - "serviceHost": null, - "serviceBasePath": null, - "serviceSchemes": [], - "infoTitle": "Planera", - "infoDescription": null, - "infoVersion": "1.0.0", - "documentTemplate": null, - "documentProcessorTypes": [], - "operationProcessorTypes": [], - "typeNameGeneratorType": null, - "schemaNameGeneratorType": null, - "contractResolverType": null, - "serializerSettingsType": null, - "useDocumentProvider": true, - "documentName": "v1", - "aspNetCoreEnvironment": null, - "createWebHostBuilderMethod": null, - "startupType": null, - "allowNullableBodyParameters": true, - "useHttpAttributeNameAsOperationId": false, - "output": null, - "outputType": "Swagger2", - "newLineBehavior": "Auto", - "assemblyPaths": [ - "bin/Debug/net7.0/Planera.dll" - ], - "assemblyConfig": null, - "referencePaths": [], - "useNuGetCache": false + "runtime": "Net80", + "defaultVariables": null, + "documentGenerator": { + "aspNetCoreToOpenApi": { + "defaultUrlTemplate": "api/{controller}/{id?}", + "defaultPropertyNameHandling": "CamelCase", + "generateOriginalParameterNames": true, + + "project": "Planera.csproj", + "msBuildProjectExtensionsPath": null, + "configuration": null, + "runtime": null, + "targetFramework": null, + "verbose": true, + "noBuild": true, + "workingDirectory": null, + "requireParametersWithoutDefault": false, + "apiGroupNames": null, + "defaultReferenceTypeNullHandling": "Null", + "defaultDictionaryValueReferenceTypeNullHandling": "NotNull", + "defaultResponseReferenceTypeNullHandling": "NotNull", + "defaultEnumHandling": "Integer", + "flattenInheritanceHierarchy": false, + "generateKnownTypes": true, + "generateEnumMappingDescription": false, + "generateXmlObjects": false, + "generateAbstractProperties": false, + "generateAbstractSchemas": true, + "ignoreObsoleteProperties": false, + "allowReferencesWithProperties": false, + "excludedTypeNames": [], + "serviceHost": null, + "serviceBasePath": null, + "serviceSchemes": [], + "infoTitle": "Planera", + "infoDescription": null, + "infoVersion": "1.0.0", + "documentTemplate": null, + "documentProcessorTypes": [], + "operationProcessorTypes": [], + "typeNameGeneratorType": null, + "schemaNameGeneratorType": null, + "contractResolverType": null, + "serializerSettingsType": null, + "documentName": "v1", + "aspNetCoreEnvironment": null, + "createWebHostBuilderMethod": null, + "startupType": null, + "allowNullableBodyParameters": true, + "output": null, + "outputType": "Swagger2", + "assemblyPaths": [], + "assemblyConfig": null, + "referencePaths": [], + "useNuGetCache": false + } + }, + "codeGenerators": { + "openApiToTypeScriptClient": { + "className": "{controller}Client", + "moduleName": "", + "namespace": "", + "typeScriptVersion": 1.8, + "template": "Fetch", + "promiseType": "Promise", + "httpClass": "Http", + "withCredentials": false, + "useSingletonProvider": false, + "injectionTokenType": "OpaqueToken", + "rxJsVersion": 6.3, + "dateTimeType": "Date", + "nullValue": "Undefined", + "generateClientClasses": true, + "generateClientInterfaces": false, + "generateOptionalParameters": true, + "exportTypes": true, + "wrapDtoExceptions": false, + "exceptionClass": "SwaggerException", + "clientBaseClass": "AuthorizedApiBase", + "wrapResponses": false, + "wrapResponseMethods": [], + "generateResponseClasses": true, + "responseClass": "ApiResponse", + "protectedMethods": [], + "configurationClass": "IConfig", + "useTransformOptionsMethod": true, + "useTransformResultMethod": false, + "generateDtoTypes": true, + "operationGenerationMode": "MultipleClientsFromOperationId", + "markOptionalProperties": true, + "generateCloneMethod": false, + "typeStyle": "Class", + "enumStyle": "Enum", + "useLeafType": false, + "classTypes": [], + "extendedClasses": [], + "extensionCode": "authorizedApiBase.ts", + "generateDefaultValues": true, + "excludedTypeNames": [], + "excludedParameterNames": [], + "handleReferences": false, + "generateTypeCheckFunctions": false, + "generateConstructorInterface": true, + "convertConstructorInterfaceData": false, + "importRequiredTypes": true, + "useGetBaseUrlMethod": false, + "baseUrlTokenName": "API_BASE_URL", + "queryNullValue": "", + "useAbortSignal": false, + "inlineNamedDictionaries": false, + "inlineNamedAny": false, + "includeHttpContext": false, + "templateDirectory": null, + "typeNameGeneratorType": null, + "propertyNameGeneratorType": null, + "enumNameGeneratorType": null, + "serviceHost": null, + "serviceSchemes": null, + "output": "../web/src/gen/planeraClient.ts", + "newLineBehavior": "Auto" + } } - }, - "codeGenerators": { - "openApiToTypeScriptClient": { - "className": "{controller}Client", - "moduleName": "", - "namespace": "", - "typeScriptVersion": 1.8, - "template": "Fetch", - "promiseType": "Promise", - "httpClass": "Http", - "withCredentials": false, - "useSingletonProvider": false, - "injectionTokenType": "OpaqueToken", - "rxJsVersion": 6.3, - "dateTimeType": "Date", - "nullValue": "Undefined", - "generateClientClasses": true, - "generateClientInterfaces": false, - "generateOptionalParameters": true, - "exportTypes": true, - "wrapDtoExceptions": false, - "exceptionClass": "SwaggerException", - "clientBaseClass": "AuthorizedApiBase", - "wrapResponses": false, - "wrapResponseMethods": [], - "generateResponseClasses": true, - "responseClass": "ApiResponse", - "protectedMethods": [], - "configurationClass": "IConfig", - "useTransformOptionsMethod": true, - "useTransformResultMethod": false, - "generateDtoTypes": true, - "operationGenerationMode": "MultipleClientsFromOperationId", - "markOptionalProperties": true, - "generateCloneMethod": false, - "typeStyle": "Class", - "enumStyle": "Enum", - "useLeafType": false, - "classTypes": [], - "extendedClasses": [], - "extensionCode": "authorizedApiBase.ts", - "generateDefaultValues": true, - "excludedTypeNames": [], - "excludedParameterNames": [], - "handleReferences": false, - "generateTypeCheckFunctions": false, - "generateConstructorInterface": true, - "convertConstructorInterfaceData": false, - "importRequiredTypes": true, - "useGetBaseUrlMethod": false, - "baseUrlTokenName": "API_BASE_URL", - "queryNullValue": "", - "useAbortSignal": false, - "inlineNamedDictionaries": false, - "inlineNamedAny": false, - "includeHttpContext": false, - "templateDirectory": null, - "typeNameGeneratorType": null, - "propertyNameGeneratorType": null, - "enumNameGeneratorType": null, - "serviceHost": null, - "serviceSchemes": null, - "output": "../web/src/gen/planeraClient.ts", - "newLineBehavior": "Auto" - } - } } diff --git a/tests/Planera.Tests.csproj b/tests/Planera.Tests.csproj index cca14a4..d2f4487 100644 --- a/tests/Planera.Tests.csproj +++ b/tests/Planera.Tests.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 enable enable @@ -9,7 +9,7 @@ - + diff --git a/web/src/gen/planeraClient.ts b/web/src/gen/planeraClient.ts index 0d8f0b9..bbf6436 100644 --- a/web/src/gen/planeraClient.ts +++ b/web/src/gen/planeraClient.ts @@ -1,6 +1,6 @@ //---------------------- // -// Generated using the NSwag toolchain v13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org) // //---------------------- @@ -39,10 +39,10 @@ export class AuthenticationClient extends AuthorizedApiBase { constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise }) { super(configuration); this.http = http ? http : window as any; - this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : ""; + this.baseUrl = baseUrl ?? ""; } - login(model?: LoginModel): Promise { + login(model: LoginModel): Promise { let url_ = this.baseUrl + "/auth/login"; url_ = url_.replace(/[?&]$/, ""); @@ -82,7 +82,7 @@ export class AuthenticationClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - register(model?: RegisterModel): Promise { + register(model: RegisterModel): Promise { let url_ = this.baseUrl + "/auth/register"; url_ = url_.replace(/[?&]$/, ""); @@ -154,7 +154,7 @@ export class AuthenticationClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - forgotPassword(username?: string): Promise { + forgotPassword(username: string): Promise { let url_ = this.baseUrl + "/auth/forgot-password"; url_ = url_.replace(/[?&]$/, ""); @@ -165,7 +165,7 @@ export class AuthenticationClient extends AuthorizedApiBase { method: "POST", headers: { "Content-Type": "application/json", - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -198,7 +198,7 @@ export class AuthenticationClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - resetPassword(model?: ResetPasswordModel): Promise { + resetPassword(model: ResetPasswordModel): Promise { let url_ = this.baseUrl + "/auth/reset-password"; url_ = url_.replace(/[?&]$/, ""); @@ -209,7 +209,7 @@ export class AuthenticationClient extends AuthorizedApiBase { method: "POST", headers: { "Content-Type": "application/json", - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -242,22 +242,22 @@ export class AuthenticationClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - confirmEmail(userId: string, token: string): Promise { + confirmEmail(userId?: string, token?: string): Promise { let url_ = this.baseUrl + "/auth/confirm-email?"; - if (userId === undefined || userId === null) - throw new Error("The parameter 'userId' must be defined and cannot be null."); - else + if (userId === null) + throw new Error("The parameter 'userId' cannot be null."); + else if (userId !== undefined) url_ += "userId=" + encodeURIComponent("" + userId) + "&"; - if (token === undefined || token === null) - throw new Error("The parameter 'token' must be defined and cannot be null."); - else + if (token === null) + throw new Error("The parameter 'token' cannot be null."); + else if (token !== undefined) url_ += "token=" + encodeURIComponent("" + token) + "&"; url_ = url_.replace(/[?&]$/, ""); let options_: RequestInit = { method: "GET", headers: { - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -290,18 +290,18 @@ export class AuthenticationClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - sendConfirmationEmail(username: string): Promise { + sendConfirmationEmail(username?: string): Promise { let url_ = this.baseUrl + "/auth/send-confirmation-email?"; - if (username === undefined || username === null) - throw new Error("The parameter 'username' must be defined and cannot be null."); - else + if (username === null) + throw new Error("The parameter 'username' cannot be null."); + else if (username !== undefined) url_ += "username=" + encodeURIComponent("" + username) + "&"; url_ = url_.replace(/[?&]$/, ""); let options_: RequestInit = { method: "POST", headers: { - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -343,10 +343,10 @@ export class FileClient extends AuthorizedApiBase { constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise }) { super(configuration); this.http = http ? http : window as any; - this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : ""; + this.baseUrl = baseUrl ?? ""; } - get(directory: string, name: string, mimeType: string, param?: string): Promise { + get(directory: string, name: string, mimeType?: string, param?: string): Promise { let url_ = this.baseUrl + "/files/{directory}/{name}?"; if (directory === undefined || directory === null) throw new Error("The parameter 'directory' must be defined."); @@ -354,9 +354,9 @@ export class FileClient extends AuthorizedApiBase { if (name === undefined || name === null) throw new Error("The parameter 'name' must be defined."); url_ = url_.replace("{name}", encodeURIComponent("" + name)); - if (mimeType === undefined || mimeType === null) - throw new Error("The parameter 'mimeType' must be defined and cannot be null."); - else + if (mimeType === null) + throw new Error("The parameter 'mimeType' cannot be null."); + else if (mimeType !== undefined) url_ += "mimeType=" + encodeURIComponent("" + mimeType) + "&"; if (param !== undefined && param !== null) url_ += "param=" + encodeURIComponent("" + param) + "&"; @@ -365,7 +365,7 @@ export class FileClient extends AuthorizedApiBase { let options_: RequestInit = { method: "GET", headers: { - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -407,7 +407,7 @@ export class NoteClient extends AuthorizedApiBase { constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise }) { super(configuration); this.http = http ? http : window as any; - this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : ""; + this.baseUrl = baseUrl ?? ""; } getAll(projectId: string, ticketId: number): Promise { @@ -459,7 +459,7 @@ export class NoteClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - create(model?: CreateNoteModel): Promise { + create(model: CreateNoteModel): Promise { let url_ = this.baseUrl + "/notes"; url_ = url_.replace(/[?&]$/, ""); @@ -470,7 +470,7 @@ export class NoteClient extends AuthorizedApiBase { method: "POST", headers: { "Content-Type": "application/json", - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -513,7 +513,7 @@ export class NoteClient extends AuthorizedApiBase { let options_: RequestInit = { method: "DELETE", headers: { - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -546,7 +546,7 @@ export class NoteClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - edit(id: number, model?: EditNoteModel): Promise { + edit(id: number, model: EditNoteModel): Promise { let url_ = this.baseUrl + "/notes/{id}"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); @@ -560,7 +560,7 @@ export class NoteClient extends AuthorizedApiBase { method: "PUT", headers: { "Content-Type": "application/json", - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -602,7 +602,7 @@ export class ProjectClient extends AuthorizedApiBase { constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise }) { super(configuration); this.http = http ? http : window as any; - this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : ""; + this.baseUrl = baseUrl ?? ""; } getAll(): Promise { @@ -648,7 +648,7 @@ export class ProjectClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - create(model?: CreateProjectModel): Promise { + create(model: CreateProjectModel): Promise { let url_ = this.baseUrl + "/projects"; url_ = url_.replace(/[?&]$/, ""); @@ -777,7 +777,7 @@ export class ProjectClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - edit(username: string, slug: string, model?: EditProjectModel): Promise { + edit(username: string, slug: string, model: EditProjectModel): Promise { let url_ = this.baseUrl + "/projects/{username}/{slug}"; if (username === undefined || username === null) throw new Error("The parameter 'username' must be defined."); @@ -794,7 +794,7 @@ export class ProjectClient extends AuthorizedApiBase { method: "PUT", headers: { "Content-Type": "application/json", - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -837,7 +837,7 @@ export class ProjectClient extends AuthorizedApiBase { let options_: RequestInit = { method: "DELETE", headers: { - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -870,14 +870,14 @@ export class ProjectClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - inviteParticipant(projectId: string, participantName: string): Promise { + inviteParticipant(projectId: string, participantName?: string): Promise { let url_ = this.baseUrl + "/projects/{projectId}/inviteParticipant?"; if (projectId === undefined || projectId === null) throw new Error("The parameter 'projectId' must be defined."); url_ = url_.replace("{projectId}", encodeURIComponent("" + projectId)); - if (participantName === undefined || participantName === null) - throw new Error("The parameter 'participantName' must be defined and cannot be null."); - else + if (participantName === null) + throw new Error("The parameter 'participantName' cannot be null."); + else if (participantName !== undefined) url_ += "participantName=" + encodeURIComponent("" + participantName) + "&"; url_ = url_.replace(/[?&]$/, ""); @@ -913,21 +913,21 @@ export class ProjectClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - removeParticipant(projectId: string, participantName: string): Promise { + removeParticipant(projectId: string, participantName?: string): Promise { let url_ = this.baseUrl + "/projects/{projectId}/removeParticipant?"; if (projectId === undefined || projectId === null) throw new Error("The parameter 'projectId' must be defined."); url_ = url_.replace("{projectId}", encodeURIComponent("" + projectId)); - if (participantName === undefined || participantName === null) - throw new Error("The parameter 'participantName' must be defined and cannot be null."); - else + if (participantName === null) + throw new Error("The parameter 'participantName' cannot be null."); + else if (participantName !== undefined) url_ += "participantName=" + encodeURIComponent("" + participantName) + "&"; url_ = url_.replace(/[?&]$/, ""); let options_: RequestInit = { method: "DELETE", headers: { - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -969,7 +969,7 @@ export class TicketClient extends AuthorizedApiBase { constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise }) { super(configuration); this.http = http ? http : window as any; - this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : ""; + this.baseUrl = baseUrl ?? ""; } get(username: string, slug: string, ticketId: number): Promise { @@ -1017,7 +1017,7 @@ export class TicketClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - getAll(username: string, slug: string, startIndex: number, amount: number): Promise { + getAll(username: string, slug: string, startIndex?: number, amount?: number): Promise { let url_ = this.baseUrl + "/tickets/{username}/{slug}?"; if (username === undefined || username === null) throw new Error("The parameter 'username' must be defined."); @@ -1025,13 +1025,13 @@ export class TicketClient extends AuthorizedApiBase { if (slug === undefined || slug === null) throw new Error("The parameter 'slug' must be defined."); url_ = url_.replace("{slug}", encodeURIComponent("" + slug)); - if (startIndex === undefined || startIndex === null) - throw new Error("The parameter 'startIndex' must be defined and cannot be null."); - else + if (startIndex === null) + throw new Error("The parameter 'startIndex' cannot be null."); + else if (startIndex !== undefined) url_ += "startIndex=" + encodeURIComponent("" + startIndex) + "&"; - if (amount === undefined || amount === null) - throw new Error("The parameter 'amount' must be defined and cannot be null."); - else + if (amount === null) + throw new Error("The parameter 'amount' cannot be null."); + else if (amount !== undefined) url_ += "amount=" + encodeURIComponent("" + amount) + "&"; url_ = url_.replace(/[?&]$/, ""); @@ -1067,7 +1067,7 @@ export class TicketClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - getAll2(username: string, slug: string, startIndex: number, amount: number, sorting: TicketSorting, filter: TicketFilter): Promise { + getAll2(username: string, slug: string, startIndex?: number, amount?: number, sorting?: TicketSorting, filter?: TicketFilter): Promise { let url_ = this.baseUrl + "/tickets/{username}/{slug}/query?"; if (username === undefined || username === null) throw new Error("The parameter 'username' must be defined."); @@ -1075,21 +1075,19 @@ export class TicketClient extends AuthorizedApiBase { if (slug === undefined || slug === null) throw new Error("The parameter 'slug' must be defined."); url_ = url_.replace("{slug}", encodeURIComponent("" + slug)); - if (startIndex === undefined || startIndex === null) - throw new Error("The parameter 'startIndex' must be defined and cannot be null."); - else + if (startIndex === null) + throw new Error("The parameter 'startIndex' cannot be null."); + else if (startIndex !== undefined) url_ += "startIndex=" + encodeURIComponent("" + startIndex) + "&"; - if (amount === undefined || amount === null) - throw new Error("The parameter 'amount' must be defined and cannot be null."); - else + if (amount === null) + throw new Error("The parameter 'amount' cannot be null."); + else if (amount !== undefined) url_ += "amount=" + encodeURIComponent("" + amount) + "&"; - if (sorting === undefined || sorting === null) - throw new Error("The parameter 'sorting' must be defined and cannot be null."); - else + if (sorting === null) + throw new Error("The parameter 'sorting' cannot be null."); + else if (sorting !== undefined) url_ += "sorting=" + encodeURIComponent("" + sorting) + "&"; - if (filter === undefined) - throw new Error("The parameter 'filter' must be defined."); - else if(filter !== null) + if (filter !== undefined && filter !== null) url_ += "filter=" + encodeURIComponent("" + filter) + "&"; url_ = url_.replace(/[?&]$/, ""); @@ -1125,7 +1123,7 @@ export class TicketClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - create(projectId: string, model?: CreateTicketModel): Promise { + create(projectId: string, model: CreateTicketModel): Promise { let url_ = this.baseUrl + "/tickets/{projectId}"; if (projectId === undefined || projectId === null) throw new Error("The parameter 'projectId' must be defined."); @@ -1168,7 +1166,7 @@ export class TicketClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - edit(projectId: string, ticketId: number, model?: EditTicketModel): Promise { + edit(projectId: string, ticketId: number, model: EditTicketModel): Promise { let url_ = this.baseUrl + "/tickets/{projectId}/{ticketId}"; if (projectId === undefined || projectId === null) throw new Error("The parameter 'projectId' must be defined."); @@ -1185,7 +1183,7 @@ export class TicketClient extends AuthorizedApiBase { method: "POST", headers: { "Content-Type": "application/json", - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -1231,7 +1229,7 @@ export class TicketClient extends AuthorizedApiBase { let options_: RequestInit = { method: "DELETE", headers: { - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -1264,7 +1262,7 @@ export class TicketClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - setStatus(projectId: string, ticketId: number, status: TicketStatus): Promise { + setStatus(projectId: string, ticketId: number, status?: TicketStatus): Promise { let url_ = this.baseUrl + "/tickets/{projectId}/{ticketId}/status?"; if (projectId === undefined || projectId === null) throw new Error("The parameter 'projectId' must be defined."); @@ -1272,16 +1270,16 @@ export class TicketClient extends AuthorizedApiBase { if (ticketId === undefined || ticketId === null) throw new Error("The parameter 'ticketId' must be defined."); url_ = url_.replace("{ticketId}", encodeURIComponent("" + ticketId)); - if (status === undefined || status === null) - throw new Error("The parameter 'status' must be defined and cannot be null."); - else + if (status === null) + throw new Error("The parameter 'status' cannot be null."); + else if (status !== undefined) url_ += "status=" + encodeURIComponent("" + status) + "&"; url_ = url_.replace(/[?&]$/, ""); let options_: RequestInit = { method: "PATCH", headers: { - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -1323,7 +1321,7 @@ export class UserClient extends AuthorizedApiBase { constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise }) { super(configuration); this.http = http ? http : window as any; - this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : ""; + this.baseUrl = baseUrl ?? ""; } get(): Promise { @@ -1362,7 +1360,7 @@ export class UserClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - edit(model?: EditUserModel): Promise { + edit(model: EditUserModel): Promise { let url_ = this.baseUrl + "/user"; url_ = url_.replace(/[?&]$/, ""); @@ -1445,7 +1443,7 @@ export class UserClient extends AuthorizedApiBase { return Promise.resolve(null as any); } - changePassword(model?: ChangePasswordModel): Promise { + changePassword(model: ChangePasswordModel): Promise { let url_ = this.baseUrl + "/changePassword"; url_ = url_.replace(/[?&]$/, ""); @@ -1456,7 +1454,7 @@ export class UserClient extends AuthorizedApiBase { method: "PUT", headers: { "Content-Type": "application/json", - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -1581,7 +1579,7 @@ export class UserClient extends AuthorizedApiBase { let options_: RequestInit = { method: "POST", headers: { - "Accept": "application/json" + "Accept": "application/octet-stream" } }; @@ -1616,8 +1614,8 @@ export class UserClient extends AuthorizedApiBase { } export class AuthenticationResult implements IAuthenticationResult { - token: string; - user: UserDto; + token?: string; + user?: UserDto; constructor(data?: IAuthenticationResult) { if (data) { @@ -1626,15 +1624,12 @@ export class AuthenticationResult implements IAuthenticationResult { (this)[property] = (data)[property]; } } - if (!data) { - this.user = new UserDto(); - } } init(_data?: any) { if (_data) { this.token = _data["token"]; - this.user = _data["user"] ? UserDto.fromJS(_data["user"]) : new UserDto(); + this.user = _data["user"] ? UserDto.fromJS(_data["user"]) : undefined; } } @@ -1654,13 +1649,13 @@ export class AuthenticationResult implements IAuthenticationResult { } export interface IAuthenticationResult { - token: string; - user: UserDto; + token?: string; + user?: UserDto; } export class UserDto implements IUserDto { - id: string; - username: string; + id?: string; + username?: string; avatarPath?: string; constructor(data?: IUserDto) { @@ -1697,8 +1692,8 @@ export class UserDto implements IUserDto { } export interface IUserDto { - id: string; - username: string; + id?: string; + username?: string; avatarPath?: string; } @@ -1794,7 +1789,7 @@ export class ResetPasswordModel implements IResetPasswordModel { userId: string; resetToken: string; newPassword: string; - confirmedPassword: string; + confirmedPassword?: string; constructor(data?: IResetPasswordModel) { if (data) { @@ -1835,22 +1830,22 @@ export interface IResetPasswordModel { userId: string; resetToken: string; newPassword: string; - confirmedPassword: string; + confirmedPassword?: string; } export class TicketDto implements ITicketDto { - id: number; - projectId: string; - projectSlug: string; + id?: number; + projectId?: string; + projectSlug?: string; project?: ProjectDto; - title: string; - description: string; - priority: TicketPriority; - assignees: UserDto[]; - notes: NoteDto[]; - author: UserDto; - status: TicketStatus; - timestamp: Date; + title?: string; + description?: string; + priority?: TicketPriority; + assignees?: UserDto[]; + notes?: NoteDto[]; + author?: UserDto; + status?: TicketStatus; + timestamp?: Date; noteCount?: number; constructor(data?: ITicketDto) { @@ -1860,11 +1855,6 @@ export class TicketDto implements ITicketDto { (this)[property] = (data)[property]; } } - if (!data) { - this.assignees = []; - this.notes = []; - this.author = new UserDto(); - } } init(_data?: any) { @@ -1886,7 +1876,7 @@ export class TicketDto implements ITicketDto { for (let item of _data["notes"]) this.notes.push(NoteDto.fromJS(item)); } - this.author = _data["author"] ? UserDto.fromJS(_data["author"]) : new UserDto(); + this.author = _data["author"] ? UserDto.fromJS(_data["author"]) : undefined; this.status = _data["status"]; this.timestamp = _data["timestamp"] ? new Date(_data["timestamp"].toString()) : undefined; this.noteCount = _data["noteCount"]; @@ -1928,30 +1918,30 @@ export class TicketDto implements ITicketDto { } export interface ITicketDto { - id: number; - projectId: string; - projectSlug: string; + id?: number; + projectId?: string; + projectSlug?: string; project?: ProjectDto; - title: string; - description: string; - priority: TicketPriority; - assignees: UserDto[]; - notes: NoteDto[]; - author: UserDto; - status: TicketStatus; - timestamp: Date; + title?: string; + description?: string; + priority?: TicketPriority; + assignees?: UserDto[]; + notes?: NoteDto[]; + author?: UserDto; + status?: TicketStatus; + timestamp?: Date; noteCount?: number; } export class ProjectDto implements IProjectDto { - id: string; - slug: string; - name: string; - description: string; - author: UserDto; + id?: string; + slug?: string; + name?: string; + description?: string; + author?: UserDto; iconPath?: string; - timestamp: Date; - participants: UserDto[]; + timestamp?: Date; + participants?: UserDto[]; constructor(data?: IProjectDto) { if (data) { @@ -1960,10 +1950,6 @@ export class ProjectDto implements IProjectDto { (this)[property] = (data)[property]; } } - if (!data) { - this.author = new UserDto(); - this.participants = []; - } } init(_data?: any) { @@ -1972,7 +1958,7 @@ export class ProjectDto implements IProjectDto { this.slug = _data["slug"]; this.name = _data["name"]; this.description = _data["description"]; - this.author = _data["author"] ? UserDto.fromJS(_data["author"]) : new UserDto(); + this.author = _data["author"] ? UserDto.fromJS(_data["author"]) : undefined; this.iconPath = _data["iconPath"]; this.timestamp = _data["timestamp"] ? new Date(_data["timestamp"].toString()) : undefined; if (Array.isArray(_data["participants"])) { @@ -2009,14 +1995,14 @@ export class ProjectDto implements IProjectDto { } export interface IProjectDto { - id: string; - slug: string; - name: string; - description: string; - author: UserDto; + id?: string; + slug?: string; + name?: string; + description?: string; + author?: UserDto; iconPath?: string; - timestamp: Date; - participants: UserDto[]; + timestamp?: Date; + participants?: UserDto[]; } export enum TicketPriority { @@ -2028,12 +2014,12 @@ export enum TicketPriority { } export class NoteDto implements INoteDto { - id: number; - content: string; - timestamp: Date; - status: TicketStatus; - project: ProjectDto; - author: UserDto; + id?: number; + content?: string; + timestamp?: Date; + status?: TicketStatus; + project?: ProjectDto; + author?: UserDto; constructor(data?: INoteDto) { if (data) { @@ -2042,10 +2028,6 @@ export class NoteDto implements INoteDto { (this)[property] = (data)[property]; } } - if (!data) { - this.project = new ProjectDto(); - this.author = new UserDto(); - } } init(_data?: any) { @@ -2054,8 +2036,8 @@ export class NoteDto implements INoteDto { this.content = _data["content"]; this.timestamp = _data["timestamp"] ? new Date(_data["timestamp"].toString()) : undefined; this.status = _data["status"]; - this.project = _data["project"] ? ProjectDto.fromJS(_data["project"]) : new ProjectDto(); - this.author = _data["author"] ? UserDto.fromJS(_data["author"]) : new UserDto(); + this.project = _data["project"] ? ProjectDto.fromJS(_data["project"]) : undefined; + this.author = _data["author"] ? UserDto.fromJS(_data["author"]) : undefined; } } @@ -2079,12 +2061,12 @@ export class NoteDto implements INoteDto { } export interface INoteDto { - id: number; - content: string; - timestamp: Date; - status: TicketStatus; - project: ProjectDto; - author: UserDto; + id?: number; + content?: string; + timestamp?: Date; + status?: TicketStatus; + project?: ProjectDto; + author?: UserDto; } export enum TicketStatus { @@ -2095,7 +2077,7 @@ export enum TicketStatus { } export class CreateNoteModel implements ICreateNoteModel { - content: string; + content?: string; ticketId: number; projectId: string; @@ -2133,13 +2115,13 @@ export class CreateNoteModel implements ICreateNoteModel { } export interface ICreateNoteModel { - content: string; + content?: string; ticketId: number; projectId: string; } export class EditNoteModel implements IEditNoteModel { - content: string; + content?: string; status?: TicketStatus; constructor(data?: IEditNoteModel) { @@ -2174,14 +2156,14 @@ export class EditNoteModel implements IEditNoteModel { } export interface IEditNoteModel { - content: string; + content?: string; status?: TicketStatus; } export class CreateProjectModel implements ICreateProjectModel { - name: string; - slug: string; - description: string; + name?: string; + slug?: string; + description?: string; icon?: string; constructor(data?: ICreateProjectModel) { @@ -2220,15 +2202,15 @@ export class CreateProjectModel implements ICreateProjectModel { } export interface ICreateProjectModel { - name: string; - slug: string; - description: string; + name?: string; + slug?: string; + description?: string; icon?: string; } export class EditProjectModel implements IEditProjectModel { - name: string; - description: string; + name?: string; + description?: string; icon?: string; constructor(data?: IEditProjectModel) { @@ -2265,14 +2247,14 @@ export class EditProjectModel implements IEditProjectModel { } export interface IEditProjectModel { - name: string; - description: string; + name?: string; + description?: string; icon?: string; } export class TicketQueryResult implements ITicketQueryResult { - tickets: TicketDto[]; - sorting: TicketSorting; + tickets?: TicketDto[]; + sorting?: TicketSorting; filter?: TicketFilter; constructor(data?: ITicketQueryResult) { @@ -2282,9 +2264,6 @@ export class TicketQueryResult implements ITicketQueryResult { (this)[property] = (data)[property]; } } - if (!data) { - this.tickets = []; - } } init(_data?: any) { @@ -2320,8 +2299,8 @@ export class TicketQueryResult implements ITicketQueryResult { } export interface ITicketQueryResult { - tickets: TicketDto[]; - sorting: TicketSorting; + tickets?: TicketDto[]; + sorting?: TicketSorting; filter?: TicketFilter; } @@ -2342,10 +2321,10 @@ export enum TicketFilter { } export class CreateTicketModel implements ICreateTicketModel { - title: string; - description: string; - priority: TicketPriority; - assigneeIds: string[]; + title?: string; + description?: string; + priority?: TicketPriority; + assigneeIds?: string[]; constructor(data?: ICreateTicketModel) { if (data) { @@ -2354,9 +2333,6 @@ export class CreateTicketModel implements ICreateTicketModel { (this)[property] = (data)[property]; } } - if (!data) { - this.assigneeIds = []; - } } init(_data?: any) { @@ -2394,15 +2370,15 @@ export class CreateTicketModel implements ICreateTicketModel { } export interface ICreateTicketModel { - title: string; - description: string; - priority: TicketPriority; - assigneeIds: string[]; + title?: string; + description?: string; + priority?: TicketPriority; + assigneeIds?: string[]; } export class EditTicketModel implements IEditTicketModel { - title: string; - description: string; + title?: string; + description?: string; constructor(data?: IEditTicketModel) { if (data) { @@ -2436,14 +2412,14 @@ export class EditTicketModel implements IEditTicketModel { } export interface IEditTicketModel { - title: string; - description: string; + title?: string; + description?: string; } export class AccountDto implements IAccountDto { - id: string; - username: string; - email: string; + id?: string; + username?: string; + email?: string; avatarPath?: string; constructor(data?: IAccountDto) { @@ -2482,9 +2458,9 @@ export class AccountDto implements IAccountDto { } export interface IAccountDto { - id: string; - username: string; - email: string; + id?: string; + username?: string; + email?: string; avatarPath?: string; } @@ -2535,7 +2511,7 @@ export interface IEditUserModel { export class ChangePasswordModel implements IChangePasswordModel { currentPassword: string; newPassword: string; - confirmedPassword: string; + confirmedPassword?: string; constructor(data?: IChangePasswordModel) { if (data) { @@ -2573,12 +2549,12 @@ export class ChangePasswordModel implements IChangePasswordModel { export interface IChangePasswordModel { currentPassword: string; newPassword: string; - confirmedPassword: string; + confirmedPassword?: string; } export class InvitationDto implements IInvitationDto { - project: ProjectDto; - user: UserDto; + project?: ProjectDto; + user?: UserDto; constructor(data?: IInvitationDto) { if (data) { @@ -2587,16 +2563,12 @@ export class InvitationDto implements IInvitationDto { (this)[property] = (data)[property]; } } - if (!data) { - this.project = new ProjectDto(); - this.user = new UserDto(); - } } init(_data?: any) { if (_data) { - this.project = _data["project"] ? ProjectDto.fromJS(_data["project"]) : new ProjectDto(); - this.user = _data["user"] ? UserDto.fromJS(_data["user"]) : new UserDto(); + this.project = _data["project"] ? ProjectDto.fromJS(_data["project"]) : undefined; + this.user = _data["user"] ? UserDto.fromJS(_data["user"]) : undefined; } } @@ -2616,8 +2588,8 @@ export class InvitationDto implements IInvitationDto { } export interface IInvitationDto { - project: ProjectDto; - user: UserDto; + project?: ProjectDto; + user?: UserDto; } export interface FileResponse {