Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Swagger generate custom generic types?

Assume we have API return model in C#

public class ApiResult<T>
{
  public T Result;
  public bool Success;
}

and returning ApiResult<string> object instance to client

so we have swagger generated model

ApiResult[String] {
  result (string, optional),
  success (boolean, optional)
}

which is incorrectly converted to typescript class using https://swagger.io/swagger-codegen/

'use strict';
import * as models from './models';
export interface ApiResultString {
    result?: string;
    success?: boolean;
}

Is it possible to generate output models with generics same as in input models?

like image 899
MelnikovI Avatar asked May 16 '18 12:05

MelnikovI


1 Answers

I have created issue on swagger-codegen on GitHub . You can support this feature there. Looks like currently it is not possible.

like image 82
MelnikovI Avatar answered Sep 29 '22 02:09

MelnikovI