コード例 #1
0
ファイル: Program.cs プロジェクト: tspence/okapi-doc
        private static OkapiParameterInfo ResolveType(SwaggerProperty prop)
        {
            var pi = new OkapiParameterInfo()
            {
                Comment   = prop.description ?? "",
                ParamName = prop.name,
                Type      = prop.type,
                TypeName  = ResolveTypeName(prop),
                Required  = prop.required,
                ReadOnly  = prop.readOnly,
                MaxLength = prop.maxLength,
                MinLength = prop.minLength,
                Example   = prop.example == null ? "" : prop.example.ToString()
            };

            // Is this an array?
            if (prop.type == "array")
            {
                pi.IsArrayType      = true;
                pi.ArrayElementType = ResolveTypeName(prop.items).Replace("?", "");
            }
            else if (pi.TypeName.StartsWith("List<"))
            {
                pi.IsArrayType      = true;
                pi.ArrayElementType = pi.TypeName.Substring(5, pi.TypeName.Length - 6);
            }
            return(pi);
        }
コード例 #2
0
        public string PhpTypeComment(OkapiInfo s, OkapiParameterInfo p)
        {
            string comment = "";

            if (p.Comment != null)
            {
                comment = NoNewlines(FixWhitespace(p.Comment));
            }

            // Is this an enum?  If so, convert it to a string - we'll add a comment later
            if (IsEnumType(p.TypeName))
            {
                return(comment + " (See " + p.TypeName.Replace("?", "") + "::* for a list of allowable values)");
            }
            else if (p.TypeName == "Byte[]")
            {
                return(comment + " (This value is encoded as a Base64 string)");
            }

            return(comment);
        }