Пример #1
0
func enumToSchema(pidl *idl.Idl, e *idl.Enum) *swagger2.Schema {
	sc := new(swagger2.Schema)
	// sc.Title = f.Name
	sc.Description = strings.Join(e.Comments, "\n")
	sc.Ref = ""
	sc.Type = "string"
	sc.Format = ""
	sc.Enum = make([]interface{}, 0)
	for _, x := range e.Values {
		sc.Enum = append(sc.Enum, x.Name)
	}
	return sc
}
Пример #2
0
func fieldToSchema(pidl *idl.Idl, f *idl.Field) *swagger2.Schema {
	sc := new(swagger2.Schema)
	// sc.Title = f.Name
	sc.Description = strings.Join(f.Comments, "\n")
	it := typeToItems(pidl, f.Type)
	sc.Ref = it.Ref
	sc.Type = it.Type
	sc.Format = it.Format
	sc.ItemsDef.Items = it.Items
	sc.Enum = it.Enum
	sc.AdditionalProperties = it.AdditionalProperties
	return sc
}
Пример #3
0
func returnsToSchema(pidl *idl.Idl, t *idl.Type) *swagger2.Schema {
	sc := new(swagger2.Schema)
	// sc.Title = f.Name
	if t.IsVoid() {
		// nil schema means the operation returns no content
		return nil
	} else {
		it := typeToItems(pidl, t)
		sc.Ref = it.Ref
		sc.Type = it.Type
		sc.Format = it.Format
		sc.ItemsDef.Items = it.Items
		sc.Enum = it.Enum
		sc.AdditionalProperties = it.AdditionalProperties
	}
	return sc
}