diff --git a/magefile.go b/magefile.go new file mode 100644 index 00000000..0071bac0 --- /dev/null +++ b/magefile.go @@ -0,0 +1,51 @@ +//go:build mage + +package main + +import ( + "golang.org/x/tools/txtar" + "os" + "path/filepath" + "strings" +) + +// Clean cleans all the output from corpus txtar files +func Clean() error { + return filepath.Walk("./testdata", cleanTxtarOut) +} + +func cleanTxtarOut(path string, _ os.FileInfo, err error) error { + if err != nil { + return err + } + + if filepath.Ext(path) != ".txtar" { + return nil + } + + data, err := os.ReadFile(path) + if err != nil { + return err + } + + archive := txtar.Parse(data) + archive.Files = filter( + archive.Files, + func(t txtar.File) bool { + return !strings.HasPrefix(t.Name, "out") + }, + ) + + return os.WriteFile(path, txtar.Format(archive), 0666) + +} + +func filter(ff []txtar.File, criteria func(f txtar.File) bool) []txtar.File { + filtered := make([]txtar.File, 0, len(ff)) + for _, f := range ff { + if criteria(f) { + filtered = append(filtered, f) + } + } + return filtered +} diff --git a/testdata/invalidlineage/defaultchange.txtar b/testdata/invalidlineage/defaultchange.txtar index 722c1e31..ef1687ee 100644 --- a/testdata/invalidlineage/defaultchange.txtar +++ b/testdata/invalidlineage/defaultchange.txtar @@ -29,10 +29,3 @@ lenses: [ } }, ] --- out/bindfail -- -not a lineage, missing #Lineage.name -(1) forced error mark - | "not a lineage" - | github.com/cockroachdb/errors/withstack/*withstack.withStack:: -Wraps: (2) not a lineage, missing #Lineage.name -Error types: (1) *markers.withMark (2) *errors.errorString diff --git a/testdata/invalidlineage/onlydef.txtar b/testdata/invalidlineage/onlydef.txtar index 2da55ff2..8a0e7a59 100644 --- a/testdata/invalidlineage/onlydef.txtar +++ b/testdata/invalidlineage/onlydef.txtar @@ -15,11 +15,3 @@ schemas: [{ } }] lenses: [] --- out/bindfail -- -_sortedSchemas: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1): - ../../lineage.cue:97:7 - ../../lineage.cue:93:21 - ../../lineage.cue:97:21 -schemas.0._schemaIsNonEmpty: invalid value {#Baz:{run:string,tell:bytes,dat:int & >=-2147483648 & <=2147483647}} (does not satisfy struct.MinFields(1)): len(fields) < MinFields(1) (0 < 1): - ../../lineage.cue:259:21 - ../../lineage.cue:259:38 diff --git a/testdata/lineage/basic-multiversion.txtar b/testdata/lineage/basic-multiversion.txtar index 587bb4e0..c5754559 100644 --- a/testdata/lineage/basic-multiversion.txtar +++ b/testdata/lineage/basic-multiversion.txtar @@ -254,30 +254,6 @@ lenses: [{ {"init":"some string","optional":32} {"renamed":"some string","optional":32,"withDefault":"foo"} [] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.2-withOptional->0.0.json -- -{"init":"some string","optional":32,"withDefault":"bar"} -{"init":"some string"} -[] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.2-withOptional->0.1.json -- -{"init":"some string","optional":32,"withDefault":"bar"} -{"init":"some string","optional":32} -[] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.2-withOptional->0.2.json -- -{"init":"some string","optional":32,"withDefault":"bar"} -{"init":"some string","optional":32,"withDefault":"bar"} -[] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.2-withOptional->0.3.json -- -{"init":"some string","optional":32,"withDefault":"bar"} -{"init":"some string","optional":32,"withDefault":"bar"} -[] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.2-withOptional->1.0.json -- -{"init":"some string","optional":32,"withDefault":"bar"} -{"renamed":"some string","optional":32,"withDefault":"foo"} -[] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.2-withOptional->1.1.json -- -{"init":"some string","optional":32,"withDefault":"bar"} -{"renamed":"some string","optional":32,"withDefault":"foo"} -[] -- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.2-withoutOptional->0.0.json -- {"init":"some string","withDefault":"foo"} {"init":"some string"} @@ -302,29 +278,29 @@ lenses: [{ {"init":"some string","withDefault":"foo"} {"renamed":"some string","withDefault":"foo"} [] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.3-withoutOptional->0.0.json -- -{"init":"some string","withDefault":"baz"} +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.2-withOptional->0.0.json -- +{"init":"some string","optional":32,"withDefault":"bar"} {"init":"some string"} [] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.3-withoutOptional->0.1.json -- -{"init":"some string","withDefault":"baz"} -{"init":"some string"} +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.2-withOptional->0.1.json -- +{"init":"some string","optional":32,"withDefault":"bar"} +{"init":"some string","optional":32} [] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.3-withoutOptional->0.2.json -- -{"init":"some string","withDefault":"baz"} -{"init":"some string","withDefault":"foo"} +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.2-withOptional->0.2.json -- +{"init":"some string","optional":32,"withDefault":"bar"} +{"init":"some string","optional":32,"withDefault":"bar"} [] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.3-withoutOptional->0.3.json -- -{"init":"some string","withDefault":"baz"} -{"init":"some string","withDefault":"baz"} +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.2-withOptional->0.3.json -- +{"init":"some string","optional":32,"withDefault":"bar"} +{"init":"some string","optional":32,"withDefault":"bar"} [] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.3-withoutOptional->1.0.json -- -{"init":"some string","withDefault":"baz"} -{"renamed":"some string","withDefault":"foo"} +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.2-withOptional->1.0.json -- +{"init":"some string","optional":32,"withDefault":"bar"} +{"renamed":"some string","optional":32,"withDefault":"foo"} [] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.3-withoutOptional->1.1.json -- -{"init":"some string","withDefault":"baz"} -{"renamed":"some string","withDefault":"foo"} +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.2-withOptional->1.1.json -- +{"init":"some string","optional":32,"withDefault":"bar"} +{"renamed":"some string","optional":32,"withDefault":"foo"} [] -- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.3-withOptional->0.0.json -- {"init":"some string","optional":32,"withDefault":"baz"} @@ -350,29 +326,29 @@ lenses: [{ {"init":"some string","optional":32,"withDefault":"baz"} {"renamed":"some string","optional":32,"withDefault":"foo"} [] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-1.0-withOptional->0.0.json -- -{"renamed":"some string","optional":32,"withDefault":"bar"} +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.3-withoutOptional->0.0.json -- +{"init":"some string","withDefault":"baz"} {"init":"some string"} [] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-1.0-withOptional->0.1.json -- -{"renamed":"some string","optional":32,"withDefault":"bar"} -{"init":"some string","optional":32} +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.3-withoutOptional->0.1.json -- +{"init":"some string","withDefault":"baz"} +{"init":"some string"} [] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-1.0-withOptional->0.2.json -- -{"renamed":"some string","optional":32,"withDefault":"bar"} -{"init":"some string","optional":32,"withDefault":"foo"} +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.3-withoutOptional->0.2.json -- +{"init":"some string","withDefault":"baz"} +{"init":"some string","withDefault":"foo"} [] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-1.0-withOptional->0.3.json -- -{"renamed":"some string","optional":32,"withDefault":"bar"} -{"init":"some string","optional":32,"withDefault":"bar"} +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.3-withoutOptional->0.3.json -- +{"init":"some string","withDefault":"baz"} +{"init":"some string","withDefault":"baz"} [] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-1.0-withOptional->1.0.json -- -{"renamed":"some string","optional":32,"withDefault":"bar"} -{"renamed":"some string","optional":32,"withDefault":"bar"} +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.3-withoutOptional->1.0.json -- +{"init":"some string","withDefault":"baz"} +{"renamed":"some string","withDefault":"foo"} [] --- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-1.0-withOptional->1.1.json -- -{"renamed":"some string","optional":32,"withDefault":"bar"} -{"renamed":"some string","optional":32,"withDefault":"bar"} +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-0.3-withoutOptional->1.1.json -- +{"init":"some string","withDefault":"baz"} +{"renamed":"some string","withDefault":"foo"} [] -- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-1.0-withoutOptional->0.0.json -- {"renamed":"some string","withDefault":"foo"} @@ -398,6 +374,30 @@ lenses: [{ {"renamed":"some string","withDefault":"foo"} {"renamed":"some string","withDefault":"foo"} [] +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-1.0-withOptional->0.0.json -- +{"renamed":"some string","optional":32,"withDefault":"bar"} +{"init":"some string"} +[] +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-1.0-withOptional->0.1.json -- +{"renamed":"some string","optional":32,"withDefault":"bar"} +{"init":"some string","optional":32} +[] +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-1.0-withOptional->0.2.json -- +{"renamed":"some string","optional":32,"withDefault":"bar"} +{"init":"some string","optional":32,"withDefault":"foo"} +[] +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-1.0-withOptional->0.3.json -- +{"renamed":"some string","optional":32,"withDefault":"bar"} +{"init":"some string","optional":32,"withDefault":"bar"} +[] +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-1.0-withOptional->1.0.json -- +{"renamed":"some string","optional":32,"withDefault":"bar"} +{"renamed":"some string","optional":32,"withDefault":"bar"} +[] +-- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-1.0-withOptional->1.1.json -- +{"renamed":"some string","optional":32,"withDefault":"bar"} +{"renamed":"some string","optional":32,"withDefault":"bar"} +[] -- out/core/instance/translate/TestInstance_Translate/lineage/basic-multiversion-1.1-withoutOptional->0.0.json -- {"renamed":"some string","withDefault":"bing"} {"init":"some string"} @@ -742,92 +742,6 @@ type BasicmultiversionWithDefault string } } } --- out/encoding/gocode/TestGenerate/group -- -== basicmultiversion_type_0.0_gen.go -package basicmultiversion - -// Init defines model for init. -type Init = string -== basicmultiversion_type_0.1_gen.go -package basicmultiversion - -// Init defines model for init. -type Init = string - -// Optional defines model for optional. -type Optional = int32 -== basicmultiversion_type_0.2_gen.go -package basicmultiversion - -// Defines values for WithDefault. -const ( - WithDefaultBar WithDefault = "bar" - WithDefaultFoo WithDefault = "foo" -) - -// Init defines model for init. -type Init = string - -// Optional defines model for optional. -type Optional = int32 - -// WithDefault defines model for withDefault. -type WithDefault string -== basicmultiversion_type_0.3_gen.go -package basicmultiversion - -// Defines values for WithDefault. -const ( - WithDefaultBar WithDefault = "bar" - WithDefaultBaz WithDefault = "baz" - WithDefaultFoo WithDefault = "foo" -) - -// Init defines model for init. -type Init = string - -// Optional defines model for optional. -type Optional = int32 - -// WithDefault defines model for withDefault. -type WithDefault string -== basicmultiversion_type_1.0_gen.go -package basicmultiversion - -// Defines values for WithDefault. -const ( - WithDefaultBar WithDefault = "bar" - WithDefaultBaz WithDefault = "baz" - WithDefaultFoo WithDefault = "foo" -) - -// Optional defines model for optional. -type Optional = int32 - -// Renamed defines model for renamed. -type Renamed = string - -// WithDefault defines model for withDefault. -type WithDefault string -== basicmultiversion_type_1.1_gen.go -package basicmultiversion - -// Defines values for WithDefault. -const ( - WithDefaultBar WithDefault = "bar" - WithDefaultBaz WithDefault = "baz" - WithDefaultBing WithDefault = "bing" - WithDefaultFoo WithDefault = "foo" -) - -// Optional defines model for optional. -type Optional = int32 - -// Renamed defines model for renamed. -type Renamed = string - -// WithDefault defines model for withDefault. -type WithDefault string -- out/encoding/openapi/TestGenerate/group -- == 0.0.json { @@ -976,98 +890,6 @@ type WithDefault string } } } --- out/encoding/gocode/TestGenerate/depointerized -- -== basicmultiversion_type_0.0_gen.go -package basicmultiversion - -// Basicmultiversion defines model for basicmultiversion. -type Basicmultiversion struct { - Init string `json:"init"` -} -== basicmultiversion_type_0.1_gen.go -package basicmultiversion - -// Basicmultiversion defines model for basicmultiversion. -type Basicmultiversion struct { - Init string `json:"init"` - Optional int32 `json:"optional,omitempty"` -} -== basicmultiversion_type_0.2_gen.go -package basicmultiversion - -// Defines values for BasicmultiversionWithDefault. -const ( - BasicmultiversionWithDefaultBar BasicmultiversionWithDefault = "bar" - BasicmultiversionWithDefaultFoo BasicmultiversionWithDefault = "foo" -) - -// Basicmultiversion defines model for basicmultiversion. -type Basicmultiversion struct { - Init string `json:"init"` - Optional int32 `json:"optional,omitempty"` - WithDefault BasicmultiversionWithDefault `json:"withDefault"` -} - -// BasicmultiversionWithDefault defines model for Basicmultiversion.WithDefault. -type BasicmultiversionWithDefault string -== basicmultiversion_type_0.3_gen.go -package basicmultiversion - -// Defines values for BasicmultiversionWithDefault. -const ( - BasicmultiversionWithDefaultBar BasicmultiversionWithDefault = "bar" - BasicmultiversionWithDefaultBaz BasicmultiversionWithDefault = "baz" - BasicmultiversionWithDefaultFoo BasicmultiversionWithDefault = "foo" -) - -// Basicmultiversion defines model for basicmultiversion. -type Basicmultiversion struct { - Init string `json:"init"` - Optional int32 `json:"optional,omitempty"` - WithDefault BasicmultiversionWithDefault `json:"withDefault"` -} - -// BasicmultiversionWithDefault defines model for Basicmultiversion.WithDefault. -type BasicmultiversionWithDefault string -== basicmultiversion_type_1.0_gen.go -package basicmultiversion - -// Defines values for BasicmultiversionWithDefault. -const ( - BasicmultiversionWithDefaultBar BasicmultiversionWithDefault = "bar" - BasicmultiversionWithDefaultBaz BasicmultiversionWithDefault = "baz" - BasicmultiversionWithDefaultFoo BasicmultiversionWithDefault = "foo" -) - -// Basicmultiversion defines model for basicmultiversion. -type Basicmultiversion struct { - Optional int32 `json:"optional,omitempty"` - Renamed string `json:"renamed"` - WithDefault BasicmultiversionWithDefault `json:"withDefault"` -} - -// BasicmultiversionWithDefault defines model for Basicmultiversion.WithDefault. -type BasicmultiversionWithDefault string -== basicmultiversion_type_1.1_gen.go -package basicmultiversion - -// Defines values for BasicmultiversionWithDefault. -const ( - BasicmultiversionWithDefaultBar BasicmultiversionWithDefault = "bar" - BasicmultiversionWithDefaultBaz BasicmultiversionWithDefault = "baz" - BasicmultiversionWithDefaultBing BasicmultiversionWithDefault = "bing" - BasicmultiversionWithDefaultFoo BasicmultiversionWithDefault = "foo" -) - -// Basicmultiversion defines model for basicmultiversion. -type Basicmultiversion struct { - Optional int32 `json:"optional,omitempty"` - Renamed string `json:"renamed"` - WithDefault BasicmultiversionWithDefault `json:"withDefault"` -} - -// BasicmultiversionWithDefault defines model for Basicmultiversion.WithDefault. -type BasicmultiversionWithDefault string -- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { @@ -1452,3 +1274,181 @@ type Basicmultiversion struct { // BasicmultiversionWithDefault defines model for Basicmultiversion.WithDefault. type BasicmultiversionWithDefault string +-- out/encoding/gocode/TestGenerate/group -- +== basicmultiversion_type_0.0_gen.go +package basicmultiversion + +// Init defines model for init. +type Init = string +== basicmultiversion_type_0.1_gen.go +package basicmultiversion + +// Init defines model for init. +type Init = string + +// Optional defines model for optional. +type Optional = int32 +== basicmultiversion_type_0.2_gen.go +package basicmultiversion + +// Defines values for WithDefault. +const ( + WithDefaultBar WithDefault = "bar" + WithDefaultFoo WithDefault = "foo" +) + +// Init defines model for init. +type Init = string + +// Optional defines model for optional. +type Optional = int32 + +// WithDefault defines model for withDefault. +type WithDefault string +== basicmultiversion_type_0.3_gen.go +package basicmultiversion + +// Defines values for WithDefault. +const ( + WithDefaultBar WithDefault = "bar" + WithDefaultBaz WithDefault = "baz" + WithDefaultFoo WithDefault = "foo" +) + +// Init defines model for init. +type Init = string + +// Optional defines model for optional. +type Optional = int32 + +// WithDefault defines model for withDefault. +type WithDefault string +== basicmultiversion_type_1.0_gen.go +package basicmultiversion + +// Defines values for WithDefault. +const ( + WithDefaultBar WithDefault = "bar" + WithDefaultBaz WithDefault = "baz" + WithDefaultFoo WithDefault = "foo" +) + +// Optional defines model for optional. +type Optional = int32 + +// Renamed defines model for renamed. +type Renamed = string + +// WithDefault defines model for withDefault. +type WithDefault string +== basicmultiversion_type_1.1_gen.go +package basicmultiversion + +// Defines values for WithDefault. +const ( + WithDefaultBar WithDefault = "bar" + WithDefaultBaz WithDefault = "baz" + WithDefaultBing WithDefault = "bing" + WithDefaultFoo WithDefault = "foo" +) + +// Optional defines model for optional. +type Optional = int32 + +// Renamed defines model for renamed. +type Renamed = string + +// WithDefault defines model for withDefault. +type WithDefault string +-- out/encoding/gocode/TestGenerate/depointerized -- +== basicmultiversion_type_0.0_gen.go +package basicmultiversion + +// Basicmultiversion defines model for basicmultiversion. +type Basicmultiversion struct { + Init string `json:"init"` +} +== basicmultiversion_type_0.1_gen.go +package basicmultiversion + +// Basicmultiversion defines model for basicmultiversion. +type Basicmultiversion struct { + Init string `json:"init"` + Optional int32 `json:"optional,omitempty"` +} +== basicmultiversion_type_0.2_gen.go +package basicmultiversion + +// Defines values for BasicmultiversionWithDefault. +const ( + BasicmultiversionWithDefaultBar BasicmultiversionWithDefault = "bar" + BasicmultiversionWithDefaultFoo BasicmultiversionWithDefault = "foo" +) + +// Basicmultiversion defines model for basicmultiversion. +type Basicmultiversion struct { + Init string `json:"init"` + Optional int32 `json:"optional,omitempty"` + WithDefault BasicmultiversionWithDefault `json:"withDefault"` +} + +// BasicmultiversionWithDefault defines model for Basicmultiversion.WithDefault. +type BasicmultiversionWithDefault string +== basicmultiversion_type_0.3_gen.go +package basicmultiversion + +// Defines values for BasicmultiversionWithDefault. +const ( + BasicmultiversionWithDefaultBar BasicmultiversionWithDefault = "bar" + BasicmultiversionWithDefaultBaz BasicmultiversionWithDefault = "baz" + BasicmultiversionWithDefaultFoo BasicmultiversionWithDefault = "foo" +) + +// Basicmultiversion defines model for basicmultiversion. +type Basicmultiversion struct { + Init string `json:"init"` + Optional int32 `json:"optional,omitempty"` + WithDefault BasicmultiversionWithDefault `json:"withDefault"` +} + +// BasicmultiversionWithDefault defines model for Basicmultiversion.WithDefault. +type BasicmultiversionWithDefault string +== basicmultiversion_type_1.0_gen.go +package basicmultiversion + +// Defines values for BasicmultiversionWithDefault. +const ( + BasicmultiversionWithDefaultBar BasicmultiversionWithDefault = "bar" + BasicmultiversionWithDefaultBaz BasicmultiversionWithDefault = "baz" + BasicmultiversionWithDefaultFoo BasicmultiversionWithDefault = "foo" +) + +// Basicmultiversion defines model for basicmultiversion. +type Basicmultiversion struct { + Optional int32 `json:"optional,omitempty"` + Renamed string `json:"renamed"` + WithDefault BasicmultiversionWithDefault `json:"withDefault"` +} + +// BasicmultiversionWithDefault defines model for Basicmultiversion.WithDefault. +type BasicmultiversionWithDefault string +== basicmultiversion_type_1.1_gen.go +package basicmultiversion + +// Defines values for BasicmultiversionWithDefault. +const ( + BasicmultiversionWithDefaultBar BasicmultiversionWithDefault = "bar" + BasicmultiversionWithDefaultBaz BasicmultiversionWithDefault = "baz" + BasicmultiversionWithDefaultBing BasicmultiversionWithDefault = "bing" + BasicmultiversionWithDefaultFoo BasicmultiversionWithDefault = "foo" +) + +// Basicmultiversion defines model for basicmultiversion. +type Basicmultiversion struct { + Optional int32 `json:"optional,omitempty"` + Renamed string `json:"renamed"` + WithDefault BasicmultiversionWithDefault `json:"withDefault"` +} + +// BasicmultiversionWithDefault defines model for Basicmultiversion.WithDefault. +type BasicmultiversionWithDefault string diff --git a/testdata/lineage/embedexref.txtar b/testdata/lineage/embedexref.txtar index 3cb486fb..259e36df 100644 --- a/testdata/lineage/embedexref.txtar +++ b/testdata/lineage/embedexref.txtar @@ -16,43 +16,24 @@ lenses: [] refField1: string refField2: 42 } --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 --- out/encoding/openapi/TestGenerate/nilcfg -- -== 0.0.json -{ - "openapi": "3.0.0", - "info": { - "title": "embedexref", - "version": "0.0" - }, - "paths": {}, - "components": { - "schemas": { - "embedexref": { - "type": "object", - "required": [ - "refField1", - "refField2" - ], - "properties": { - "refField1": { - "type": "string" - }, - "refField2": { - "type": "integer", - "enum": [ - 42 - ] - } - } - } - } - } +-- out/encoding/gocode/TestGenerate/nilcfg -- +== embedexref_type_0.0_gen.go +package embedexref + +// Defines values for EmbedexrefRefField2. +const ( + EmbedexrefRefField2N42 EmbedexrefRefField2 = 42 +) + +// Embedexref defines model for embedexref. +type Embedexref struct { + RefField1 string `json:"refField1"` + RefField2 EmbedexrefRefField2 `json:"refField2"` } --- out/encoding/openapi/TestGenerate/expandrefs -- + +// EmbedexrefRefField2 defines model for Embedexref.RefField2. +type EmbedexrefRefField2 int +-- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { "openapi": "3.0.0", @@ -84,6 +65,20 @@ Lenses count: 0 } } } +-- out/encoding/gocode/TestGenerate/group -- +== embedexref_type_0.0_gen.go +package embedexref + +// Defines values for RefField2. +const ( + RefField2N42 RefField2 = 42 +) + +// RefField1 defines model for refField1. +type RefField1 = string + +// RefField2 defines model for refField2. +type RefField2 int -- out/encoding/openapi/TestGenerate/group -- == 0.0.json { @@ -107,37 +102,6 @@ Lenses count: 0 } } } --- out/encoding/gocode/TestGenerate/nilcfg -- -== embedexref_type_0.0_gen.go -package embedexref - -// Defines values for EmbedexrefRefField2. -const ( - EmbedexrefRefField2N42 EmbedexrefRefField2 = 42 -) - -// Embedexref defines model for embedexref. -type Embedexref struct { - RefField1 string `json:"refField1"` - RefField2 EmbedexrefRefField2 `json:"refField2"` -} - -// EmbedexrefRefField2 defines model for Embedexref.RefField2. -type EmbedexrefRefField2 int --- out/encoding/gocode/TestGenerate/group -- -== embedexref_type_0.0_gen.go -package embedexref - -// Defines values for RefField2. -const ( - RefField2N42 RefField2 = 42 -) - -// RefField1 defines model for refField1. -type RefField1 = string - -// RefField2 defines model for refField2. -type RefField2 int -- out/encoding/gocode/TestGenerate/depointerized -- == embedexref_type_0.0_gen.go package embedexref @@ -155,6 +119,38 @@ type Embedexref struct { // EmbedexrefRefField2 defines model for Embedexref.RefField2. type EmbedexrefRefField2 int +-- out/encoding/openapi/TestGenerate/expandrefs -- +== 0.0.json +{ + "openapi": "3.0.0", + "info": { + "title": "embedexref", + "version": "0.0" + }, + "paths": {}, + "components": { + "schemas": { + "embedexref": { + "type": "object", + "required": [ + "refField1", + "refField2" + ], + "properties": { + "refField1": { + "type": "string" + }, + "refField2": { + "type": "integer", + "enum": [ + 42 + ] + } + } + } + } + } +} -- out/encoding/gocode/TestGenerate/godeclincomments -- == embedexref_type_0.0_gen.go package embedexref @@ -189,3 +185,7 @@ type Embedexref struct { // EmbedexrefRefField2 defines model for Embedexref.RefField2. type EmbedexrefRefField2 int +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 diff --git a/testdata/lineage/embedref.txtar b/testdata/lineage/embedref.txtar index 7892821d..042a30ea 100644 --- a/testdata/lineage/embedref.txtar +++ b/testdata/lineage/embedref.txtar @@ -17,10 +17,6 @@ schemas: [{ }] lenses: [] --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -71,56 +67,34 @@ Lenses count: 0 } } } --- out/encoding/openapi/TestGenerate/expandrefs -- -== 0.0.json -{ - "openapi": "3.0.0", - "info": { - "title": "embedref", - "version": "0.0" - }, - "paths": {}, - "components": { - "schemas": { - "EmbedRef": { - "type": "object", - "required": [ - "refField1", - "refField2" - ], - "properties": { - "refField1": { - "type": "string" - }, - "refField2": { - "type": "integer", - "enum": [ - 42 - ] - } - } - }, - "embedref": { - "type": "object", - "required": [ - "refField1", - "refField2" - ], - "properties": { - "refField1": { - "type": "string" - }, - "refField2": { - "type": "integer", - "enum": [ - 42 - ] - } - } - } - } - } +-- out/encoding/gocode/TestGenerate/group -- +== embedref_type_0.0_gen.go +package embedref + +// Defines values for EmbedRefRefField2. +const ( + EmbedRefRefField2N42 EmbedRefRefField2 = 42 +) + +// Defines values for RefField2. +const ( + RefField2N42 RefField2 = 42 +) + +// EmbedRef defines model for EmbedRef. +type EmbedRef struct { + RefField1 string `json:"refField1"` + RefField2 EmbedRefRefField2 `json:"refField2"` } + +// EmbedRefRefField2 defines model for EmbedRef.RefField2. +type EmbedRefRefField2 int + +// RefField1 defines model for refField1. +type RefField1 = string + +// RefField2 defines model for refField2. +type RefField2 int -- out/encoding/openapi/TestGenerate/group -- == 0.0.json { @@ -162,7 +136,7 @@ Lenses count: 0 } } } --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/depointerized -- == embedref_type_0.0_gen.go package embedref @@ -193,35 +167,57 @@ type Embedref struct { // EmbedrefRefField2 defines model for Embedref.RefField2. type EmbedrefRefField2 int --- out/encoding/gocode/TestGenerate/group -- -== embedref_type_0.0_gen.go -package embedref - -// Defines values for EmbedRefRefField2. -const ( - EmbedRefRefField2N42 EmbedRefRefField2 = 42 -) - -// Defines values for RefField2. -const ( - RefField2N42 RefField2 = 42 -) - -// EmbedRef defines model for EmbedRef. -type EmbedRef struct { - RefField1 string `json:"refField1"` - RefField2 EmbedRefRefField2 `json:"refField2"` +-- out/encoding/openapi/TestGenerate/expandrefs -- +== 0.0.json +{ + "openapi": "3.0.0", + "info": { + "title": "embedref", + "version": "0.0" + }, + "paths": {}, + "components": { + "schemas": { + "EmbedRef": { + "type": "object", + "required": [ + "refField1", + "refField2" + ], + "properties": { + "refField1": { + "type": "string" + }, + "refField2": { + "type": "integer", + "enum": [ + 42 + ] + } + } + }, + "embedref": { + "type": "object", + "required": [ + "refField1", + "refField2" + ], + "properties": { + "refField1": { + "type": "string" + }, + "refField2": { + "type": "integer", + "enum": [ + 42 + ] + } + } + } + } + } } - -// EmbedRefRefField2 defines model for EmbedRef.RefField2. -type EmbedRefRefField2 int - -// RefField1 defines model for refField1. -type RefField1 = string - -// RefField2 defines model for refField2. -type RefField2 int --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == embedref_type_0.0_gen.go package embedref @@ -252,7 +248,7 @@ type Embedref struct { // EmbedrefRefField2 defines model for Embedref.RefField2. type EmbedrefRefField2 int --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/encoding/gocode/TestGenerate/expandref -- == embedref_type_0.0_gen.go package embedref @@ -283,7 +279,11 @@ type Embedref struct { // EmbedrefRefField2 defines model for Embedref.RefField2. type EmbedrefRefField2 int --- out/encoding/gocode/TestGenerate/expandref -- +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == embedref_type_0.0_gen.go package embedref diff --git a/testdata/lineage/expand.txtar b/testdata/lineage/expand.txtar index 8528ec6b..925f744c 100644 --- a/testdata/lineage/expand.txtar +++ b/testdata/lineage/expand.txtar @@ -70,10 +70,6 @@ lenses: [{ } } }] --- out/bind -- -Schema count: 4 -Schema versions: 0.0, 0.1, 0.2, 0.3 -Lenses count: 3 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -194,126 +190,55 @@ Lenses count: 3 } } } --- out/encoding/openapi/TestGenerate/expandrefs -- -== 0.0.json -{ - "openapi": "3.0.0", - "info": { - "title": "expand", - "version": "0.0" - }, - "paths": {}, - "components": { - "schemas": { - "expand": { - "type": "object", - "required": [ - "init" - ], - "properties": { - "init": { - "type": "string" - } - } - } - } - } -}== 0.1.json -{ - "openapi": "3.0.0", - "info": { - "title": "expand", - "version": "0.1" - }, - "paths": {}, - "components": { - "schemas": { - "expand": { - "type": "object", - "required": [ - "init" - ], - "properties": { - "init": { - "type": "string" - }, - "optional": { - "type": "integer" - } - } - } - } - } -}== 0.2.json -{ - "openapi": "3.0.0", - "info": { - "title": "expand", - "version": "0.2" - }, - "paths": {}, - "components": { - "schemas": { - "expand": { - "type": "object", - "required": [ - "init" - ], - "properties": { - "init": { - "type": "string" - }, - "optional": { - "type": "integer" - }, - "withDefault": { - "type": "string", - "enum": [ - "foo", - "bar" - ], - "default": "foo" - } - } - } - } - } -}== 0.3.json -{ - "openapi": "3.0.0", - "info": { - "title": "expand", - "version": "0.3" - }, - "paths": {}, - "components": { - "schemas": { - "expand": { - "type": "object", - "required": [ - "init" - ], - "properties": { - "init": { - "type": "string" - }, - "optional": { - "type": "integer" - }, - "withDefault": { - "type": "string", - "enum": [ - "foo", - "bar", - "baz" - ], - "default": "foo" - } - } - } - } - } -} +-- out/encoding/gocode/TestGenerate/group -- +== expand_type_0.0_gen.go +package expand + +// Init defines model for init. +type Init = string +== expand_type_0.1_gen.go +package expand + +// Init defines model for init. +type Init = string + +// Optional defines model for optional. +type Optional = int +== expand_type_0.2_gen.go +package expand + +// Defines values for WithDefault. +const ( + WithDefaultBar WithDefault = "bar" + WithDefaultFoo WithDefault = "foo" +) + +// Init defines model for init. +type Init = string + +// Optional defines model for optional. +type Optional = int + +// WithDefault defines model for withDefault. +type WithDefault string +== expand_type_0.3_gen.go +package expand + +// Defines values for WithDefault. +const ( + WithDefaultBar WithDefault = "bar" + WithDefaultBaz WithDefault = "baz" + WithDefaultFoo WithDefault = "foo" +) + +// Init defines model for init. +type Init = string + +// Optional defines model for optional. +type Optional = int + +// WithDefault defines model for withDefault. +type WithDefault string -- out/encoding/openapi/TestGenerate/group -- == 0.0.json { @@ -402,7 +327,7 @@ Lenses count: 3 } } } --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/depointerized -- == expand_type_0.0_gen.go package expand @@ -416,7 +341,7 @@ package expand // Expand defines model for expand. type Expand struct { Init string `json:"init"` - Optional *int `json:"optional,omitempty"` + Optional int `json:"optional,omitempty"` } == expand_type_0.2_gen.go package expand @@ -429,9 +354,9 @@ const ( // Expand defines model for expand. type Expand struct { - Init string `json:"init"` - Optional *int `json:"optional,omitempty"` - WithDefault *ExpandWithDefault `json:"withDefault,omitempty"` + Init string `json:"init"` + Optional int `json:"optional,omitempty"` + WithDefault ExpandWithDefault `json:"withDefault,omitempty"` } // ExpandWithDefault defines model for Expand.WithDefault. @@ -448,63 +373,134 @@ const ( // Expand defines model for expand. type Expand struct { - Init string `json:"init"` - Optional *int `json:"optional,omitempty"` - WithDefault *ExpandWithDefault `json:"withDefault,omitempty"` + Init string `json:"init"` + Optional int `json:"optional,omitempty"` + WithDefault ExpandWithDefault `json:"withDefault,omitempty"` } // ExpandWithDefault defines model for Expand.WithDefault. type ExpandWithDefault string --- out/encoding/gocode/TestGenerate/group -- -== expand_type_0.0_gen.go -package expand - -// Init defines model for init. -type Init = string -== expand_type_0.1_gen.go -package expand - -// Init defines model for init. -type Init = string - -// Optional defines model for optional. -type Optional = int -== expand_type_0.2_gen.go -package expand - -// Defines values for WithDefault. -const ( - WithDefaultBar WithDefault = "bar" - WithDefaultFoo WithDefault = "foo" -) - -// Init defines model for init. -type Init = string - -// Optional defines model for optional. -type Optional = int - -// WithDefault defines model for withDefault. -type WithDefault string -== expand_type_0.3_gen.go -package expand - -// Defines values for WithDefault. -const ( - WithDefaultBar WithDefault = "bar" - WithDefaultBaz WithDefault = "baz" - WithDefaultFoo WithDefault = "foo" -) - -// Init defines model for init. -type Init = string - -// Optional defines model for optional. -type Optional = int - -// WithDefault defines model for withDefault. -type WithDefault string --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/encoding/openapi/TestGenerate/expandrefs -- +== 0.0.json +{ + "openapi": "3.0.0", + "info": { + "title": "expand", + "version": "0.0" + }, + "paths": {}, + "components": { + "schemas": { + "expand": { + "type": "object", + "required": [ + "init" + ], + "properties": { + "init": { + "type": "string" + } + } + } + } + } +}== 0.1.json +{ + "openapi": "3.0.0", + "info": { + "title": "expand", + "version": "0.1" + }, + "paths": {}, + "components": { + "schemas": { + "expand": { + "type": "object", + "required": [ + "init" + ], + "properties": { + "init": { + "type": "string" + }, + "optional": { + "type": "integer" + } + } + } + } + } +}== 0.2.json +{ + "openapi": "3.0.0", + "info": { + "title": "expand", + "version": "0.2" + }, + "paths": {}, + "components": { + "schemas": { + "expand": { + "type": "object", + "required": [ + "init" + ], + "properties": { + "init": { + "type": "string" + }, + "optional": { + "type": "integer" + }, + "withDefault": { + "type": "string", + "enum": [ + "foo", + "bar" + ], + "default": "foo" + } + } + } + } + } +}== 0.3.json +{ + "openapi": "3.0.0", + "info": { + "title": "expand", + "version": "0.3" + }, + "paths": {}, + "components": { + "schemas": { + "expand": { + "type": "object", + "required": [ + "init" + ], + "properties": { + "init": { + "type": "string" + }, + "optional": { + "type": "integer" + }, + "withDefault": { + "type": "string", + "enum": [ + "foo", + "bar", + "baz" + ], + "default": "foo" + } + } + } + } + } +} +-- out/encoding/gocode/TestGenerate/godeclincomments -- == expand_type_0.0_gen.go package expand @@ -518,7 +514,7 @@ package expand // Expand defines model for expand. type Expand struct { Init string `json:"init"` - Optional int `json:"optional,omitempty"` + Optional *int `json:"optional,omitempty"` } == expand_type_0.2_gen.go package expand @@ -531,9 +527,9 @@ const ( // Expand defines model for expand. type Expand struct { - Init string `json:"init"` - Optional int `json:"optional,omitempty"` - WithDefault ExpandWithDefault `json:"withDefault,omitempty"` + Init string `json:"init"` + Optional *int `json:"optional,omitempty"` + WithDefault *ExpandWithDefault `json:"withDefault,omitempty"` } // ExpandWithDefault defines model for Expand.WithDefault. @@ -550,14 +546,14 @@ const ( // Expand defines model for expand. type Expand struct { - Init string `json:"init"` - Optional int `json:"optional,omitempty"` - WithDefault ExpandWithDefault `json:"withDefault,omitempty"` + Init string `json:"init"` + Optional *int `json:"optional,omitempty"` + WithDefault *ExpandWithDefault `json:"withDefault,omitempty"` } // ExpandWithDefault defines model for Expand.WithDefault. type ExpandWithDefault string --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/encoding/gocode/TestGenerate/expandref -- == expand_type_0.0_gen.go package expand @@ -610,7 +606,11 @@ type Expand struct { // ExpandWithDefault defines model for Expand.WithDefault. type ExpandWithDefault string --- out/encoding/gocode/TestGenerate/expandref -- +-- out/bind -- +Schema count: 4 +Schema versions: 0.0, 0.1, 0.2, 0.3 +Lenses count: 3 +-- out/encoding/gocode/TestGenerate/nilcfg -- == expand_type_0.0_gen.go package expand diff --git a/testdata/lineage/join/embedref.txtar b/testdata/lineage/join/embedref.txtar index fc005881..dc2a4ab5 100644 --- a/testdata/lineage/join/embedref.txtar +++ b/testdata/lineage/join/embedref.txtar @@ -19,10 +19,6 @@ EmbedRef: { refField1: string refField2: 42 } --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -67,42 +63,23 @@ Lenses count: 0 } } } --- out/encoding/openapi/TestGenerate/expandrefs -- -== 0.0.json -{ - "openapi": "3.0.0", - "info": { - "title": "embedref", - "version": "0.0" - }, - "paths": {}, - "components": { - "schemas": { - "embedref": { - "type": "object", - "required": [ - "refField1", - "foo", - "refField2" - ], - "properties": { - "refField1": { - "type": "string" - }, - "foo": { - "type": "string" - }, - "refField2": { - "type": "integer", - "enum": [ - 42 - ] - } - } - } - } - } -} +-- out/encoding/gocode/TestGenerate/group -- +== embedref_type_0.0_gen.go +package embedref + +// Defines values for RefField2. +const ( + RefField2N42 RefField2 = 42 +) + +// Foo defines model for foo. +type Foo = string + +// RefField1 defines model for refField1. +type RefField1 = string + +// RefField2 defines model for refField2. +type RefField2 int -- out/encoding/openapi/TestGenerate/group -- == 0.0.json { @@ -129,7 +106,7 @@ Lenses count: 0 } } } --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/depointerized -- == embedref_type_0.0_gen.go package embedref @@ -147,24 +124,43 @@ type Embedref struct { // EmbedrefRefField2 defines model for Embedref.RefField2. type EmbedrefRefField2 int --- out/encoding/gocode/TestGenerate/group -- -== embedref_type_0.0_gen.go -package embedref - -// Defines values for RefField2. -const ( - RefField2N42 RefField2 = 42 -) - -// Foo defines model for foo. -type Foo = string - -// RefField1 defines model for refField1. -type RefField1 = string - -// RefField2 defines model for refField2. -type RefField2 int --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/encoding/openapi/TestGenerate/expandrefs -- +== 0.0.json +{ + "openapi": "3.0.0", + "info": { + "title": "embedref", + "version": "0.0" + }, + "paths": {}, + "components": { + "schemas": { + "embedref": { + "type": "object", + "required": [ + "refField1", + "foo", + "refField2" + ], + "properties": { + "refField1": { + "type": "string" + }, + "foo": { + "type": "string" + }, + "refField2": { + "type": "integer", + "enum": [ + 42 + ] + } + } + } + } + } +} +-- out/encoding/gocode/TestGenerate/godeclincomments -- == embedref_type_0.0_gen.go package embedref @@ -182,7 +178,7 @@ type Embedref struct { // EmbedrefRefField2 defines model for Embedref.RefField2. type EmbedrefRefField2 int --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/encoding/gocode/TestGenerate/expandref -- == embedref_type_0.0_gen.go package embedref @@ -200,7 +196,11 @@ type Embedref struct { // EmbedrefRefField2 defines model for Embedref.RefField2. type EmbedrefRefField2 int --- out/encoding/gocode/TestGenerate/expandref -- +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == embedref_type_0.0_gen.go package embedref diff --git a/testdata/lineage/join/exref.txtar b/testdata/lineage/join/exref.txtar index d546e099..c9f4986e 100644 --- a/testdata/lineage/join/exref.txtar +++ b/testdata/lineage/join/exref.txtar @@ -23,10 +23,6 @@ ExRef: { #ExRefDef: { defField: string } --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -90,54 +86,21 @@ Lenses count: 0 } } } --- out/encoding/openapi/TestGenerate/expandrefs -- -== 0.0.json -{ - "openapi": "3.0.0", - "info": { - "title": "exref", - "version": "0.0" - }, - "paths": {}, - "components": { - "schemas": { - "exref": { - "type": "object", - "required": [ - "ref", - "foo", - "refdef" - ], - "properties": { - "ref": { - "type": "object", - "required": [ - "normalField" - ], - "properties": { - "normalField": { - "type": "string" - } - } - }, - "foo": { - "type": "string" - }, - "refdef": { - "type": "object", - "required": [ - "defField" - ], - "properties": { - "defField": { - "type": "string" - } - } - } - } - } - } - } +-- out/encoding/gocode/TestGenerate/group -- +== exref_type_0.0_gen.go +package exref + +// Foo defines model for foo. +type Foo = string + +// Ref defines model for ref. +type Ref struct { + NormalField string `json:"normalField"` +} + +// Refdef defines model for refdef. +type Refdef struct { + DefField string `json:"defField"` } -- out/encoding/openapi/TestGenerate/group -- == 0.0.json @@ -178,7 +141,7 @@ Lenses count: 0 } } } --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/depointerized -- == exref_type_0.0_gen.go package exref @@ -198,23 +161,56 @@ type Exref struct { Ref ExRef `json:"ref"` Refdef ExRefDef `json:"refdef"` } --- out/encoding/gocode/TestGenerate/group -- -== exref_type_0.0_gen.go -package exref - -// Foo defines model for foo. -type Foo = string - -// Ref defines model for ref. -type Ref struct { - NormalField string `json:"normalField"` -} - -// Refdef defines model for refdef. -type Refdef struct { - DefField string `json:"defField"` +-- out/encoding/openapi/TestGenerate/expandrefs -- +== 0.0.json +{ + "openapi": "3.0.0", + "info": { + "title": "exref", + "version": "0.0" + }, + "paths": {}, + "components": { + "schemas": { + "exref": { + "type": "object", + "required": [ + "ref", + "foo", + "refdef" + ], + "properties": { + "ref": { + "type": "object", + "required": [ + "normalField" + ], + "properties": { + "normalField": { + "type": "string" + } + } + }, + "foo": { + "type": "string" + }, + "refdef": { + "type": "object", + "required": [ + "defField" + ], + "properties": { + "defField": { + "type": "string" + } + } + } + } + } + } + } } --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == exref_type_0.0_gen.go package exref @@ -234,7 +230,25 @@ type Exref struct { Ref ExRef `json:"ref"` Refdef ExRefDef `json:"refdef"` } --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/encoding/gocode/TestGenerate/expandref -- +== exref_type_0.0_gen.go +package exref + +// Exref defines model for exref. +type Exref struct { + Foo string `json:"foo"` + Ref struct { + NormalField string `json:"normalField"` + } `json:"ref"` + Refdef struct { + DefField string `json:"defField"` + } `json:"refdef"` +} +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == exref_type_0.0_gen.go package exref @@ -254,17 +268,3 @@ type Exref struct { Ref ExRef `json:"ref"` Refdef ExRefDef `json:"refdef"` } --- out/encoding/gocode/TestGenerate/expandref -- -== exref_type_0.0_gen.go -package exref - -// Exref defines model for exref. -type Exref struct { - Foo string `json:"foo"` - Ref struct { - NormalField string `json:"normalField"` - } `json:"ref"` - Refdef struct { - DefField string `json:"defField"` - } `json:"refdef"` -} diff --git a/testdata/lineage/join/nearoptional.txtar b/testdata/lineage/join/nearoptional.txtar index 6702cdb1..905031a0 100644 --- a/testdata/lineage/join/nearoptional.txtar +++ b/testdata/lineage/join/nearoptional.txtar @@ -22,100 +22,6 @@ schemas: [{ } }] lenses: [] --- out/encoding/gocode/TestGenerate/nilcfg -- -== nearoptional_type_0.0_gen.go -package nearoptional - -// Nearoptional defines model for nearoptional. -type Nearoptional struct { - Abool *bool `json:"abool,omitempty"` - Abytes []byte `json:"abytes,omitempty"` - Alist []string `json:"alist,omitempty"` - Anint *int `json:"anint,omitempty"` - Astring *string `json:"astring,omitempty"` - Astruct *struct { - Nested string `json:"nested"` - } `json:"astruct,omitempty"` - Notoptional int32 `json:"notoptional"` -} --- out/encoding/gocode/TestGenerate/group -- -== nearoptional_type_0.0_gen.go -package nearoptional - -// Abool defines model for abool. -type Abool = bool - -// Abytes defines model for abytes. -type Abytes = []byte - -// Alist defines model for alist. -type Alist = []string - -// Anint defines model for anint. -type Anint = int - -// Astring defines model for astring. -type Astring = string - -// Astruct defines model for astruct. -type Astruct struct { - Nested string `json:"nested"` -} - -// Notoptional defines model for notoptional. -type Notoptional = int32 --- out/encoding/gocode/TestGenerate/depointerized -- -== nearoptional_type_0.0_gen.go -package nearoptional - -// Nearoptional defines model for nearoptional. -type Nearoptional struct { - Abool bool `json:"abool,omitempty"` - Abytes []byte `json:"abytes,omitempty"` - Alist []string `json:"alist,omitempty"` - Anint int `json:"anint,omitempty"` - Astring string `json:"astring,omitempty"` - Astruct struct { - Nested string `json:"nested"` - } `json:"astruct,omitempty"` - Notoptional int32 `json:"notoptional"` -} --- out/encoding/gocode/TestGenerate/godeclincomments -- -== nearoptional_type_0.0_gen.go -package nearoptional - -// Nearoptional defines model for nearoptional. -type Nearoptional struct { - Abool *bool `json:"abool,omitempty"` - Abytes []byte `json:"abytes,omitempty"` - Alist []string `json:"alist,omitempty"` - Anint *int `json:"anint,omitempty"` - Astring *string `json:"astring,omitempty"` - Astruct *struct { - Nested string `json:"nested"` - } `json:"astruct,omitempty"` - Notoptional int32 `json:"notoptional"` -} --- out/encoding/gocode/TestGenerate/expandref -- -== nearoptional_type_0.0_gen.go -package nearoptional - -// Nearoptional defines model for nearoptional. -type Nearoptional struct { - Abool *bool `json:"abool,omitempty"` - Abytes []byte `json:"abytes,omitempty"` - Alist []string `json:"alist,omitempty"` - Anint *int `json:"anint,omitempty"` - Astring *string `json:"astring,omitempty"` - Astruct *struct { - Nested string `json:"nested"` - } `json:"astruct,omitempty"` - Notoptional int32 `json:"notoptional"` -} --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -172,6 +78,32 @@ Lenses count: 0 } } } +-- out/encoding/gocode/TestGenerate/group -- +== nearoptional_type_0.0_gen.go +package nearoptional + +// Abool defines model for abool. +type Abool = bool + +// Abytes defines model for abytes. +type Abytes = []byte + +// Alist defines model for alist. +type Alist = []string + +// Anint defines model for anint. +type Anint = int + +// Astring defines model for astring. +type Astring = string + +// Astruct defines model for astruct. +type Astruct struct { + Nested string `json:"nested"` +} + +// Notoptional defines model for notoptional. +type Notoptional = int32 -- out/encoding/openapi/TestGenerate/group -- == 0.0.json { @@ -220,6 +152,22 @@ Lenses count: 0 } } } +-- out/encoding/gocode/TestGenerate/depointerized -- +== nearoptional_type_0.0_gen.go +package nearoptional + +// Nearoptional defines model for nearoptional. +type Nearoptional struct { + Abool bool `json:"abool,omitempty"` + Abytes []byte `json:"abytes,omitempty"` + Alist []string `json:"alist,omitempty"` + Anint int `json:"anint,omitempty"` + Astring string `json:"astring,omitempty"` + Astruct struct { + Nested string `json:"nested"` + } `json:"astruct,omitempty"` + Notoptional int32 `json:"notoptional"` +} -- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { @@ -276,3 +224,55 @@ Lenses count: 0 } } } +-- out/encoding/gocode/TestGenerate/godeclincomments -- +== nearoptional_type_0.0_gen.go +package nearoptional + +// Nearoptional defines model for nearoptional. +type Nearoptional struct { + Abool *bool `json:"abool,omitempty"` + Abytes []byte `json:"abytes,omitempty"` + Alist []string `json:"alist,omitempty"` + Anint *int `json:"anint,omitempty"` + Astring *string `json:"astring,omitempty"` + Astruct *struct { + Nested string `json:"nested"` + } `json:"astruct,omitempty"` + Notoptional int32 `json:"notoptional"` +} +-- out/encoding/gocode/TestGenerate/expandref -- +== nearoptional_type_0.0_gen.go +package nearoptional + +// Nearoptional defines model for nearoptional. +type Nearoptional struct { + Abool *bool `json:"abool,omitempty"` + Abytes []byte `json:"abytes,omitempty"` + Alist []string `json:"alist,omitempty"` + Anint *int `json:"anint,omitempty"` + Astring *string `json:"astring,omitempty"` + Astruct *struct { + Nested string `json:"nested"` + } `json:"astruct,omitempty"` + Notoptional int32 `json:"notoptional"` +} +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- +== nearoptional_type_0.0_gen.go +package nearoptional + +// Nearoptional defines model for nearoptional. +type Nearoptional struct { + Abool *bool `json:"abool,omitempty"` + Abytes []byte `json:"abytes,omitempty"` + Alist []string `json:"alist,omitempty"` + Anint *int `json:"anint,omitempty"` + Astring *string `json:"astring,omitempty"` + Astruct *struct { + Nested string `json:"nested"` + } `json:"astruct,omitempty"` + Notoptional int32 `json:"notoptional"` +} diff --git a/testdata/lineage/join/onenone.txtar b/testdata/lineage/join/onenone.txtar index 0113caeb..d4c60e9e 100644 --- a/testdata/lineage/join/onenone.txtar +++ b/testdata/lineage/join/onenone.txtar @@ -13,10 +13,6 @@ schemas: [{ } }] lenses: [] --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -42,7 +38,7 @@ Lenses count: 0 } } } --- out/encoding/openapi/TestGenerate/expandrefs -- +-- out/encoding/openapi/TestGenerate/group -- == 0.0.json { "openapi": "3.0.0", @@ -53,21 +49,21 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "onenone": { - "type": "object", - "required": [ - "foo" - ], - "properties": { - "foo": { - "type": "string" - } - } + "foo": { + "type": "string" } } } } --- out/encoding/openapi/TestGenerate/group -- +-- out/encoding/gocode/TestGenerate/depointerized -- +== onenone_type_0.0_gen.go +package onenone + +// Onenone defines model for onenone. +type Onenone struct { + Foo string `json:"foo"` +} +-- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { "openapi": "3.0.0", @@ -78,13 +74,21 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "foo": { - "type": "string" + "onenone": { + "type": "object", + "required": [ + "foo" + ], + "properties": { + "foo": { + "type": "string" + } + } } } } } --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == onenone_type_0.0_gen.go package onenone @@ -92,13 +96,7 @@ package onenone type Onenone struct { Foo string `json:"foo"` } --- out/encoding/gocode/TestGenerate/group -- -== onenone_type_0.0_gen.go -package onenone - -// Foo defines model for foo. -type Foo = string --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/encoding/gocode/TestGenerate/expandref -- == onenone_type_0.0_gen.go package onenone @@ -106,7 +104,11 @@ package onenone type Onenone struct { Foo string `json:"foo"` } --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == onenone_type_0.0_gen.go package onenone @@ -114,11 +116,9 @@ package onenone type Onenone struct { Foo string `json:"foo"` } --- out/encoding/gocode/TestGenerate/expandref -- +-- out/encoding/gocode/TestGenerate/group -- == onenone_type_0.0_gen.go package onenone -// Onenone defines model for onenone. -type Onenone struct { - Foo string `json:"foo"` -} +// Foo defines model for foo. +type Foo = string diff --git a/testdata/lineage/join/oneone.txtar b/testdata/lineage/join/oneone.txtar index 1cdc0332..eae87de2 100644 --- a/testdata/lineage/join/oneone.txtar +++ b/testdata/lineage/join/oneone.txtar @@ -14,10 +14,6 @@ schemas: [{ } }] lenses: [] --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -55,6 +51,44 @@ Lenses count: 0 } } } +-- out/encoding/gocode/TestGenerate/group -- +== oneone_type_0.0_gen.go +package oneone + +// Bar defines model for bar. +type Bar = string + +// Foo defines model for foo. +type Foo = string +-- out/encoding/openapi/TestGenerate/group -- +== 0.0.json +{ + "openapi": "3.0.0", + "info": { + "title": "oneone", + "version": "0.0" + }, + "paths": {}, + "components": { + "schemas": { + "foo": { + "type": "string" + }, + "bar": { + "type": "string" + } + } + } +} +-- out/encoding/gocode/TestGenerate/depointerized -- +== oneone_type_0.0_gen.go +package oneone + +// Oneone defines model for oneone. +type Oneone struct { + Bar string `json:"bar"` + Foo string `json:"foo"` +} -- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { @@ -84,45 +118,7 @@ Lenses count: 0 } } } --- out/encoding/openapi/TestGenerate/group -- -== 0.0.json -{ - "openapi": "3.0.0", - "info": { - "title": "oneone", - "version": "0.0" - }, - "paths": {}, - "components": { - "schemas": { - "foo": { - "type": "string" - }, - "bar": { - "type": "string" - } - } - } -} --- out/encoding/gocode/TestGenerate/nilcfg -- -== oneone_type_0.0_gen.go -package oneone - -// Oneone defines model for oneone. -type Oneone struct { - Bar string `json:"bar"` - Foo string `json:"foo"` -} --- out/encoding/gocode/TestGenerate/group -- -== oneone_type_0.0_gen.go -package oneone - -// Bar defines model for bar. -type Bar = string - -// Foo defines model for foo. -type Foo = string --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == oneone_type_0.0_gen.go package oneone @@ -131,7 +127,7 @@ type Oneone struct { Bar string `json:"bar"` Foo string `json:"foo"` } --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/encoding/gocode/TestGenerate/expandref -- == oneone_type_0.0_gen.go package oneone @@ -140,7 +136,11 @@ type Oneone struct { Bar string `json:"bar"` Foo string `json:"foo"` } --- out/encoding/gocode/TestGenerate/expandref -- +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == oneone_type_0.0_gen.go package oneone diff --git a/testdata/lineage/join/onestruct.txtar b/testdata/lineage/join/onestruct.txtar index 59bea26e..88c53a1b 100644 --- a/testdata/lineage/join/onestruct.txtar +++ b/testdata/lineage/join/onestruct.txtar @@ -16,10 +16,6 @@ schemas: [{ } }] lenses: [] --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -65,7 +61,7 @@ Lenses count: 0 } } } --- out/encoding/openapi/TestGenerate/expandrefs -- +-- out/encoding/openapi/TestGenerate/group -- == 0.0.json { "openapi": "3.0.0", @@ -76,33 +72,35 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "onestruct": { + "aField": { "type": "object", "required": [ - "aField", - "foo" + "defLitField" ], "properties": { - "aField": { - "type": "object", - "required": [ - "defLitField" - ], - "properties": { - "defLitField": { - "type": "string" - } - } - }, - "foo": { + "defLitField": { "type": "string" } } + }, + "foo": { + "type": "string" } } } } --- out/encoding/openapi/TestGenerate/group -- +-- out/encoding/gocode/TestGenerate/depointerized -- +== onestruct_type_0.0_gen.go +package onestruct + +// Onestruct defines model for onestruct. +type Onestruct struct { + AField struct { + DefLitField string `json:"defLitField"` + } `json:"aField"` + Foo string `json:"foo"` +} +-- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { "openapi": "3.0.0", @@ -113,24 +111,33 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "aField": { + "onestruct": { "type": "object", "required": [ - "defLitField" + "aField", + "foo" ], "properties": { - "defLitField": { + "aField": { + "type": "object", + "required": [ + "defLitField" + ], + "properties": { + "defLitField": { + "type": "string" + } + } + }, + "foo": { "type": "string" } } - }, - "foo": { - "type": "string" } } } } --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == onestruct_type_0.0_gen.go package onestruct @@ -141,18 +148,7 @@ type Onestruct struct { } `json:"aField"` Foo string `json:"foo"` } --- out/encoding/gocode/TestGenerate/group -- -== onestruct_type_0.0_gen.go -package onestruct - -// AField defines model for aField. -type AField struct { - DefLitField string `json:"defLitField"` -} - -// Foo defines model for foo. -type Foo = string --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/encoding/gocode/TestGenerate/expandref -- == onestruct_type_0.0_gen.go package onestruct @@ -163,7 +159,11 @@ type Onestruct struct { } `json:"aField"` Foo string `json:"foo"` } --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == onestruct_type_0.0_gen.go package onestruct @@ -174,14 +174,14 @@ type Onestruct struct { } `json:"aField"` Foo string `json:"foo"` } --- out/encoding/gocode/TestGenerate/expandref -- +-- out/encoding/gocode/TestGenerate/group -- == onestruct_type_0.0_gen.go package onestruct -// Onestruct defines model for onestruct. -type Onestruct struct { - AField struct { - DefLitField string `json:"defLitField"` - } `json:"aField"` - Foo string `json:"foo"` +// AField defines model for aField. +type AField struct { + DefLitField string `json:"defLitField"` } + +// Foo defines model for foo. +type Foo = string diff --git a/testdata/lineage/join/repeat.txtar b/testdata/lineage/join/repeat.txtar index a760335b..c3d39a87 100644 --- a/testdata/lineage/join/repeat.txtar +++ b/testdata/lineage/join/repeat.txtar @@ -14,10 +14,6 @@ schemas: [{ } }] lenses: [] --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -43,7 +39,13 @@ Lenses count: 0 } } } --- out/encoding/openapi/TestGenerate/expandrefs -- +-- out/encoding/gocode/TestGenerate/group -- +== repeat_type_0.0_gen.go +package repeat + +// Foo defines model for foo. +type Foo = string +-- out/encoding/openapi/TestGenerate/group -- == 0.0.json { "openapi": "3.0.0", @@ -54,21 +56,21 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "repeat": { - "type": "object", - "required": [ - "foo" - ], - "properties": { - "foo": { - "type": "string" - } - } + "foo": { + "type": "string" } } } } --- out/encoding/openapi/TestGenerate/group -- +-- out/encoding/gocode/TestGenerate/depointerized -- +== repeat_type_0.0_gen.go +package repeat + +// Repeat defines model for repeat. +type Repeat struct { + Foo string `json:"foo"` +} +-- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { "openapi": "3.0.0", @@ -79,27 +81,21 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "foo": { - "type": "string" + "repeat": { + "type": "object", + "required": [ + "foo" + ], + "properties": { + "foo": { + "type": "string" + } + } } } } } --- out/encoding/gocode/TestGenerate/nilcfg -- -== repeat_type_0.0_gen.go -package repeat - -// Repeat defines model for repeat. -type Repeat struct { - Foo string `json:"foo"` -} --- out/encoding/gocode/TestGenerate/group -- -== repeat_type_0.0_gen.go -package repeat - -// Foo defines model for foo. -type Foo = string --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == repeat_type_0.0_gen.go package repeat @@ -107,7 +103,7 @@ package repeat type Repeat struct { Foo string `json:"foo"` } --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/encoding/gocode/TestGenerate/expandref -- == repeat_type_0.0_gen.go package repeat @@ -115,7 +111,11 @@ package repeat type Repeat struct { Foo string `json:"foo"` } --- out/encoding/gocode/TestGenerate/expandref -- +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == repeat_type_0.0_gen.go package repeat diff --git a/testdata/lineage/maps.txtar b/testdata/lineage/maps.txtar index f76f8c8e..cc6cd2eb 100644 --- a/testdata/lineage/maps.txtar +++ b/testdata/lineage/maps.txtar @@ -24,10 +24,6 @@ lin: lenses: [] aMap: [string]: bool aStruct: foo: string --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -138,6 +134,128 @@ Lenses count: 0 } } } +-- out/encoding/openapi/TestGenerate/group -- +== 0.0.json +{ + "openapi": "3.0.0", + "info": { + "title": "maps", + "version": "0.0" + }, + "paths": {}, + "components": { + "schemas": { + "valPrimitive": { + "type": "object", + "additionalProperties": { + "type": "boolean" + } + }, + "valList": { + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "valStruct": { + "type": "object", + "additionalProperties": { + "type": "object", + "required": [ + "foo" + ], + "properties": { + "foo": { + "type": "string" + } + } + } + }, + "optValPrimitive": { + "type": "object", + "additionalProperties": { + "type": "boolean" + } + }, + "optValList": { + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "optValStruct": { + "type": "object", + "additionalProperties": { + "type": "object", + "required": [ + "foo" + ], + "properties": { + "foo": { + "type": "string" + } + } + } + }, + "aStruct": { + "type": "object", + "required": [ + "foo" + ], + "properties": { + "foo": { + "type": "string" + } + } + }, + "refValue": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/aStruct" + } + }, + "someField": { + "type": "object", + "additionalProperties": { + "type": "boolean" + } + } + } + } +} +-- out/encoding/gocode/TestGenerate/depointerized -- +== maps_type_0.0_gen.go +package maps + +// AMap defines model for aMap. +type AMap map[string]bool + +// AStruct defines model for aStruct. +type AStruct struct { + Foo string `json:"foo"` +} + +// Maps defines model for maps. +type Maps struct { + OptValList map[string][]string `json:"optValList,omitempty"` + OptValPrimitive map[string]bool `json:"optValPrimitive,omitempty"` + OptValStruct map[string]struct { + Foo string `json:"foo"` + } `json:"optValStruct,omitempty"` + RefValue map[string]AStruct `json:"refValue"` + SomeField AMap `json:"someField"` + ValList map[string][]string `json:"valList"` + ValPrimitive map[string]bool `json:"valPrimitive"` + ValStruct map[string]struct { + Foo string `json:"foo"` + } `json:"valStruct"` +} -- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { @@ -242,101 +360,6 @@ Lenses count: 0 } } } --- out/encoding/openapi/TestGenerate/group -- -== 0.0.json -{ - "openapi": "3.0.0", - "info": { - "title": "maps", - "version": "0.0" - }, - "paths": {}, - "components": { - "schemas": { - "valPrimitive": { - "type": "object", - "additionalProperties": { - "type": "boolean" - } - }, - "valList": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "valStruct": { - "type": "object", - "additionalProperties": { - "type": "object", - "required": [ - "foo" - ], - "properties": { - "foo": { - "type": "string" - } - } - } - }, - "optValPrimitive": { - "type": "object", - "additionalProperties": { - "type": "boolean" - } - }, - "optValList": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "optValStruct": { - "type": "object", - "additionalProperties": { - "type": "object", - "required": [ - "foo" - ], - "properties": { - "foo": { - "type": "string" - } - } - } - }, - "aStruct": { - "type": "object", - "required": [ - "foo" - ], - "properties": { - "foo": { - "type": "string" - } - } - }, - "refValue": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/aStruct" - } - }, - "someField": { - "type": "object", - "additionalProperties": { - "type": "boolean" - } - } - } - } -} -- out/encoding/openapi/TestGenerate/subpath -- == 0.0.json { @@ -377,7 +400,7 @@ Lenses count: 0 } } } --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == maps_type_0.0_gen.go package maps @@ -404,54 +427,10 @@ type Maps struct { Foo string `json:"foo"` } `json:"valStruct"` } --- out/encoding/gocode/TestGenerate/group -- -== maps_type_0.0_gen.go -package maps - -// AStruct defines model for aStruct. -type AStruct struct { - Foo string `json:"foo"` -} - -// OptValList defines model for optValList. -type OptValList map[string][]string - -// OptValPrimitive defines model for optValPrimitive. -type OptValPrimitive map[string]bool - -// OptValStruct defines model for optValStruct. -type OptValStruct map[string]struct { - Foo string `json:"foo"` -} - -// RefValue defines model for refValue. -type RefValue map[string]AStruct - -// SomeField defines model for someField. -type SomeField map[string]bool - -// ValList defines model for valList. -type ValList map[string][]string - -// ValPrimitive defines model for valPrimitive. -type ValPrimitive map[string]bool - -// ValStruct defines model for valStruct. -type ValStruct map[string]struct { - Foo string `json:"foo"` -} --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/encoding/gocode/TestGenerate/expandref -- == maps_type_0.0_gen.go package maps -// AMap defines model for aMap. -type AMap map[string]bool - -// AStruct defines model for aStruct. -type AStruct struct { - Foo string `json:"foo"` -} - // Maps defines model for maps. type Maps struct { OptValList map[string][]string `json:"optValList,omitempty"` @@ -459,15 +438,21 @@ type Maps struct { OptValStruct map[string]struct { Foo string `json:"foo"` } `json:"optValStruct,omitempty"` - RefValue map[string]AStruct `json:"refValue"` - SomeField AMap `json:"someField"` + RefValue map[string]struct { + Foo string `json:"foo"` + } `json:"refValue"` + SomeField map[string]bool `json:"someField"` ValList map[string][]string `json:"valList"` ValPrimitive map[string]bool `json:"valPrimitive"` ValStruct map[string]struct { Foo string `json:"foo"` } `json:"valStruct"` } --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == maps_type_0.0_gen.go package maps @@ -494,24 +479,39 @@ type Maps struct { Foo string `json:"foo"` } `json:"valStruct"` } --- out/encoding/gocode/TestGenerate/expandref -- +-- out/encoding/gocode/TestGenerate/group -- == maps_type_0.0_gen.go package maps -// Maps defines model for maps. -type Maps struct { - OptValList map[string][]string `json:"optValList,omitempty"` - OptValPrimitive map[string]bool `json:"optValPrimitive,omitempty"` - OptValStruct map[string]struct { - Foo string `json:"foo"` - } `json:"optValStruct,omitempty"` - RefValue map[string]struct { - Foo string `json:"foo"` - } `json:"refValue"` - SomeField map[string]bool `json:"someField"` - ValList map[string][]string `json:"valList"` - ValPrimitive map[string]bool `json:"valPrimitive"` - ValStruct map[string]struct { - Foo string `json:"foo"` - } `json:"valStruct"` +// AStruct defines model for aStruct. +type AStruct struct { + Foo string `json:"foo"` +} + +// OptValList defines model for optValList. +type OptValList map[string][]string + +// OptValPrimitive defines model for optValPrimitive. +type OptValPrimitive map[string]bool + +// OptValStruct defines model for optValStruct. +type OptValStruct map[string]struct { + Foo string `json:"foo"` +} + +// RefValue defines model for refValue. +type RefValue map[string]AStruct + +// SomeField defines model for someField. +type SomeField map[string]bool + +// ValList defines model for valList. +type ValList map[string][]string + +// ValPrimitive defines model for valPrimitive. +type ValPrimitive map[string]bool + +// ValStruct defines model for valStruct. +type ValStruct map[string]struct { + Foo string `json:"foo"` } diff --git a/testdata/lineage/nearoptional.txtar b/testdata/lineage/nearoptional.txtar index 1daac20c..f725ddad 100644 --- a/testdata/lineage/nearoptional.txtar +++ b/testdata/lineage/nearoptional.txtar @@ -76,6 +76,32 @@ lenses: [] } } } +-- out/encoding/gocode/TestGenerate/group -- +== nearoptional_type_0.0_gen.go +package nearoptional + +// Abool defines model for abool. +type Abool = bool + +// Abytes defines model for abytes. +type Abytes = []byte + +// Alist defines model for alist. +type Alist = []string + +// Anint defines model for anint. +type Anint = int + +// Astring defines model for astring. +type Astring = string + +// Astruct defines model for astruct. +type Astruct struct { + Nested string `json:"nested"` +} + +// Notoptional defines model for notoptional. +type Notoptional = int32 -- out/encoding/openapi/TestGenerate/group -- == 0.0.json { @@ -124,6 +150,22 @@ lenses: [] } } } +-- out/encoding/gocode/TestGenerate/depointerized -- +== nearoptional_type_0.0_gen.go +package nearoptional + +// Nearoptional defines model for nearoptional. +type Nearoptional struct { + Abool bool `json:"abool,omitempty"` + Abytes []byte `json:"abytes,omitempty"` + Alist []string `json:"alist,omitempty"` + Anint int `json:"anint,omitempty"` + Astring string `json:"astring,omitempty"` + Astruct struct { + Nested string `json:"nested"` + } `json:"astruct,omitempty"` + Notoptional int32 `json:"notoptional"` +} -- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { @@ -180,7 +222,7 @@ lenses: [] } } } --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == nearoptional_type_0.0_gen.go package nearoptional @@ -196,49 +238,7 @@ type Nearoptional struct { } `json:"astruct,omitempty"` Notoptional int32 `json:"notoptional"` } --- out/encoding/gocode/TestGenerate/group -- -== nearoptional_type_0.0_gen.go -package nearoptional - -// Abool defines model for abool. -type Abool = bool - -// Abytes defines model for abytes. -type Abytes = []byte - -// Alist defines model for alist. -type Alist = []string - -// Anint defines model for anint. -type Anint = int - -// Astring defines model for astring. -type Astring = string - -// Astruct defines model for astruct. -type Astruct struct { - Nested string `json:"nested"` -} - -// Notoptional defines model for notoptional. -type Notoptional = int32 --- out/encoding/gocode/TestGenerate/depointerized -- -== nearoptional_type_0.0_gen.go -package nearoptional - -// Nearoptional defines model for nearoptional. -type Nearoptional struct { - Abool bool `json:"abool,omitempty"` - Abytes []byte `json:"abytes,omitempty"` - Alist []string `json:"alist,omitempty"` - Anint int `json:"anint,omitempty"` - Astring string `json:"astring,omitempty"` - Astruct struct { - Nested string `json:"nested"` - } `json:"astruct,omitempty"` - Notoptional int32 `json:"notoptional"` -} --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/encoding/gocode/TestGenerate/expandref -- == nearoptional_type_0.0_gen.go package nearoptional @@ -254,7 +254,11 @@ type Nearoptional struct { } `json:"astruct,omitempty"` Notoptional int32 `json:"notoptional"` } --- out/encoding/gocode/TestGenerate/expandref -- +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == nearoptional_type_0.0_gen.go package nearoptional @@ -270,7 +274,3 @@ type Nearoptional struct { } `json:"astruct,omitempty"` Notoptional int32 `json:"notoptional"` } --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 diff --git a/testdata/lineage/noref.txtar b/testdata/lineage/noref.txtar index 95c36785..2f82a4ff 100644 --- a/testdata/lineage/noref.txtar +++ b/testdata/lineage/noref.txtar @@ -17,10 +17,6 @@ schemas: [{ } }] lenses: [] --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -67,7 +63,7 @@ Lenses count: 0 } } } --- out/encoding/openapi/TestGenerate/expandrefs -- +-- out/encoding/openapi/TestGenerate/group -- == 0.0.json { "openapi": "3.0.0", @@ -78,6 +74,9 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { + "someField": { + "type": "string" + }, "Baz": { "type": "object", "required": [ @@ -98,22 +97,26 @@ Lenses count: 0 "format": "int32" } } - }, - "noref": { - "type": "object", - "required": [ - "someField" - ], - "properties": { - "someField": { - "type": "string" - } - } } } } } --- out/encoding/openapi/TestGenerate/group -- +-- out/encoding/gocode/TestGenerate/depointerized -- +== noref_type_0.0_gen.go +package noref + +// Baz defines model for Baz. +type Baz struct { + Dat int32 `json:"dat"` + Run string `json:"run"` + Tell []byte `json:"tell"` +} + +// Noref defines model for noref. +type Noref struct { + SomeField string `json:"someField"` +} +-- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { "openapi": "3.0.0", @@ -124,9 +127,6 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "someField": { - "type": "string" - }, "Baz": { "type": "object", "required": [ @@ -147,11 +147,22 @@ Lenses count: 0 "format": "int32" } } + }, + "noref": { + "type": "object", + "required": [ + "someField" + ], + "properties": { + "someField": { + "type": "string" + } + } } } } } --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == noref_type_0.0_gen.go package noref @@ -166,20 +177,7 @@ type Baz struct { type Noref struct { SomeField string `json:"someField"` } --- out/encoding/gocode/TestGenerate/group -- -== noref_type_0.0_gen.go -package noref - -// Baz defines model for Baz. -type Baz struct { - Dat int32 `json:"dat"` - Run string `json:"run"` - Tell []byte `json:"tell"` -} - -// SomeField defines model for someField. -type SomeField = string --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/encoding/gocode/TestGenerate/expandref -- == noref_type_0.0_gen.go package noref @@ -194,7 +192,11 @@ type Baz struct { type Noref struct { SomeField string `json:"someField"` } --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == noref_type_0.0_gen.go package noref @@ -209,7 +211,7 @@ type Baz struct { type Noref struct { SomeField string `json:"someField"` } --- out/encoding/gocode/TestGenerate/expandref -- +-- out/encoding/gocode/TestGenerate/group -- == noref_type_0.0_gen.go package noref @@ -220,7 +222,5 @@ type Baz struct { Tell []byte `json:"tell"` } -// Noref defines model for noref. -type Noref struct { - SomeField string `json:"someField"` -} +// SomeField defines model for someField. +type SomeField = string diff --git a/testdata/lineage/one-schema-versionless.txtar b/testdata/lineage/one-schema-versionless.txtar index c9d9c60a..508bcf1d 100644 --- a/testdata/lineage/one-schema-versionless.txtar +++ b/testdata/lineage/one-schema-versionless.txtar @@ -10,10 +10,6 @@ schemas: [{ firstfield: string } }] --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -39,7 +35,7 @@ Lenses count: 0 } } } --- out/encoding/openapi/TestGenerate/expandrefs -- +-- out/encoding/openapi/TestGenerate/group -- == 0.0.json { "openapi": "3.0.0", @@ -50,21 +46,21 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "oneschemaversionless": { - "type": "object", - "required": [ - "firstfield" - ], - "properties": { - "firstfield": { - "type": "string" - } - } + "firstfield": { + "type": "string" } } } } --- out/encoding/openapi/TestGenerate/group -- +-- out/encoding/gocode/TestGenerate/depointerized -- +== oneschemaversionless_type_0.0_gen.go +package oneschemaversionless + +// Oneschemaversionless defines model for oneschemaversionless. +type Oneschemaversionless struct { + Firstfield string `json:"firstfield"` +} +-- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { "openapi": "3.0.0", @@ -75,13 +71,21 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "firstfield": { - "type": "string" + "oneschemaversionless": { + "type": "object", + "required": [ + "firstfield" + ], + "properties": { + "firstfield": { + "type": "string" + } + } } } } } --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == oneschemaversionless_type_0.0_gen.go package oneschemaversionless @@ -89,13 +93,7 @@ package oneschemaversionless type Oneschemaversionless struct { Firstfield string `json:"firstfield"` } --- out/encoding/gocode/TestGenerate/group -- -== oneschemaversionless_type_0.0_gen.go -package oneschemaversionless - -// Firstfield defines model for firstfield. -type Firstfield = string --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/encoding/gocode/TestGenerate/expandref -- == oneschemaversionless_type_0.0_gen.go package oneschemaversionless @@ -103,7 +101,11 @@ package oneschemaversionless type Oneschemaversionless struct { Firstfield string `json:"firstfield"` } --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == oneschemaversionless_type_0.0_gen.go package oneschemaversionless @@ -111,11 +113,9 @@ package oneschemaversionless type Oneschemaversionless struct { Firstfield string `json:"firstfield"` } --- out/encoding/gocode/TestGenerate/expandref -- +-- out/encoding/gocode/TestGenerate/group -- == oneschemaversionless_type_0.0_gen.go package oneschemaversionless -// Oneschemaversionless defines model for oneschemaversionless. -type Oneschemaversionless struct { - Firstfield string `json:"firstfield"` -} +// Firstfield defines model for firstfield. +type Firstfield = string diff --git a/testdata/lineage/refexscalar.txtar b/testdata/lineage/refexscalar.txtar index 02baecdc..7cc25323 100644 --- a/testdata/lineage/refexscalar.txtar +++ b/testdata/lineage/refexscalar.txtar @@ -14,10 +14,6 @@ schemas: [{ lenses: [] #Baz: string --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -46,7 +42,7 @@ Lenses count: 0 } } } --- out/encoding/openapi/TestGenerate/expandrefs -- +-- out/encoding/openapi/TestGenerate/group -- == 0.0.json { "openapi": "3.0.0", @@ -57,21 +53,24 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "refscalar": { - "type": "object", - "required": [ - "someField" - ], - "properties": { - "someField": { - "type": "string" - } - } + "someField": { + "type": "string" } } } } --- out/encoding/openapi/TestGenerate/group -- +-- out/encoding/gocode/TestGenerate/depointerized -- +== refscalar_type_0.0_gen.go +package refscalar + +// Baz defines model for Baz. +type Baz = string + +// Refscalar defines model for refscalar. +type Refscalar struct { + SomeField Baz `json:"someField"` +} +-- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { "openapi": "3.0.0", @@ -82,8 +81,16 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "someField": { - "type": "string" + "refscalar": { + "type": "object", + "required": [ + "someField" + ], + "properties": { + "someField": { + "type": "string" + } + } } } } @@ -122,7 +129,7 @@ Lenses count: 0 } } } --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == refscalar_type_0.0_gen.go package refscalar @@ -133,24 +140,19 @@ type Baz = string type Refscalar struct { SomeField Baz `json:"someField"` } --- out/encoding/gocode/TestGenerate/group -- -== refscalar_type_0.0_gen.go -package refscalar - -// SomeField defines model for someField. -type SomeField = string --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/encoding/gocode/TestGenerate/expandref -- == refscalar_type_0.0_gen.go package refscalar -// Baz defines model for Baz. -type Baz = string - // Refscalar defines model for refscalar. type Refscalar struct { - SomeField Baz `json:"someField"` + SomeField string `json:"someField"` } --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == refscalar_type_0.0_gen.go package refscalar @@ -161,11 +163,9 @@ type Baz = string type Refscalar struct { SomeField Baz `json:"someField"` } --- out/encoding/gocode/TestGenerate/expandref -- +-- out/encoding/gocode/TestGenerate/group -- == refscalar_type_0.0_gen.go package refscalar -// Refscalar defines model for refscalar. -type Refscalar struct { - SomeField string `json:"someField"` -} +// SomeField defines model for someField. +type SomeField = string diff --git a/testdata/lineage/refexstruct.txtar b/testdata/lineage/refexstruct.txtar index 597183f9..39317d4b 100644 --- a/testdata/lineage/refexstruct.txtar +++ b/testdata/lineage/refexstruct.txtar @@ -17,10 +17,6 @@ lenses: [] tell: bytes dat: int32 } --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -67,6 +63,41 @@ Lenses count: 0 } } } +-- out/encoding/openapi/TestGenerate/group -- +== 0.0.json +{ + "openapi": "3.0.0", + "info": { + "title": "refexstruct", + "version": "0.0" + }, + "paths": {}, + "components": { + "schemas": { + "aBaz": { + "type": "object", + "required": [ + "run", + "tell", + "dat" + ], + "properties": { + "run": { + "type": "string" + }, + "tell": { + "type": "string", + "format": "binary" + }, + "dat": { + "type": "integer", + "format": "int32" + } + } + } + } + } +} -- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { @@ -110,42 +141,7 @@ Lenses count: 0 } } } --- out/encoding/openapi/TestGenerate/group -- -== 0.0.json -{ - "openapi": "3.0.0", - "info": { - "title": "refexstruct", - "version": "0.0" - }, - "paths": {}, - "components": { - "schemas": { - "aBaz": { - "type": "object", - "required": [ - "run", - "tell", - "dat" - ], - "properties": { - "run": { - "type": "string" - }, - "tell": { - "type": "string", - "format": "binary" - }, - "dat": { - "type": "integer", - "format": "int32" - } - } - } - } - } -} --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == refexstruct_type_0.0_gen.go package refexstruct @@ -160,17 +156,23 @@ type Baz struct { type Refexstruct struct { ABaz Baz `json:"aBaz"` } --- out/encoding/gocode/TestGenerate/group -- +-- out/encoding/gocode/TestGenerate/expandref -- == refexstruct_type_0.0_gen.go package refexstruct -// ABaz defines model for aBaz. -type ABaz struct { - Dat int32 `json:"dat"` - Run string `json:"run"` - Tell []byte `json:"tell"` +// Refexstruct defines model for refexstruct. +type Refexstruct struct { + ABaz struct { + Dat int32 `json:"dat"` + Run string `json:"run"` + Tell []byte `json:"tell"` + } `json:"aBaz"` } --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == refexstruct_type_0.0_gen.go package refexstruct @@ -185,7 +187,17 @@ type Baz struct { type Refexstruct struct { ABaz Baz `json:"aBaz"` } --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/encoding/gocode/TestGenerate/group -- +== refexstruct_type_0.0_gen.go +package refexstruct + +// ABaz defines model for aBaz. +type ABaz struct { + Dat int32 `json:"dat"` + Run string `json:"run"` + Tell []byte `json:"tell"` +} +-- out/encoding/gocode/TestGenerate/depointerized -- == refexstruct_type_0.0_gen.go package refexstruct @@ -200,15 +212,3 @@ type Baz struct { type Refexstruct struct { ABaz Baz `json:"aBaz"` } --- out/encoding/gocode/TestGenerate/expandref -- -== refexstruct_type_0.0_gen.go -package refexstruct - -// Refexstruct defines model for refexstruct. -type Refexstruct struct { - ABaz struct { - Dat int32 `json:"dat"` - Run string `json:"run"` - Tell []byte `json:"tell"` - } `json:"aBaz"` -} diff --git a/testdata/lineage/refscalar.txtar b/testdata/lineage/refscalar.txtar index 2cfaf434..97887e15 100644 --- a/testdata/lineage/refscalar.txtar +++ b/testdata/lineage/refscalar.txtar @@ -13,10 +13,6 @@ schemas: [{ } }] lenses: [] --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -45,7 +41,7 @@ Lenses count: 0 } } } --- out/encoding/openapi/TestGenerate/expandrefs -- +-- out/encoding/openapi/TestGenerate/group -- == 0.0.json { "openapi": "3.0.0", @@ -56,24 +52,27 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "Baz": { + "aBaz": { "type": "string" }, - "refscalar": { - "type": "object", - "required": [ - "aBaz" - ], - "properties": { - "aBaz": { - "type": "string" - } - } + "Baz": { + "type": "string" } } } } --- out/encoding/openapi/TestGenerate/group -- +-- out/encoding/gocode/TestGenerate/depointerized -- +== refscalar_type_0.0_gen.go +package refscalar + +// Baz defines model for Baz. +type Baz = string + +// Refscalar defines model for refscalar. +type Refscalar struct { + ABaz Baz `json:"aBaz"` +} +-- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { "openapi": "3.0.0", @@ -84,16 +83,24 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "aBaz": { - "type": "string" - }, "Baz": { "type": "string" + }, + "refscalar": { + "type": "object", + "required": [ + "aBaz" + ], + "properties": { + "aBaz": { + "type": "string" + } + } } } } } --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == refscalar_type_0.0_gen.go package refscalar @@ -104,16 +111,7 @@ type Baz = string type Refscalar struct { ABaz Baz `json:"aBaz"` } --- out/encoding/gocode/TestGenerate/group -- -== refscalar_type_0.0_gen.go -package refscalar - -// Baz defines model for Baz. -type Baz = string - -// ABaz defines model for aBaz. -type ABaz = string --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/encoding/gocode/TestGenerate/expandref -- == refscalar_type_0.0_gen.go package refscalar @@ -122,9 +120,13 @@ type Baz = string // Refscalar defines model for refscalar. type Refscalar struct { - ABaz Baz `json:"aBaz"` + ABaz string `json:"aBaz"` } --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == refscalar_type_0.0_gen.go package refscalar @@ -135,14 +137,12 @@ type Baz = string type Refscalar struct { ABaz Baz `json:"aBaz"` } --- out/encoding/gocode/TestGenerate/expandref -- +-- out/encoding/gocode/TestGenerate/group -- == refscalar_type_0.0_gen.go package refscalar // Baz defines model for Baz. type Baz = string -// Refscalar defines model for refscalar. -type Refscalar struct { - ABaz string `json:"aBaz"` -} +// ABaz defines model for aBaz. +type ABaz = string diff --git a/testdata/lineage/refstruct.txtar b/testdata/lineage/refstruct.txtar index 0553b8e1..e8d96b28 100644 --- a/testdata/lineage/refstruct.txtar +++ b/testdata/lineage/refstruct.txtar @@ -17,10 +17,6 @@ schemas: [{ } }] lenses: [] --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -67,7 +63,7 @@ Lenses count: 0 } } } --- out/encoding/openapi/TestGenerate/expandrefs -- +-- out/encoding/openapi/TestGenerate/group -- == 0.0.json { "openapi": "3.0.0", @@ -78,7 +74,7 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "Baz": { + "aBaz": { "type": "object", "required": [ "run", @@ -99,39 +95,31 @@ Lenses count: 0 } } }, - "refstruct": { + "Baz": { "type": "object", "required": [ - "aBaz" + "run", + "tell", + "dat" ], "properties": { - "aBaz": { - "type": "object", - "required": [ - "run", - "tell", - "dat" - ], - "properties": { - "run": { - "type": "string" - }, - "tell": { - "type": "string", - "format": "binary" - }, - "dat": { - "type": "integer", - "format": "int32" - } - } + "run": { + "type": "string" + }, + "tell": { + "type": "string", + "format": "binary" + }, + "dat": { + "type": "integer", + "format": "int32" } } } } } } --- out/encoding/openapi/TestGenerate/group -- +-- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { "openapi": "3.0.0", @@ -142,7 +130,7 @@ Lenses count: 0 "paths": {}, "components": { "schemas": { - "aBaz": { + "Baz": { "type": "object", "required": [ "run", @@ -163,31 +151,39 @@ Lenses count: 0 } } }, - "Baz": { + "refstruct": { "type": "object", "required": [ - "run", - "tell", - "dat" + "aBaz" ], "properties": { - "run": { - "type": "string" - }, - "tell": { - "type": "string", - "format": "binary" - }, - "dat": { - "type": "integer", - "format": "int32" + "aBaz": { + "type": "object", + "required": [ + "run", + "tell", + "dat" + ], + "properties": { + "run": { + "type": "string" + }, + "tell": { + "type": "string", + "format": "binary" + }, + "dat": { + "type": "integer", + "format": "int32" + } + } } } } } } } --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == refstruct_type_0.0_gen.go package refstruct @@ -202,7 +198,7 @@ type Baz struct { type Refstruct struct { ABaz Baz `json:"aBaz"` } --- out/encoding/gocode/TestGenerate/group -- +-- out/encoding/gocode/TestGenerate/expandref -- == refstruct_type_0.0_gen.go package refstruct @@ -213,13 +209,19 @@ type Baz struct { Tell []byte `json:"tell"` } -// ABaz defines model for aBaz. -type ABaz struct { - Dat int32 `json:"dat"` - Run string `json:"run"` - Tell []byte `json:"tell"` +// Refstruct defines model for refstruct. +type Refstruct struct { + ABaz struct { + Dat int32 `json:"dat"` + Run string `json:"run"` + Tell []byte `json:"tell"` + } `json:"aBaz"` } --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0 +-- out/encoding/gocode/TestGenerate/nilcfg -- == refstruct_type_0.0_gen.go package refstruct @@ -234,7 +236,7 @@ type Baz struct { type Refstruct struct { ABaz Baz `json:"aBaz"` } --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/encoding/gocode/TestGenerate/group -- == refstruct_type_0.0_gen.go package refstruct @@ -245,11 +247,13 @@ type Baz struct { Tell []byte `json:"tell"` } -// Refstruct defines model for refstruct. -type Refstruct struct { - ABaz Baz `json:"aBaz"` +// ABaz defines model for aBaz. +type ABaz struct { + Dat int32 `json:"dat"` + Run string `json:"run"` + Tell []byte `json:"tell"` } --- out/encoding/gocode/TestGenerate/expandref -- +-- out/encoding/gocode/TestGenerate/depointerized -- == refstruct_type_0.0_gen.go package refstruct @@ -262,9 +266,5 @@ type Baz struct { // Refstruct defines model for refstruct. type Refstruct struct { - ABaz struct { - Dat int32 `json:"dat"` - Run string `json:"run"` - Tell []byte `json:"tell"` - } `json:"aBaz"` + ABaz Baz `json:"aBaz"` } diff --git a/testdata/lineage/trivial-two-comments.txtar b/testdata/lineage/trivial-two-comments.txtar index 14c236e2..36e041bc 100644 --- a/testdata/lineage/trivial-two-comments.txtar +++ b/testdata/lineage/trivial-two-comments.txtar @@ -34,10 +34,6 @@ lin: lenses: [{ firstfield: input.firstfield } }] --- out/bind -- -Schema count: 2 -Schema versions: 0.0, 0.1 -Lenses count: 1 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -93,100 +89,6 @@ Lenses count: 1 } } } --- out/encoding/gocode/TestGenerate/nilcfg -- -== trivialtwocomments_type_0.0_gen.go -package trivialtwocomments - -// Trivialtwocomments defines model for trivialtwocomments. -type Trivialtwocomments struct { - // TODO some thing to be done - Firstfield string `json:"firstfield"` -} -== trivialtwocomments_type_0.1_gen.go -package trivialtwocomments - -// Trivialtwocomments defines model for trivialtwocomments. -type Trivialtwocomments struct { - // TODO some thing to be done - Firstfield string `json:"firstfield"` - - // Secondfield but clearly this one is a great idea - Secondfield *int32 `json:"secondfield,omitempty"` -} --- out/encoding/gocode/TestGenerate/group -- -== trivialtwocomments_type_0.0_gen.go -package trivialtwocomments - -// TODO some thing to be done -type Firstfield = string -== trivialtwocomments_type_0.1_gen.go -package trivialtwocomments - -// TODO some thing to be done -type Firstfield = string - -// Secondfield but clearly this one is a great idea -type Secondfield = int32 --- out/encoding/gocode/TestGenerate/depointerized -- -== trivialtwocomments_type_0.0_gen.go -package trivialtwocomments - -// Trivialtwocomments defines model for trivialtwocomments. -type Trivialtwocomments struct { - // TODO some thing to be done - Firstfield string `json:"firstfield"` -} -== trivialtwocomments_type_0.1_gen.go -package trivialtwocomments - -// Trivialtwocomments defines model for trivialtwocomments. -type Trivialtwocomments struct { - // TODO some thing to be done - Firstfield string `json:"firstfield"` - - // Secondfield but clearly this one is a great idea - Secondfield int32 `json:"secondfield,omitempty"` -} --- out/encoding/gocode/TestGenerate/godeclincomments -- -== trivialtwocomments_type_0.0_gen.go -package trivialtwocomments - -// Trivialtwocomments defines model for trivialtwocomments. -type Trivialtwocomments struct { - // Firstfield TODO some thing to be done - Firstfield string `json:"firstfield"` -} -== trivialtwocomments_type_0.1_gen.go -package trivialtwocomments - -// Trivialtwocomments defines model for trivialtwocomments. -type Trivialtwocomments struct { - // Firstfield TODO some thing to be done - Firstfield string `json:"firstfield"` - - // Secondfield but clearly this one is a great idea - Secondfield *int32 `json:"secondfield,omitempty"` -} --- out/encoding/gocode/TestGenerate/expandref -- -== trivialtwocomments_type_0.0_gen.go -package trivialtwocomments - -// Trivialtwocomments defines model for trivialtwocomments. -type Trivialtwocomments struct { - // TODO some thing to be done - Firstfield string `json:"firstfield"` -} -== trivialtwocomments_type_0.1_gen.go -package trivialtwocomments - -// Trivialtwocomments defines model for trivialtwocomments. -type Trivialtwocomments struct { - // TODO some thing to be done - Firstfield string `json:"firstfield"` - - // Secondfield but clearly this one is a great idea - Secondfield *int32 `json:"secondfield,omitempty"` -} -- out/encoding/openapi/TestGenerate/group -- == 0.0.json { @@ -281,3 +183,101 @@ type Trivialtwocomments struct { } } } +-- out/encoding/gocode/TestGenerate/godeclincomments -- +== trivialtwocomments_type_0.0_gen.go +package trivialtwocomments + +// Trivialtwocomments defines model for trivialtwocomments. +type Trivialtwocomments struct { + // Firstfield TODO some thing to be done + Firstfield string `json:"firstfield"` +} +== trivialtwocomments_type_0.1_gen.go +package trivialtwocomments + +// Trivialtwocomments defines model for trivialtwocomments. +type Trivialtwocomments struct { + // Firstfield TODO some thing to be done + Firstfield string `json:"firstfield"` + + // Secondfield but clearly this one is a great idea + Secondfield *int32 `json:"secondfield,omitempty"` +} +-- out/encoding/gocode/TestGenerate/expandref -- +== trivialtwocomments_type_0.0_gen.go +package trivialtwocomments + +// Trivialtwocomments defines model for trivialtwocomments. +type Trivialtwocomments struct { + // TODO some thing to be done + Firstfield string `json:"firstfield"` +} +== trivialtwocomments_type_0.1_gen.go +package trivialtwocomments + +// Trivialtwocomments defines model for trivialtwocomments. +type Trivialtwocomments struct { + // TODO some thing to be done + Firstfield string `json:"firstfield"` + + // Secondfield but clearly this one is a great idea + Secondfield *int32 `json:"secondfield,omitempty"` +} +-- out/bind -- +Schema count: 2 +Schema versions: 0.0, 0.1 +Lenses count: 1 +-- out/encoding/gocode/TestGenerate/nilcfg -- +== trivialtwocomments_type_0.0_gen.go +package trivialtwocomments + +// Trivialtwocomments defines model for trivialtwocomments. +type Trivialtwocomments struct { + // TODO some thing to be done + Firstfield string `json:"firstfield"` +} +== trivialtwocomments_type_0.1_gen.go +package trivialtwocomments + +// Trivialtwocomments defines model for trivialtwocomments. +type Trivialtwocomments struct { + // TODO some thing to be done + Firstfield string `json:"firstfield"` + + // Secondfield but clearly this one is a great idea + Secondfield *int32 `json:"secondfield,omitempty"` +} +-- out/encoding/gocode/TestGenerate/group -- +== trivialtwocomments_type_0.0_gen.go +package trivialtwocomments + +// TODO some thing to be done +type Firstfield = string +== trivialtwocomments_type_0.1_gen.go +package trivialtwocomments + +// TODO some thing to be done +type Firstfield = string + +// Secondfield but clearly this one is a great idea +type Secondfield = int32 +-- out/encoding/gocode/TestGenerate/depointerized -- +== trivialtwocomments_type_0.0_gen.go +package trivialtwocomments + +// Trivialtwocomments defines model for trivialtwocomments. +type Trivialtwocomments struct { + // TODO some thing to be done + Firstfield string `json:"firstfield"` +} +== trivialtwocomments_type_0.1_gen.go +package trivialtwocomments + +// Trivialtwocomments defines model for trivialtwocomments. +type Trivialtwocomments struct { + // TODO some thing to be done + Firstfield string `json:"firstfield"` + + // Secondfield but clearly this one is a great idea + Secondfield int32 `json:"secondfield,omitempty"` +} diff --git a/testdata/lineage/trivial-two.txtar b/testdata/lineage/trivial-two.txtar index 1584b93c..f5af8a72 100644 --- a/testdata/lineage/trivial-two.txtar +++ b/testdata/lineage/trivial-two.txtar @@ -28,10 +28,6 @@ lin: lenses: [{ firstfield: input.firstfield } }] --- out/bind -- -Schema count: 2 -Schema versions: 0.0, 0.1 -Lenses count: 1 -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -84,7 +80,7 @@ Lenses count: 1 } } } --- out/encoding/openapi/TestGenerate/expandrefs -- +-- out/encoding/openapi/TestGenerate/group -- == 0.0.json { "openapi": "3.0.0", @@ -95,16 +91,8 @@ Lenses count: 1 "paths": {}, "components": { "schemas": { - "trivialtwo": { - "type": "object", - "required": [ - "firstfield" - ], - "properties": { - "firstfield": { - "type": "string" - } - } + "firstfield": { + "type": "string" } } } @@ -118,25 +106,17 @@ Lenses count: 1 "paths": {}, "components": { "schemas": { - "trivialtwo": { - "type": "object", - "required": [ - "firstfield" - ], - "properties": { - "firstfield": { - "type": "string" - }, - "secondfield": { - "type": "integer", - "format": "int32" - } - } + "firstfield": { + "type": "string" + }, + "secondfield": { + "type": "integer", + "format": "int32" } } } } --- out/encoding/openapi/TestGenerate/group -- +-- out/encoding/openapi/TestGenerate/expandrefs -- == 0.0.json { "openapi": "3.0.0", @@ -147,8 +127,16 @@ Lenses count: 1 "paths": {}, "components": { "schemas": { - "firstfield": { - "type": "string" + "trivialtwo": { + "type": "object", + "required": [ + "firstfield" + ], + "properties": { + "firstfield": { + "type": "string" + } + } } } } @@ -162,17 +150,25 @@ Lenses count: 1 "paths": {}, "components": { "schemas": { - "firstfield": { - "type": "string" - }, - "secondfield": { - "type": "integer", - "format": "int32" + "trivialtwo": { + "type": "object", + "required": [ + "firstfield" + ], + "properties": { + "firstfield": { + "type": "string" + }, + "secondfield": { + "type": "integer", + "format": "int32" + } + } } } } } --- out/encoding/gocode/TestGenerate/nilcfg -- +-- out/encoding/gocode/TestGenerate/godeclincomments -- == trivialtwo_type_0.0_gen.go package trivialtwo @@ -188,21 +184,7 @@ type Trivialtwo struct { Firstfield string `json:"firstfield"` Secondfield *int32 `json:"secondfield,omitempty"` } --- out/encoding/gocode/TestGenerate/group -- -== trivialtwo_type_0.0_gen.go -package trivialtwo - -// Firstfield defines model for firstfield. -type Firstfield = string -== trivialtwo_type_0.1_gen.go -package trivialtwo - -// Firstfield defines model for firstfield. -type Firstfield = string - -// Secondfield defines model for secondfield. -type Secondfield = int32 --- out/encoding/gocode/TestGenerate/depointerized -- +-- out/encoding/gocode/TestGenerate/expandref -- == trivialtwo_type_0.0_gen.go package trivialtwo @@ -216,9 +198,13 @@ package trivialtwo // Trivialtwo defines model for trivialtwo. type Trivialtwo struct { Firstfield string `json:"firstfield"` - Secondfield int32 `json:"secondfield,omitempty"` + Secondfield *int32 `json:"secondfield,omitempty"` } --- out/encoding/gocode/TestGenerate/godeclincomments -- +-- out/bind -- +Schema count: 2 +Schema versions: 0.0, 0.1 +Lenses count: 1 +-- out/encoding/gocode/TestGenerate/nilcfg -- == trivialtwo_type_0.0_gen.go package trivialtwo @@ -234,7 +220,21 @@ type Trivialtwo struct { Firstfield string `json:"firstfield"` Secondfield *int32 `json:"secondfield,omitempty"` } --- out/encoding/gocode/TestGenerate/expandref -- +-- out/encoding/gocode/TestGenerate/group -- +== trivialtwo_type_0.0_gen.go +package trivialtwo + +// Firstfield defines model for firstfield. +type Firstfield = string +== trivialtwo_type_0.1_gen.go +package trivialtwo + +// Firstfield defines model for firstfield. +type Firstfield = string + +// Secondfield defines model for secondfield. +type Secondfield = int32 +-- out/encoding/gocode/TestGenerate/depointerized -- == trivialtwo_type_0.0_gen.go package trivialtwo @@ -248,5 +248,5 @@ package trivialtwo // Trivialtwo defines model for trivialtwo. type Trivialtwo struct { Firstfield string `json:"firstfield"` - Secondfield *int32 `json:"secondfield,omitempty"` + Secondfield int32 `json:"secondfield,omitempty"` } diff --git a/testdata/lineage/union.txtar b/testdata/lineage/union.txtar index 5025aff3..56632e44 100644 --- a/testdata/lineage/union.txtar +++ b/testdata/lineage/union.txtar @@ -29,47 +29,6 @@ schemas: [{ } }] lenses: [] --- out/bind -- -Schema count: 1 -Schema versions: 0.0 -Lenses count: 0 --- out/encoding/gocode/TestGenerate/group -- -== union_type_0.0_gen.go -package union - -// DoubleList defines model for doubleList. -type DoubleList = [][]interface{} - -// EmptyStructs defines model for emptyStructs. -type EmptyStructs = [][]map[string]any - -// ListUnion defines model for listUnion. -type ListUnion = []interface{} - -// MapChained defines model for mapChained. -type MapChained map[string]map[string]interface{} - -// MapDoubleList defines model for mapDoubleList. -type MapDoubleList map[string][][]interface{} - -// MapList defines model for mapList. -type MapList map[string][]interface{} - -// MapListChained defines model for mapListChained. -type MapListChained map[string]map[string]map[string][]interface{} - -// MapTripleList defines model for mapTripleList. -type MapTripleList map[string][][][]interface{} - -// MapUnion defines model for mapUnion. -type MapUnion map[string]interface{} - -// NestedStruct defines model for nestedStruct. -type NestedStruct struct { - ListUnion []interface{} `json:"listUnion"` - MapUnion map[string]interface{} `json:"mapUnion"` - StructUnion interface{} `json:"structUnion"` -} -- out/encoding/openapi/TestGenerate/nilcfg -- == 0.0.json { @@ -591,95 +550,7 @@ type NestedStruct struct { } } } --- out/encoding/gocode/TestGenerate/nilcfg -- -== union_type_0.0_gen.go -package union - -// Union defines model for union. -type Union struct { - DoubleList [][]interface{} `json:"doubleList"` - EmptyStructs [][]map[string]any `json:"emptyStructs"` - ListUnion []interface{} `json:"listUnion"` - MapChained map[string]map[string]interface{} `json:"mapChained"` - MapDoubleList map[string][][]interface{} `json:"mapDoubleList"` - MapList map[string][]interface{} `json:"mapList"` - MapListChained map[string]map[string]map[string][]interface{} `json:"mapListChained"` - MapTripleList map[string][][][]interface{} `json:"mapTripleList"` - MapUnion map[string]interface{} `json:"mapUnion"` - NestedStruct struct { - ListUnion []interface{} `json:"listUnion"` - MapUnion map[string]interface{} `json:"mapUnion"` - StructUnion interface{} `json:"structUnion"` - } `json:"nestedStruct"` - OptionalUnion *interface{} `json:"optionalUnion,omitempty"` - TheUnion interface{} `json:"theUnion"` -} --- out/encoding/gocode/TestGenerate/depointerized -- -== union_type_0.0_gen.go -package union - -// Union defines model for union. -type Union struct { - DoubleList [][]interface{} `json:"doubleList"` - EmptyStructs [][]map[string]any `json:"emptyStructs"` - ListUnion []interface{} `json:"listUnion"` - MapChained map[string]map[string]interface{} `json:"mapChained"` - MapDoubleList map[string][][]interface{} `json:"mapDoubleList"` - MapList map[string][]interface{} `json:"mapList"` - MapListChained map[string]map[string]map[string][]interface{} `json:"mapListChained"` - MapTripleList map[string][][][]interface{} `json:"mapTripleList"` - MapUnion map[string]interface{} `json:"mapUnion"` - NestedStruct struct { - ListUnion []interface{} `json:"listUnion"` - MapUnion map[string]interface{} `json:"mapUnion"` - StructUnion interface{} `json:"structUnion"` - } `json:"nestedStruct"` - OptionalUnion interface{} `json:"optionalUnion,omitempty"` - TheUnion interface{} `json:"theUnion"` -} --- out/encoding/gocode/TestGenerate/godeclincomments -- -== union_type_0.0_gen.go -package union - -// Union defines model for union. -type Union struct { - DoubleList [][]interface{} `json:"doubleList"` - EmptyStructs [][]map[string]any `json:"emptyStructs"` - ListUnion []interface{} `json:"listUnion"` - MapChained map[string]map[string]interface{} `json:"mapChained"` - MapDoubleList map[string][][]interface{} `json:"mapDoubleList"` - MapList map[string][]interface{} `json:"mapList"` - MapListChained map[string]map[string]map[string][]interface{} `json:"mapListChained"` - MapTripleList map[string][][][]interface{} `json:"mapTripleList"` - MapUnion map[string]interface{} `json:"mapUnion"` - NestedStruct struct { - ListUnion []interface{} `json:"listUnion"` - MapUnion map[string]interface{} `json:"mapUnion"` - StructUnion interface{} `json:"structUnion"` - } `json:"nestedStruct"` - OptionalUnion *interface{} `json:"optionalUnion,omitempty"` - TheUnion interface{} `json:"theUnion"` -} --- out/encoding/gocode/TestGenerate/expandref -- -== union_type_0.0_gen.go -package union - -// Union defines model for union. -type Union struct { - DoubleList [][]interface{} `json:"doubleList"` - EmptyStructs [][]map[string]any `json:"emptyStructs"` - ListUnion []interface{} `json:"listUnion"` - MapChained map[string]map[string]interface{} `json:"mapChained"` - MapDoubleList map[string][][]interface{} `json:"mapDoubleList"` - MapList map[string][]interface{} `json:"mapList"` - MapListChained map[string]map[string]map[string][]interface{} `json:"mapListChained"` - MapTripleList map[string][][][]interface{} `json:"mapTripleList"` - MapUnion map[string]interface{} `json:"mapUnion"` - NestedStruct struct { - ListUnion []interface{} `json:"listUnion"` - MapUnion map[string]interface{} `json:"mapUnion"` - StructUnion interface{} `json:"structUnion"` - } `json:"nestedStruct"` - OptionalUnion *interface{} `json:"optionalUnion,omitempty"` - TheUnion interface{} `json:"theUnion"` -} +-- out/bind -- +Schema count: 1 +Schema versions: 0.0 +Lenses count: 0