Skip to content

Commit

Permalink
🐛 Add FluentValidationSchemaProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
jasontaylordev committed Nov 23, 2023
1 parent 211671b commit 80749c2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/Web/ClientApp/src/app/web-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ export interface ITodoItemBriefDto {

export class CreateTodoItemCommand implements ICreateTodoItemCommand {
listId?: number;
title?: string | undefined;
title!: string | undefined;

constructor(data?: ICreateTodoItemCommand) {
if (data) {
Expand Down Expand Up @@ -741,12 +741,12 @@ export class CreateTodoItemCommand implements ICreateTodoItemCommand {

export interface ICreateTodoItemCommand {
listId?: number;
title?: string | undefined;
title: string | undefined;
}

export class UpdateTodoItemCommand implements IUpdateTodoItemCommand {
id?: number;
title?: string | undefined;
title!: string | undefined;
done?: boolean;

constructor(data?: IUpdateTodoItemCommand) {
Expand Down Expand Up @@ -784,7 +784,7 @@ export class UpdateTodoItemCommand implements IUpdateTodoItemCommand {

export interface IUpdateTodoItemCommand {
id?: number;
title?: string | undefined;
title: string | undefined;
done?: boolean;
}

Expand Down Expand Up @@ -1052,7 +1052,7 @@ export interface ITodoItemDto {
}

export class CreateTodoListCommand implements ICreateTodoListCommand {
title?: string | undefined;
title!: string | undefined;

constructor(data?: ICreateTodoListCommand) {
if (data) {
Expand Down Expand Up @@ -1084,12 +1084,12 @@ export class CreateTodoListCommand implements ICreateTodoListCommand {
}

export interface ICreateTodoListCommand {
title?: string | undefined;
title: string | undefined;
}

export class UpdateTodoListCommand implements IUpdateTodoListCommand {
id?: number;
title?: string | undefined;
title!: string | undefined;

constructor(data?: IUpdateTodoListCommand) {
if (data) {
Expand Down Expand Up @@ -1124,7 +1124,7 @@ export class UpdateTodoListCommand implements IUpdateTodoListCommand {

export interface IUpdateTodoListCommand {
id?: number;
title?: string | undefined;
title: string | undefined;
}

export class WeatherForecast implements IWeatherForecast {
Expand Down
4 changes: 2 additions & 2 deletions src/Web/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public static IServiceCollection AddWebServices(this IServiceCollection services
{
configure.Title = "CleanArchitecture API";


// Add the fluent validations schema processor
var fluentValidationSchemaProcessor =
sp.CreateScope().ServiceProvider.GetRequiredService<FluentValidationSchemaProcessor>();

// BUG: SchemaProcessors is missing in NSwag 14 (https://github.com/RicoSuter/NSwag/issues/4524#issuecomment-1811897079)
// configure.SchemaProcessors.Add(fluentValidationSchemaProcessor);
configure.SchemaSettings.SchemaProcessors.Add(fluentValidationSchemaProcessor);

#if (UseApiOnly)
// Add JWT
Expand Down
20 changes: 20 additions & 0 deletions src/Web/wwwroot/api/specification.json
Original file line number Diff line number Diff line change
Expand Up @@ -377,27 +377,37 @@
"CreateTodoItemCommand": {
"type": "object",
"additionalProperties": false,
"required": [
"title"
],
"properties": {
"listId": {
"type": "integer",
"format": "int32"
},
"title": {
"type": "string",
"maxLength": 200,
"minLength": 0,
"nullable": true
}
}
},
"UpdateTodoItemCommand": {
"type": "object",
"additionalProperties": false,
"required": [
"title"
],
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"title": {
"type": "string",
"maxLength": 200,
"minLength": 0,
"nullable": true
},
"done": {
Expand Down Expand Up @@ -530,23 +540,33 @@
"CreateTodoListCommand": {
"type": "object",
"additionalProperties": false,
"required": [
"title"
],
"properties": {
"title": {
"type": "string",
"maxLength": 200,
"minLength": 0,
"nullable": true
}
}
},
"UpdateTodoListCommand": {
"type": "object",
"additionalProperties": false,
"required": [
"title"
],
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"title": {
"type": "string",
"maxLength": 200,
"minLength": 0,
"nullable": true
}
}
Expand Down

0 comments on commit 80749c2

Please sign in to comment.