Skip to content

Commit 65b1d0f

Browse files
authored
Update to omicron 5cfd735 (#284)
1 parent 719d3ae commit 65b1d0f

File tree

3 files changed

+81
-4
lines changed

3 files changed

+81
-4
lines changed

VERSION_OMICRON

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rel/v14/rc1
1+
5cfd735

internal/generate/types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ func createOneOf(s *openapi3.Schema, name, typeName string) ([]TypeTemplate, []E
724724
}
725725

726726
propertyName := strcase.ToCamel(prop)
727+
727728
// Avoids duplication for every enum
728729
if !containsMatchFirstWord(parsedProperties, propertyName) {
729730
field := TypeFields{
@@ -753,6 +754,15 @@ func createOneOf(s *openapi3.Schema, name, typeName string) ([]TypeTemplate, []E
753754

754755
enumFieldName = strcase.ToCamel(p.Value.Enum[0].(string))
755756
}
757+
758+
// Enums can appear in a valid OpenAPI spec as a OneOf without necessarily
759+
// being identified as such. If we find an object with a single property
760+
// nested inside a OneOf we will assume this is an enum and modify the name of
761+
// the struct that will be created out of this object.
762+
// e.g. https://github.com/oxidecomputer/omicron/blob/158c0b205f23772dc6c4c97633fd1769cc0e00d4/openapi/nexus.json#L18637-L18682
763+
if len(keys) == 1 && p.Value.Enum == nil {
764+
enumFieldName = propertyName
765+
}
756766
}
757767

758768
// TODO: This is the only place that has an "additional name" at the end

oxide/types.go

Lines changed: 70 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)