MelnikovI
MelnikovI

Reputation: 1045

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?

Upvotes: 8

Views: 5187

Answers (1)

MelnikovI
MelnikovI

Reputation: 1045

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

Upvotes: 4

Related Questions