id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
18,500 | graph-gophers/dataloader | trace.go | TraceLoad | func (NoopTracer) TraceLoad(ctx context.Context, key Key) (context.Context, TraceLoadFinishFunc) {
return ctx, func(Thunk) {}
} | go | func (NoopTracer) TraceLoad(ctx context.Context, key Key) (context.Context, TraceLoadFinishFunc) {
return ctx, func(Thunk) {}
} | [
"func",
"(",
"NoopTracer",
")",
"TraceLoad",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"Key",
")",
"(",
"context",
".",
"Context",
",",
"TraceLoadFinishFunc",
")",
"{",
"return",
"ctx",
",",
"func",
"(",
"Thunk",
")",
"{",
"}",
"\n",
"}"
] | // TraceLoad is a noop function | [
"TraceLoad",
"is",
"a",
"noop",
"function"
] | 1232fe340ae7c1ca82f7b43eb35dd7ced94aa085 | https://github.com/graph-gophers/dataloader/blob/1232fe340ae7c1ca82f7b43eb35dd7ced94aa085/trace.go#L66-L68 |
18,501 | graph-gophers/dataloader | trace.go | TraceLoadMany | func (NoopTracer) TraceLoadMany(ctx context.Context, keys Keys) (context.Context, TraceLoadManyFinishFunc) {
return ctx, func(ThunkMany) {}
} | go | func (NoopTracer) TraceLoadMany(ctx context.Context, keys Keys) (context.Context, TraceLoadManyFinishFunc) {
return ctx, func(ThunkMany) {}
} | [
"func",
"(",
"NoopTracer",
")",
"TraceLoadMany",
"(",
"ctx",
"context",
".",
"Context",
",",
"keys",
"Keys",
")",
"(",
"context",
".",
"Context",
",",
"TraceLoadManyFinishFunc",
")",
"{",
"return",
"ctx",
",",
"func",
"(",
"ThunkMany",
")",
"{",
"}",
"\n... | // TraceLoadMany is a noop function | [
"TraceLoadMany",
"is",
"a",
"noop",
"function"
] | 1232fe340ae7c1ca82f7b43eb35dd7ced94aa085 | https://github.com/graph-gophers/dataloader/blob/1232fe340ae7c1ca82f7b43eb35dd7ced94aa085/trace.go#L71-L73 |
18,502 | graph-gophers/dataloader | trace.go | TraceBatch | func (NoopTracer) TraceBatch(ctx context.Context, keys Keys) (context.Context, TraceBatchFinishFunc) {
return ctx, func(result []*Result) {}
} | go | func (NoopTracer) TraceBatch(ctx context.Context, keys Keys) (context.Context, TraceBatchFinishFunc) {
return ctx, func(result []*Result) {}
} | [
"func",
"(",
"NoopTracer",
")",
"TraceBatch",
"(",
"ctx",
"context",
".",
"Context",
",",
"keys",
"Keys",
")",
"(",
"context",
".",
"Context",
",",
"TraceBatchFinishFunc",
")",
"{",
"return",
"ctx",
",",
"func",
"(",
"result",
"[",
"]",
"*",
"Result",
... | // TraceBatch is a noop function | [
"TraceBatch",
"is",
"a",
"noop",
"function"
] | 1232fe340ae7c1ca82f7b43eb35dd7ced94aa085 | https://github.com/graph-gophers/dataloader/blob/1232fe340ae7c1ca82f7b43eb35dd7ced94aa085/trace.go#L76-L78 |
18,503 | googleapis/gnostic | plugins/gnostic-go-generator/main.go | main | 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 | 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... | [
"func",
"main",
"(",
")",
"{",
"env",
",",
"err",
":=",
"plugins",
".",
"NewEnvironment",
"(",
")",
"\n",
"env",
".",
"RespondAndExitIfError",
"(",
"err",
")",
"\n\n",
"packageName",
",",
"err",
":=",
"resolvePackageName",
"(",
"env",
".",
"Request",
"."... | // This is the main function for the code generation plugin. | [
"This",
"is",
"the",
"main",
"function",
"for",
"the",
"code",
"generation",
"plugin",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/plugins/gnostic-go-generator/main.go#L32-L79 |
18,504 | googleapis/gnostic | plugins/gnostic-go-generator/main.go | resolvePackageName | 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 | 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
} | [
"func",
"resolvePackageName",
"(",
"p",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"p",
",",
"err",
":=",
"filepath",
".",
"Abs",
"(",
"p",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"p",
"=",
"filepath",
".",
"Base",
"(",
"p",
")",
"... | // resolvePackageName converts a path to a valid package name or
// error if path can't be resolved or resolves to an invalid package name. | [
"resolvePackageName",
"converts",
"a",
"path",
"to",
"a",
"valid",
"package",
"name",
"or",
"error",
"if",
"path",
"can",
"t",
"be",
"resolved",
"or",
"resolves",
"to",
"an",
"invalid",
"package",
"name",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/plugins/gnostic-go-generator/main.go#L83-L93 |
18,505 | googleapis/gnostic | printer/code.go | Print | 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 | 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"
} | [
"func",
"(",
"c",
"*",
"Code",
")",
"Print",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"len",
"(",
"args",
")",
">",
"0",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"c",
".",
"indent",
";",
"i",
"++",
"{",
"c",
".",
"text... | // Print adds a line of code using the current indentation. Accepts printf-style format strings and arguments. | [
"Print",
"adds",
"a",
"line",
"of",
"code",
"using",
"the",
"current",
"indentation",
".",
"Accepts",
"printf",
"-",
"style",
"format",
"strings",
"and",
"arguments",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/printer/code.go#L31-L39 |
18,506 | googleapis/gnostic | printer/code.go | PrintIf | 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 | 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"
} | [
"func",
"(",
"c",
"*",
"Code",
")",
"PrintIf",
"(",
"condition",
"bool",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"!",
"condition",
"{",
"return",
"\n",
"}",
"\n",
"if",
"len",
"(",
"args",
")",
">",
"0",
"{",
"for",
"i",
":="... | // PrintIf adds a line of code using the current indentation if a condition is true. Accepts printf-style format strings and arguments. | [
"PrintIf",
"adds",
"a",
"line",
"of",
"code",
"using",
"the",
"current",
"indentation",
"if",
"a",
"condition",
"is",
"true",
".",
"Accepts",
"printf",
"-",
"style",
"format",
"strings",
"and",
"arguments",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/printer/code.go#L42-L53 |
18,507 | googleapis/gnostic | jsonschema/operations.go | IsEmpty | 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 | 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... | [
"func",
"(",
"schema",
"*",
"Schema",
")",
"IsEmpty",
"(",
")",
"bool",
"{",
"return",
"(",
"schema",
".",
"Schema",
"==",
"nil",
")",
"&&",
"(",
"schema",
".",
"ID",
"==",
"nil",
")",
"&&",
"(",
"schema",
".",
"MultipleOf",
"==",
"nil",
")",
"&&... | //
// OPERATIONS
// The following methods perform operations on Schemas.
//
// IsEmpty returns true if no members of the Schema are specified. | [
"OPERATIONS",
"The",
"following",
"methods",
"perform",
"operations",
"on",
"Schemas",
".",
"IsEmpty",
"returns",
"true",
"if",
"no",
"members",
"of",
"the",
"Schema",
"are",
"specified",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/operations.go#L29-L64 |
18,508 | googleapis/gnostic | jsonschema/operations.go | IsEqual | func (schema *Schema) IsEqual(schema2 *Schema) bool {
return schema.String() == schema2.String()
} | go | func (schema *Schema) IsEqual(schema2 *Schema) bool {
return schema.String() == schema2.String()
} | [
"func",
"(",
"schema",
"*",
"Schema",
")",
"IsEqual",
"(",
"schema2",
"*",
"Schema",
")",
"bool",
"{",
"return",
"schema",
".",
"String",
"(",
")",
"==",
"schema2",
".",
"String",
"(",
")",
"\n",
"}"
] | // IsEqual returns true if two schemas are equal. | [
"IsEqual",
"returns",
"true",
"if",
"two",
"schemas",
"are",
"equal",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/operations.go#L67-L69 |
18,509 | googleapis/gnostic | jsonschema/operations.go | applyToSchemas | 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 | 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... | [
"func",
"(",
"schema",
"*",
"Schema",
")",
"applyToSchemas",
"(",
"operation",
"SchemaOperation",
",",
"context",
"string",
")",
"{",
"if",
"schema",
".",
"AdditionalItems",
"!=",
"nil",
"{",
"s",
":=",
"schema",
".",
"AdditionalItems",
".",
"Schema",
"\n",
... | // Applies a specified function to a Schema and all of the Schemas that it contains. | [
"Applies",
"a",
"specified",
"function",
"to",
"a",
"Schema",
"and",
"all",
"of",
"the",
"Schemas",
"that",
"it",
"contains",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/operations.go#L75-L151 |
18,510 | googleapis/gnostic | jsonschema/operations.go | TypeIs | 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 | 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... | [
"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",
"!=",
"... | // TypeIs returns true if the Type of a Schema includes the specified type | [
"TypeIs",
"returns",
"true",
"if",
"the",
"Type",
"of",
"a",
"Schema",
"includes",
"the",
"specified",
"type"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/operations.go#L260-L274 |
18,511 | googleapis/gnostic | jsonschema/operations.go | resolveJSONPointer | 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 | 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... | [
"func",
"(",
"schema",
"*",
"Schema",
")",
"resolveJSONPointer",
"(",
"ref",
"string",
")",
"(",
"result",
"*",
"Schema",
",",
"err",
"error",
")",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"ref",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(... | // resolveJSONPointer resolves JSON pointers.
// This current implementation is very crude and custom for OpenAPI 2.0 schemas.
// It panics for any pointer that it is unable to resolve. | [
"resolveJSONPointer",
"resolves",
"JSON",
"pointers",
".",
"This",
"current",
"implementation",
"is",
"very",
"crude",
"and",
"custom",
"for",
"OpenAPI",
"2",
".",
"0",
"schemas",
".",
"It",
"panics",
"for",
"any",
"pointer",
"that",
"it",
"is",
"unable",
"t... | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/operations.go#L312-L351 |
18,512 | googleapis/gnostic | jsonschema/operations.go | ResolveAllOfs | 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 | 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")
} | [
"func",
"(",
"schema",
"*",
"Schema",
")",
"ResolveAllOfs",
"(",
")",
"{",
"schema",
".",
"applyToSchemas",
"(",
"func",
"(",
"schema",
"*",
"Schema",
",",
"context",
"string",
")",
"{",
"if",
"schema",
".",
"AllOf",
"!=",
"nil",
"{",
"for",
"_",
","... | // ResolveAllOfs replaces "allOf" elements by merging their properties into the parent Schema. | [
"ResolveAllOfs",
"replaces",
"allOf",
"elements",
"by",
"merging",
"their",
"properties",
"into",
"the",
"parent",
"Schema",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/operations.go#L354-L364 |
18,513 | googleapis/gnostic | jsonschema/operations.go | ResolveAnyOfs | func (schema *Schema) ResolveAnyOfs() {
schema.applyToSchemas(
func(schema *Schema, context string) {
if schema.AnyOf != nil {
schema.OneOf = schema.AnyOf
schema.AnyOf = nil
}
}, "resolveAnyOfs")
} | go | func (schema *Schema) ResolveAnyOfs() {
schema.applyToSchemas(
func(schema *Schema, context string) {
if schema.AnyOf != nil {
schema.OneOf = schema.AnyOf
schema.AnyOf = nil
}
}, "resolveAnyOfs")
} | [
"func",
"(",
"schema",
"*",
"Schema",
")",
"ResolveAnyOfs",
"(",
")",
"{",
"schema",
".",
"applyToSchemas",
"(",
"func",
"(",
"schema",
"*",
"Schema",
",",
"context",
"string",
")",
"{",
"if",
"schema",
".",
"AnyOf",
"!=",
"nil",
"{",
"schema",
".",
... | // ResolveAnyOfs replaces all "anyOf" elements with "oneOf". | [
"ResolveAnyOfs",
"replaces",
"all",
"anyOf",
"elements",
"with",
"oneOf",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/operations.go#L367-L375 |
18,514 | googleapis/gnostic | jsonschema/operations.go | CopyOfficialSchemaProperty | 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 | 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)}))
} | [
"func",
"(",
"schema",
"*",
"Schema",
")",
"CopyOfficialSchemaProperty",
"(",
"name",
"string",
")",
"{",
"*",
"schema",
".",
"Properties",
"=",
"append",
"(",
"*",
"schema",
".",
"Properties",
",",
"NewNamedSchema",
"(",
"name",
",",
"&",
"Schema",
"{",
... | // CopyOfficialSchemaProperty copies a named property from the official JSON Schema definition | [
"CopyOfficialSchemaProperty",
"copies",
"a",
"named",
"property",
"from",
"the",
"official",
"JSON",
"Schema",
"definition"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/operations.go#L383-L387 |
18,515 | googleapis/gnostic | jsonschema/operations.go | CopyOfficialSchemaProperties | func (schema *Schema) CopyOfficialSchemaProperties(names []string) {
for _, name := range names {
schema.CopyOfficialSchemaProperty(name)
}
} | go | func (schema *Schema) CopyOfficialSchemaProperties(names []string) {
for _, name := range names {
schema.CopyOfficialSchemaProperty(name)
}
} | [
"func",
"(",
"schema",
"*",
"Schema",
")",
"CopyOfficialSchemaProperties",
"(",
"names",
"[",
"]",
"string",
")",
"{",
"for",
"_",
",",
"name",
":=",
"range",
"names",
"{",
"schema",
".",
"CopyOfficialSchemaProperty",
"(",
"name",
")",
"\n",
"}",
"\n",
"... | // CopyOfficialSchemaProperties copies named properties from the official JSON Schema definition | [
"CopyOfficialSchemaProperties",
"copies",
"named",
"properties",
"from",
"the",
"official",
"JSON",
"Schema",
"definition"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/operations.go#L390-L394 |
18,516 | googleapis/gnostic | jsonwriter/writer.go | escape | func escape(s string) string {
s = strings.Replace(s, "\n", "\\n", -1)
s = strings.Replace(s, "\"", "\\\"", -1)
return s
} | go | func escape(s string) string {
s = strings.Replace(s, "\n", "\\n", -1)
s = strings.Replace(s, "\"", "\\\"", -1)
return s
} | [
"func",
"escape",
"(",
"s",
"string",
")",
"string",
"{",
"s",
"=",
"strings",
".",
"Replace",
"(",
"s",
",",
"\"",
"\\n",
"\"",
",",
"\"",
"\\\\",
"\"",
",",
"-",
"1",
")",
"\n",
"s",
"=",
"strings",
".",
"Replace",
"(",
"s",
",",
"\"",
"\\\... | // basic escaping, will need to be improved or replaced | [
"basic",
"escaping",
"will",
"need",
"to",
"be",
"improved",
"or",
"replaced"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonwriter/writer.go#L29-L33 |
18,517 | googleapis/gnostic | jsonwriter/writer.go | Marshal | 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 | 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
} | [
"func",
"Marshal",
"(",
"in",
"interface",
"{",
"}",
")",
"(",
"out",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"w",
"writer",
"\n",
"m",
",",
"ok",
":=",
"in",
".",
"(",
"yaml",
".",
"MapSlice",
")",
"\n",
"if",
"!",
"ok",
"{",... | // Marshal writes a yaml.MapSlice as JSON | [
"Marshal",
"writes",
"a",
"yaml",
".",
"MapSlice",
"as",
"JSON"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonwriter/writer.go#L159-L168 |
18,518 | googleapis/gnostic | compiler/context.go | NewContextWithExtensions | func NewContextWithExtensions(name string, parent *Context, extensionHandlers *[]ExtensionHandler) *Context {
return &Context{Name: name, Parent: parent, ExtensionHandlers: extensionHandlers}
} | go | func NewContextWithExtensions(name string, parent *Context, extensionHandlers *[]ExtensionHandler) *Context {
return &Context{Name: name, Parent: parent, ExtensionHandlers: extensionHandlers}
} | [
"func",
"NewContextWithExtensions",
"(",
"name",
"string",
",",
"parent",
"*",
"Context",
",",
"extensionHandlers",
"*",
"[",
"]",
"ExtensionHandler",
")",
"*",
"Context",
"{",
"return",
"&",
"Context",
"{",
"Name",
":",
"name",
",",
"Parent",
":",
"parent",... | // NewContextWithExtensions returns a new object representing the compiler state | [
"NewContextWithExtensions",
"returns",
"a",
"new",
"object",
"representing",
"the",
"compiler",
"state"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/context.go#L25-L27 |
18,519 | googleapis/gnostic | compiler/context.go | NewContext | 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 | 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}
} | [
"func",
"NewContext",
"(",
"name",
"string",
",",
"parent",
"*",
"Context",
")",
"*",
"Context",
"{",
"if",
"parent",
"!=",
"nil",
"{",
"return",
"&",
"Context",
"{",
"Name",
":",
"name",
",",
"Parent",
":",
"parent",
",",
"ExtensionHandlers",
":",
"pa... | // NewContext returns a new object representing the compiler state | [
"NewContext",
"returns",
"a",
"new",
"object",
"representing",
"the",
"compiler",
"state"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/context.go#L30-L35 |
18,520 | googleapis/gnostic | compiler/context.go | Description | func (context *Context) Description() string {
if context.Parent != nil {
return context.Parent.Description() + "." + context.Name
}
return context.Name
} | go | func (context *Context) Description() string {
if context.Parent != nil {
return context.Parent.Description() + "." + context.Name
}
return context.Name
} | [
"func",
"(",
"context",
"*",
"Context",
")",
"Description",
"(",
")",
"string",
"{",
"if",
"context",
".",
"Parent",
"!=",
"nil",
"{",
"return",
"context",
".",
"Parent",
".",
"Description",
"(",
")",
"+",
"\"",
"\"",
"+",
"context",
".",
"Name",
"\n... | // Description returns a text description of the compiler state | [
"Description",
"returns",
"a",
"text",
"description",
"of",
"the",
"compiler",
"state"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/context.go#L38-L43 |
18,521 | googleapis/gnostic | linters/go/gnostic-lint-descriptions/linter_v2.go | analyzeDocument | 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 | 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)... | [
"func",
"(",
"s",
"*",
"DocumentLinterV2",
")",
"analyzeDocument",
"(",
"document",
"*",
"openapi",
".",
"Document",
")",
"[",
"]",
"*",
"plugins",
".",
"Message",
"{",
"messages",
":=",
"make",
"(",
"[",
"]",
"*",
"plugins",
".",
"Message",
",",
"0",
... | // Analyze an OpenAPI description. | [
"Analyze",
"an",
"OpenAPI",
"description",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/linters/go/gnostic-lint-descriptions/linter_v2.go#L36-L60 |
18,522 | googleapis/gnostic | linters/go/gnostic-lint-descriptions/linter_v2.go | analyzeDefinition | 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 | 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... | [
"func",
"(",
"s",
"*",
"DocumentLinterV2",
")",
"analyzeDefinition",
"(",
"keys",
"[",
"]",
"string",
",",
"definition",
"*",
"openapi",
".",
"Schema",
")",
"[",
"]",
"*",
"plugins",
".",
"Message",
"{",
"messages",
":=",
"make",
"(",
"[",
"]",
"*",
... | // Analyze a definition in an OpenAPI description. | [
"Analyze",
"a",
"definition",
"in",
"an",
"OpenAPI",
"description",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/linters/go/gnostic-lint-descriptions/linter_v2.go#L155-L180 |
18,523 | googleapis/gnostic | jsonschema/reader.go | NewSchemaFromFile | 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 | 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
} | [
"func",
"NewSchemaFromFile",
"(",
"filename",
"string",
")",
"(",
"schema",
"*",
"Schema",
",",
"err",
"error",
")",
"{",
"file",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // NewSchemaFromFile reads a schema from a file.
// Currently this assumes that schemas are stored in the source distribution of this project. | [
"NewSchemaFromFile",
"reads",
"a",
"schema",
"from",
"a",
"file",
".",
"Currently",
"this",
"assumes",
"that",
"schemas",
"are",
"stored",
"in",
"the",
"source",
"distribution",
"of",
"this",
"project",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/reader.go#L30-L41 |
18,524 | googleapis/gnostic | generate-gnostic/domain.go | NewDomain | 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 | 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... | [
"func",
"NewDomain",
"(",
"schema",
"*",
"jsonschema",
".",
"Schema",
",",
"version",
"string",
")",
"*",
"Domain",
"{",
"cc",
":=",
"&",
"Domain",
"{",
"}",
"\n",
"cc",
".",
"TypeModels",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"TypeModel"... | // NewDomain creates a domain representation. | [
"NewDomain",
"creates",
"a",
"domain",
"representation",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/generate-gnostic/domain.go#L40-L50 |
18,525 | googleapis/gnostic | generate-gnostic/domain.go | TypeNameForStub | func (domain *Domain) TypeNameForStub(stub string) string {
return domain.Prefix + strings.ToUpper(stub[0:1]) + stub[1:len(stub)]
} | go | func (domain *Domain) TypeNameForStub(stub string) string {
return domain.Prefix + strings.ToUpper(stub[0:1]) + stub[1:len(stub)]
} | [
"func",
"(",
"domain",
"*",
"Domain",
")",
"TypeNameForStub",
"(",
"stub",
"string",
")",
"string",
"{",
"return",
"domain",
".",
"Prefix",
"+",
"strings",
".",
"ToUpper",
"(",
"stub",
"[",
"0",
":",
"1",
"]",
")",
"+",
"stub",
"[",
"1",
":",
"len"... | // TypeNameForStub returns a capitalized name to use for a generated type. | [
"TypeNameForStub",
"returns",
"a",
"capitalized",
"name",
"to",
"use",
"for",
"a",
"generated",
"type",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/generate-gnostic/domain.go#L53-L57 |
18,526 | googleapis/gnostic | generate-gnostic/domain.go | typeNameForReference | 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 | 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"
} | [
"func",
"(",
"domain",
"*",
"Domain",
")",
"typeNameForReference",
"(",
"reference",
"string",
")",
"string",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"reference",
",",
"\"",
"\"",
")",
"\n",
"first",
":=",
"parts",
"[",
"0",
"]",
"\n",
"last"... | // typeNameForReference returns a capitalized name to use for a generated type based on a JSON reference | [
"typeNameForReference",
"returns",
"a",
"capitalized",
"name",
"to",
"use",
"for",
"a",
"generated",
"type",
"based",
"on",
"a",
"JSON",
"reference"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/generate-gnostic/domain.go#L60-L68 |
18,527 | googleapis/gnostic | generate-gnostic/domain.go | propertyNameForReference | 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 | 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
} | [
"func",
"(",
"domain",
"*",
"Domain",
")",
"propertyNameForReference",
"(",
"reference",
"string",
")",
"*",
"string",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"reference",
",",
"\"",
"\"",
")",
"\n",
"first",
":=",
"parts",
"[",
"0",
"]",
"\n... | // propertyNameForReference returns a property name to use for a JSON reference | [
"propertyNameForReference",
"returns",
"a",
"property",
"name",
"to",
"use",
"for",
"a",
"JSON",
"reference"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/generate-gnostic/domain.go#L71-L79 |
18,528 | googleapis/gnostic | generate-gnostic/domain.go | arrayItemTypeForSchema | 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 | 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 {
... | [
"func",
"(",
"domain",
"*",
"Domain",
")",
"arrayItemTypeForSchema",
"(",
"propertyName",
"string",
",",
"schema",
"*",
"jsonschema",
".",
"Schema",
")",
"string",
"{",
"// default",
"itemTypeName",
":=",
"\"",
"\"",
"\n\n",
"if",
"schema",
".",
"Items",
"!=... | // arrayItemTypeForSchema determines the item type for arrays defined by a schema | [
"arrayItemTypeForSchema",
"determines",
"the",
"item",
"type",
"for",
"arrays",
"defined",
"by",
"a",
"schema"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/generate-gnostic/domain.go#L82-L135 |
18,529 | googleapis/gnostic | generate-gnostic/domain.go | BuildTypeForDefinition | 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 | 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
} | [
"func",
"(",
"domain",
"*",
"Domain",
")",
"BuildTypeForDefinition",
"(",
"typeName",
"string",
",",
"propertyName",
"string",
",",
"schema",
"*",
"jsonschema",
".",
"Schema",
")",
"*",
"TypeModel",
"{",
"if",
"(",
"schema",
".",
"Type",
"==",
"nil",
")",
... | // BuildTypeForDefinition creates a type representation for a schema definition. | [
"BuildTypeForDefinition",
"creates",
"a",
"type",
"representation",
"for",
"a",
"schema",
"definition",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/generate-gnostic/domain.go#L479-L487 |
18,530 | googleapis/gnostic | generate-gnostic/domain.go | Description | func (domain *Domain) Description() string {
typeNames := domain.sortedTypeNames()
result := ""
for _, typeName := range typeNames {
result += domain.TypeModels[typeName].description()
}
return result
} | go | func (domain *Domain) Description() string {
typeNames := domain.sortedTypeNames()
result := ""
for _, typeName := range typeNames {
result += domain.TypeModels[typeName].description()
}
return result
} | [
"func",
"(",
"domain",
"*",
"Domain",
")",
"Description",
"(",
")",
"string",
"{",
"typeNames",
":=",
"domain",
".",
"sortedTypeNames",
"(",
")",
"\n",
"result",
":=",
"\"",
"\"",
"\n",
"for",
"_",
",",
"typeName",
":=",
"range",
"typeNames",
"{",
"res... | // Description returns a string representation of a domain. | [
"Description",
"returns",
"a",
"string",
"representation",
"of",
"a",
"domain",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/generate-gnostic/domain.go#L617-L624 |
18,531 | googleapis/gnostic | compiler/helpers.go | UnpackMap | 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 | 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
} | [
"func",
"UnpackMap",
"(",
"in",
"interface",
"{",
"}",
")",
"(",
"yaml",
".",
"MapSlice",
",",
"bool",
")",
"{",
"m",
",",
"ok",
":=",
"in",
".",
"(",
"yaml",
".",
"MapSlice",
")",
"\n",
"if",
"ok",
"{",
"return",
"m",
",",
"true",
"\n",
"}",
... | // compiler helper functions, usually called from generated code
// UnpackMap gets a yaml.MapSlice if possible. | [
"compiler",
"helper",
"functions",
"usually",
"called",
"from",
"generated",
"code",
"UnpackMap",
"gets",
"a",
"yaml",
".",
"MapSlice",
"if",
"possible",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/helpers.go#L28-L40 |
18,532 | googleapis/gnostic | compiler/helpers.go | SortedKeysForMap | 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 | 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
} | [
"func",
"SortedKeysForMap",
"(",
"m",
"yaml",
".",
"MapSlice",
")",
"[",
"]",
"string",
"{",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"for",
"_",
",",
"item",
":=",
"range",
"m",
"{",
"keys",
"=",
"append",
"(",
"keys",... | // SortedKeysForMap returns the sorted keys of a yaml.MapSlice. | [
"SortedKeysForMap",
"returns",
"the",
"sorted",
"keys",
"of",
"a",
"yaml",
".",
"MapSlice",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/helpers.go#L43-L50 |
18,533 | googleapis/gnostic | compiler/helpers.go | MapHasKey | 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 | 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
} | [
"func",
"MapHasKey",
"(",
"m",
"yaml",
".",
"MapSlice",
",",
"key",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"item",
":=",
"range",
"m",
"{",
"itemKey",
",",
"ok",
":=",
"item",
".",
"Key",
".",
"(",
"string",
")",
"\n",
"if",
"ok",
"&&",
"... | // MapHasKey returns true if a yaml.MapSlice contains a specified key. | [
"MapHasKey",
"returns",
"true",
"if",
"a",
"yaml",
".",
"MapSlice",
"contains",
"a",
"specified",
"key",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/helpers.go#L53-L61 |
18,534 | googleapis/gnostic | compiler/helpers.go | MapValueForKey | 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 | 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
} | [
"func",
"MapValueForKey",
"(",
"m",
"yaml",
".",
"MapSlice",
",",
"key",
"string",
")",
"interface",
"{",
"}",
"{",
"for",
"_",
",",
"item",
":=",
"range",
"m",
"{",
"itemKey",
",",
"ok",
":=",
"item",
".",
"Key",
".",
"(",
"string",
")",
"\n",
"... | // MapValueForKey gets the value of a map value for a specified key. | [
"MapValueForKey",
"gets",
"the",
"value",
"of",
"a",
"map",
"value",
"for",
"a",
"specified",
"key",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/helpers.go#L64-L72 |
18,535 | googleapis/gnostic | compiler/helpers.go | ConvertInterfaceArrayToStringArray | 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 | 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
} | [
"func",
"ConvertInterfaceArrayToStringArray",
"(",
"interfaceArray",
"[",
"]",
"interface",
"{",
"}",
")",
"[",
"]",
"string",
"{",
"stringArray",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"for",
"_",
",",
"item",
":=",
"range",
"interf... | // ConvertInterfaceArrayToStringArray converts an array of interfaces to an array of strings, if possible. | [
"ConvertInterfaceArrayToStringArray",
"converts",
"an",
"array",
"of",
"interfaces",
"to",
"an",
"array",
"of",
"strings",
"if",
"possible",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/helpers.go#L75-L84 |
18,536 | googleapis/gnostic | compiler/helpers.go | MissingKeysInMap | 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 | 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
} | [
"func",
"MissingKeysInMap",
"(",
"m",
"yaml",
".",
"MapSlice",
",",
"requiredKeys",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"missingKeys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"for",
"_",
",",
"k",
":=",
"range",
"r... | // MissingKeysInMap identifies which keys from a list of required keys are not in a map. | [
"MissingKeysInMap",
"identifies",
"which",
"keys",
"from",
"a",
"list",
"of",
"required",
"keys",
"are",
"not",
"in",
"a",
"map",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/helpers.go#L87-L95 |
18,537 | googleapis/gnostic | compiler/helpers.go | InvalidKeysInMap | 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 | 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... | [
"func",
"InvalidKeysInMap",
"(",
"m",
"yaml",
".",
"MapSlice",
",",
"allowedKeys",
"[",
"]",
"string",
",",
"allowedPatterns",
"[",
"]",
"*",
"regexp",
".",
"Regexp",
")",
"[",
"]",
"string",
"{",
"invalidKeys",
":=",
"make",
"(",
"[",
"]",
"string",
"... | // InvalidKeysInMap returns keys in a map that don't match a list of allowed keys and patterns. | [
"InvalidKeysInMap",
"returns",
"keys",
"in",
"a",
"map",
"that",
"don",
"t",
"match",
"a",
"list",
"of",
"allowed",
"keys",
"and",
"patterns",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/helpers.go#L98-L127 |
18,538 | googleapis/gnostic | compiler/helpers.go | StringArrayContainsValue | func StringArrayContainsValue(array []string, value string) bool {
for _, item := range array {
if item == value {
return true
}
}
return false
} | go | func StringArrayContainsValue(array []string, value string) bool {
for _, item := range array {
if item == value {
return true
}
}
return false
} | [
"func",
"StringArrayContainsValue",
"(",
"array",
"[",
"]",
"string",
",",
"value",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"item",
":=",
"range",
"array",
"{",
"if",
"item",
"==",
"value",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"ret... | // StringArrayContainsValue returns true if a string array contains a specified value. | [
"StringArrayContainsValue",
"returns",
"true",
"if",
"a",
"string",
"array",
"contains",
"a",
"specified",
"value",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/helpers.go#L167-L174 |
18,539 | googleapis/gnostic | compiler/helpers.go | StringArrayContainsValues | func StringArrayContainsValues(array []string, values []string) bool {
for _, value := range values {
if !StringArrayContainsValue(array, value) {
return false
}
}
return true
} | go | func StringArrayContainsValues(array []string, values []string) bool {
for _, value := range values {
if !StringArrayContainsValue(array, value) {
return false
}
}
return true
} | [
"func",
"StringArrayContainsValues",
"(",
"array",
"[",
"]",
"string",
",",
"values",
"[",
"]",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"value",
":=",
"range",
"values",
"{",
"if",
"!",
"StringArrayContainsValue",
"(",
"array",
",",
"value",
")",
"{... | // StringArrayContainsValues returns true if a string array contains all of a list of specified values. | [
"StringArrayContainsValues",
"returns",
"true",
"if",
"a",
"string",
"array",
"contains",
"all",
"of",
"a",
"list",
"of",
"specified",
"values",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/helpers.go#L177-L184 |
18,540 | googleapis/gnostic | compiler/helpers.go | StringValue | 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 | 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
} | [
"func",
"StringValue",
"(",
"item",
"interface",
"{",
"}",
")",
"(",
"value",
"string",
",",
"ok",
"bool",
")",
"{",
"value",
",",
"ok",
"=",
"item",
".",
"(",
"string",
")",
"\n",
"if",
"ok",
"{",
"return",
"value",
",",
"ok",
"\n",
"}",
"\n",
... | // StringValue returns the string value of an item. | [
"StringValue",
"returns",
"the",
"string",
"value",
"of",
"an",
"item",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/helpers.go#L187-L197 |
18,541 | googleapis/gnostic | generate-gnostic/types.go | NewTypeRequest | func NewTypeRequest(name string, propertyName string, schema *jsonschema.Schema) *TypeRequest {
return &TypeRequest{Name: name, PropertyName: propertyName, Schema: schema}
} | go | func NewTypeRequest(name string, propertyName string, schema *jsonschema.Schema) *TypeRequest {
return &TypeRequest{Name: name, PropertyName: propertyName, Schema: schema}
} | [
"func",
"NewTypeRequest",
"(",
"name",
"string",
",",
"propertyName",
"string",
",",
"schema",
"*",
"jsonschema",
".",
"Schema",
")",
"*",
"TypeRequest",
"{",
"return",
"&",
"TypeRequest",
"{",
"Name",
":",
"name",
",",
"PropertyName",
":",
"propertyName",
"... | // NewTypeRequest creates a TypeRequest. | [
"NewTypeRequest",
"creates",
"a",
"TypeRequest",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/generate-gnostic/types.go#L35-L37 |
18,542 | googleapis/gnostic | generate-gnostic/types.go | NewTypePropertyWithNameAndType | func NewTypePropertyWithNameAndType(name string, typeName string) *TypeProperty {
return &TypeProperty{Name: name, Type: typeName}
} | go | func NewTypePropertyWithNameAndType(name string, typeName string) *TypeProperty {
return &TypeProperty{Name: name, Type: typeName}
} | [
"func",
"NewTypePropertyWithNameAndType",
"(",
"name",
"string",
",",
"typeName",
"string",
")",
"*",
"TypeProperty",
"{",
"return",
"&",
"TypeProperty",
"{",
"Name",
":",
"name",
",",
"Type",
":",
"typeName",
"}",
"\n",
"}"
] | // NewTypePropertyWithNameAndType creates a TypeProperty | [
"NewTypePropertyWithNameAndType",
"creates",
"a",
"TypeProperty"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/generate-gnostic/types.go#L70-L72 |
18,543 | googleapis/gnostic | generate-gnostic/types.go | NewTypePropertyWithNameTypeAndPattern | func NewTypePropertyWithNameTypeAndPattern(name string, typeName string, pattern string) *TypeProperty {
return &TypeProperty{Name: name, Type: typeName, Pattern: pattern}
} | go | func NewTypePropertyWithNameTypeAndPattern(name string, typeName string, pattern string) *TypeProperty {
return &TypeProperty{Name: name, Type: typeName, Pattern: pattern}
} | [
"func",
"NewTypePropertyWithNameTypeAndPattern",
"(",
"name",
"string",
",",
"typeName",
"string",
",",
"pattern",
"string",
")",
"*",
"TypeProperty",
"{",
"return",
"&",
"TypeProperty",
"{",
"Name",
":",
"name",
",",
"Type",
":",
"typeName",
",",
"Pattern",
"... | // NewTypePropertyWithNameTypeAndPattern creates a TypeProperty | [
"NewTypePropertyWithNameTypeAndPattern",
"creates",
"a",
"TypeProperty"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/generate-gnostic/types.go#L75-L77 |
18,544 | googleapis/gnostic | generate-gnostic/types.go | FieldName | func (typeProperty *TypeProperty) FieldName() string {
propertyName := typeProperty.Name
if propertyName == "$ref" {
return "XRef"
}
return strings.Title(snakeCaseToCamelCase(propertyName))
} | go | func (typeProperty *TypeProperty) FieldName() string {
propertyName := typeProperty.Name
if propertyName == "$ref" {
return "XRef"
}
return strings.Title(snakeCaseToCamelCase(propertyName))
} | [
"func",
"(",
"typeProperty",
"*",
"TypeProperty",
")",
"FieldName",
"(",
")",
"string",
"{",
"propertyName",
":=",
"typeProperty",
".",
"Name",
"\n",
"if",
"propertyName",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"strings",
... | // FieldName returns the message field name to use for a property. | [
"FieldName",
"returns",
"the",
"message",
"field",
"name",
"to",
"use",
"for",
"a",
"property",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/generate-gnostic/types.go#L80-L86 |
18,545 | googleapis/gnostic | plugins/gnostic-analyze/summarize/main.go | walker | 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 | 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... | [
"func",
"walker",
"(",
"p",
"string",
",",
"info",
"os",
".",
"FileInfo",
",",
"err",
"error",
")",
"error",
"{",
"basename",
":=",
"path",
".",
"Base",
"(",
"p",
")",
"\n",
"if",
"basename",
"!=",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n... | // walker is called for each summary file found. | [
"walker",
"is",
"called",
"for",
"each",
"summary",
"file",
"found",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/plugins/gnostic-analyze/summarize/main.go#L34-L50 |
18,546 | googleapis/gnostic | plugins/gnostic-analyze/main.go | sendAndExitIfError | func sendAndExitIfError(err error, response *plugins.Response) {
if err != nil {
response.Errors = append(response.Errors, err.Error())
sendAndExit(response)
}
} | go | func sendAndExitIfError(err error, response *plugins.Response) {
if err != nil {
response.Errors = append(response.Errors, err.Error())
sendAndExit(response)
}
} | [
"func",
"sendAndExitIfError",
"(",
"err",
"error",
",",
"response",
"*",
"plugins",
".",
"Response",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"response",
".",
"Errors",
"=",
"append",
"(",
"response",
".",
"Errors",
",",
"err",
".",
"Error",
"(",
")",
... | // Record an error, then serialize and return a response. | [
"Record",
"an",
"error",
"then",
"serialize",
"and",
"return",
"a",
"response",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/plugins/gnostic-analyze/main.go#L42-L47 |
18,547 | googleapis/gnostic | plugins/gnostic-analyze/main.go | sendAndExit | func sendAndExit(response *plugins.Response) {
responseBytes, _ := proto.Marshal(response)
os.Stdout.Write(responseBytes)
os.Exit(0)
} | go | func sendAndExit(response *plugins.Response) {
responseBytes, _ := proto.Marshal(response)
os.Stdout.Write(responseBytes)
os.Exit(0)
} | [
"func",
"sendAndExit",
"(",
"response",
"*",
"plugins",
".",
"Response",
")",
"{",
"responseBytes",
",",
"_",
":=",
"proto",
".",
"Marshal",
"(",
"response",
")",
"\n",
"os",
".",
"Stdout",
".",
"Write",
"(",
"responseBytes",
")",
"\n",
"os",
".",
"Exi... | // Serialize and return a response. | [
"Serialize",
"and",
"return",
"a",
"response",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/plugins/gnostic-analyze/main.go#L50-L54 |
18,548 | googleapis/gnostic | jsonschema/models.go | NewSchemaNumberWithInteger | func NewSchemaNumberWithInteger(i int64) *SchemaNumber {
result := &SchemaNumber{}
result.Integer = &i
return result
} | go | func NewSchemaNumberWithInteger(i int64) *SchemaNumber {
result := &SchemaNumber{}
result.Integer = &i
return result
} | [
"func",
"NewSchemaNumberWithInteger",
"(",
"i",
"int64",
")",
"*",
"SchemaNumber",
"{",
"result",
":=",
"&",
"SchemaNumber",
"{",
"}",
"\n",
"result",
".",
"Integer",
"=",
"&",
"i",
"\n",
"return",
"result",
"\n",
"}"
] | // NewSchemaNumberWithInteger creates and returns a new object | [
"NewSchemaNumberWithInteger",
"creates",
"and",
"returns",
"a",
"new",
"object"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/models.go#L86-L90 |
18,549 | googleapis/gnostic | jsonschema/models.go | NewSchemaNumberWithFloat | func NewSchemaNumberWithFloat(f float64) *SchemaNumber {
result := &SchemaNumber{}
result.Float = &f
return result
} | go | func NewSchemaNumberWithFloat(f float64) *SchemaNumber {
result := &SchemaNumber{}
result.Float = &f
return result
} | [
"func",
"NewSchemaNumberWithFloat",
"(",
"f",
"float64",
")",
"*",
"SchemaNumber",
"{",
"result",
":=",
"&",
"SchemaNumber",
"{",
"}",
"\n",
"result",
".",
"Float",
"=",
"&",
"f",
"\n",
"return",
"result",
"\n",
"}"
] | // NewSchemaNumberWithFloat creates and returns a new object | [
"NewSchemaNumberWithFloat",
"creates",
"and",
"returns",
"a",
"new",
"object"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/models.go#L93-L97 |
18,550 | googleapis/gnostic | jsonschema/models.go | NewSchemaOrBooleanWithSchema | func NewSchemaOrBooleanWithSchema(s *Schema) *SchemaOrBoolean {
result := &SchemaOrBoolean{}
result.Schema = s
return result
} | go | func NewSchemaOrBooleanWithSchema(s *Schema) *SchemaOrBoolean {
result := &SchemaOrBoolean{}
result.Schema = s
return result
} | [
"func",
"NewSchemaOrBooleanWithSchema",
"(",
"s",
"*",
"Schema",
")",
"*",
"SchemaOrBoolean",
"{",
"result",
":=",
"&",
"SchemaOrBoolean",
"{",
"}",
"\n",
"result",
".",
"Schema",
"=",
"s",
"\n",
"return",
"result",
"\n",
"}"
] | // NewSchemaOrBooleanWithSchema creates and returns a new object | [
"NewSchemaOrBooleanWithSchema",
"creates",
"and",
"returns",
"a",
"new",
"object"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/models.go#L106-L110 |
18,551 | googleapis/gnostic | jsonschema/models.go | NewSchemaOrBooleanWithBoolean | func NewSchemaOrBooleanWithBoolean(b bool) *SchemaOrBoolean {
result := &SchemaOrBoolean{}
result.Boolean = &b
return result
} | go | func NewSchemaOrBooleanWithBoolean(b bool) *SchemaOrBoolean {
result := &SchemaOrBoolean{}
result.Boolean = &b
return result
} | [
"func",
"NewSchemaOrBooleanWithBoolean",
"(",
"b",
"bool",
")",
"*",
"SchemaOrBoolean",
"{",
"result",
":=",
"&",
"SchemaOrBoolean",
"{",
"}",
"\n",
"result",
".",
"Boolean",
"=",
"&",
"b",
"\n",
"return",
"result",
"\n",
"}"
] | // NewSchemaOrBooleanWithBoolean creates and returns a new object | [
"NewSchemaOrBooleanWithBoolean",
"creates",
"and",
"returns",
"a",
"new",
"object"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/models.go#L113-L117 |
18,552 | googleapis/gnostic | jsonschema/models.go | NewStringOrStringArrayWithString | func NewStringOrStringArrayWithString(s string) *StringOrStringArray {
result := &StringOrStringArray{}
result.String = &s
return result
} | go | func NewStringOrStringArrayWithString(s string) *StringOrStringArray {
result := &StringOrStringArray{}
result.String = &s
return result
} | [
"func",
"NewStringOrStringArrayWithString",
"(",
"s",
"string",
")",
"*",
"StringOrStringArray",
"{",
"result",
":=",
"&",
"StringOrStringArray",
"{",
"}",
"\n",
"result",
".",
"String",
"=",
"&",
"s",
"\n",
"return",
"result",
"\n",
"}"
] | // NewStringOrStringArrayWithString creates and returns a new object | [
"NewStringOrStringArrayWithString",
"creates",
"and",
"returns",
"a",
"new",
"object"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/models.go#L127-L131 |
18,553 | googleapis/gnostic | jsonschema/models.go | NewStringOrStringArrayWithStringArray | func NewStringOrStringArrayWithStringArray(a []string) *StringOrStringArray {
result := &StringOrStringArray{}
result.StringArray = &a
return result
} | go | func NewStringOrStringArrayWithStringArray(a []string) *StringOrStringArray {
result := &StringOrStringArray{}
result.StringArray = &a
return result
} | [
"func",
"NewStringOrStringArrayWithStringArray",
"(",
"a",
"[",
"]",
"string",
")",
"*",
"StringOrStringArray",
"{",
"result",
":=",
"&",
"StringOrStringArray",
"{",
"}",
"\n",
"result",
".",
"StringArray",
"=",
"&",
"a",
"\n",
"return",
"result",
"\n",
"}"
] | // NewStringOrStringArrayWithStringArray creates and returns a new object | [
"NewStringOrStringArrayWithStringArray",
"creates",
"and",
"returns",
"a",
"new",
"object"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/models.go#L134-L138 |
18,554 | googleapis/gnostic | jsonschema/models.go | NewSchemaOrSchemaArrayWithSchema | func NewSchemaOrSchemaArrayWithSchema(s *Schema) *SchemaOrSchemaArray {
result := &SchemaOrSchemaArray{}
result.Schema = s
return result
} | go | func NewSchemaOrSchemaArrayWithSchema(s *Schema) *SchemaOrSchemaArray {
result := &SchemaOrSchemaArray{}
result.Schema = s
return result
} | [
"func",
"NewSchemaOrSchemaArrayWithSchema",
"(",
"s",
"*",
"Schema",
")",
"*",
"SchemaOrSchemaArray",
"{",
"result",
":=",
"&",
"SchemaOrSchemaArray",
"{",
"}",
"\n",
"result",
".",
"Schema",
"=",
"s",
"\n",
"return",
"result",
"\n",
"}"
] | // NewSchemaOrSchemaArrayWithSchema creates and returns a new object | [
"NewSchemaOrSchemaArrayWithSchema",
"creates",
"and",
"returns",
"a",
"new",
"object"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/models.go#L155-L159 |
18,555 | googleapis/gnostic | jsonschema/models.go | NewSchemaOrSchemaArrayWithSchemaArray | func NewSchemaOrSchemaArrayWithSchemaArray(a []*Schema) *SchemaOrSchemaArray {
result := &SchemaOrSchemaArray{}
result.SchemaArray = &a
return result
} | go | func NewSchemaOrSchemaArrayWithSchemaArray(a []*Schema) *SchemaOrSchemaArray {
result := &SchemaOrSchemaArray{}
result.SchemaArray = &a
return result
} | [
"func",
"NewSchemaOrSchemaArrayWithSchemaArray",
"(",
"a",
"[",
"]",
"*",
"Schema",
")",
"*",
"SchemaOrSchemaArray",
"{",
"result",
":=",
"&",
"SchemaOrSchemaArray",
"{",
"}",
"\n",
"result",
".",
"SchemaArray",
"=",
"&",
"a",
"\n",
"return",
"result",
"\n",
... | // NewSchemaOrSchemaArrayWithSchemaArray creates and returns a new object | [
"NewSchemaOrSchemaArrayWithSchemaArray",
"creates",
"and",
"returns",
"a",
"new",
"object"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/models.go#L162-L166 |
18,556 | googleapis/gnostic | jsonschema/models.go | NewNamedSchema | func NewNamedSchema(name string, value *Schema) *NamedSchema {
return &NamedSchema{Name: name, Value: value}
} | go | func NewNamedSchema(name string, value *Schema) *NamedSchema {
return &NamedSchema{Name: name, Value: value}
} | [
"func",
"NewNamedSchema",
"(",
"name",
"string",
",",
"value",
"*",
"Schema",
")",
"*",
"NamedSchema",
"{",
"return",
"&",
"NamedSchema",
"{",
"Name",
":",
"name",
",",
"Value",
":",
"value",
"}",
"\n",
"}"
] | // NewNamedSchema creates and returns a new object | [
"NewNamedSchema",
"creates",
"and",
"returns",
"a",
"new",
"object"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/models.go#L183-L185 |
18,557 | googleapis/gnostic | jsonschema/models.go | namedSchemaArrayElementWithName | 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 | 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
} | [
"func",
"namedSchemaArrayElementWithName",
"(",
"array",
"*",
"[",
"]",
"*",
"NamedSchema",
",",
"name",
"string",
")",
"*",
"Schema",
"{",
"if",
"array",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"for",
"_",
",",
"pair",
":=",
"range",
"*",
... | // Access named subschemas by name | [
"Access",
"named",
"subschemas",
"by",
"name"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/models.go#L196-L206 |
18,558 | googleapis/gnostic | jsonschema/models.go | PropertyWithName | func (s *Schema) PropertyWithName(name string) *Schema {
return namedSchemaArrayElementWithName(s.Properties, name)
} | go | func (s *Schema) PropertyWithName(name string) *Schema {
return namedSchemaArrayElementWithName(s.Properties, name)
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"PropertyWithName",
"(",
"name",
"string",
")",
"*",
"Schema",
"{",
"return",
"namedSchemaArrayElementWithName",
"(",
"s",
".",
"Properties",
",",
"name",
")",
"\n",
"}"
] | // PropertyWithName returns the selected element. | [
"PropertyWithName",
"returns",
"the",
"selected",
"element",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/models.go#L209-L211 |
18,559 | googleapis/gnostic | jsonschema/models.go | PatternPropertyWithName | func (s *Schema) PatternPropertyWithName(name string) *Schema {
return namedSchemaArrayElementWithName(s.PatternProperties, name)
} | go | func (s *Schema) PatternPropertyWithName(name string) *Schema {
return namedSchemaArrayElementWithName(s.PatternProperties, name)
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"PatternPropertyWithName",
"(",
"name",
"string",
")",
"*",
"Schema",
"{",
"return",
"namedSchemaArrayElementWithName",
"(",
"s",
".",
"PatternProperties",
",",
"name",
")",
"\n",
"}"
] | // PatternPropertyWithName returns the selected element. | [
"PatternPropertyWithName",
"returns",
"the",
"selected",
"element",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/models.go#L214-L216 |
18,560 | googleapis/gnostic | jsonschema/models.go | DefinitionWithName | func (s *Schema) DefinitionWithName(name string) *Schema {
return namedSchemaArrayElementWithName(s.Definitions, name)
} | go | func (s *Schema) DefinitionWithName(name string) *Schema {
return namedSchemaArrayElementWithName(s.Definitions, name)
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"DefinitionWithName",
"(",
"name",
"string",
")",
"*",
"Schema",
"{",
"return",
"namedSchemaArrayElementWithName",
"(",
"s",
".",
"Definitions",
",",
"name",
")",
"\n",
"}"
] | // DefinitionWithName returns the selected element. | [
"DefinitionWithName",
"returns",
"the",
"selected",
"element",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/models.go#L219-L221 |
18,561 | googleapis/gnostic | jsonschema/models.go | AddProperty | func (s *Schema) AddProperty(name string, property *Schema) {
*s.Properties = append(*s.Properties, NewNamedSchema(name, property))
} | go | func (s *Schema) AddProperty(name string, property *Schema) {
*s.Properties = append(*s.Properties, NewNamedSchema(name, property))
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"AddProperty",
"(",
"name",
"string",
",",
"property",
"*",
"Schema",
")",
"{",
"*",
"s",
".",
"Properties",
"=",
"append",
"(",
"*",
"s",
".",
"Properties",
",",
"NewNamedSchema",
"(",
"name",
",",
"property",
"... | // AddProperty adds a named property. | [
"AddProperty",
"adds",
"a",
"named",
"property",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/jsonschema/models.go#L224-L226 |
18,562 | googleapis/gnostic | OpenAPIv3/schema-generator/main.go | lowerFirst | func lowerFirst(s string) string {
if s == "" {
return ""
}
r, n := utf8.DecodeRuneInString(s)
return string(unicode.ToLower(r)) + s[n:]
} | go | func lowerFirst(s string) string {
if s == "" {
return ""
}
r, n := utf8.DecodeRuneInString(s)
return string(unicode.ToLower(r)) + s[n:]
} | [
"func",
"lowerFirst",
"(",
"s",
"string",
")",
"string",
"{",
"if",
"s",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"r",
",",
"n",
":=",
"utf8",
".",
"DecodeRuneInString",
"(",
"s",
")",
"\n",
"return",
"string",
"(",
"unicode",
... | // convert the first character of a string to lower case | [
"convert",
"the",
"first",
"character",
"of",
"a",
"string",
"to",
"lower",
"case"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/OpenAPIv3/schema-generator/main.go#L36-L42 |
18,563 | googleapis/gnostic | OpenAPIv3/schema-generator/main.go | ReadSection | 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 | 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... | [
"func",
"ReadSection",
"(",
"text",
"string",
",",
"level",
"int",
")",
"(",
"section",
"*",
"Section",
")",
"{",
"titlePattern",
":=",
"regexp",
".",
"MustCompile",
"(",
"\"",
"\"",
"+",
"strings",
".",
"Repeat",
"(",
"\"",
"\"",
",",
"level",
")",
... | // ReadSection reads a section of the OpenAPI Specification, recursively dividing it into subsections | [
"ReadSection",
"reads",
"a",
"section",
"of",
"the",
"OpenAPI",
"Specification",
"recursively",
"dividing",
"it",
"into",
"subsections"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/OpenAPIv3/schema-generator/main.go#L53-L83 |
18,564 | googleapis/gnostic | OpenAPIv3/schema-generator/main.go | Display | 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 | 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... | [
"func",
"(",
"s",
"*",
"Section",
")",
"Display",
"(",
"section",
"string",
")",
"{",
"if",
"len",
"(",
"s",
".",
"Children",
")",
"==",
"0",
"{",
"//fmt.Printf(\"%s\\n\", s.Text)",
"}",
"else",
"{",
"for",
"i",
",",
"child",
":=",
"range",
"s",
".",... | // Display recursively displays a section of the specification. | [
"Display",
"recursively",
"displays",
"a",
"section",
"of",
"the",
"specification",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/OpenAPIv3/schema-generator/main.go#L86-L101 |
18,565 | googleapis/gnostic | OpenAPIv3/schema-generator/main.go | stripLink | 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 | 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([]... | [
"func",
"stripLink",
"(",
"input",
"string",
")",
"(",
"output",
"string",
")",
"{",
"stringPattern",
":=",
"regexp",
".",
"MustCompile",
"(",
"\"",
"\"",
")",
"\n",
"stringWithLinkPattern",
":=",
"regexp",
".",
"MustCompile",
"(",
"\"",
"\"",
")",
"\n",
... | // remove a link from a string, leaving only the text that follows it
// if there is no link, just return the string | [
"remove",
"a",
"link",
"from",
"a",
"string",
"leaving",
"only",
"the",
"text",
"that",
"follows",
"it",
"if",
"there",
"is",
"no",
"link",
"just",
"return",
"the",
"string"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/OpenAPIv3/schema-generator/main.go#L105-L115 |
18,566 | googleapis/gnostic | OpenAPIv3/schema-generator/main.go | parseFixedFields | 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 | 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... | [
"func",
"parseFixedFields",
"(",
"input",
"string",
",",
"schemaObject",
"*",
"SchemaObject",
")",
"{",
"lines",
":=",
"strings",
".",
"Split",
"(",
"input",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"for",
"_",
",",
"line",
":=",
"range",
"lines",
"{",
"// r... | // extract the fixed fields from a table in a section | [
"extract",
"the",
"fixed",
"fields",
"from",
"a",
"table",
"in",
"a",
"section"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/OpenAPIv3/schema-generator/main.go#L138-L217 |
18,567 | googleapis/gnostic | OpenAPIv3/schema-generator/main.go | parsePatternedFields | 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 | 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... | [
"func",
"parsePatternedFields",
"(",
"input",
"string",
",",
"schemaObject",
"*",
"SchemaObject",
")",
"{",
"lines",
":=",
"strings",
".",
"Split",
"(",
"input",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"for",
"_",
",",
"line",
":=",
"range",
"lines",
"{",
"... | // extract the patterned fields from a table in a section | [
"extract",
"the",
"patterned",
"fields",
"from",
"a",
"table",
"in",
"a",
"section"
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/OpenAPIv3/schema-generator/main.go#L220-L267 |
18,568 | googleapis/gnostic | OpenAPIv3/schema-generator/main.go | NewSchemaModel | 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 | 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... | [
"func",
"NewSchemaModel",
"(",
"filename",
"string",
")",
"(",
"schemaModel",
"*",
"SchemaModel",
",",
"err",
"error",
")",
"{",
"b",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"n... | // NewSchemaModel returns a new SchemaModel. | [
"NewSchemaModel",
"returns",
"a",
"new",
"SchemaModel",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/OpenAPIv3/schema-generator/main.go#L304-L363 |
18,569 | googleapis/gnostic | compiler/error.go | NewError | func NewError(context *Context, message string) *Error {
return &Error{Context: context, Message: message}
} | go | func NewError(context *Context, message string) *Error {
return &Error{Context: context, Message: message}
} | [
"func",
"NewError",
"(",
"context",
"*",
"Context",
",",
"message",
"string",
")",
"*",
"Error",
"{",
"return",
"&",
"Error",
"{",
"Context",
":",
"context",
",",
"Message",
":",
"message",
"}",
"\n",
"}"
] | // NewError creates an Error. | [
"NewError",
"creates",
"an",
"Error",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/error.go#L24-L26 |
18,570 | googleapis/gnostic | compiler/error.go | Error | func (err *Error) Error() string {
if err.Context == nil {
return "ERROR " + err.Message
}
return "ERROR " + err.Context.Description() + " " + err.Message
} | go | func (err *Error) Error() string {
if err.Context == nil {
return "ERROR " + err.Message
}
return "ERROR " + err.Context.Description() + " " + err.Message
} | [
"func",
"(",
"err",
"*",
"Error",
")",
"Error",
"(",
")",
"string",
"{",
"if",
"err",
".",
"Context",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"+",
"err",
".",
"Message",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"+",
"err",
".",
"Context",
".",
"D... | // Error returns the string value of an Error. | [
"Error",
"returns",
"the",
"string",
"value",
"of",
"an",
"Error",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/error.go#L29-L34 |
18,571 | googleapis/gnostic | compiler/error.go | NewErrorGroupOrNil | 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 | func NewErrorGroupOrNil(errors []error) error {
if len(errors) == 0 {
return nil
} else if len(errors) == 1 {
return errors[0]
} else {
return &ErrorGroup{Errors: errors}
}
} | [
"func",
"NewErrorGroupOrNil",
"(",
"errors",
"[",
"]",
"error",
")",
"error",
"{",
"if",
"len",
"(",
"errors",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"else",
"if",
"len",
"(",
"errors",
")",
"==",
"1",
"{",
"return",
"errors",
"[",
"0",
... | // NewErrorGroupOrNil returns a new ErrorGroup for a slice of errors or nil if the slice is empty. | [
"NewErrorGroupOrNil",
"returns",
"a",
"new",
"ErrorGroup",
"for",
"a",
"slice",
"of",
"errors",
"or",
"nil",
"if",
"the",
"slice",
"is",
"empty",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/compiler/error.go#L42-L50 |
18,572 | googleapis/gnostic | gnostic.go | getOpenAPIVersionFromInfo | 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 | 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... | [
"func",
"getOpenAPIVersionFromInfo",
"(",
"info",
"interface",
"{",
"}",
")",
"int",
"{",
"m",
",",
"ok",
":=",
"compiler",
".",
"UnpackMap",
"(",
"info",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"SourceFormatUnknown",
"\n",
"}",
"\n",
"swagger",
",",
... | // Determine the version of an OpenAPI description read from JSON or YAML. | [
"Determine",
"the",
"version",
"of",
"an",
"OpenAPI",
"description",
"read",
"from",
"JSON",
"or",
"YAML",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/gnostic.go#L65-L83 |
18,573 | googleapis/gnostic | gnostic.go | newGnostic | 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 | 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 ... | [
"func",
"newGnostic",
"(",
")",
"*",
"Gnostic",
"{",
"g",
":=",
"&",
"Gnostic",
"{",
"}",
"\n",
"// Option fields initialize to their default values.",
"g",
".",
"usage",
"=",
"`\nUsage: gnostic SOURCE [OPTIONS]\n SOURCE is the filename or URL of an API description.\nOptions:\... | // Initialize a structure to store global application state. | [
"Initialize",
"a",
"structure",
"to",
"store",
"global",
"application",
"state",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/gnostic.go#L266-L296 |
18,574 | googleapis/gnostic | gnostic.go | readOptions | 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 | 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 ... | [
"func",
"(",
"g",
"*",
"Gnostic",
")",
"readOptions",
"(",
")",
"{",
"// plugin processing matches patterns of the form \"--PLUGIN-out=PATH\" and \"--PLUGIN_out=PATH\"",
"pluginRegex",
":=",
"regexp",
".",
"MustCompile",
"(",
"\"",
"\"",
")",
"\n\n",
"// extension processin... | // Parse command-line options. | [
"Parse",
"command",
"-",
"line",
"options",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/gnostic.go#L299-L351 |
18,575 | googleapis/gnostic | gnostic.go | validateOptions | 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 | 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 == ""... | [
"func",
"(",
"g",
"*",
"Gnostic",
")",
"validateOptions",
"(",
")",
"{",
"if",
"g",
".",
"binaryOutputPath",
"==",
"\"",
"\"",
"&&",
"g",
".",
"textOutputPath",
"==",
"\"",
"\"",
"&&",
"g",
".",
"yamlOutputPath",
"==",
"\"",
"\"",
"&&",
"g",
".",
"... | // Validate command-line options. | [
"Validate",
"command",
"-",
"line",
"options",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/gnostic.go#L354-L372 |
18,576 | googleapis/gnostic | gnostic.go | errorBytes | func (g *Gnostic) errorBytes(err error) []byte {
return []byte("Errors reading " + g.sourceName + "\n" + err.Error())
} | go | func (g *Gnostic) errorBytes(err error) []byte {
return []byte("Errors reading " + g.sourceName + "\n" + err.Error())
} | [
"func",
"(",
"g",
"*",
"Gnostic",
")",
"errorBytes",
"(",
"err",
"error",
")",
"[",
"]",
"byte",
"{",
"return",
"[",
"]",
"byte",
"(",
"\"",
"\"",
"+",
"g",
".",
"sourceName",
"+",
"\"",
"\\n",
"\"",
"+",
"err",
".",
"Error",
"(",
")",
")",
"... | // Generate an error message to be written to stderr or a file. | [
"Generate",
"an",
"error",
"message",
"to",
"be",
"written",
"to",
"stderr",
"or",
"a",
"file",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/gnostic.go#L375-L377 |
18,577 | googleapis/gnostic | gnostic.go | readOpenAPIText | 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 | 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... | [
"func",
"(",
"g",
"*",
"Gnostic",
")",
"readOpenAPIText",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"message",
"proto",
".",
"Message",
",",
"err",
"error",
")",
"{",
"info",
",",
"err",
":=",
"compiler",
".",
"ReadInfoFromBytes",
"(",
"g",
".",
"sou... | // Read an OpenAPI description from YAML or JSON. | [
"Read",
"an",
"OpenAPI",
"description",
"from",
"YAML",
"or",
"JSON",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/gnostic.go#L380-L411 |
18,578 | googleapis/gnostic | gnostic.go | readOpenAPIBinary | 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 | 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... | [
"func",
"(",
"g",
"*",
"Gnostic",
")",
"readOpenAPIBinary",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"message",
"proto",
".",
"Message",
",",
"err",
"error",
")",
"{",
"// try to read an OpenAPI v3 document",
"documentV3",
":=",
"&",
"openapi_v3",
".",
"Docu... | // Read an OpenAPI binary file. | [
"Read",
"an",
"OpenAPI",
"binary",
"file",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/gnostic.go#L414-L437 |
18,579 | googleapis/gnostic | gnostic.go | writeBinaryOutput | 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 | 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")
}
} | [
"func",
"(",
"g",
"*",
"Gnostic",
")",
"writeBinaryOutput",
"(",
"message",
"proto",
".",
"Message",
")",
"{",
"protoBytes",
",",
"err",
":=",
"proto",
".",
"Marshal",
"(",
"message",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"writeFile",
"(",
"g",
"... | // Write a binary pb representation. | [
"Write",
"a",
"binary",
"pb",
"representation",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/gnostic.go#L440-L448 |
18,580 | googleapis/gnostic | gnostic.go | writeTextOutput | func (g *Gnostic) writeTextOutput(message proto.Message) {
bytes := []byte(proto.MarshalTextString(message))
writeFile(g.textOutputPath, bytes, g.sourceName, "text")
} | go | func (g *Gnostic) writeTextOutput(message proto.Message) {
bytes := []byte(proto.MarshalTextString(message))
writeFile(g.textOutputPath, bytes, g.sourceName, "text")
} | [
"func",
"(",
"g",
"*",
"Gnostic",
")",
"writeTextOutput",
"(",
"message",
"proto",
".",
"Message",
")",
"{",
"bytes",
":=",
"[",
"]",
"byte",
"(",
"proto",
".",
"MarshalTextString",
"(",
"message",
")",
")",
"\n",
"writeFile",
"(",
"g",
".",
"textOutpu... | // Write a text pb representation. | [
"Write",
"a",
"text",
"pb",
"representation",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/gnostic.go#L451-L454 |
18,581 | googleapis/gnostic | gnostic.go | writeMessagesOutput | 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 | 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")
}
} | [
"func",
"(",
"g",
"*",
"Gnostic",
")",
"writeMessagesOutput",
"(",
"message",
"proto",
".",
"Message",
")",
"{",
"protoBytes",
",",
"err",
":=",
"proto",
".",
"Marshal",
"(",
"message",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"writeFile",
"(",
"g",
... | // Write messages. | [
"Write",
"messages",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/gnostic.go#L510-L518 |
18,582 | googleapis/gnostic | gnostic.go | performActions | 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 | 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... | [
"func",
"(",
"g",
"*",
"Gnostic",
")",
"performActions",
"(",
"message",
"proto",
".",
"Message",
")",
"(",
"err",
"error",
")",
"{",
"// Optionally resolve internal references.",
"if",
"g",
".",
"resolveReferences",
"{",
"if",
"g",
".",
"sourceFormat",
"==",
... | // Perform all actions specified in the command-line options. | [
"Perform",
"all",
"actions",
"specified",
"in",
"the",
"command",
"-",
"line",
"options",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/gnostic.go#L521-L568 |
18,583 | googleapis/gnostic | extensions/extensions.go | ProcessExtension | 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 | 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... | [
"func",
"ProcessExtension",
"(",
"handleExtension",
"extensionHandler",
")",
"{",
"response",
":=",
"&",
"ExtensionHandlerResponse",
"{",
"}",
"\n",
"forInputYamlFromOpenapic",
"(",
"func",
"(",
"version",
"string",
",",
"extensionName",
"string",
",",
"yamlInput",
... | // ProcessExtension calles the handler for a specified extension. | [
"ProcessExtension",
"calles",
"the",
"handler",
"for",
"a",
"specified",
"extension",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/extensions/extensions.go#L49-L82 |
18,584 | googleapis/gnostic | discovery/discovery.go | NewAnnotations | 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 | 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 {
... | [
"func",
"NewAnnotations",
"(",
"in",
"interface",
"{",
"}",
",",
"context",
"*",
"compiler",
".",
"Context",
")",
"(",
"*",
"Annotations",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"x",
":=",
"&",
... | // NewAnnotations creates an object of type Annotations if possible, returning an error if not. | [
"NewAnnotations",
"creates",
"an",
"object",
"of",
"type",
"Annotations",
"if",
"possible",
"returning",
"an",
"error",
"if",
"not",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L33-L61 |
18,585 | googleapis/gnostic | discovery/discovery.go | NewAny | 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 | 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)
} | [
"func",
"NewAny",
"(",
"in",
"interface",
"{",
"}",
",",
"context",
"*",
"compiler",
".",
"Context",
")",
"(",
"*",
"Any",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"x",
":=",
"&",
"Any",
"{",
... | // NewAny creates an object of type Any if possible, returning an error if not. | [
"NewAny",
"creates",
"an",
"object",
"of",
"type",
"Any",
"if",
"possible",
"returning",
"an",
"error",
"if",
"not",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L64-L70 |
18,586 | googleapis/gnostic | discovery/discovery.go | NewAuth | 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 | 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... | [
"func",
"NewAuth",
"(",
"in",
"interface",
"{",
"}",
",",
"context",
"*",
"compiler",
".",
"Context",
")",
"(",
"*",
"Auth",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"x",
":=",
"&",
"Auth",
"{... | // NewAuth creates an object of type Auth if possible, returning an error if not. | [
"NewAuth",
"creates",
"an",
"object",
"of",
"type",
"Auth",
"if",
"possible",
"returning",
"an",
"error",
"if",
"not",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L73-L99 |
18,587 | googleapis/gnostic | discovery/discovery.go | NewMediaUpload | 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 | 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 {
... | [
"func",
"NewMediaUpload",
"(",
"in",
"interface",
"{",
"}",
",",
"context",
"*",
"compiler",
".",
"Context",
")",
"(",
"*",
"MediaUpload",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"x",
":=",
"&",
... | // NewMediaUpload creates an object of type MediaUpload if possible, returning an error if not. | [
"NewMediaUpload",
"creates",
"an",
"object",
"of",
"type",
"MediaUpload",
"if",
"possible",
"returning",
"an",
"error",
"if",
"not",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L446-L501 |
18,588 | googleapis/gnostic | discovery/discovery.go | NewMethods | 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 | 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... | [
"func",
"NewMethods",
"(",
"in",
"interface",
"{",
"}",
",",
"context",
"*",
"compiler",
".",
"Context",
")",
"(",
"*",
"Methods",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"x",
":=",
"&",
"Metho... | // NewMethods creates an object of type Methods if possible, returning an error if not. | [
"NewMethods",
"creates",
"an",
"object",
"of",
"type",
"Methods",
"if",
"possible",
"returning",
"an",
"error",
"if",
"not",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L672-L699 |
18,589 | googleapis/gnostic | discovery/discovery.go | NewProtocols | 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 | 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... | [
"func",
"NewProtocols",
"(",
"in",
"interface",
"{",
"}",
",",
"context",
"*",
"compiler",
".",
"Context",
")",
"(",
"*",
"Protocols",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"x",
":=",
"&",
"P... | // NewProtocols creates an object of type Protocols if possible, returning an error if not. | [
"NewProtocols",
"creates",
"an",
"object",
"of",
"type",
"Protocols",
"if",
"possible",
"returning",
"an",
"error",
"if",
"not",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L1137-L1172 |
18,590 | googleapis/gnostic | discovery/discovery.go | NewResource | 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 | 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... | [
"func",
"NewResource",
"(",
"in",
"interface",
"{",
"}",
",",
"context",
"*",
"compiler",
".",
"Context",
")",
"(",
"*",
"Resource",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"x",
":=",
"&",
"Res... | // NewResource creates an object of type Resource if possible, returning an error if not. | [
"NewResource",
"creates",
"an",
"object",
"of",
"type",
"Resource",
"if",
"possible",
"returning",
"an",
"error",
"if",
"not",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L1213-L1248 |
18,591 | googleapis/gnostic | discovery/discovery.go | NewResources | 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 | 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... | [
"func",
"NewResources",
"(",
"in",
"interface",
"{",
"}",
",",
"context",
"*",
"compiler",
".",
"Context",
")",
"(",
"*",
"Resources",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"x",
":=",
"&",
"R... | // NewResources creates an object of type Resources if possible, returning an error if not. | [
"NewResources",
"creates",
"an",
"object",
"of",
"type",
"Resources",
"if",
"possible",
"returning",
"an",
"error",
"if",
"not",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L1251-L1278 |
18,592 | googleapis/gnostic | discovery/discovery.go | NewScopes | 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 | 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... | [
"func",
"NewScopes",
"(",
"in",
"interface",
"{",
"}",
",",
"context",
"*",
"compiler",
".",
"Context",
")",
"(",
"*",
"Scopes",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"x",
":=",
"&",
"Scopes"... | // NewScopes creates an object of type Scopes if possible, returning an error if not. | [
"NewScopes",
"creates",
"an",
"object",
"of",
"type",
"Scopes",
"if",
"possible",
"returning",
"an",
"error",
"if",
"not",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L1602-L1629 |
18,593 | googleapis/gnostic | discovery/discovery.go | NewSimple | 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 | 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 :=... | [
"func",
"NewSimple",
"(",
"in",
"interface",
"{",
"}",
",",
"context",
"*",
"compiler",
".",
"Context",
")",
"(",
"*",
"Simple",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"x",
":=",
"&",
"Simple"... | // NewSimple creates an object of type Simple if possible, returning an error if not. | [
"NewSimple",
"creates",
"an",
"object",
"of",
"type",
"Simple",
"if",
"possible",
"returning",
"an",
"error",
"if",
"not",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L1632-L1667 |
18,594 | googleapis/gnostic | discovery/discovery.go | NewStringArray | 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 | 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))... | [
"func",
"NewStringArray",
"(",
"in",
"interface",
"{",
"}",
",",
"context",
"*",
"compiler",
".",
"Context",
")",
"(",
"*",
"StringArray",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"x",
":=",
"&",
... | // NewStringArray creates an object of type StringArray if possible, returning an error if not. | [
"NewStringArray",
"creates",
"an",
"object",
"of",
"type",
"StringArray",
"if",
"possible",
"returning",
"an",
"error",
"if",
"not",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L1670-L1684 |
18,595 | googleapis/gnostic | discovery/discovery.go | ResolveReferences | 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 | 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)
} | [
"func",
"(",
"m",
"*",
"MediaUpload",
")",
"ResolveReferences",
"(",
"root",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"if",
"m",
".",
"Protocols",
"!=",
... | // ResolveReferences resolves references found inside MediaUpload objects. | [
"ResolveReferences",
"resolves",
"references",
"found",
"inside",
"MediaUpload",
"objects",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L1759-L1768 |
18,596 | googleapis/gnostic | discovery/discovery.go | ResolveReferences | 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 | 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 {
... | [
"func",
"(",
"m",
"*",
"Method",
")",
"ResolveReferences",
"(",
"root",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"if",
"m",
".",
"Parameters",
"!=",
"n... | // ResolveReferences resolves references found inside Method objects. | [
"ResolveReferences",
"resolves",
"references",
"found",
"inside",
"Method",
"objects",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L1771-L1798 |
18,597 | googleapis/gnostic | discovery/discovery.go | ResolveReferences | 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 | 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)... | [
"func",
"(",
"m",
"*",
"Methods",
")",
"ResolveReferences",
"(",
"root",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"for",
"_",
",",
"item",
":=",
"range... | // ResolveReferences resolves references found inside Methods objects. | [
"ResolveReferences",
"resolves",
"references",
"found",
"inside",
"Methods",
"objects",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L1801-L1812 |
18,598 | googleapis/gnostic | discovery/discovery.go | ResolveReferences | 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 | 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)
} | [
"func",
"(",
"m",
"*",
"NamedMethod",
")",
"ResolveReferences",
"(",
"root",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"if",
"m",
".",
"Value",
"!=",
"n... | // ResolveReferences resolves references found inside NamedMethod objects. | [
"ResolveReferences",
"resolves",
"references",
"found",
"inside",
"NamedMethod",
"objects",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L1815-L1824 |
18,599 | googleapis/gnostic | discovery/discovery.go | ResolveReferences | 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 | 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 {
... | [
"func",
"(",
"m",
"*",
"Protocols",
")",
"ResolveReferences",
"(",
"root",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"0",
")",
"\n",
"if",
"m",
".",
"Simple",
"!=",
"ni... | // ResolveReferences resolves references found inside Protocols objects. | [
"ResolveReferences",
"resolves",
"references",
"found",
"inside",
"Protocols",
"objects",
"."
] | 909070f02b666e4e9adf7eda93c304a8ba2a8063 | https://github.com/googleapis/gnostic/blob/909070f02b666e4e9adf7eda93c304a8ba2a8063/discovery/discovery.go#L1945-L1960 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.