function recursiveTypeName()

in packages/autorest.go/src/transform/transform.ts [1012:1066]


function recursiveTypeName(schema: m4.Schema): string {
  const rawJSON = 'RawJSON';
  switch (schema.type) {
    case m4.SchemaType.Any:
      if (schema.language.go!.rawJSONAsBytes) {
        return rawJSON;
      }
      return 'Interface';
    case m4.SchemaType.AnyObject:
      if (schema.language.go!.rawJSONAsBytes) {
        return rawJSON;
      }
      return 'Object';
    case m4.SchemaType.Array: {
      const arraySchema = <m4.ArraySchema>schema;
      const arrayElem = arraySchema.elementType;
      return `${recursiveTypeName(arrayElem)}Array`;
    }
    case m4.SchemaType.Boolean:
      return 'Bool';
    case m4.SchemaType.ByteArray:
      return 'ByteArray';
    case m4.SchemaType.Choice:
      return (<m4.ChoiceSchema>schema).language.go!.name;
    case m4.SchemaType.SealedChoice:
      return (<m4.SealedChoiceSchema>schema).language.go!.name;
    case m4.SchemaType.Date:
    case m4.SchemaType.DateTime:
    case m4.SchemaType.UnixTime:
      return 'Time';
    case m4.SchemaType.Dictionary: {
      const dictSchema = <m4.DictionarySchema>schema;
      const dictElem = dictSchema.elementType;
      return `MapOf${recursiveTypeName(dictElem)}`;
    }
    case m4.SchemaType.Integer:
      if ((<m4.NumberSchema>schema).precision === 32) {
        return 'Int32';
      }
      return 'Int64';
    case m4.SchemaType.Number:
      if ((<m4.NumberSchema>schema).precision === 32) {
        return 'Float32';
      }
      return 'Float64';
    case m4.SchemaType.Object:
      return schema.language.go!.name;
    case m4.SchemaType.Duration:
    case m4.SchemaType.String:
    case m4.SchemaType.Uuid:
      return 'String';
    default:
      throw new Error(`unhandled response schema type ${schema.type}`);
  }
}