示例#1
0
func setParameterType(s *spec.Parameter, f *descriptor.Field) {
	if f.GetLabel() == godesc.FieldDescriptorProto_LABEL_REPEATED {
		s.Type = "array"
		items := new(spec.Items)
		if f.GetType() == godesc.FieldDescriptorProto_TYPE_MESSAGE {
			items.Ref = spec.MustCreateRef("#/definitions/" + f.GetTypeName())
		} else {
			ty, format := toSwaggerType(f.GetType())
			items.Type = ty
			items.Format = format
		}

		s.Items = items
		return
	}

	if f.GetType() == godesc.FieldDescriptorProto_TYPE_MESSAGE {
		s.Ref = spec.MustCreateRef("#/definitions/" + f.GetTypeName())
		return
	}

	ty, format := toSwaggerType(f.GetType())
	s.Type = ty
	s.Format = format
}
示例#2
0
func messageRef(m *descriptor.Message) spec.Ref {
	return spec.MustCreateRef("#/definitions/" + m.GetModelName())
}