A Model Object holds the definition of a new model for this API Declaration.
Models in Swagger allow for inheritance. The inheritance is controlled by two fields - SubTypes to give the name of the models extending this definition, and Discriminator to support polymorphism.
상속: SwaggerModel
예제 #1
0
 public EnumSchema(Type t, Model sModel)
 {
     Type = "string";
     Ref = DefintionsRefLocation + t.Name;
     Description = sModel.Description;
     Enum = t.GetTypeInfo().GetEnumNames();
 }
예제 #2
0
 public EnumerableSchema(Type t, Model sModel)
 {
     Type = "array";
     Items = new Item();
     Type subType = t.GetTypeInfo().GetGenericArguments().FirstOrDefault();
     Items.Type = "object";
     Items.Ref = DefintionsRefLocation + subType?.Name;
     Ref = DefintionsRefLocation + subType?.Name + "[]";
 }
예제 #3
0
 public ObjectSchema(Type t, Model sModel)
 {
     Type = "object";
     Ref = DefintionsRefLocation + t.Name;
     Required = (sModel.Required as IList<string>)?.Select(x => x.ToCamelCase()).ToList();
     Description = sModel.Description;
     Properties = new Dictionary<string, Schema>();
     foreach (var member in sModel.Properties)
     {
         Properties.Add(member.Key.ToCamelCase(), GenerateSchemaForProperty(member.Value));
     }
 }