_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q18500 | TraceLoad | train | func (NoopTracer) TraceLoad(ctx context.Context, key Key) (context.Context, TraceLoadFinishFunc) {
return ctx, func(Thunk) {}
} | go | {
"resource": ""
} |
q18501 | TraceLoadMany | train | func (NoopTracer) TraceLoadMany(ctx context.Context, keys Keys) (context.Context, TraceLoadManyFinishFunc) {
return ctx, func(ThunkMany) {}
} | go | {
"resource": ""
} |
q18502 | TraceBatch | train | func (NoopTracer) TraceBatch(ctx context.Context, keys Keys) (context.Context, TraceBatchFinishFunc) {
return ctx, func(result []*Result) {}
} | go | {
"resource": ""
} |
q18503 | main | train | func main() {
env, err := plugins.NewEnvironment()
env.RespondAndExitIfError(err)
packageName, err := resolvePackageName(env.Request.OutputPath)
env.RespondAndExitIfError(err)
// Use the name used to run the plugin to decide which files to generate.
var files []string
switch {
case strings.Contains(env.Invoca... | go | {
"resource": ""
} |
q18504 | resolvePackageName | train | func resolvePackageName(p string) (string, error) {
p, err := filepath.Abs(p)
if err == nil {
p = filepath.Base(p)
_, err = format.Source([]byte("package " + p))
}
if err != nil {
return "", errors.New("invalid package name " + p)
}
return p, nil
} | go | {
"resource": ""
} |
q18505 | Print | train | func (c *Code) Print(args ...interface{}) {
if len(args) > 0 {
for i := 0; i < c.indent; i++ {
c.text += indentation
}
c.text += fmt.Sprintf(args[0].(string), args[1:]...)
}
c.text += "\n"
} | go | {
"resource": ""
} |
q18506 | PrintIf | train | func (c *Code) PrintIf(condition bool, args ...interface{}) {
if !condition {
return
}
if len(args) > 0 {
for i := 0; i < c.indent; i++ {
c.text += indentation
}
c.text += fmt.Sprintf(args[0].(string), args[1:]...)
}
c.text += "\n"
} | go | {
"resource": ""
} |
q18507 | IsEmpty | train | func (schema *Schema) IsEmpty() bool {
return (schema.Schema == nil) &&
(schema.ID == nil) &&
(schema.MultipleOf == nil) &&
(schema.Maximum == nil) &&
(schema.ExclusiveMaximum == nil) &&
(schema.Minimum == nil) &&
(schema.ExclusiveMinimum == nil) &&
(schema.MaxLength == nil) &&
(schema.MinLength == nil... | go | {
"resource": ""
} |
q18508 | IsEqual | train | func (schema *Schema) IsEqual(schema2 *Schema) bool {
return schema.String() == schema2.String()
} | go | {
"resource": ""
} |
q18509 | applyToSchemas | train | func (schema *Schema) applyToSchemas(operation SchemaOperation, context string) {
if schema.AdditionalItems != nil {
s := schema.AdditionalItems.Schema
if s != nil {
s.applyToSchemas(operation, "AdditionalItems")
}
}
if schema.Items != nil {
if schema.Items.SchemaArray != nil {
for _, s := range *(sc... | go | {
"resource": ""
} |
q18510 | TypeIs | train | func (schema *Schema) TypeIs(typeName string) bool {
if schema.Type != nil {
// the schema Type is either a string or an array of strings
if schema.Type.String != nil {
return (*(schema.Type.String) == typeName)
} else if schema.Type.StringArray != nil {
for _, n := range *(schema.Type.StringArray) {
i... | go | {
"resource": ""
} |
q18511 | resolveJSONPointer | train | func (schema *Schema) resolveJSONPointer(ref string) (result *Schema, err error) {
parts := strings.Split(ref, "#")
if len(parts) == 2 {
documentName := parts[0] + "#"
if documentName == "#" && schema.ID != nil {
documentName = *(schema.ID)
}
path := parts[1]
document := schemas[documentName]
pathParts... | go | {
"resource": ""
} |
q18512 | ResolveAllOfs | train | func (schema *Schema) ResolveAllOfs() {
schema.applyToSchemas(
func(schema *Schema, context string) {
if schema.AllOf != nil {
for _, allOf := range *(schema.AllOf) {
schema.CopyProperties(allOf)
}
schema.AllOf = nil
}
}, "resolveAllOfs")
} | go | {
"resource": ""
} |
q18513 | ResolveAnyOfs | train | func (schema *Schema) ResolveAnyOfs() {
schema.applyToSchemas(
func(schema *Schema, context string) {
if schema.AnyOf != nil {
schema.OneOf = schema.AnyOf
schema.AnyOf = nil
}
}, "resolveAnyOfs")
} | go | {
"resource": ""
} |
q18514 | CopyOfficialSchemaProperty | train | func (schema *Schema) CopyOfficialSchemaProperty(name string) {
*schema.Properties = append(*schema.Properties,
NewNamedSchema(name,
&Schema{Ref: stringptr("http://json-schema.org/draft-04/schema#/properties/" + name)}))
} | go | {
"resource": ""
} |
q18515 | CopyOfficialSchemaProperties | train | func (schema *Schema) CopyOfficialSchemaProperties(names []string) {
for _, name := range names {
schema.CopyOfficialSchemaProperty(name)
}
} | go | {
"resource": ""
} |
q18516 | escape | train | func escape(s string) string {
s = strings.Replace(s, "\n", "\\n", -1)
s = strings.Replace(s, "\"", "\\\"", -1)
return s
} | go | {
"resource": ""
} |
q18517 | Marshal | train | func Marshal(in interface{}) (out []byte, err error) {
var w writer
m, ok := in.(yaml.MapSlice)
if !ok {
return nil, errors.New("invalid type passed to Marshal")
}
w.writeMap(m, "")
w.writeString("\n")
return w.bytes(), err
} | go | {
"resource": ""
} |
q18518 | NewContextWithExtensions | train | func NewContextWithExtensions(name string, parent *Context, extensionHandlers *[]ExtensionHandler) *Context {
return &Context{Name: name, Parent: parent, ExtensionHandlers: extensionHandlers}
} | go | {
"resource": ""
} |
q18519 | NewContext | train | func NewContext(name string, parent *Context) *Context {
if parent != nil {
return &Context{Name: name, Parent: parent, ExtensionHandlers: parent.ExtensionHandlers}
}
return &Context{Name: name, Parent: parent, ExtensionHandlers: nil}
} | go | {
"resource": ""
} |
q18520 | Description | train | func (context *Context) Description() string {
if context.Parent != nil {
return context.Parent.Description() + "." + context.Name
}
return context.Name
} | go | {
"resource": ""
} |
q18521 | analyzeDocument | train | func (s *DocumentLinterV2) analyzeDocument(document *openapi.Document) []*plugins.Message {
messages := make([]*plugins.Message, 0, 0)
for _, pair := range document.Paths.Path {
path := pair.Value
if path.Get != nil {
messages = append(messages, s.analyzeOperation([]string{"paths", pair.Name, "get"}, path.Get)... | go | {
"resource": ""
} |
q18522 | analyzeDefinition | train | func (s *DocumentLinterV2) analyzeDefinition(keys []string, definition *openapi.Schema) []*plugins.Message {
messages := make([]*plugins.Message, 0)
if definition.Description == "" {
messages = append(messages,
&plugins.Message{
Level: plugins.Message_WARNING,
Code: "NODESCRIPTION",
Text: "Definiti... | go | {
"resource": ""
} |
q18523 | NewSchemaFromFile | train | func NewSchemaFromFile(filename string) (schema *Schema, err error) {
file, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
var info yaml.MapSlice
err = yaml.Unmarshal(file, &info)
if err != nil {
return nil, err
}
return NewSchemaFromObject(info), nil
} | go | {
"resource": ""
} |
q18524 | NewDomain | train | func NewDomain(schema *jsonschema.Schema, version string) *Domain {
cc := &Domain{}
cc.TypeModels = make(map[string]*TypeModel, 0)
cc.TypeNameOverrides = make(map[string]string, 0)
cc.PropertyNameOverrides = make(map[string]string, 0)
cc.ObjectTypeRequests = make(map[string]*TypeRequest, 0)
cc.MapTypeRequests = m... | go | {
"resource": ""
} |
q18525 | TypeNameForStub | train | func (domain *Domain) TypeNameForStub(stub string) string {
return domain.Prefix + strings.ToUpper(stub[0:1]) + stub[1:len(stub)]
} | go | {
"resource": ""
} |
q18526 | typeNameForReference | train | func (domain *Domain) typeNameForReference(reference string) string {
parts := strings.Split(reference, "/")
first := parts[0]
last := parts[len(parts)-1]
if first == "#" {
return domain.TypeNameForStub(last)
}
return "Schema"
} | go | {
"resource": ""
} |
q18527 | propertyNameForReference | train | func (domain *Domain) propertyNameForReference(reference string) *string {
parts := strings.Split(reference, "/")
first := parts[0]
last := parts[len(parts)-1]
if first == "#" {
return &last
}
return nil
} | go | {
"resource": ""
} |
q18528 | arrayItemTypeForSchema | train | func (domain *Domain) arrayItemTypeForSchema(propertyName string, schema *jsonschema.Schema) string {
// default
itemTypeName := "Any"
if schema.Items != nil {
if schema.Items.SchemaArray != nil {
if len(*(schema.Items.SchemaArray)) > 0 {
ref := (*schema.Items.SchemaArray)[0].Ref
if ref != nil {
... | go | {
"resource": ""
} |
q18529 | BuildTypeForDefinition | train | func (domain *Domain) BuildTypeForDefinition(
typeName string,
propertyName string,
schema *jsonschema.Schema) *TypeModel {
if (schema.Type == nil) || (*schema.Type.String == "object") {
return domain.buildTypeForDefinitionObject(typeName, propertyName, schema)
}
return nil
} | go | {
"resource": ""
} |
q18530 | Description | train | func (domain *Domain) Description() string {
typeNames := domain.sortedTypeNames()
result := ""
for _, typeName := range typeNames {
result += domain.TypeModels[typeName].description()
}
return result
} | go | {
"resource": ""
} |
q18531 | UnpackMap | train | func UnpackMap(in interface{}) (yaml.MapSlice, bool) {
m, ok := in.(yaml.MapSlice)
if ok {
return m, true
}
// do we have an empty array?
a, ok := in.([]interface{})
if ok && len(a) == 0 {
// if so, return an empty map
return yaml.MapSlice{}, true
}
return nil, false
} | go | {
"resource": ""
} |
q18532 | SortedKeysForMap | train | func SortedKeysForMap(m yaml.MapSlice) []string {
keys := make([]string, 0)
for _, item := range m {
keys = append(keys, item.Key.(string))
}
sort.Strings(keys)
return keys
} | go | {
"resource": ""
} |
q18533 | MapHasKey | train | func MapHasKey(m yaml.MapSlice, key string) bool {
for _, item := range m {
itemKey, ok := item.Key.(string)
if ok && key == itemKey {
return true
}
}
return false
} | go | {
"resource": ""
} |
q18534 | MapValueForKey | train | func MapValueForKey(m yaml.MapSlice, key string) interface{} {
for _, item := range m {
itemKey, ok := item.Key.(string)
if ok && key == itemKey {
return item.Value
}
}
return nil
} | go | {
"resource": ""
} |
q18535 | ConvertInterfaceArrayToStringArray | train | func ConvertInterfaceArrayToStringArray(interfaceArray []interface{}) []string {
stringArray := make([]string, 0)
for _, item := range interfaceArray {
v, ok := item.(string)
if ok {
stringArray = append(stringArray, v)
}
}
return stringArray
} | go | {
"resource": ""
} |
q18536 | MissingKeysInMap | train | func MissingKeysInMap(m yaml.MapSlice, requiredKeys []string) []string {
missingKeys := make([]string, 0)
for _, k := range requiredKeys {
if !MapHasKey(m, k) {
missingKeys = append(missingKeys, k)
}
}
return missingKeys
} | go | {
"resource": ""
} |
q18537 | InvalidKeysInMap | train | func InvalidKeysInMap(m yaml.MapSlice, allowedKeys []string, allowedPatterns []*regexp.Regexp) []string {
invalidKeys := make([]string, 0)
for _, item := range m {
itemKey, ok := item.Key.(string)
if ok {
key := itemKey
found := false
// does the key match an allowed key?
for _, allowedKey := range al... | go | {
"resource": ""
} |
q18538 | StringArrayContainsValue | train | func StringArrayContainsValue(array []string, value string) bool {
for _, item := range array {
if item == value {
return true
}
}
return false
} | go | {
"resource": ""
} |
q18539 | StringArrayContainsValues | train | func StringArrayContainsValues(array []string, values []string) bool {
for _, value := range values {
if !StringArrayContainsValue(array, value) {
return false
}
}
return true
} | go | {
"resource": ""
} |
q18540 | StringValue | train | func StringValue(item interface{}) (value string, ok bool) {
value, ok = item.(string)
if ok {
return value, ok
}
intValue, ok := item.(int)
if ok {
return strconv.Itoa(intValue), true
}
return "", false
} | go | {
"resource": ""
} |
q18541 | NewTypeRequest | train | func NewTypeRequest(name string, propertyName string, schema *jsonschema.Schema) *TypeRequest {
return &TypeRequest{Name: name, PropertyName: propertyName, Schema: schema}
} | go | {
"resource": ""
} |
q18542 | NewTypePropertyWithNameAndType | train | func NewTypePropertyWithNameAndType(name string, typeName string) *TypeProperty {
return &TypeProperty{Name: name, Type: typeName}
} | go | {
"resource": ""
} |
q18543 | NewTypePropertyWithNameTypeAndPattern | train | func NewTypePropertyWithNameTypeAndPattern(name string, typeName string, pattern string) *TypeProperty {
return &TypeProperty{Name: name, Type: typeName, Pattern: pattern}
} | go | {
"resource": ""
} |
q18544 | FieldName | train | func (typeProperty *TypeProperty) FieldName() string {
propertyName := typeProperty.Name
if propertyName == "$ref" {
return "XRef"
}
return strings.Title(snakeCaseToCamelCase(propertyName))
} | go | {
"resource": ""
} |
q18545 | walker | train | func walker(p string, info os.FileInfo, err error) error {
basename := path.Base(p)
if basename != "summary.json" {
return nil
}
data, err := ioutil.ReadFile(p)
if err != nil {
return err
}
var s statistics.DocumentStatistics
err = json.Unmarshal(data, &s)
if err != nil {
return err
}
stats = append(st... | go | {
"resource": ""
} |
q18546 | sendAndExitIfError | train | func sendAndExitIfError(err error, response *plugins.Response) {
if err != nil {
response.Errors = append(response.Errors, err.Error())
sendAndExit(response)
}
} | go | {
"resource": ""
} |
q18547 | sendAndExit | train | func sendAndExit(response *plugins.Response) {
responseBytes, _ := proto.Marshal(response)
os.Stdout.Write(responseBytes)
os.Exit(0)
} | go | {
"resource": ""
} |
q18548 | NewSchemaNumberWithInteger | train | func NewSchemaNumberWithInteger(i int64) *SchemaNumber {
result := &SchemaNumber{}
result.Integer = &i
return result
} | go | {
"resource": ""
} |
q18549 | NewSchemaNumberWithFloat | train | func NewSchemaNumberWithFloat(f float64) *SchemaNumber {
result := &SchemaNumber{}
result.Float = &f
return result
} | go | {
"resource": ""
} |
q18550 | NewSchemaOrBooleanWithSchema | train | func NewSchemaOrBooleanWithSchema(s *Schema) *SchemaOrBoolean {
result := &SchemaOrBoolean{}
result.Schema = s
return result
} | go | {
"resource": ""
} |
q18551 | NewSchemaOrBooleanWithBoolean | train | func NewSchemaOrBooleanWithBoolean(b bool) *SchemaOrBoolean {
result := &SchemaOrBoolean{}
result.Boolean = &b
return result
} | go | {
"resource": ""
} |
q18552 | NewStringOrStringArrayWithString | train | func NewStringOrStringArrayWithString(s string) *StringOrStringArray {
result := &StringOrStringArray{}
result.String = &s
return result
} | go | {
"resource": ""
} |
q18553 | NewStringOrStringArrayWithStringArray | train | func NewStringOrStringArrayWithStringArray(a []string) *StringOrStringArray {
result := &StringOrStringArray{}
result.StringArray = &a
return result
} | go | {
"resource": ""
} |
q18554 | NewSchemaOrSchemaArrayWithSchema | train | func NewSchemaOrSchemaArrayWithSchema(s *Schema) *SchemaOrSchemaArray {
result := &SchemaOrSchemaArray{}
result.Schema = s
return result
} | go | {
"resource": ""
} |
q18555 | NewSchemaOrSchemaArrayWithSchemaArray | train | func NewSchemaOrSchemaArrayWithSchemaArray(a []*Schema) *SchemaOrSchemaArray {
result := &SchemaOrSchemaArray{}
result.SchemaArray = &a
return result
} | go | {
"resource": ""
} |
q18556 | NewNamedSchema | train | func NewNamedSchema(name string, value *Schema) *NamedSchema {
return &NamedSchema{Name: name, Value: value}
} | go | {
"resource": ""
} |
q18557 | namedSchemaArrayElementWithName | train | func namedSchemaArrayElementWithName(array *[]*NamedSchema, name string) *Schema {
if array == nil {
return nil
}
for _, pair := range *array {
if pair.Name == name {
return pair.Value
}
}
return nil
} | go | {
"resource": ""
} |
q18558 | PropertyWithName | train | func (s *Schema) PropertyWithName(name string) *Schema {
return namedSchemaArrayElementWithName(s.Properties, name)
} | go | {
"resource": ""
} |
q18559 | PatternPropertyWithName | train | func (s *Schema) PatternPropertyWithName(name string) *Schema {
return namedSchemaArrayElementWithName(s.PatternProperties, name)
} | go | {
"resource": ""
} |
q18560 | DefinitionWithName | train | func (s *Schema) DefinitionWithName(name string) *Schema {
return namedSchemaArrayElementWithName(s.Definitions, name)
} | go | {
"resource": ""
} |
q18561 | AddProperty | train | func (s *Schema) AddProperty(name string, property *Schema) {
*s.Properties = append(*s.Properties, NewNamedSchema(name, property))
} | go | {
"resource": ""
} |
q18562 | lowerFirst | train | func lowerFirst(s string) string {
if s == "" {
return ""
}
r, n := utf8.DecodeRuneInString(s)
return string(unicode.ToLower(r)) + s[n:]
} | go | {
"resource": ""
} |
q18563 | ReadSection | train | func ReadSection(text string, level int) (section *Section) {
titlePattern := regexp.MustCompile("^" + strings.Repeat("#", level) + " .*$")
subtitlePattern := regexp.MustCompile("^" + strings.Repeat("#", level+1) + " .*$")
section = &Section{Level: level, Text: text}
lines := strings.Split(string(text), "\n")
sub... | go | {
"resource": ""
} |
q18564 | Display | train | func (s *Section) Display(section string) {
if len(s.Children) == 0 {
//fmt.Printf("%s\n", s.Text)
} else {
for i, child := range s.Children {
var subsection string
if section == "" {
subsection = fmt.Sprintf("%d", i)
} else {
subsection = fmt.Sprintf("%s.%d", section, i)
}
fmt.Printf("%-12... | go | {
"resource": ""
} |
q18565 | stripLink | train | func stripLink(input string) (output string) {
stringPattern := regexp.MustCompile("^(.*)$")
stringWithLinkPattern := regexp.MustCompile("^<a .*</a>(.*)$")
if matches := stringWithLinkPattern.FindSubmatch([]byte(input)); matches != nil {
return string(matches[1])
} else if matches := stringPattern.FindSubmatch([]... | go | {
"resource": ""
} |
q18566 | parseFixedFields | train | func parseFixedFields(input string, schemaObject *SchemaObject) {
lines := strings.Split(input, "\n")
for _, line := range lines {
// replace escaped bars with "OR", assuming these are used to describe union types
line = strings.Replace(line, " \\| ", " OR ", -1)
// split the table on the remaining bars
par... | go | {
"resource": ""
} |
q18567 | parsePatternedFields | train | func parsePatternedFields(input string, schemaObject *SchemaObject) {
lines := strings.Split(input, "\n")
for _, line := range lines {
line = strings.Replace(line, " \\| ", " OR ", -1)
parts := strings.Split(line, "|")
if len(parts) > 1 {
fieldName := strings.Trim(stripLink(parts[0]), " ")
fieldName = r... | go | {
"resource": ""
} |
q18568 | NewSchemaModel | train | func NewSchemaModel(filename string) (schemaModel *SchemaModel, err error) {
b, err := ioutil.ReadFile("3.0.1.md")
if err != nil {
return nil, err
}
// divide the specification into sections
document := ReadSection(string(b), 1)
document.Display("")
// read object names and their details
specification := d... | go | {
"resource": ""
} |
q18569 | NewError | train | func NewError(context *Context, message string) *Error {
return &Error{Context: context, Message: message}
} | go | {
"resource": ""
} |
q18570 | Error | train | func (err *Error) Error() string {
if err.Context == nil {
return "ERROR " + err.Message
}
return "ERROR " + err.Context.Description() + " " + err.Message
} | go | {
"resource": ""
} |
q18571 | NewErrorGroupOrNil | train | func NewErrorGroupOrNil(errors []error) error {
if len(errors) == 0 {
return nil
} else if len(errors) == 1 {
return errors[0]
} else {
return &ErrorGroup{Errors: errors}
}
} | go | {
"resource": ""
} |
q18572 | getOpenAPIVersionFromInfo | train | func getOpenAPIVersionFromInfo(info interface{}) int {
m, ok := compiler.UnpackMap(info)
if !ok {
return SourceFormatUnknown
}
swagger, ok := compiler.MapValueForKey(m, "swagger").(string)
if ok && strings.HasPrefix(swagger, "2.0") {
return SourceFormatOpenAPI2
}
openapi, ok := compiler.MapValueForKey(m, "op... | go | {
"resource": ""
} |
q18573 | newGnostic | train | func newGnostic() *Gnostic {
g := &Gnostic{}
// Option fields initialize to their default values.
g.usage = `
Usage: gnostic SOURCE [OPTIONS]
SOURCE is the filename or URL of an API description.
Options:
--pb-out=PATH Write a binary proto to the specified location.
--text-out=PATH Write a text proto ... | go | {
"resource": ""
} |
q18574 | readOptions | train | func (g *Gnostic) readOptions() {
// plugin processing matches patterns of the form "--PLUGIN-out=PATH" and "--PLUGIN_out=PATH"
pluginRegex := regexp.MustCompile("--(.+)[-_]out=(.+)")
// extension processing matches patterns of the form "--x-EXTENSION"
extensionRegex := regexp.MustCompile("--x-(.+)")
for i, arg ... | go | {
"resource": ""
} |
q18575 | validateOptions | train | func (g *Gnostic) validateOptions() {
if g.binaryOutputPath == "" &&
g.textOutputPath == "" &&
g.yamlOutputPath == "" &&
g.jsonOutputPath == "" &&
g.errorOutputPath == "" &&
len(g.pluginCalls) == 0 {
fmt.Fprintf(os.Stderr, "Missing output directives.\n%s\n", g.usage)
os.Exit(-1)
}
if g.sourceName == ""... | go | {
"resource": ""
} |
q18576 | errorBytes | train | func (g *Gnostic) errorBytes(err error) []byte {
return []byte("Errors reading " + g.sourceName + "\n" + err.Error())
} | go | {
"resource": ""
} |
q18577 | readOpenAPIText | train | func (g *Gnostic) readOpenAPIText(bytes []byte) (message proto.Message, err error) {
info, err := compiler.ReadInfoFromBytes(g.sourceName, bytes)
if err != nil {
return nil, err
}
// Determine the OpenAPI version.
g.sourceFormat = getOpenAPIVersionFromInfo(info)
if g.sourceFormat == SourceFormatUnknown {
retu... | go | {
"resource": ""
} |
q18578 | readOpenAPIBinary | train | func (g *Gnostic) readOpenAPIBinary(data []byte) (message proto.Message, err error) {
// try to read an OpenAPI v3 document
documentV3 := &openapi_v3.Document{}
err = proto.Unmarshal(data, documentV3)
if err == nil && strings.HasPrefix(documentV3.Openapi, "3.0") {
g.sourceFormat = SourceFormatOpenAPI3
return do... | go | {
"resource": ""
} |
q18579 | writeBinaryOutput | train | func (g *Gnostic) writeBinaryOutput(message proto.Message) {
protoBytes, err := proto.Marshal(message)
if err != nil {
writeFile(g.errorOutputPath, g.errorBytes(err), g.sourceName, "errors")
defer os.Exit(-1)
} else {
writeFile(g.binaryOutputPath, protoBytes, g.sourceName, "pb")
}
} | go | {
"resource": ""
} |
q18580 | writeTextOutput | train | func (g *Gnostic) writeTextOutput(message proto.Message) {
bytes := []byte(proto.MarshalTextString(message))
writeFile(g.textOutputPath, bytes, g.sourceName, "text")
} | go | {
"resource": ""
} |
q18581 | writeMessagesOutput | train | func (g *Gnostic) writeMessagesOutput(message proto.Message) {
protoBytes, err := proto.Marshal(message)
if err != nil {
writeFile(g.messageOutputPath, g.errorBytes(err), g.sourceName, "errors")
defer os.Exit(-1)
} else {
writeFile(g.messageOutputPath, protoBytes, g.sourceName, "messages.pb")
}
} | go | {
"resource": ""
} |
q18582 | performActions | train | func (g *Gnostic) performActions(message proto.Message) (err error) {
// Optionally resolve internal references.
if g.resolveReferences {
if g.sourceFormat == SourceFormatOpenAPI2 {
document := message.(*openapi_v2.Document)
_, err = document.ResolveReferences(g.sourceName)
} else if g.sourceFormat == Sourc... | go | {
"resource": ""
} |
q18583 | ProcessExtension | train | func ProcessExtension(handleExtension extensionHandler) {
response := &ExtensionHandlerResponse{}
forInputYamlFromOpenapic(
func(version string, extensionName string, yamlInput string) {
var newObject proto.Message
var err error
handled, newObject, err := handleExtension(extensionName, yamlInput)
if !h... | go | {
"resource": ""
} |
q18584 | NewAnnotations | train | func NewAnnotations(in interface{}, context *compiler.Context) (*Annotations, error) {
errors := make([]error, 0)
x := &Annotations{}
m, ok := compiler.UnpackMap(in)
if !ok {
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
errors = append(errors, compiler.NewError(context, message))
} else {
... | go | {
"resource": ""
} |
q18585 | NewAny | train | func NewAny(in interface{}, context *compiler.Context) (*Any, error) {
errors := make([]error, 0)
x := &Any{}
bytes, _ := yaml.Marshal(in)
x.Yaml = string(bytes)
return x, compiler.NewErrorGroupOrNil(errors)
} | go | {
"resource": ""
} |
q18586 | NewAuth | train | func NewAuth(in interface{}, context *compiler.Context) (*Auth, error) {
errors := make([]error, 0)
x := &Auth{}
m, ok := compiler.UnpackMap(in)
if !ok {
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
errors = append(errors, compiler.NewError(context, message))
} else {
allowedKeys := []str... | go | {
"resource": ""
} |
q18587 | NewMediaUpload | train | func NewMediaUpload(in interface{}, context *compiler.Context) (*MediaUpload, error) {
errors := make([]error, 0)
x := &MediaUpload{}
m, ok := compiler.UnpackMap(in)
if !ok {
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
errors = append(errors, compiler.NewError(context, message))
} else {
... | go | {
"resource": ""
} |
q18588 | NewMethods | train | func NewMethods(in interface{}, context *compiler.Context) (*Methods, error) {
errors := make([]error, 0)
x := &Methods{}
m, ok := compiler.UnpackMap(in)
if !ok {
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
errors = append(errors, compiler.NewError(context, message))
} else {
// repeated... | go | {
"resource": ""
} |
q18589 | NewProtocols | train | func NewProtocols(in interface{}, context *compiler.Context) (*Protocols, error) {
errors := make([]error, 0)
x := &Protocols{}
m, ok := compiler.UnpackMap(in)
if !ok {
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
errors = append(errors, compiler.NewError(context, message))
} else {
allow... | go | {
"resource": ""
} |
q18590 | NewResource | train | func NewResource(in interface{}, context *compiler.Context) (*Resource, error) {
errors := make([]error, 0)
x := &Resource{}
m, ok := compiler.UnpackMap(in)
if !ok {
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
errors = append(errors, compiler.NewError(context, message))
} else {
allowedK... | go | {
"resource": ""
} |
q18591 | NewResources | train | func NewResources(in interface{}, context *compiler.Context) (*Resources, error) {
errors := make([]error, 0)
x := &Resources{}
m, ok := compiler.UnpackMap(in)
if !ok {
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
errors = append(errors, compiler.NewError(context, message))
} else {
// re... | go | {
"resource": ""
} |
q18592 | NewScopes | train | func NewScopes(in interface{}, context *compiler.Context) (*Scopes, error) {
errors := make([]error, 0)
x := &Scopes{}
m, ok := compiler.UnpackMap(in)
if !ok {
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
errors = append(errors, compiler.NewError(context, message))
} else {
// repeated Na... | go | {
"resource": ""
} |
q18593 | NewSimple | train | func NewSimple(in interface{}, context *compiler.Context) (*Simple, error) {
errors := make([]error, 0)
x := &Simple{}
m, ok := compiler.UnpackMap(in)
if !ok {
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
errors = append(errors, compiler.NewError(context, message))
} else {
allowedKeys :=... | go | {
"resource": ""
} |
q18594 | NewStringArray | train | func NewStringArray(in interface{}, context *compiler.Context) (*StringArray, error) {
errors := make([]error, 0)
x := &StringArray{}
a, ok := in.([]interface{})
if !ok {
message := fmt.Sprintf("has unexpected value for StringArray: %+v (%T)", in, in)
errors = append(errors, compiler.NewError(context, message))... | go | {
"resource": ""
} |
q18595 | ResolveReferences | train | func (m *MediaUpload) ResolveReferences(root string) (interface{}, error) {
errors := make([]error, 0)
if m.Protocols != nil {
_, err := m.Protocols.ResolveReferences(root)
if err != nil {
errors = append(errors, err)
}
}
return nil, compiler.NewErrorGroupOrNil(errors)
} | go | {
"resource": ""
} |
q18596 | ResolveReferences | train | func (m *Method) ResolveReferences(root string) (interface{}, error) {
errors := make([]error, 0)
if m.Parameters != nil {
_, err := m.Parameters.ResolveReferences(root)
if err != nil {
errors = append(errors, err)
}
}
if m.Request != nil {
_, err := m.Request.ResolveReferences(root)
if err != nil {
... | go | {
"resource": ""
} |
q18597 | ResolveReferences | train | func (m *Methods) ResolveReferences(root string) (interface{}, error) {
errors := make([]error, 0)
for _, item := range m.AdditionalProperties {
if item != nil {
_, err := item.ResolveReferences(root)
if err != nil {
errors = append(errors, err)
}
}
}
return nil, compiler.NewErrorGroupOrNil(errors)... | go | {
"resource": ""
} |
q18598 | ResolveReferences | train | func (m *NamedMethod) ResolveReferences(root string) (interface{}, error) {
errors := make([]error, 0)
if m.Value != nil {
_, err := m.Value.ResolveReferences(root)
if err != nil {
errors = append(errors, err)
}
}
return nil, compiler.NewErrorGroupOrNil(errors)
} | go | {
"resource": ""
} |
q18599 | ResolveReferences | train | func (m *Protocols) ResolveReferences(root string) (interface{}, error) {
errors := make([]error, 0)
if m.Simple != nil {
_, err := m.Simple.ResolveReferences(root)
if err != nil {
errors = append(errors, err)
}
}
if m.Resumable != nil {
_, err := m.Resumable.ResolveReferences(root)
if err != nil {
... | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.