0

I want to generate a TypeScript client from an openApi specification. I'm using NSwagStudio to create the config file. I leave the default {controller}Client value, but the placeholder returns nothing, the class name will be just Client.

What could be the problem?

 "codeGenerators": {
    "openApiToTypeScriptClient": {
      "className": "{controller}Client",
      "operationGenerationMode": "MultipleClientsFromOperationId",
...
[ApiController]
public class WorkoutsController : ControllerBase
{
    private readonly IWorkoutService _workoutService;

    public WorkoutsController(IWorkoutService workoutService)
    {
        _workoutService = workoutService;
    }

    [ProducesResponseType(StatusCodes.Status404NotFound)]
    [ProducesResponseType(typeof(WorkoutResponse), StatusCodes.Status200OK)]
    [HttpGet(ApiEndpoints.Workouts.Get)]
    public async Task<IActionResult> Get([FromRoute] Guid id, CancellationToken token)
    {
        var workout = await _workoutService.GetByIdAsync(id, token);
        if (workout is null)
            return NotFound();

        var workoutResponse = workout.ToWorkoutResponse();
        return Ok(workoutResponse);
    }
...
{
    "openapi": "3.0.1",
    "info": {
        "title": "fitflow.RestApi",
        "version": "1.0"
    },
    "paths": {
        "/api/workouts/{id}": {
            "get": {
                "tags": [
                    "Workouts"
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "style": "simple",
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "text/plain": {
                                "schema": {
                                    "$ref": "#/components/schemas/WorkoutResponse"
                                }
                            },
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WorkoutResponse"
                                }
                            },
                            "text/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WorkoutResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "content": {
                            "text/plain": {
                                "schema": {
                                    "$ref": "#/components/schemas/ProblemDetails"
                                }
                            },
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ProblemDetails"
                                }
                            },
                            "text/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ProblemDetails"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/workouts": {
...

0 Answers0