id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c18500
TraceLoadFinishFunc) { return ctx, func(Thunk) {} }
c18501
TraceLoadManyFinishFunc) { return ctx, func(ThunkMany) {} }
c18502
{ return ctx, func(result []*Result) {} }
c18503
"model.json", Data: modelJSON} env.Response.Files = append(env.Response.Files, modelFile) // Create the renderer. renderer, err := NewServiceRenderer(surfaceModel) renderer.Package = packageName env.RespondAndExitIfError(err) // Run the renderer to generate files and add them to the response ...
c18504
_, err = format.Source([]byte("package " + p)) } if err != nil { return "", errors.New("invalid package name " + p) } return p, nil }
c18505
i++ { c.text += indentation } c.text += fmt.Sprintf(args[0].(string), args[1:]...) } c.text += "\n" }
c18506
+= indentation } c.text += fmt.Sprintf(args[0].(string), args[1:]...) } c.text += "\n" }
c18507
nil) && (schema.Properties == nil) && (schema.PatternProperties == nil) && (schema.Dependencies == nil) && (schema.Enumeration == nil) && (schema.Type == nil) && (schema.AllOf == nil) && (schema.AnyOf == nil) && (schema.OneOf == nil) && (schema.Not == nil) && (schema.Definitions == nil) && (schem...
c18508
schema.String() == schema2.String() }
c18509
s := schemaOrStringArray.Schema if s != nil { s.applyToSchemas(operation, "Dependencies") } } } if schema.AllOf != nil { for _, s := range *(schema.AllOf) { s.applyToSchemas(operation, "AllOf") } } if schema.AnyOf != nil { for _, s := range *(schema.AnyOf) { s.applyToSchemas(operation, "...
c18510
{ for _, n := range *(schema.Type.StringArray) { if n == typeName { return true } } } } return false }
c18511
result = pair.Value } } case "properties": dictionary := document.Properties for _, pair := range *dictionary { if pair.Name == pathParts[2] { result = pair.Value } } default: break } } } if result == nil { return nil, fmt.Errorf("unresolved pointer: %+v", ref) ...
c18512
schema.CopyProperties(allOf) } schema.AllOf = nil } }, "resolveAllOfs") }
c18513
string) { if schema.AnyOf != nil { schema.OneOf = schema.AnyOf schema.AnyOf = nil } }, "resolveAnyOfs") }
c18514
NewNamedSchema(name, &Schema{Ref: stringptr("http://json-schema.org/draft-04/schema#/properties/" + name)})) }
c18515
schema.CopyOfficialSchemaProperty(name) } }
c18516
s = strings.Replace(s, "\"", "\\\"", -1) return s }
c18517
type passed to Marshal") } w.writeMap(m, "") w.writeString("\n") return w.bytes(), err }
c18518
return &Context{Name: name, Parent: parent, ExtensionHandlers: extensionHandlers} }
c18519
parent.ExtensionHandlers} } return &Context{Name: name, Parent: parent, ExtensionHandlers: nil} }
c18520
return context.Parent.Description() + "." + context.Name } return context.Name }
c18521
messages = append(messages, s.analyzeOperation([]string{"paths", pair.Name, "delete"}, path.Delete)...) } } if document.Definitions != nil { for _, pair := range document.Definitions.AdditionalProperties { definition := pair.Value messages = append(messages, s.analyzeDefinition([]string{"definitions", pair...
c18522
if propertySchema.Description == "" { messages = append(messages, &plugins.Message{ Level: plugins.Message_WARNING, Code: "NODESCRIPTION", Text: "Property has no description.", Keys: append(keys, []string{"properties", pair.Name}...)}) } } } return messages }
c18523
&info) if err != nil { return nil, err } return NewSchemaFromObject(info), nil }
c18524
make(map[string]*TypeRequest, 0) cc.MapTypeRequests = make(map[string]string, 0) cc.Schema = schema cc.Version = version return cc }
c18525
{ return domain.Prefix + strings.ToUpper(stub[0:1]) + stub[1:len(stub)] }
c18526
if first == "#" { return domain.TypeNameForStub(last) } return "Schema" }
c18527
"/") first := parts[0] last := parts[len(parts)-1] if first == "#" { return &last } return nil }
c18528
if schema.Items.Schema.Ref != nil { itemTypeName = domain.typeNameForReference(*schema.Items.Schema.Ref) } else if schema.Items.Schema.OneOf != nil { // this type is implied by the "oneOf" itemTypeName = domain.TypeNameForStub(propertyName + "Item") domain.ObjectTypeRequests[itemTypeName] = Ne...
c18529
== "object") { return domain.buildTypeForDefinitionObject(typeName, propertyName, schema) } return nil }
c18530
result := "" for _, typeName := range typeNames { result += domain.TypeModels[typeName].description() } return result }
c18531
0 { // if so, return an empty map return yaml.MapSlice{}, true } return nil, false }
c18532
keys = append(keys, item.Key.(string)) } sort.Strings(keys) return keys }
c18533
if ok && key == itemKey { return true } } return false }
c18534
if ok && key == itemKey { return item.Value } } return nil }
c18535
for _, item := range interfaceArray { v, ok := item.(string) if ok { stringArray = append(stringArray, v) } } return stringArray }
c18536
if !MapHasKey(m, k) { missingKeys = append(missingKeys, k) } } return missingKeys }
c18537
for _, allowedKey := range allowedKeys { if key == allowedKey { found = true break } } if !found { // does the key match an allowed pattern? for _, allowedPattern := range allowedPatterns { if allowedPattern.MatchString(key) { found = true break } } if !fou...
c18538
if item == value { return true } } return false }
c18539
!StringArrayContainsValue(array, value) { return false } } return true }
c18540
ok { return strconv.Itoa(intValue), true } return "", false }
c18541
&TypeRequest{Name: name, PropertyName: propertyName, Schema: schema} }
c18542
return &TypeProperty{Name: name, Type: typeName} }
c18543
return &TypeProperty{Name: name, Type: typeName, Pattern: pattern} }
c18544
"XRef" } return strings.Title(snakeCaseToCamelCase(propertyName)) }
c18545
statistics.DocumentStatistics err = json.Unmarshal(data, &s) if err != nil { return err } stats = append(stats, s) return nil }
c18546
err != nil { response.Errors = append(response.Errors, err.Error()) sendAndExit(response) } }
c18547
os.Stdout.Write(responseBytes) os.Exit(0) }
c18548
&SchemaNumber{} result.Integer = &i return result }
c18549
&SchemaNumber{} result.Float = &f return result }
c18550
&SchemaOrBoolean{} result.Schema = s return result }
c18551
&SchemaOrBoolean{} result.Boolean = &b return result }
c18552
&StringOrStringArray{} result.String = &s return result }
c18553
&StringOrStringArray{} result.StringArray = &a return result }
c18554
&SchemaOrSchemaArray{} result.Schema = s return result }
c18555
&SchemaOrSchemaArray{} result.SchemaArray = &a return result }
c18556
&NamedSchema{Name: name, Value: value} }
c18557
if pair.Name == name { return pair.Value } } return nil }
c18558
{ return namedSchemaArrayElementWithName(s.Properties, name) }
c18559
namedSchemaArrayElementWithName(s.PatternProperties, name) }
c18560
namedSchemaArrayElementWithName(s.Definitions, name) }
c18561
append(*s.Properties, NewNamedSchema(name, property)) }
c18562
return string(unicode.ToLower(r)) + s[n:] }
c18563
else if subtitlePattern.Match([]byte(line)) { // we've found a subsection title. // if there's a subsection that we've already been reading, save it if len(subsection) != 0 { child := ReadSection(subsection, level+1) section.Children = append(section.Children, child) } // start a new subsection ...
c18564
} else { subsection = fmt.Sprintf("%s.%d", section, i) } fmt.Printf("%-12s %s\n", subsection, child.NiceTitle()) child.Display(subsection) } } }
c18565
string(matches[1]) } else if matches := stringPattern.FindSubmatch([]byte(input)); matches != nil { return string(matches[1]) } else { return input } }
c18566
requiredLabel1 := "**Required.** " requiredLabel2 := "**REQUIRED**." if strings.Contains(description, requiredLabel1) || strings.Contains(description, requiredLabel2) { // only include required values if their "Validity" is "Any" or if no validity is specified valid := true if len(parts) ==...
c18567
false mapPattern := regexp.MustCompile("^Mapstring,\\[(.*)\\]$") if matches := mapPattern.FindSubmatch([]byte(typeName)); matches != nil { typeName = string(matches[1]) isMap = true } description := strings.Trim(parts[len(parts)-1], " ") description = removeMarkdownLinks(description) ...
c18568
removeMarkdownLinks(description) description = strings.Trim(description, " \t\n") description = strings.Replace(description, "\n", " ", -1) schemaObject.Description = description } // is the object extendable? if strings.Contains(section.Text, "Specification Extensions") { schemaObject.Extend...
c18569
&Error{Context: context, Message: message} }
c18570
" + err.Context.Description() + " " + err.Message }
c18571
return errors[0] } else { return &ErrorGroup{Errors: errors} } }
c18572
"3.0") { return SourceFormatOpenAPI3 } kind, ok := compiler.MapValueForKey(m, "kind").(string) if ok && kind == "discovery#restDescription" { return SourceFormatDiscovery } return SourceFormatUnknown }
c18573
plugins that return messages only. PLUGIN must not match any other gnostic option. --x-EXTENSION Use the extension named gnostic-x-EXTENSION to process OpenAPI specification extensions. --resolve-refs Explicitly resolve $ref references. T...
c18574
compiler.ExtensionHandler{Name: extensionPrefix + extensionName} g.extensionHandlers = append(g.extensionHandlers, extensionHandler) } else if arg == "--resolve-refs" { g.resolveReferences = true } else if arg == "--time-plugins" { g.timePlugins = true } else if arg[0] == '-' && arg[1] == '-' { // tr...
c18575
"No input specified.\n%s\n", g.usage) os.Exit(-1) } // If we get here and the error output is unspecified, write errors to stderr. if g.errorOutputPath == "" { g.errorOutputPath = "=" } }
c18576
" + g.sourceName + "\n" + err.Error()) }
c18577
== SourceFormatOpenAPI3 { document, err := openapi_v3.NewDocument(info, compiler.NewContextWithExtensions("$root", nil, &g.extensionHandlers)) if err != nil { return nil, err } message = document } else { document, err := discovery_v1.NewDocument(info, compiler.NewContextWithExtensions("$root", nil, &g.e...
c18578
that failed, try to read a Discovery Format document discoveryDocument := &discovery_v1.Document{} err = proto.Unmarshal(data, discoveryDocument) if err == nil { // && strings.HasPrefix(documentV2.Swagger, "2.0") { g.sourceFormat = SourceFormatDiscovery return discoveryDocument, nil } return nil, err }
c18579
defer os.Exit(-1) } else { writeFile(g.binaryOutputPath, protoBytes, g.sourceName, "pb") } }
c18580
writeFile(g.textOutputPath, bytes, g.sourceName, "text") }
c18581
os.Exit(-1) } else { writeFile(g.messageOutputPath, protoBytes, g.sourceName, "messages.pb") } }
c18582
nil { writeFile(g.errorOutputPath, g.errorBytes(err), g.sourceName, "errors") defer os.Exit(-1) // run all plugins, even when some have errors } messages = append(messages, pluginMessages...) } if g.messageOutputPath != "" { g.writeMessagesOutput(&plugins.Messages{Messages: messages}) } else { // Prin...
c18583
os.Exit(0) } // If we reach here, then the extension is handled response.Handled = true if err != nil { response.Error = append(response.Error, err.Error()) responseBytes, _ := proto.Marshal(response) os.Stdout.Write(responseBytes) os.Exit(0) } response.Value, err = ptypes.MarshalAny...
c18584
string required = 1; v1 := compiler.MapValueForKey(m, "required") if v1 != nil { v, ok := v1.([]interface{}) if ok { x.Required = compiler.ConvertInterfaceArrayToStringArray(v) } else { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) errors = append(errors, compil...
c18585
yaml.Marshal(in) x.Yaml = string(bytes) return x, compiler.NewErrorGroupOrNil(errors) }
c18586
// Oauth2 oauth2 = 1; v1 := compiler.MapValueForKey(m, "oauth2") if v1 != nil { var err error x.Oauth2, err = NewOauth2(v1, compiler.NewContext("oauth2", context)) if err != nil { errors = append(errors, err) } } } return x, compiler.NewErrorGroupOrNil(errors) }
c18587
v, ok := v1.([]interface{}) if ok { x.Accept = compiler.ConvertInterfaceArrayToStringArray(v) } else { message := fmt.Sprintf("has unexpected value for accept: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) } } // string max_size = 2; v2 := compiler.MapValu...
c18588
// MAP: Method x.AdditionalProperties = make([]*NamedMethod, 0) for _, item := range m { k, ok := compiler.StringValue(item.Key) if ok { v := item.Value pair := &NamedMethod{} pair.Name = k var err error pair.Value, err = NewMethod(v, compiler.NewContext(k, context)) if err != nil { ...
c18589
v1 := compiler.MapValueForKey(m, "simple") if v1 != nil { var err error x.Simple, err = NewSimple(v1, compiler.NewContext("simple", context)) if err != nil { errors = append(errors, err) } } // Resumable resumable = 2; v2 := compiler.MapValueForKey(m, "resumable") if v2 != nil { var err er...
c18590
:= compiler.MapValueForKey(m, "methods") if v1 != nil { var err error x.Methods, err = NewMethods(v1, compiler.NewContext("methods", context)) if err != nil { errors = append(errors, err) } } // Resources resources = 2; v2 := compiler.MapValueForKey(m, "resources") if v2 != nil { var err e...
c18591
v := item.Value pair := &NamedResource{} pair.Name = k var err error pair.Value, err = NewResource(v, compiler.NewContext(k, context)) if err != nil { errors = append(errors, err) } x.AdditionalProperties = append(x.AdditionalProperties, pair) } } } return x, compiler.NewErro...
c18592
// MAP: Scope x.AdditionalProperties = make([]*NamedScope, 0) for _, item := range m { k, ok := compiler.StringValue(item.Key) if ok { v := item.Value pair := &NamedScope{} pair.Name = k var err error pair.Value, err = NewScope(v, compiler.NewContext(k, context)) if err != nil { ...
c18593
strings.Join(invalidKeys, ", ")) errors = append(errors, compiler.NewError(context, message)) } // bool multipart = 1; v1 := compiler.MapValueForKey(m, "multipart") if v1 != nil { x.Multipart, ok = v1.(bool) if !ok { message := fmt.Sprintf("has unexpected value for multipart: %+v (%T)", v1, v1) ...
c18594
{ x.Value = make([]string, 0) for _, s := range a { x.Value = append(x.Value, s.(string)) } } return x, compiler.NewErrorGroupOrNil(errors) }
c18595
errors = append(errors, err) } } return nil, compiler.NewErrorGroupOrNil(errors) }
c18596
nil { errors = append(errors, err) } } if m.MediaUpload != nil { _, err := m.MediaUpload.ResolveReferences(root) if err != nil { errors = append(errors, err) } } return nil, compiler.NewErrorGroupOrNil(errors) }
c18597
if err != nil { errors = append(errors, err) } } } return nil, compiler.NewErrorGroupOrNil(errors) }
c18598
errors = append(errors, err) } } return nil, compiler.NewErrorGroupOrNil(errors) }
c18599
} if m.Resumable != nil { _, err := m.Resumable.ResolveReferences(root) if err != nil { errors = append(errors, err) } } return nil, compiler.NewErrorGroupOrNil(errors) }