Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/MarkRosemaker/openapi-flatten v0.0.0-20261112181512-46b453b2a7e8
github.com/MarkRosemaker/ordmap v0.0.0-20261112181350-ce24cb2b5e89
github.com/ettle/strcase v0.2.0
github.com/go-api-libs/api v0.0.0-20261111173335-ea65a0d2e99a
github.com/go-api-libs/api v0.0.0-20261112190634-bde25c574d51
github.com/spf13/afero v1.15.0
mvdan.cc/gofumpt v0.12.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ github.com/MarkRosemaker/yaml2json v0.0.0-20261109120453-1b901dbf7e8f h1:Z3r19i6
github.com/MarkRosemaker/yaml2json v0.0.0-20261109120453-1b901dbf7e8f/go.mod h1:DxNA9SDFrzw+RHsnxjIxjUzHy0I4+3hZg7R13u3SBvE=
github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q=
github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A=
github.com/go-api-libs/api v0.0.0-20261111173335-ea65a0d2e99a h1:mHiqVzJo8VZFc8ofQzeS8UhGVBOfzFlpDA5flrFXxXc=
github.com/go-api-libs/api v0.0.0-20261111173335-ea65a0d2e99a/go.mod h1:nJuMPHY4qEhbWBvTdDFOPK+LC3Uo8RM9kPhIQfzXv4s=
github.com/go-api-libs/api v0.0.0-20261112190634-bde25c574d51 h1:JVrl63yl8vSasO3y4K81aIOYjvyuprdZzKJD8PqStnY=
github.com/go-api-libs/api v0.0.0-20261112190634-bde25c574d51/go.mod h1:nJuMPHY4qEhbWBvTdDFOPK+LC3Uo8RM9kPhIQfzXv4s=
github.com/go-api-libs/types v0.0.0-20261109120451-6cd1daca4971 h1:SAGMMY0sujlZjekNUL4cvoACSOKdOj55CrikCTFzAdU=
github.com/go-api-libs/types v0.0.0-20261109120451-6cd1daca4971/go.mod h1:z0z6qkZc45AvoRnluq7PkVSlSSF25sT0diJ+vrubYfA=
github.com/go-quicktest/qt v1.102.0 h1:HSQxCeh5YZH3EL3W39ixjtyaEhcWSXQHtHnMBzSs474=
Expand Down
1 change: 1 addition & 0 deletions golden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
_ "github.com/MarkRosemaker/cassette"
_ "github.com/go-api-libs/api"
_ "github.com/go-api-libs/api/server"
_ "github.com/go-api-libs/api/union"
)

// TestCodegen_Golden builds the generated packages and runs their tests.
Expand Down
7 changes: 6 additions & 1 deletion ir/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ import (
)

// Enums are the enums a generated test checks the Valid method of: each member is one, and a value of its type that none
// is, if there is such a value, is not.
// is, if there is such a value, is not. Besides the enums of the specification, they are the types of the tags tagged
// structs declare for themselves (see [Tagged.Enum]), as enums of strings.
func (doc Document) Enums() []Schema {
var enums []Schema

for _, s := range doc.Schemas {
if s.Kind == SchemaKindEnum && len(s.EnumValues) > 0 {
enums = append(enums, s)
}

if s.Tagged != nil && len(s.Tagged.Enum) > 0 {
enums = append(enums, Schema{Name: s.Tagged.Type, Kind: SchemaKindEnum, Type: "string", EnumValues: s.Tagged.Enum})
}
}

return enums
Expand Down
6 changes: 3 additions & 3 deletions ir/tagged.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ type TaggedOwn struct {
func (o TaggedOwn) Need() string {
switch {
case !o.Required:
return "jsonTagOptional"
return "union.TagOptional"
case o.Nullable:
return "jsonTagRequiredOrNull"
return "union.TagRequiredOrNull"
default:
return "jsonTagRequired"
return "union.TagRequired"
}
}

Expand Down
1 change: 1 addition & 0 deletions render/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var importPaths = map[string]string{
"jsonutil": "github.com/MarkRosemaker/jsonutil",
"server": "github.com/go-api-libs/api/server",
"types": "github.com/go-api-libs/types",
"union": "github.com/go-api-libs/api/union",
}

// writeImports gives the Go source src the import section it needs: each package of [importPaths] it uses, and no
Expand Down
Loading
Loading