diff --git a/.package.json.swp b/.package.json.swp new file mode 100644 index 00000000000..ca863e2bc32 Binary files /dev/null and b/.package.json.swp differ diff --git a/fern/pages/changelogs/cli/2024-11-14.mdx b/fern/pages/changelogs/cli/2024-11-14.mdx new file mode 100644 index 00000000000..3e4c87f2815 --- /dev/null +++ b/fern/pages/changelogs/cli/2024-11-14.mdx @@ -0,0 +1,5 @@ +## 0.45.0-rc44 +**`(fix):`** Update the IR's `ServiceTypeReferenceInfo` to include all transitive types +referenced by a service. + + diff --git a/fern/pages/changelogs/go-sdk/2024-11-14.mdx b/fern/pages/changelogs/go-sdk/2024-11-14.mdx new file mode 100644 index 00000000000..eb0300038d1 --- /dev/null +++ b/fern/pages/changelogs/go-sdk/2024-11-14.mdx @@ -0,0 +1,4 @@ +## 0.31.0 +**`(feat):`** Improves type file layout with zero impact on backwards compatibility. +Shared types are now more accurately placed in the `types.go` file, whereas types referenced by a single service are now placed in a file that matches the service's filename (e.g. user.go). + diff --git a/generators/go/internal/generator/generator.go b/generators/go/internal/generator/generator.go index 12ed80a035d..230affc07c8 100644 --- a/generators/go/internal/generator/generator.go +++ b/generators/go/internal/generator/generator.go @@ -17,6 +17,9 @@ import ( ) const ( + // sharedTypesFilename is the filename for the shared types file. + sharedTypesFilename = "types.go" + // packageDocsFilename represents the standard package documentation filename. packageDocsFilename = "doc.go" @@ -1357,7 +1360,15 @@ func fileInfoToTypes( continue } fileInfo := fileInfoForType(rootPackageName, irService.Name.FernFilepath) - result[fileInfo] = append(result[fileInfo], &typeToGenerate{ID: irEndpoint.Name.OriginalName, FernFilepath: irService.Name.FernFilepath, Endpoint: irEndpoint, Service: irService}) + result[fileInfo] = append( + result[fileInfo], + &typeToGenerate{ + ID: irEndpoint.Name.OriginalName, + FernFilepath: irService.Name.FernFilepath, + Endpoint: irEndpoint, + Service: irService, + }, + ) } } if irServiceTypeReferenceInfo == nil { @@ -1365,35 +1376,30 @@ func fileInfoToTypes( // to the file-per-type naming convention. for _, irType := range irTypes { fileInfo := fileInfoForType(rootPackageName, irType.Name.FernFilepath) - result[fileInfo] = append(result[fileInfo], &typeToGenerate{ID: irType.Name.TypeId, FernFilepath: irType.Name.FernFilepath, TypeDeclaration: irType}) + result[fileInfo] = append( + result[fileInfo], + &typeToGenerate{ + ID: irType.Name.TypeId, + FernFilepath: irType.Name.FernFilepath, + TypeDeclaration: irType, + }, + ) } } else { - directories := make(map[fernir.TypeId][]string) - for irTypeId, irType := range irTypes { - var elements []string - for _, packageName := range irType.Name.FernFilepath.PackagePath { - elements = append(elements, strings.ToLower(packageName.CamelCase.SafeName)) - } - directories[irTypeId] = elements - } sharedTypes := irServiceTypeReferenceInfo.SharedTypes if typeIds, ok := irServiceTypeReferenceInfo.TypesReferencedOnlyByService["service_"]; ok { // The root service types should be included alongside the other shared types. sharedTypes = append(sharedTypes, typeIds...) } - for _, sharedTypeId := range sharedTypes { - typeDeclaration, ok := irTypes[sharedTypeId] + for _, typeId := range sharedTypes { + typeDeclaration, ok := irTypes[typeId] if !ok { // Should be unreachable. - return nil, fmt.Errorf("IR ServiceTypeReferenceInfo referenced type %q which doesn't exist", sharedTypeId) + return nil, fmt.Errorf("IR ServiceTypeReferenceInfo referenced type %q which doesn't exist", typeId) } - fileInfo := fileInfo{ - filename: "types.go", - packageName: rootPackageName, - } - if directory := directories[sharedTypeId]; len(directory) > 0 { - fileInfo.filename = filepath.Join(append(directory, fileInfo.filename)...) - fileInfo.packageName = directory[len(directory)-1] + fileInfo := fileInfoForType(rootPackageName, typeDeclaration.Name.FernFilepath) + if isReservedFilename(filepath.Base(fileInfo.filename)) { + fileInfo.filename = filepath.Join(filepath.Dir(fileInfo.filename), sharedTypesFilename) } result[fileInfo] = append( result[fileInfo], @@ -1414,56 +1420,18 @@ func fileInfoToTypes( // Should be unreachable. return nil, fmt.Errorf("IR ServiceTypeReferenceInfo referenced service %q which doesn't exist", serviceId) } - fernFilepath := service.Name.FernFilepath - var basename string - if service.Name.FernFilepath.File != nil { - basename = fernFilepath.File.SnakeCase.UnsafeName - } else { - basename = fernFilepath.PackagePath[len(fernFilepath.PackagePath)-1].SnakeCase.UnsafeName - } - var packages []string - for _, packageName := range fernFilepath.PackagePath { - packages = append(packages, strings.ToLower(packageName.CamelCase.SafeName)) - } - servicePackageName := rootPackageName - if len(packages) > 0 { - servicePackageName = packages[len(packages)-1] - } - serviceFileInfo := fileInfo{ - filename: filepath.Join(append(packages, fmt.Sprintf("%s.go", basename))...), - packageName: servicePackageName, - } for _, typeId := range typeIds { typeDeclaration, ok := irTypes[typeId] if !ok { // Should be unreachable. return nil, fmt.Errorf("IR ServiceTypeReferenceInfo referenced type %q which doesn't exist", typeId) } - typeFilename := "types.go" - typePackageName := rootPackageName - if directory := directories[typeId]; len(directory) > 0 { - typeFilename = filepath.Join(append(directory, typeFilename)...) - typePackageName = directory[len(directory)-1] + fileInfo := fileInfoForType(rootPackageName, typeDeclaration.Name.FernFilepath) + if shouldSetFileInfoToMatchService(typeDeclaration.Name.FernFilepath, service.Name.FernFilepath) { + fileInfo.filename = filepath.Join(filepath.Dir(fileInfo.filename), service.Name.FernFilepath.File.SnakeCase.UnsafeName+".go") } - if servicePackageName != typePackageName { - // There is only one service referencing this type, but it still - // belongs in the package where it was defined. - typeFileInfo := fileInfo{ - filename: typeFilename, - packageName: typePackageName, - } - result[typeFileInfo] = append( - result[typeFileInfo], - &typeToGenerate{ - ID: typeId, - FernFilepath: typeDeclaration.Name.FernFilepath, - TypeDeclaration: typeDeclaration, - }, - ) - continue - } - result[serviceFileInfo] = append( - result[serviceFileInfo], + result[fileInfo] = append( + result[fileInfo], &typeToGenerate{ ID: typeDeclaration.Name.TypeId, FernFilepath: typeDeclaration.Name.FernFilepath, @@ -1480,6 +1448,36 @@ func fileInfoToTypes( return result, nil } +func shouldSetFileInfoToMatchService( + typeFernFilepath *fernir.FernFilepath, + serviceFernFilepath *fernir.FernFilepath, +) bool { + if serviceFernFilepath.File == nil || typeFernFilepath.File != nil { + // If the service is a root client or the type is already defined + // in a particular non-root package, we can leave it as-is. + return false + } + if !packagePathIsEqual(typeFernFilepath, serviceFernFilepath) { + // We only want to set the file info if the type is defined in the + // same package as the service. + return false + } + filename := serviceFernFilepath.File.SnakeCase.UnsafeName + return !isReservedFilename(filename) +} + +func packagePathIsEqual(a, b *fernir.FernFilepath) bool { + if len(a.PackagePath) != len(b.PackagePath) { + return false + } + for i := range a.PackagePath { + if a.PackagePath[i].CamelCase.SafeName != b.PackagePath[i].CamelCase.SafeName { + return false + } + } + return true +} + func fileInfoToErrors( rootPackageName string, irErrorDeclarations map[fernir.ErrorId]*fernir.ErrorDeclaration, @@ -1615,6 +1613,19 @@ func needsPaginationHelpers(ir *fernir.IntermediateRepresentation) bool { return false } +func isReservedFilename(filename string) bool { + _, ok := reservedFilenames[filename] + return ok +} + +var reservedFilenames = map[string]struct{}{ + "environments.go": struct{}{}, + "errors.go": struct{}{}, + "file_param.go": struct{}{}, + "optional.go": struct{}{}, + "pointer.go": struct{}{}, +} + // pointerFunctionNames enumerates all of the pointer function names. var pointerFunctionNames = map[string]struct{}{ "Bool": struct{}{}, diff --git a/generators/go/internal/testdata/model/alias/fixtures/types.go b/generators/go/internal/testdata/model/alias/fixtures/imdb.go similarity index 100% rename from generators/go/internal/testdata/model/alias/fixtures/types.go rename to generators/go/internal/testdata/model/alias/fixtures/imdb.go diff --git a/generators/go/internal/testdata/model/builtin/fixtures/types.go b/generators/go/internal/testdata/model/builtin/fixtures/imdb.go similarity index 100% rename from generators/go/internal/testdata/model/builtin/fixtures/types.go rename to generators/go/internal/testdata/model/builtin/fixtures/imdb.go diff --git a/generators/go/internal/testdata/model/custom/fixtures/types.go b/generators/go/internal/testdata/model/custom/fixtures/imdb.go similarity index 100% rename from generators/go/internal/testdata/model/custom/fixtures/types.go rename to generators/go/internal/testdata/model/custom/fixtures/imdb.go diff --git a/generators/go/internal/testdata/model/enum/fixtures/types.go b/generators/go/internal/testdata/model/enum/fixtures/imdb.go similarity index 100% rename from generators/go/internal/testdata/model/enum/fixtures/types.go rename to generators/go/internal/testdata/model/enum/fixtures/imdb.go diff --git a/generators/go/internal/testdata/model/extends/fixtures/types.go b/generators/go/internal/testdata/model/extends/fixtures/imdb.go similarity index 100% rename from generators/go/internal/testdata/model/extends/fixtures/types.go rename to generators/go/internal/testdata/model/extends/fixtures/imdb.go diff --git a/generators/go/internal/testdata/model/github/fixtures/bar/types.go b/generators/go/internal/testdata/model/github/fixtures/bar/bar.go similarity index 100% rename from generators/go/internal/testdata/model/github/fixtures/bar/types.go rename to generators/go/internal/testdata/model/github/fixtures/bar/bar.go diff --git a/generators/go/internal/testdata/model/github/fixtures/types.go b/generators/go/internal/testdata/model/github/fixtures/foo.go similarity index 100% rename from generators/go/internal/testdata/model/github/fixtures/types.go rename to generators/go/internal/testdata/model/github/fixtures/foo.go diff --git a/generators/go/internal/testdata/model/ir/fixtures/auth.go b/generators/go/internal/testdata/model/ir/fixtures/auth.go new file mode 100644 index 00000000000..59789316a87 --- /dev/null +++ b/generators/go/internal/testdata/model/ir/fixtures/auth.go @@ -0,0 +1,372 @@ +// This file was auto-generated by Fern from our API Definition. + +package ir + +import ( + json "encoding/json" + fmt "fmt" + core "sdk/core" +) + +type ApiAuth struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Requirement AuthSchemesRequirement `json:"requirement" url:"requirement"` + Schemes []*AuthScheme `json:"schemes,omitempty" url:"schemes,omitempty"` + + extraProperties map[string]interface{} +} + +func (a *ApiAuth) GetDocs() *string { + if a == nil { + return nil + } + return a.Docs +} + +func (a *ApiAuth) GetRequirement() AuthSchemesRequirement { + if a == nil { + return "" + } + return a.Requirement +} + +func (a *ApiAuth) GetSchemes() []*AuthScheme { + if a == nil { + return nil + } + return a.Schemes +} + +func (a *ApiAuth) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *ApiAuth) UnmarshalJSON(data []byte) error { + type unmarshaler ApiAuth + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *a = ApiAuth(value) + + extraProperties, err := core.ExtractExtraProperties(data, *a) + if err != nil { + return err + } + a.extraProperties = extraProperties + + return nil +} + +func (a *ApiAuth) String() string { + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} + +type AuthScheme struct { + Type string + Bearer *BearerAuthScheme + Basic *BasicAuthScheme + Header *HeaderAuthScheme +} + +func NewAuthSchemeFromBearer(value *BearerAuthScheme) *AuthScheme { + return &AuthScheme{Type: "bearer", Bearer: value} +} + +func NewAuthSchemeFromBasic(value *BasicAuthScheme) *AuthScheme { + return &AuthScheme{Type: "basic", Basic: value} +} + +func NewAuthSchemeFromHeader(value *HeaderAuthScheme) *AuthScheme { + return &AuthScheme{Type: "header", Header: value} +} + +func (a *AuthScheme) GetType() string { + if a == nil { + return "" + } + return a.Type +} + +func (a *AuthScheme) GetBearer() *BearerAuthScheme { + if a == nil { + return nil + } + return a.Bearer +} + +func (a *AuthScheme) GetBasic() *BasicAuthScheme { + if a == nil { + return nil + } + return a.Basic +} + +func (a *AuthScheme) GetHeader() *HeaderAuthScheme { + if a == nil { + return nil + } + return a.Header +} + +func (a *AuthScheme) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"_type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + a.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant _type", a) + } + switch unmarshaler.Type { + case "bearer": + value := new(BearerAuthScheme) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + a.Bearer = value + case "basic": + value := new(BasicAuthScheme) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + a.Basic = value + case "header": + value := new(HeaderAuthScheme) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + a.Header = value + } + return nil +} + +func (a AuthScheme) MarshalJSON() ([]byte, error) { + switch a.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", a.Type, a) + case "bearer": + return core.MarshalJSONWithExtraProperty(a.Bearer, "_type", "bearer") + case "basic": + return core.MarshalJSONWithExtraProperty(a.Basic, "_type", "basic") + case "header": + return core.MarshalJSONWithExtraProperty(a.Header, "_type", "header") + } +} + +type AuthSchemeVisitor interface { + VisitBearer(*BearerAuthScheme) error + VisitBasic(*BasicAuthScheme) error + VisitHeader(*HeaderAuthScheme) error +} + +func (a *AuthScheme) Accept(visitor AuthSchemeVisitor) error { + switch a.Type { + default: + return fmt.Errorf("invalid type %s in %T", a.Type, a) + case "bearer": + return visitor.VisitBearer(a.Bearer) + case "basic": + return visitor.VisitBasic(a.Basic) + case "header": + return visitor.VisitHeader(a.Header) + } +} + +type AuthSchemesRequirement string + +const ( + AuthSchemesRequirementAll AuthSchemesRequirement = "ALL" + AuthSchemesRequirementAny AuthSchemesRequirement = "ANY" +) + +func NewAuthSchemesRequirementFromString(s string) (AuthSchemesRequirement, error) { + switch s { + case "ALL": + return AuthSchemesRequirementAll, nil + case "ANY": + return AuthSchemesRequirementAny, nil + } + var t AuthSchemesRequirement + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (a AuthSchemesRequirement) Ptr() *AuthSchemesRequirement { + return &a +} + +type BasicAuthScheme struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Username *Name `json:"username,omitempty" url:"username,omitempty"` + Password *Name `json:"password,omitempty" url:"password,omitempty"` + + extraProperties map[string]interface{} +} + +func (b *BasicAuthScheme) GetDocs() *string { + if b == nil { + return nil + } + return b.Docs +} + +func (b *BasicAuthScheme) GetUsername() *Name { + if b == nil { + return nil + } + return b.Username +} + +func (b *BasicAuthScheme) GetPassword() *Name { + if b == nil { + return nil + } + return b.Password +} + +func (b *BasicAuthScheme) GetExtraProperties() map[string]interface{} { + return b.extraProperties +} + +func (b *BasicAuthScheme) UnmarshalJSON(data []byte) error { + type unmarshaler BasicAuthScheme + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *b = BasicAuthScheme(value) + + extraProperties, err := core.ExtractExtraProperties(data, *b) + if err != nil { + return err + } + b.extraProperties = extraProperties + + return nil +} + +func (b *BasicAuthScheme) String() string { + if value, err := core.StringifyJSON(b); err == nil { + return value + } + return fmt.Sprintf("%#v", b) +} + +type BearerAuthScheme struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Token *Name `json:"token,omitempty" url:"token,omitempty"` + + extraProperties map[string]interface{} +} + +func (b *BearerAuthScheme) GetDocs() *string { + if b == nil { + return nil + } + return b.Docs +} + +func (b *BearerAuthScheme) GetToken() *Name { + if b == nil { + return nil + } + return b.Token +} + +func (b *BearerAuthScheme) GetExtraProperties() map[string]interface{} { + return b.extraProperties +} + +func (b *BearerAuthScheme) UnmarshalJSON(data []byte) error { + type unmarshaler BearerAuthScheme + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *b = BearerAuthScheme(value) + + extraProperties, err := core.ExtractExtraProperties(data, *b) + if err != nil { + return err + } + b.extraProperties = extraProperties + + return nil +} + +func (b *BearerAuthScheme) String() string { + if value, err := core.StringifyJSON(b); err == nil { + return value + } + return fmt.Sprintf("%#v", b) +} + +type HeaderAuthScheme struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Name *NameAndWireValue `json:"name,omitempty" url:"name,omitempty"` + ValueType *TypeReference `json:"valueType,omitempty" url:"valueType,omitempty"` + Prefix *string `json:"prefix,omitempty" url:"prefix,omitempty"` + + extraProperties map[string]interface{} +} + +func (h *HeaderAuthScheme) GetDocs() *string { + if h == nil { + return nil + } + return h.Docs +} + +func (h *HeaderAuthScheme) GetName() *NameAndWireValue { + if h == nil { + return nil + } + return h.Name +} + +func (h *HeaderAuthScheme) GetValueType() *TypeReference { + if h == nil { + return nil + } + return h.ValueType +} + +func (h *HeaderAuthScheme) GetPrefix() *string { + if h == nil { + return nil + } + return h.Prefix +} + +func (h *HeaderAuthScheme) GetExtraProperties() map[string]interface{} { + return h.extraProperties +} + +func (h *HeaderAuthScheme) UnmarshalJSON(data []byte) error { + type unmarshaler HeaderAuthScheme + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *h = HeaderAuthScheme(value) + + extraProperties, err := core.ExtractExtraProperties(data, *h) + if err != nil { + return err + } + h.extraProperties = extraProperties + + return nil +} + +func (h *HeaderAuthScheme) String() string { + if value, err := core.StringifyJSON(h); err == nil { + return value + } + return fmt.Sprintf("%#v", h) +} diff --git a/generators/go/internal/testdata/model/ir/fixtures/commons.go b/generators/go/internal/testdata/model/ir/fixtures/commons.go new file mode 100644 index 00000000000..c51ef9deffa --- /dev/null +++ b/generators/go/internal/testdata/model/ir/fixtures/commons.go @@ -0,0 +1,455 @@ +// This file was auto-generated by Fern from our API Definition. + +package ir + +import ( + json "encoding/json" + fmt "fmt" + core "sdk/core" +) + +type Availability struct { + Status AvailabilityStatus `json:"status" url:"status"` + Message *string `json:"message,omitempty" url:"message,omitempty"` + + extraProperties map[string]interface{} +} + +func (a *Availability) GetStatus() AvailabilityStatus { + if a == nil { + return "" + } + return a.Status +} + +func (a *Availability) GetMessage() *string { + if a == nil { + return nil + } + return a.Message +} + +func (a *Availability) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *Availability) UnmarshalJSON(data []byte) error { + type unmarshaler Availability + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *a = Availability(value) + + extraProperties, err := core.ExtractExtraProperties(data, *a) + if err != nil { + return err + } + a.extraProperties = extraProperties + + return nil +} + +func (a *Availability) String() string { + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} + +type AvailabilityStatus string + +const ( + AvailabilityStatusInDevelopment AvailabilityStatus = "IN_DEVELOPMENT" + AvailabilityStatusPreRelease AvailabilityStatus = "PRE_RELEASE" + AvailabilityStatusGeneralAvailability AvailabilityStatus = "GENERAL_AVAILABILITY" + AvailabilityStatusDeprecated AvailabilityStatus = "DEPRECATED" +) + +func NewAvailabilityStatusFromString(s string) (AvailabilityStatus, error) { + switch s { + case "IN_DEVELOPMENT": + return AvailabilityStatusInDevelopment, nil + case "PRE_RELEASE": + return AvailabilityStatusPreRelease, nil + case "GENERAL_AVAILABILITY": + return AvailabilityStatusGeneralAvailability, nil + case "DEPRECATED": + return AvailabilityStatusDeprecated, nil + } + var t AvailabilityStatus + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (a AvailabilityStatus) Ptr() *AvailabilityStatus { + return &a +} + +type Declaration struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Availability *Availability `json:"availability,omitempty" url:"availability,omitempty"` + + extraProperties map[string]interface{} +} + +func (d *Declaration) GetDocs() *string { + if d == nil { + return nil + } + return d.Docs +} + +func (d *Declaration) GetAvailability() *Availability { + if d == nil { + return nil + } + return d.Availability +} + +func (d *Declaration) GetExtraProperties() map[string]interface{} { + return d.extraProperties +} + +func (d *Declaration) UnmarshalJSON(data []byte) error { + type unmarshaler Declaration + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = Declaration(value) + + extraProperties, err := core.ExtractExtraProperties(data, *d) + if err != nil { + return err + } + d.extraProperties = extraProperties + + return nil +} + +func (d *Declaration) String() string { + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type ErrorId = string + +type FernFilepath struct { + AllParts []*Name `json:"allParts,omitempty" url:"allParts,omitempty"` + PackagePath []*Name `json:"packagePath,omitempty" url:"packagePath,omitempty"` + File *Name `json:"file,omitempty" url:"file,omitempty"` + + extraProperties map[string]interface{} +} + +func (f *FernFilepath) GetAllParts() []*Name { + if f == nil { + return nil + } + return f.AllParts +} + +func (f *FernFilepath) GetPackagePath() []*Name { + if f == nil { + return nil + } + return f.PackagePath +} + +func (f *FernFilepath) GetFile() *Name { + if f == nil { + return nil + } + return f.File +} + +func (f *FernFilepath) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *FernFilepath) UnmarshalJSON(data []byte) error { + type unmarshaler FernFilepath + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = FernFilepath(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + return nil +} + +func (f *FernFilepath) String() string { + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + +type Name struct { + OriginalName string `json:"originalName" url:"originalName"` + CamelCase *SafeAndUnsafeString `json:"camelCase,omitempty" url:"camelCase,omitempty"` + PascalCase *SafeAndUnsafeString `json:"pascalCase,omitempty" url:"pascalCase,omitempty"` + SnakeCase *SafeAndUnsafeString `json:"snakeCase,omitempty" url:"snakeCase,omitempty"` + ScreamingSnakeCase *SafeAndUnsafeString `json:"screamingSnakeCase,omitempty" url:"screamingSnakeCase,omitempty"` + + extraProperties map[string]interface{} +} + +func (n *Name) GetOriginalName() string { + if n == nil { + return "" + } + return n.OriginalName +} + +func (n *Name) GetCamelCase() *SafeAndUnsafeString { + if n == nil { + return nil + } + return n.CamelCase +} + +func (n *Name) GetPascalCase() *SafeAndUnsafeString { + if n == nil { + return nil + } + return n.PascalCase +} + +func (n *Name) GetSnakeCase() *SafeAndUnsafeString { + if n == nil { + return nil + } + return n.SnakeCase +} + +func (n *Name) GetScreamingSnakeCase() *SafeAndUnsafeString { + if n == nil { + return nil + } + return n.ScreamingSnakeCase +} + +func (n *Name) GetExtraProperties() map[string]interface{} { + return n.extraProperties +} + +func (n *Name) UnmarshalJSON(data []byte) error { + type unmarshaler Name + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = Name(value) + + extraProperties, err := core.ExtractExtraProperties(data, *n) + if err != nil { + return err + } + n.extraProperties = extraProperties + + return nil +} + +func (n *Name) String() string { + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + +type NameAndWireValue struct { + WireValue string `json:"wireValue" url:"wireValue"` + Name *Name `json:"name,omitempty" url:"name,omitempty"` + + extraProperties map[string]interface{} +} + +func (n *NameAndWireValue) GetWireValue() string { + if n == nil { + return "" + } + return n.WireValue +} + +func (n *NameAndWireValue) GetName() *Name { + if n == nil { + return nil + } + return n.Name +} + +func (n *NameAndWireValue) GetExtraProperties() map[string]interface{} { + return n.extraProperties +} + +func (n *NameAndWireValue) UnmarshalJSON(data []byte) error { + type unmarshaler NameAndWireValue + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NameAndWireValue(value) + + extraProperties, err := core.ExtractExtraProperties(data, *n) + if err != nil { + return err + } + n.extraProperties = extraProperties + + return nil +} + +func (n *NameAndWireValue) String() string { + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + +type SafeAndUnsafeString struct { + // this name might overlap with reserved keywords of the language being generated + UnsafeName string `json:"unsafeName" url:"unsafeName"` + // this name will NOT overlap with reserved keywords of the language being generated + SafeName string `json:"safeName" url:"safeName"` + + extraProperties map[string]interface{} +} + +func (s *SafeAndUnsafeString) GetUnsafeName() string { + if s == nil { + return "" + } + return s.UnsafeName +} + +func (s *SafeAndUnsafeString) GetSafeName() string { + if s == nil { + return "" + } + return s.SafeName +} + +func (s *SafeAndUnsafeString) GetExtraProperties() map[string]interface{} { + return s.extraProperties +} + +func (s *SafeAndUnsafeString) UnmarshalJSON(data []byte) error { + type unmarshaler SafeAndUnsafeString + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = SafeAndUnsafeString(value) + + extraProperties, err := core.ExtractExtraProperties(data, *s) + if err != nil { + return err + } + s.extraProperties = extraProperties + + return nil +} + +func (s *SafeAndUnsafeString) String() string { + if value, err := core.StringifyJSON(s); err == nil { + return value + } + return fmt.Sprintf("%#v", s) +} + +type ServiceId = string + +type SubpackageId = string + +type TypeId = string + +type WithDocs struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + + extraProperties map[string]interface{} +} + +func (w *WithDocs) GetDocs() *string { + if w == nil { + return nil + } + return w.Docs +} + +func (w *WithDocs) GetExtraProperties() map[string]interface{} { + return w.extraProperties +} + +func (w *WithDocs) UnmarshalJSON(data []byte) error { + type unmarshaler WithDocs + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *w = WithDocs(value) + + extraProperties, err := core.ExtractExtraProperties(data, *w) + if err != nil { + return err + } + w.extraProperties = extraProperties + + return nil +} + +func (w *WithDocs) String() string { + if value, err := core.StringifyJSON(w); err == nil { + return value + } + return fmt.Sprintf("%#v", w) +} + +type WithJsonExample struct { + JsonExample interface{} `json:"jsonExample,omitempty" url:"jsonExample,omitempty"` + + extraProperties map[string]interface{} +} + +func (w *WithJsonExample) GetJsonExample() interface{} { + if w == nil { + return nil + } + return w.JsonExample +} + +func (w *WithJsonExample) GetExtraProperties() map[string]interface{} { + return w.extraProperties +} + +func (w *WithJsonExample) UnmarshalJSON(data []byte) error { + type unmarshaler WithJsonExample + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *w = WithJsonExample(value) + + extraProperties, err := core.ExtractExtraProperties(data, *w) + if err != nil { + return err + } + w.extraProperties = extraProperties + + return nil +} + +func (w *WithJsonExample) String() string { + if value, err := core.StringifyJSON(w); err == nil { + return value + } + return fmt.Sprintf("%#v", w) +} diff --git a/generators/go/internal/testdata/model/ir/fixtures/constants.go b/generators/go/internal/testdata/model/ir/fixtures/constants.go new file mode 100644 index 00000000000..c04a61803fc --- /dev/null +++ b/generators/go/internal/testdata/model/ir/fixtures/constants.go @@ -0,0 +1,50 @@ +// This file was auto-generated by Fern from our API Definition. + +package ir + +import ( + json "encoding/json" + fmt "fmt" + core "sdk/core" +) + +type Constants struct { + ErrorInstanceIdKey *NameAndWireValue `json:"errorInstanceIdKey,omitempty" url:"errorInstanceIdKey,omitempty"` + + extraProperties map[string]interface{} +} + +func (c *Constants) GetErrorInstanceIdKey() *NameAndWireValue { + if c == nil { + return nil + } + return c.ErrorInstanceIdKey +} + +func (c *Constants) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *Constants) UnmarshalJSON(data []byte) error { + type unmarshaler Constants + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = Constants(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + return nil +} + +func (c *Constants) String() string { + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} diff --git a/generators/go/internal/testdata/model/ir/fixtures/environment.go b/generators/go/internal/testdata/model/ir/fixtures/environment.go new file mode 100644 index 00000000000..9c77cd34204 --- /dev/null +++ b/generators/go/internal/testdata/model/ir/fixtures/environment.go @@ -0,0 +1,423 @@ +// This file was auto-generated by Fern from our API Definition. + +package ir + +import ( + json "encoding/json" + fmt "fmt" + core "sdk/core" +) + +type EnvironmentBaseUrlId = string + +type EnvironmentBaseUrlWithId struct { + Id EnvironmentBaseUrlId `json:"id" url:"id"` + Name *Name `json:"name,omitempty" url:"name,omitempty"` + + extraProperties map[string]interface{} +} + +func (e *EnvironmentBaseUrlWithId) GetId() EnvironmentBaseUrlId { + if e == nil { + return "" + } + return e.Id +} + +func (e *EnvironmentBaseUrlWithId) GetName() *Name { + if e == nil { + return nil + } + return e.Name +} + +func (e *EnvironmentBaseUrlWithId) GetExtraProperties() map[string]interface{} { + return e.extraProperties +} + +func (e *EnvironmentBaseUrlWithId) UnmarshalJSON(data []byte) error { + type unmarshaler EnvironmentBaseUrlWithId + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = EnvironmentBaseUrlWithId(value) + + extraProperties, err := core.ExtractExtraProperties(data, *e) + if err != nil { + return err + } + e.extraProperties = extraProperties + + return nil +} + +func (e *EnvironmentBaseUrlWithId) String() string { + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +type EnvironmentId = string + +type EnvironmentUrl = string + +type Environments struct { + Type string + SingleBaseUrl *SingleBaseUrlEnvironments + MultipleBaseUrls *MultipleBaseUrlsEnvironments +} + +func NewEnvironmentsFromSingleBaseUrl(value *SingleBaseUrlEnvironments) *Environments { + return &Environments{Type: "singleBaseUrl", SingleBaseUrl: value} +} + +func NewEnvironmentsFromMultipleBaseUrls(value *MultipleBaseUrlsEnvironments) *Environments { + return &Environments{Type: "multipleBaseUrls", MultipleBaseUrls: value} +} + +func (e *Environments) GetType() string { + if e == nil { + return "" + } + return e.Type +} + +func (e *Environments) GetSingleBaseUrl() *SingleBaseUrlEnvironments { + if e == nil { + return nil + } + return e.SingleBaseUrl +} + +func (e *Environments) GetMultipleBaseUrls() *MultipleBaseUrlsEnvironments { + if e == nil { + return nil + } + return e.MultipleBaseUrls +} + +func (e *Environments) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + e.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", e) + } + switch unmarshaler.Type { + case "singleBaseUrl": + value := new(SingleBaseUrlEnvironments) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + e.SingleBaseUrl = value + case "multipleBaseUrls": + value := new(MultipleBaseUrlsEnvironments) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + e.MultipleBaseUrls = value + } + return nil +} + +func (e Environments) MarshalJSON() ([]byte, error) { + switch e.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", e.Type, e) + case "singleBaseUrl": + return core.MarshalJSONWithExtraProperty(e.SingleBaseUrl, "type", "singleBaseUrl") + case "multipleBaseUrls": + return core.MarshalJSONWithExtraProperty(e.MultipleBaseUrls, "type", "multipleBaseUrls") + } +} + +type EnvironmentsVisitor interface { + VisitSingleBaseUrl(*SingleBaseUrlEnvironments) error + VisitMultipleBaseUrls(*MultipleBaseUrlsEnvironments) error +} + +func (e *Environments) Accept(visitor EnvironmentsVisitor) error { + switch e.Type { + default: + return fmt.Errorf("invalid type %s in %T", e.Type, e) + case "singleBaseUrl": + return visitor.VisitSingleBaseUrl(e.SingleBaseUrl) + case "multipleBaseUrls": + return visitor.VisitMultipleBaseUrls(e.MultipleBaseUrls) + } +} + +type EnvironmentsConfig struct { + DefaultEnvironment *EnvironmentId `json:"defaultEnvironment,omitempty" url:"defaultEnvironment,omitempty"` + Environments *Environments `json:"environments,omitempty" url:"environments,omitempty"` + + extraProperties map[string]interface{} +} + +func (e *EnvironmentsConfig) GetDefaultEnvironment() *EnvironmentId { + if e == nil { + return nil + } + return e.DefaultEnvironment +} + +func (e *EnvironmentsConfig) GetEnvironments() *Environments { + if e == nil { + return nil + } + return e.Environments +} + +func (e *EnvironmentsConfig) GetExtraProperties() map[string]interface{} { + return e.extraProperties +} + +func (e *EnvironmentsConfig) UnmarshalJSON(data []byte) error { + type unmarshaler EnvironmentsConfig + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = EnvironmentsConfig(value) + + extraProperties, err := core.ExtractExtraProperties(data, *e) + if err != nil { + return err + } + e.extraProperties = extraProperties + + return nil +} + +func (e *EnvironmentsConfig) String() string { + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +type MultipleBaseUrlsEnvironment struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Id EnvironmentId `json:"id" url:"id"` + Name *Name `json:"name,omitempty" url:"name,omitempty"` + Urls map[EnvironmentBaseUrlId]EnvironmentUrl `json:"urls,omitempty" url:"urls,omitempty"` + + extraProperties map[string]interface{} +} + +func (m *MultipleBaseUrlsEnvironment) GetDocs() *string { + if m == nil { + return nil + } + return m.Docs +} + +func (m *MultipleBaseUrlsEnvironment) GetId() EnvironmentId { + if m == nil { + return "" + } + return m.Id +} + +func (m *MultipleBaseUrlsEnvironment) GetName() *Name { + if m == nil { + return nil + } + return m.Name +} + +func (m *MultipleBaseUrlsEnvironment) GetUrls() map[EnvironmentBaseUrlId]EnvironmentUrl { + if m == nil { + return nil + } + return m.Urls +} + +func (m *MultipleBaseUrlsEnvironment) GetExtraProperties() map[string]interface{} { + return m.extraProperties +} + +func (m *MultipleBaseUrlsEnvironment) UnmarshalJSON(data []byte) error { + type unmarshaler MultipleBaseUrlsEnvironment + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *m = MultipleBaseUrlsEnvironment(value) + + extraProperties, err := core.ExtractExtraProperties(data, *m) + if err != nil { + return err + } + m.extraProperties = extraProperties + + return nil +} + +func (m *MultipleBaseUrlsEnvironment) String() string { + if value, err := core.StringifyJSON(m); err == nil { + return value + } + return fmt.Sprintf("%#v", m) +} + +type MultipleBaseUrlsEnvironments struct { + BaseUrls []*EnvironmentBaseUrlWithId `json:"baseUrls,omitempty" url:"baseUrls,omitempty"` + Environments []*MultipleBaseUrlsEnvironment `json:"environments,omitempty" url:"environments,omitempty"` + + extraProperties map[string]interface{} +} + +func (m *MultipleBaseUrlsEnvironments) GetBaseUrls() []*EnvironmentBaseUrlWithId { + if m == nil { + return nil + } + return m.BaseUrls +} + +func (m *MultipleBaseUrlsEnvironments) GetEnvironments() []*MultipleBaseUrlsEnvironment { + if m == nil { + return nil + } + return m.Environments +} + +func (m *MultipleBaseUrlsEnvironments) GetExtraProperties() map[string]interface{} { + return m.extraProperties +} + +func (m *MultipleBaseUrlsEnvironments) UnmarshalJSON(data []byte) error { + type unmarshaler MultipleBaseUrlsEnvironments + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *m = MultipleBaseUrlsEnvironments(value) + + extraProperties, err := core.ExtractExtraProperties(data, *m) + if err != nil { + return err + } + m.extraProperties = extraProperties + + return nil +} + +func (m *MultipleBaseUrlsEnvironments) String() string { + if value, err := core.StringifyJSON(m); err == nil { + return value + } + return fmt.Sprintf("%#v", m) +} + +type SingleBaseUrlEnvironment struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Id EnvironmentId `json:"id" url:"id"` + Name *Name `json:"name,omitempty" url:"name,omitempty"` + Url EnvironmentUrl `json:"url" url:"url"` + + extraProperties map[string]interface{} +} + +func (s *SingleBaseUrlEnvironment) GetDocs() *string { + if s == nil { + return nil + } + return s.Docs +} + +func (s *SingleBaseUrlEnvironment) GetId() EnvironmentId { + if s == nil { + return "" + } + return s.Id +} + +func (s *SingleBaseUrlEnvironment) GetName() *Name { + if s == nil { + return nil + } + return s.Name +} + +func (s *SingleBaseUrlEnvironment) GetUrl() EnvironmentUrl { + if s == nil { + return "" + } + return s.Url +} + +func (s *SingleBaseUrlEnvironment) GetExtraProperties() map[string]interface{} { + return s.extraProperties +} + +func (s *SingleBaseUrlEnvironment) UnmarshalJSON(data []byte) error { + type unmarshaler SingleBaseUrlEnvironment + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = SingleBaseUrlEnvironment(value) + + extraProperties, err := core.ExtractExtraProperties(data, *s) + if err != nil { + return err + } + s.extraProperties = extraProperties + + return nil +} + +func (s *SingleBaseUrlEnvironment) String() string { + if value, err := core.StringifyJSON(s); err == nil { + return value + } + return fmt.Sprintf("%#v", s) +} + +type SingleBaseUrlEnvironments struct { + Environments []*SingleBaseUrlEnvironment `json:"environments,omitempty" url:"environments,omitempty"` + + extraProperties map[string]interface{} +} + +func (s *SingleBaseUrlEnvironments) GetEnvironments() []*SingleBaseUrlEnvironment { + if s == nil { + return nil + } + return s.Environments +} + +func (s *SingleBaseUrlEnvironments) GetExtraProperties() map[string]interface{} { + return s.extraProperties +} + +func (s *SingleBaseUrlEnvironments) UnmarshalJSON(data []byte) error { + type unmarshaler SingleBaseUrlEnvironments + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = SingleBaseUrlEnvironments(value) + + extraProperties, err := core.ExtractExtraProperties(data, *s) + if err != nil { + return err + } + s.extraProperties = extraProperties + + return nil +} + +func (s *SingleBaseUrlEnvironments) String() string { + if value, err := core.StringifyJSON(s); err == nil { + return value + } + return fmt.Sprintf("%#v", s) +} diff --git a/generators/go/internal/testdata/model/ir/fixtures/http.go b/generators/go/internal/testdata/model/ir/fixtures/http.go new file mode 100644 index 00000000000..44c18ee909d --- /dev/null +++ b/generators/go/internal/testdata/model/ir/fixtures/http.go @@ -0,0 +1,2582 @@ +// This file was auto-generated by Fern from our API Definition. + +package ir + +import ( + json "encoding/json" + fmt "fmt" + core "sdk/core" +) + +type DeclaredServiceName struct { + FernFilepath *FernFilepath `json:"fernFilepath,omitempty" url:"fernFilepath,omitempty"` + + extraProperties map[string]interface{} +} + +func (d *DeclaredServiceName) GetFernFilepath() *FernFilepath { + if d == nil { + return nil + } + return d.FernFilepath +} + +func (d *DeclaredServiceName) GetExtraProperties() map[string]interface{} { + return d.extraProperties +} + +func (d *DeclaredServiceName) UnmarshalJSON(data []byte) error { + type unmarshaler DeclaredServiceName + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DeclaredServiceName(value) + + extraProperties, err := core.ExtractExtraProperties(data, *d) + if err != nil { + return err + } + d.extraProperties = extraProperties + + return nil +} + +func (d *DeclaredServiceName) String() string { + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type EndpointName = *Name + +type ExampleEndpointCall struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Name *Name `json:"name,omitempty" url:"name,omitempty"` + Url string `json:"url" url:"url"` + RootPathParameters []*ExamplePathParameter `json:"rootPathParameters,omitempty" url:"rootPathParameters,omitempty"` + ServicePathParameters []*ExamplePathParameter `json:"servicePathParameters,omitempty" url:"servicePathParameters,omitempty"` + EndpointPathParameters []*ExamplePathParameter `json:"endpointPathParameters,omitempty" url:"endpointPathParameters,omitempty"` + ServiceHeaders []*ExampleHeader `json:"serviceHeaders,omitempty" url:"serviceHeaders,omitempty"` + EndpointHeaders []*ExampleHeader `json:"endpointHeaders,omitempty" url:"endpointHeaders,omitempty"` + QueryParameters []*ExampleQueryParameter `json:"queryParameters,omitempty" url:"queryParameters,omitempty"` + Request *ExampleRequestBody `json:"request,omitempty" url:"request,omitempty"` + Response *ExampleResponse `json:"response,omitempty" url:"response,omitempty"` + + extraProperties map[string]interface{} +} + +func (e *ExampleEndpointCall) GetDocs() *string { + if e == nil { + return nil + } + return e.Docs +} + +func (e *ExampleEndpointCall) GetName() *Name { + if e == nil { + return nil + } + return e.Name +} + +func (e *ExampleEndpointCall) GetUrl() string { + if e == nil { + return "" + } + return e.Url +} + +func (e *ExampleEndpointCall) GetRootPathParameters() []*ExamplePathParameter { + if e == nil { + return nil + } + return e.RootPathParameters +} + +func (e *ExampleEndpointCall) GetServicePathParameters() []*ExamplePathParameter { + if e == nil { + return nil + } + return e.ServicePathParameters +} + +func (e *ExampleEndpointCall) GetEndpointPathParameters() []*ExamplePathParameter { + if e == nil { + return nil + } + return e.EndpointPathParameters +} + +func (e *ExampleEndpointCall) GetServiceHeaders() []*ExampleHeader { + if e == nil { + return nil + } + return e.ServiceHeaders +} + +func (e *ExampleEndpointCall) GetEndpointHeaders() []*ExampleHeader { + if e == nil { + return nil + } + return e.EndpointHeaders +} + +func (e *ExampleEndpointCall) GetQueryParameters() []*ExampleQueryParameter { + if e == nil { + return nil + } + return e.QueryParameters +} + +func (e *ExampleEndpointCall) GetRequest() *ExampleRequestBody { + if e == nil { + return nil + } + return e.Request +} + +func (e *ExampleEndpointCall) GetResponse() *ExampleResponse { + if e == nil { + return nil + } + return e.Response +} + +func (e *ExampleEndpointCall) GetExtraProperties() map[string]interface{} { + return e.extraProperties +} + +func (e *ExampleEndpointCall) UnmarshalJSON(data []byte) error { + type unmarshaler ExampleEndpointCall + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = ExampleEndpointCall(value) + + extraProperties, err := core.ExtractExtraProperties(data, *e) + if err != nil { + return err + } + e.extraProperties = extraProperties + + return nil +} + +func (e *ExampleEndpointCall) String() string { + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +type ExampleEndpointErrorResponse struct { + Error *DeclaredErrorName `json:"error,omitempty" url:"error,omitempty"` + Body *ExampleTypeReference `json:"body,omitempty" url:"body,omitempty"` + + extraProperties map[string]interface{} +} + +func (e *ExampleEndpointErrorResponse) GetError() *DeclaredErrorName { + if e == nil { + return nil + } + return e.Error +} + +func (e *ExampleEndpointErrorResponse) GetBody() *ExampleTypeReference { + if e == nil { + return nil + } + return e.Body +} + +func (e *ExampleEndpointErrorResponse) GetExtraProperties() map[string]interface{} { + return e.extraProperties +} + +func (e *ExampleEndpointErrorResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ExampleEndpointErrorResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = ExampleEndpointErrorResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *e) + if err != nil { + return err + } + e.extraProperties = extraProperties + + return nil +} + +func (e *ExampleEndpointErrorResponse) String() string { + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +type ExampleEndpointSuccessResponse struct { + Body *ExampleTypeReference `json:"body,omitempty" url:"body,omitempty"` + + extraProperties map[string]interface{} +} + +func (e *ExampleEndpointSuccessResponse) GetBody() *ExampleTypeReference { + if e == nil { + return nil + } + return e.Body +} + +func (e *ExampleEndpointSuccessResponse) GetExtraProperties() map[string]interface{} { + return e.extraProperties +} + +func (e *ExampleEndpointSuccessResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ExampleEndpointSuccessResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = ExampleEndpointSuccessResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *e) + if err != nil { + return err + } + e.extraProperties = extraProperties + + return nil +} + +func (e *ExampleEndpointSuccessResponse) String() string { + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +type ExampleHeader struct { + WireKey string `json:"wireKey" url:"wireKey"` + Value *ExampleTypeReference `json:"value,omitempty" url:"value,omitempty"` + + extraProperties map[string]interface{} +} + +func (e *ExampleHeader) GetWireKey() string { + if e == nil { + return "" + } + return e.WireKey +} + +func (e *ExampleHeader) GetValue() *ExampleTypeReference { + if e == nil { + return nil + } + return e.Value +} + +func (e *ExampleHeader) GetExtraProperties() map[string]interface{} { + return e.extraProperties +} + +func (e *ExampleHeader) UnmarshalJSON(data []byte) error { + type unmarshaler ExampleHeader + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = ExampleHeader(value) + + extraProperties, err := core.ExtractExtraProperties(data, *e) + if err != nil { + return err + } + e.extraProperties = extraProperties + + return nil +} + +func (e *ExampleHeader) String() string { + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +type ExampleInlinedRequestBody struct { + JsonExample interface{} `json:"jsonExample,omitempty" url:"jsonExample,omitempty"` + Properties []*ExampleInlinedRequestBodyProperty `json:"properties,omitempty" url:"properties,omitempty"` + + extraProperties map[string]interface{} +} + +func (e *ExampleInlinedRequestBody) GetJsonExample() interface{} { + if e == nil { + return nil + } + return e.JsonExample +} + +func (e *ExampleInlinedRequestBody) GetProperties() []*ExampleInlinedRequestBodyProperty { + if e == nil { + return nil + } + return e.Properties +} + +func (e *ExampleInlinedRequestBody) GetExtraProperties() map[string]interface{} { + return e.extraProperties +} + +func (e *ExampleInlinedRequestBody) UnmarshalJSON(data []byte) error { + type unmarshaler ExampleInlinedRequestBody + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = ExampleInlinedRequestBody(value) + + extraProperties, err := core.ExtractExtraProperties(data, *e) + if err != nil { + return err + } + e.extraProperties = extraProperties + + return nil +} + +func (e *ExampleInlinedRequestBody) String() string { + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +type ExampleInlinedRequestBodyProperty struct { + WireKey string `json:"wireKey" url:"wireKey"` + Value *ExampleTypeReference `json:"value,omitempty" url:"value,omitempty"` + // this property may have been brought in via extension. originalTypeDeclaration + // is the name of the type that contains this property + OriginalTypeDeclaration *DeclaredTypeName `json:"originalTypeDeclaration,omitempty" url:"originalTypeDeclaration,omitempty"` + + extraProperties map[string]interface{} +} + +func (e *ExampleInlinedRequestBodyProperty) GetWireKey() string { + if e == nil { + return "" + } + return e.WireKey +} + +func (e *ExampleInlinedRequestBodyProperty) GetValue() *ExampleTypeReference { + if e == nil { + return nil + } + return e.Value +} + +func (e *ExampleInlinedRequestBodyProperty) GetOriginalTypeDeclaration() *DeclaredTypeName { + if e == nil { + return nil + } + return e.OriginalTypeDeclaration +} + +func (e *ExampleInlinedRequestBodyProperty) GetExtraProperties() map[string]interface{} { + return e.extraProperties +} + +func (e *ExampleInlinedRequestBodyProperty) UnmarshalJSON(data []byte) error { + type unmarshaler ExampleInlinedRequestBodyProperty + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = ExampleInlinedRequestBodyProperty(value) + + extraProperties, err := core.ExtractExtraProperties(data, *e) + if err != nil { + return err + } + e.extraProperties = extraProperties + + return nil +} + +func (e *ExampleInlinedRequestBodyProperty) String() string { + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +type ExamplePathParameter struct { + Key string `json:"key" url:"key"` + Value *ExampleTypeReference `json:"value,omitempty" url:"value,omitempty"` + + extraProperties map[string]interface{} +} + +func (e *ExamplePathParameter) GetKey() string { + if e == nil { + return "" + } + return e.Key +} + +func (e *ExamplePathParameter) GetValue() *ExampleTypeReference { + if e == nil { + return nil + } + return e.Value +} + +func (e *ExamplePathParameter) GetExtraProperties() map[string]interface{} { + return e.extraProperties +} + +func (e *ExamplePathParameter) UnmarshalJSON(data []byte) error { + type unmarshaler ExamplePathParameter + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = ExamplePathParameter(value) + + extraProperties, err := core.ExtractExtraProperties(data, *e) + if err != nil { + return err + } + e.extraProperties = extraProperties + + return nil +} + +func (e *ExamplePathParameter) String() string { + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +type ExampleQueryParameter struct { + WireKey string `json:"wireKey" url:"wireKey"` + Value *ExampleTypeReference `json:"value,omitempty" url:"value,omitempty"` + + extraProperties map[string]interface{} +} + +func (e *ExampleQueryParameter) GetWireKey() string { + if e == nil { + return "" + } + return e.WireKey +} + +func (e *ExampleQueryParameter) GetValue() *ExampleTypeReference { + if e == nil { + return nil + } + return e.Value +} + +func (e *ExampleQueryParameter) GetExtraProperties() map[string]interface{} { + return e.extraProperties +} + +func (e *ExampleQueryParameter) UnmarshalJSON(data []byte) error { + type unmarshaler ExampleQueryParameter + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = ExampleQueryParameter(value) + + extraProperties, err := core.ExtractExtraProperties(data, *e) + if err != nil { + return err + } + e.extraProperties = extraProperties + + return nil +} + +func (e *ExampleQueryParameter) String() string { + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +type ExampleRequestBody struct { + Type string + InlinedRequestBody *ExampleInlinedRequestBody + Reference *ExampleTypeReference +} + +func NewExampleRequestBodyFromInlinedRequestBody(value *ExampleInlinedRequestBody) *ExampleRequestBody { + return &ExampleRequestBody{Type: "inlinedRequestBody", InlinedRequestBody: value} +} + +func NewExampleRequestBodyFromReference(value *ExampleTypeReference) *ExampleRequestBody { + return &ExampleRequestBody{Type: "reference", Reference: value} +} + +func (e *ExampleRequestBody) GetType() string { + if e == nil { + return "" + } + return e.Type +} + +func (e *ExampleRequestBody) GetInlinedRequestBody() *ExampleInlinedRequestBody { + if e == nil { + return nil + } + return e.InlinedRequestBody +} + +func (e *ExampleRequestBody) GetReference() *ExampleTypeReference { + if e == nil { + return nil + } + return e.Reference +} + +func (e *ExampleRequestBody) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + e.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", e) + } + switch unmarshaler.Type { + case "inlinedRequestBody": + value := new(ExampleInlinedRequestBody) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + e.InlinedRequestBody = value + case "reference": + value := new(ExampleTypeReference) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + e.Reference = value + } + return nil +} + +func (e ExampleRequestBody) MarshalJSON() ([]byte, error) { + switch e.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", e.Type, e) + case "inlinedRequestBody": + return core.MarshalJSONWithExtraProperty(e.InlinedRequestBody, "type", "inlinedRequestBody") + case "reference": + return core.MarshalJSONWithExtraProperty(e.Reference, "type", "reference") + } +} + +type ExampleRequestBodyVisitor interface { + VisitInlinedRequestBody(*ExampleInlinedRequestBody) error + VisitReference(*ExampleTypeReference) error +} + +func (e *ExampleRequestBody) Accept(visitor ExampleRequestBodyVisitor) error { + switch e.Type { + default: + return fmt.Errorf("invalid type %s in %T", e.Type, e) + case "inlinedRequestBody": + return visitor.VisitInlinedRequestBody(e.InlinedRequestBody) + case "reference": + return visitor.VisitReference(e.Reference) + } +} + +type ExampleResponse struct { + Type string + Ok *ExampleEndpointSuccessResponse + Error *ExampleEndpointErrorResponse +} + +func NewExampleResponseFromOk(value *ExampleEndpointSuccessResponse) *ExampleResponse { + return &ExampleResponse{Type: "ok", Ok: value} +} + +func NewExampleResponseFromError(value *ExampleEndpointErrorResponse) *ExampleResponse { + return &ExampleResponse{Type: "error", Error: value} +} + +func (e *ExampleResponse) GetType() string { + if e == nil { + return "" + } + return e.Type +} + +func (e *ExampleResponse) GetOk() *ExampleEndpointSuccessResponse { + if e == nil { + return nil + } + return e.Ok +} + +func (e *ExampleResponse) GetError() *ExampleEndpointErrorResponse { + if e == nil { + return nil + } + return e.Error +} + +func (e *ExampleResponse) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + e.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", e) + } + switch unmarshaler.Type { + case "ok": + value := new(ExampleEndpointSuccessResponse) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + e.Ok = value + case "error": + value := new(ExampleEndpointErrorResponse) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + e.Error = value + } + return nil +} + +func (e ExampleResponse) MarshalJSON() ([]byte, error) { + switch e.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", e.Type, e) + case "ok": + return core.MarshalJSONWithExtraProperty(e.Ok, "type", "ok") + case "error": + return core.MarshalJSONWithExtraProperty(e.Error, "type", "error") + } +} + +type ExampleResponseVisitor interface { + VisitOk(*ExampleEndpointSuccessResponse) error + VisitError(*ExampleEndpointErrorResponse) error +} + +func (e *ExampleResponse) Accept(visitor ExampleResponseVisitor) error { + switch e.Type { + default: + return fmt.Errorf("invalid type %s in %T", e.Type, e) + case "ok": + return visitor.VisitOk(e.Ok) + case "error": + return visitor.VisitError(e.Error) + } +} + +type FileDownloadResponse struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + + extraProperties map[string]interface{} +} + +func (f *FileDownloadResponse) GetDocs() *string { + if f == nil { + return nil + } + return f.Docs +} + +func (f *FileDownloadResponse) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *FileDownloadResponse) UnmarshalJSON(data []byte) error { + type unmarshaler FileDownloadResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = FileDownloadResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + return nil +} + +func (f *FileDownloadResponse) String() string { + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + +type FileProperty struct { + Key *NameAndWireValue `json:"key,omitempty" url:"key,omitempty"` + IsOptional bool `json:"isOptional" url:"isOptional"` + + extraProperties map[string]interface{} +} + +func (f *FileProperty) GetKey() *NameAndWireValue { + if f == nil { + return nil + } + return f.Key +} + +func (f *FileProperty) GetIsOptional() bool { + if f == nil { + return false + } + return f.IsOptional +} + +func (f *FileProperty) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *FileProperty) UnmarshalJSON(data []byte) error { + type unmarshaler FileProperty + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = FileProperty(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + return nil +} + +func (f *FileProperty) String() string { + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + +type FileUploadRequest struct { + Name *Name `json:"name,omitempty" url:"name,omitempty"` + Properties []*FileUploadRequestProperty `json:"properties,omitempty" url:"properties,omitempty"` + + extraProperties map[string]interface{} +} + +func (f *FileUploadRequest) GetName() *Name { + if f == nil { + return nil + } + return f.Name +} + +func (f *FileUploadRequest) GetProperties() []*FileUploadRequestProperty { + if f == nil { + return nil + } + return f.Properties +} + +func (f *FileUploadRequest) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *FileUploadRequest) UnmarshalJSON(data []byte) error { + type unmarshaler FileUploadRequest + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = FileUploadRequest(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + return nil +} + +func (f *FileUploadRequest) String() string { + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + +type FileUploadRequestProperty struct { + Type string + File *FileProperty + BodyProperty *InlinedRequestBodyProperty +} + +func NewFileUploadRequestPropertyFromFile(value *FileProperty) *FileUploadRequestProperty { + return &FileUploadRequestProperty{Type: "file", File: value} +} + +func NewFileUploadRequestPropertyFromBodyProperty(value *InlinedRequestBodyProperty) *FileUploadRequestProperty { + return &FileUploadRequestProperty{Type: "bodyProperty", BodyProperty: value} +} + +func (f *FileUploadRequestProperty) GetType() string { + if f == nil { + return "" + } + return f.Type +} + +func (f *FileUploadRequestProperty) GetFile() *FileProperty { + if f == nil { + return nil + } + return f.File +} + +func (f *FileUploadRequestProperty) GetBodyProperty() *InlinedRequestBodyProperty { + if f == nil { + return nil + } + return f.BodyProperty +} + +func (f *FileUploadRequestProperty) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + f.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", f) + } + switch unmarshaler.Type { + case "file": + value := new(FileProperty) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + f.File = value + case "bodyProperty": + value := new(InlinedRequestBodyProperty) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + f.BodyProperty = value + } + return nil +} + +func (f FileUploadRequestProperty) MarshalJSON() ([]byte, error) { + switch f.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", f.Type, f) + case "file": + return core.MarshalJSONWithExtraProperty(f.File, "type", "file") + case "bodyProperty": + return core.MarshalJSONWithExtraProperty(f.BodyProperty, "type", "bodyProperty") + } +} + +type FileUploadRequestPropertyVisitor interface { + VisitFile(*FileProperty) error + VisitBodyProperty(*InlinedRequestBodyProperty) error +} + +func (f *FileUploadRequestProperty) Accept(visitor FileUploadRequestPropertyVisitor) error { + switch f.Type { + default: + return fmt.Errorf("invalid type %s in %T", f.Type, f) + case "file": + return visitor.VisitFile(f.File) + case "bodyProperty": + return visitor.VisitBodyProperty(f.BodyProperty) + } +} + +type HttpEndpoint struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Availability *Availability `json:"availability,omitempty" url:"availability,omitempty"` + Name EndpointName `json:"name,omitempty" url:"name,omitempty"` + DisplayName *string `json:"displayName,omitempty" url:"displayName,omitempty"` + Method HttpMethod `json:"method" url:"method"` + Headers []*HttpHeader `json:"headers,omitempty" url:"headers,omitempty"` + BaseUrl *EnvironmentBaseUrlId `json:"baseUrl,omitempty" url:"baseUrl,omitempty"` + Path *HttpPath `json:"path,omitempty" url:"path,omitempty"` + FullPath *HttpPath `json:"fullPath,omitempty" url:"fullPath,omitempty"` + PathParameters []*PathParameter `json:"pathParameters,omitempty" url:"pathParameters,omitempty"` + AllPathParameters []*PathParameter `json:"allPathParameters,omitempty" url:"allPathParameters,omitempty"` + QueryParameters []*QueryParameter `json:"queryParameters,omitempty" url:"queryParameters,omitempty"` + RequestBody *HttpRequestBody `json:"requestBody,omitempty" url:"requestBody,omitempty"` + SdkRequest *SdkRequest `json:"sdkRequest,omitempty" url:"sdkRequest,omitempty"` + Response *HttpResponse `json:"response,omitempty" url:"response,omitempty"` + StreamingResponse *StreamingResponse `json:"streamingResponse,omitempty" url:"streamingResponse,omitempty"` + SdkResponse *SdkResponse `json:"sdkResponse,omitempty" url:"sdkResponse,omitempty"` + Errors ResponseErrors `json:"errors,omitempty" url:"errors,omitempty"` + Auth bool `json:"auth" url:"auth"` + Examples []*ExampleEndpointCall `json:"examples,omitempty" url:"examples,omitempty"` + + extraProperties map[string]interface{} +} + +func (h *HttpEndpoint) GetDocs() *string { + if h == nil { + return nil + } + return h.Docs +} + +func (h *HttpEndpoint) GetAvailability() *Availability { + if h == nil { + return nil + } + return h.Availability +} + +func (h *HttpEndpoint) GetName() EndpointName { + if h == nil { + return nil + } + return h.Name +} + +func (h *HttpEndpoint) GetDisplayName() *string { + if h == nil { + return nil + } + return h.DisplayName +} + +func (h *HttpEndpoint) GetMethod() HttpMethod { + if h == nil { + return "" + } + return h.Method +} + +func (h *HttpEndpoint) GetHeaders() []*HttpHeader { + if h == nil { + return nil + } + return h.Headers +} + +func (h *HttpEndpoint) GetBaseUrl() *EnvironmentBaseUrlId { + if h == nil { + return nil + } + return h.BaseUrl +} + +func (h *HttpEndpoint) GetPath() *HttpPath { + if h == nil { + return nil + } + return h.Path +} + +func (h *HttpEndpoint) GetFullPath() *HttpPath { + if h == nil { + return nil + } + return h.FullPath +} + +func (h *HttpEndpoint) GetPathParameters() []*PathParameter { + if h == nil { + return nil + } + return h.PathParameters +} + +func (h *HttpEndpoint) GetAllPathParameters() []*PathParameter { + if h == nil { + return nil + } + return h.AllPathParameters +} + +func (h *HttpEndpoint) GetQueryParameters() []*QueryParameter { + if h == nil { + return nil + } + return h.QueryParameters +} + +func (h *HttpEndpoint) GetRequestBody() *HttpRequestBody { + if h == nil { + return nil + } + return h.RequestBody +} + +func (h *HttpEndpoint) GetSdkRequest() *SdkRequest { + if h == nil { + return nil + } + return h.SdkRequest +} + +func (h *HttpEndpoint) GetResponse() *HttpResponse { + if h == nil { + return nil + } + return h.Response +} + +func (h *HttpEndpoint) GetStreamingResponse() *StreamingResponse { + if h == nil { + return nil + } + return h.StreamingResponse +} + +func (h *HttpEndpoint) GetSdkResponse() *SdkResponse { + if h == nil { + return nil + } + return h.SdkResponse +} + +func (h *HttpEndpoint) GetErrors() ResponseErrors { + if h == nil { + return nil + } + return h.Errors +} + +func (h *HttpEndpoint) GetAuth() bool { + if h == nil { + return false + } + return h.Auth +} + +func (h *HttpEndpoint) GetExamples() []*ExampleEndpointCall { + if h == nil { + return nil + } + return h.Examples +} + +func (h *HttpEndpoint) GetExtraProperties() map[string]interface{} { + return h.extraProperties +} + +func (h *HttpEndpoint) UnmarshalJSON(data []byte) error { + type unmarshaler HttpEndpoint + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *h = HttpEndpoint(value) + + extraProperties, err := core.ExtractExtraProperties(data, *h) + if err != nil { + return err + } + h.extraProperties = extraProperties + + return nil +} + +func (h *HttpEndpoint) String() string { + if value, err := core.StringifyJSON(h); err == nil { + return value + } + return fmt.Sprintf("%#v", h) +} + +type HttpHeader struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Availability *Availability `json:"availability,omitempty" url:"availability,omitempty"` + Name *NameAndWireValue `json:"name,omitempty" url:"name,omitempty"` + ValueType *TypeReference `json:"valueType,omitempty" url:"valueType,omitempty"` + + extraProperties map[string]interface{} +} + +func (h *HttpHeader) GetDocs() *string { + if h == nil { + return nil + } + return h.Docs +} + +func (h *HttpHeader) GetAvailability() *Availability { + if h == nil { + return nil + } + return h.Availability +} + +func (h *HttpHeader) GetName() *NameAndWireValue { + if h == nil { + return nil + } + return h.Name +} + +func (h *HttpHeader) GetValueType() *TypeReference { + if h == nil { + return nil + } + return h.ValueType +} + +func (h *HttpHeader) GetExtraProperties() map[string]interface{} { + return h.extraProperties +} + +func (h *HttpHeader) UnmarshalJSON(data []byte) error { + type unmarshaler HttpHeader + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *h = HttpHeader(value) + + extraProperties, err := core.ExtractExtraProperties(data, *h) + if err != nil { + return err + } + h.extraProperties = extraProperties + + return nil +} + +func (h *HttpHeader) String() string { + if value, err := core.StringifyJSON(h); err == nil { + return value + } + return fmt.Sprintf("%#v", h) +} + +type HttpMethod string + +const ( + HttpMethodGet HttpMethod = "GET" + HttpMethodPost HttpMethod = "POST" + HttpMethodPut HttpMethod = "PUT" + HttpMethodPatch HttpMethod = "PATCH" + HttpMethodDelete HttpMethod = "DELETE" +) + +func NewHttpMethodFromString(s string) (HttpMethod, error) { + switch s { + case "GET": + return HttpMethodGet, nil + case "POST": + return HttpMethodPost, nil + case "PUT": + return HttpMethodPut, nil + case "PATCH": + return HttpMethodPatch, nil + case "DELETE": + return HttpMethodDelete, nil + } + var t HttpMethod + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (h HttpMethod) Ptr() *HttpMethod { + return &h +} + +type HttpPath struct { + Head string `json:"head" url:"head"` + Parts []*HttpPathPart `json:"parts,omitempty" url:"parts,omitempty"` + + extraProperties map[string]interface{} +} + +func (h *HttpPath) GetHead() string { + if h == nil { + return "" + } + return h.Head +} + +func (h *HttpPath) GetParts() []*HttpPathPart { + if h == nil { + return nil + } + return h.Parts +} + +func (h *HttpPath) GetExtraProperties() map[string]interface{} { + return h.extraProperties +} + +func (h *HttpPath) UnmarshalJSON(data []byte) error { + type unmarshaler HttpPath + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *h = HttpPath(value) + + extraProperties, err := core.ExtractExtraProperties(data, *h) + if err != nil { + return err + } + h.extraProperties = extraProperties + + return nil +} + +func (h *HttpPath) String() string { + if value, err := core.StringifyJSON(h); err == nil { + return value + } + return fmt.Sprintf("%#v", h) +} + +type HttpPathPart struct { + PathParameter string `json:"pathParameter" url:"pathParameter"` + Tail string `json:"tail" url:"tail"` + + extraProperties map[string]interface{} +} + +func (h *HttpPathPart) GetPathParameter() string { + if h == nil { + return "" + } + return h.PathParameter +} + +func (h *HttpPathPart) GetTail() string { + if h == nil { + return "" + } + return h.Tail +} + +func (h *HttpPathPart) GetExtraProperties() map[string]interface{} { + return h.extraProperties +} + +func (h *HttpPathPart) UnmarshalJSON(data []byte) error { + type unmarshaler HttpPathPart + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *h = HttpPathPart(value) + + extraProperties, err := core.ExtractExtraProperties(data, *h) + if err != nil { + return err + } + h.extraProperties = extraProperties + + return nil +} + +func (h *HttpPathPart) String() string { + if value, err := core.StringifyJSON(h); err == nil { + return value + } + return fmt.Sprintf("%#v", h) +} + +type HttpRequestBody struct { + Type string + InlinedRequestBody *InlinedRequestBody + Reference *HttpRequestBodyReference + FileUpload *FileUploadRequest +} + +func NewHttpRequestBodyFromInlinedRequestBody(value *InlinedRequestBody) *HttpRequestBody { + return &HttpRequestBody{Type: "inlinedRequestBody", InlinedRequestBody: value} +} + +func NewHttpRequestBodyFromReference(value *HttpRequestBodyReference) *HttpRequestBody { + return &HttpRequestBody{Type: "reference", Reference: value} +} + +func NewHttpRequestBodyFromFileUpload(value *FileUploadRequest) *HttpRequestBody { + return &HttpRequestBody{Type: "fileUpload", FileUpload: value} +} + +func (h *HttpRequestBody) GetType() string { + if h == nil { + return "" + } + return h.Type +} + +func (h *HttpRequestBody) GetInlinedRequestBody() *InlinedRequestBody { + if h == nil { + return nil + } + return h.InlinedRequestBody +} + +func (h *HttpRequestBody) GetReference() *HttpRequestBodyReference { + if h == nil { + return nil + } + return h.Reference +} + +func (h *HttpRequestBody) GetFileUpload() *FileUploadRequest { + if h == nil { + return nil + } + return h.FileUpload +} + +func (h *HttpRequestBody) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + h.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", h) + } + switch unmarshaler.Type { + case "inlinedRequestBody": + value := new(InlinedRequestBody) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + h.InlinedRequestBody = value + case "reference": + value := new(HttpRequestBodyReference) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + h.Reference = value + case "fileUpload": + value := new(FileUploadRequest) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + h.FileUpload = value + } + return nil +} + +func (h HttpRequestBody) MarshalJSON() ([]byte, error) { + switch h.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", h.Type, h) + case "inlinedRequestBody": + return core.MarshalJSONWithExtraProperty(h.InlinedRequestBody, "type", "inlinedRequestBody") + case "reference": + return core.MarshalJSONWithExtraProperty(h.Reference, "type", "reference") + case "fileUpload": + return core.MarshalJSONWithExtraProperty(h.FileUpload, "type", "fileUpload") + } +} + +type HttpRequestBodyVisitor interface { + VisitInlinedRequestBody(*InlinedRequestBody) error + VisitReference(*HttpRequestBodyReference) error + VisitFileUpload(*FileUploadRequest) error +} + +func (h *HttpRequestBody) Accept(visitor HttpRequestBodyVisitor) error { + switch h.Type { + default: + return fmt.Errorf("invalid type %s in %T", h.Type, h) + case "inlinedRequestBody": + return visitor.VisitInlinedRequestBody(h.InlinedRequestBody) + case "reference": + return visitor.VisitReference(h.Reference) + case "fileUpload": + return visitor.VisitFileUpload(h.FileUpload) + } +} + +type HttpRequestBodyReference struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + RequestBodyType *TypeReference `json:"requestBodyType,omitempty" url:"requestBodyType,omitempty"` + + extraProperties map[string]interface{} +} + +func (h *HttpRequestBodyReference) GetDocs() *string { + if h == nil { + return nil + } + return h.Docs +} + +func (h *HttpRequestBodyReference) GetRequestBodyType() *TypeReference { + if h == nil { + return nil + } + return h.RequestBodyType +} + +func (h *HttpRequestBodyReference) GetExtraProperties() map[string]interface{} { + return h.extraProperties +} + +func (h *HttpRequestBodyReference) UnmarshalJSON(data []byte) error { + type unmarshaler HttpRequestBodyReference + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *h = HttpRequestBodyReference(value) + + extraProperties, err := core.ExtractExtraProperties(data, *h) + if err != nil { + return err + } + h.extraProperties = extraProperties + + return nil +} + +func (h *HttpRequestBodyReference) String() string { + if value, err := core.StringifyJSON(h); err == nil { + return value + } + return fmt.Sprintf("%#v", h) +} + +type HttpResponse struct { + Type string + Json *JsonResponse + FileDownload *FileDownloadResponse +} + +func NewHttpResponseFromJson(value *JsonResponse) *HttpResponse { + return &HttpResponse{Type: "json", Json: value} +} + +func NewHttpResponseFromFileDownload(value *FileDownloadResponse) *HttpResponse { + return &HttpResponse{Type: "fileDownload", FileDownload: value} +} + +func (h *HttpResponse) GetType() string { + if h == nil { + return "" + } + return h.Type +} + +func (h *HttpResponse) GetJson() *JsonResponse { + if h == nil { + return nil + } + return h.Json +} + +func (h *HttpResponse) GetFileDownload() *FileDownloadResponse { + if h == nil { + return nil + } + return h.FileDownload +} + +func (h *HttpResponse) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + h.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", h) + } + switch unmarshaler.Type { + case "json": + value := new(JsonResponse) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + h.Json = value + case "fileDownload": + value := new(FileDownloadResponse) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + h.FileDownload = value + } + return nil +} + +func (h HttpResponse) MarshalJSON() ([]byte, error) { + switch h.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", h.Type, h) + case "json": + return core.MarshalJSONWithExtraProperty(h.Json, "type", "json") + case "fileDownload": + return core.MarshalJSONWithExtraProperty(h.FileDownload, "type", "fileDownload") + } +} + +type HttpResponseVisitor interface { + VisitJson(*JsonResponse) error + VisitFileDownload(*FileDownloadResponse) error +} + +func (h *HttpResponse) Accept(visitor HttpResponseVisitor) error { + switch h.Type { + default: + return fmt.Errorf("invalid type %s in %T", h.Type, h) + case "json": + return visitor.VisitJson(h.Json) + case "fileDownload": + return visitor.VisitFileDownload(h.FileDownload) + } +} + +type HttpService struct { + Availability *Availability `json:"availability,omitempty" url:"availability,omitempty"` + Name *DeclaredServiceName `json:"name,omitempty" url:"name,omitempty"` + DisplayName *string `json:"displayName,omitempty" url:"displayName,omitempty"` + BasePath *HttpPath `json:"basePath,omitempty" url:"basePath,omitempty"` + Endpoints []*HttpEndpoint `json:"endpoints,omitempty" url:"endpoints,omitempty"` + Headers []*HttpHeader `json:"headers,omitempty" url:"headers,omitempty"` + PathParameters []*PathParameter `json:"pathParameters,omitempty" url:"pathParameters,omitempty"` + + extraProperties map[string]interface{} +} + +func (h *HttpService) GetAvailability() *Availability { + if h == nil { + return nil + } + return h.Availability +} + +func (h *HttpService) GetName() *DeclaredServiceName { + if h == nil { + return nil + } + return h.Name +} + +func (h *HttpService) GetDisplayName() *string { + if h == nil { + return nil + } + return h.DisplayName +} + +func (h *HttpService) GetBasePath() *HttpPath { + if h == nil { + return nil + } + return h.BasePath +} + +func (h *HttpService) GetEndpoints() []*HttpEndpoint { + if h == nil { + return nil + } + return h.Endpoints +} + +func (h *HttpService) GetHeaders() []*HttpHeader { + if h == nil { + return nil + } + return h.Headers +} + +func (h *HttpService) GetPathParameters() []*PathParameter { + if h == nil { + return nil + } + return h.PathParameters +} + +func (h *HttpService) GetExtraProperties() map[string]interface{} { + return h.extraProperties +} + +func (h *HttpService) UnmarshalJSON(data []byte) error { + type unmarshaler HttpService + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *h = HttpService(value) + + extraProperties, err := core.ExtractExtraProperties(data, *h) + if err != nil { + return err + } + h.extraProperties = extraProperties + + return nil +} + +func (h *HttpService) String() string { + if value, err := core.StringifyJSON(h); err == nil { + return value + } + return fmt.Sprintf("%#v", h) +} + +type InlinedRequestBody struct { + Name *Name `json:"name,omitempty" url:"name,omitempty"` + Extends []*DeclaredTypeName `json:"extends,omitempty" url:"extends,omitempty"` + Properties []*InlinedRequestBodyProperty `json:"properties,omitempty" url:"properties,omitempty"` + + extraProperties map[string]interface{} +} + +func (i *InlinedRequestBody) GetName() *Name { + if i == nil { + return nil + } + return i.Name +} + +func (i *InlinedRequestBody) GetExtends() []*DeclaredTypeName { + if i == nil { + return nil + } + return i.Extends +} + +func (i *InlinedRequestBody) GetProperties() []*InlinedRequestBodyProperty { + if i == nil { + return nil + } + return i.Properties +} + +func (i *InlinedRequestBody) GetExtraProperties() map[string]interface{} { + return i.extraProperties +} + +func (i *InlinedRequestBody) UnmarshalJSON(data []byte) error { + type unmarshaler InlinedRequestBody + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *i = InlinedRequestBody(value) + + extraProperties, err := core.ExtractExtraProperties(data, *i) + if err != nil { + return err + } + i.extraProperties = extraProperties + + return nil +} + +func (i *InlinedRequestBody) String() string { + if value, err := core.StringifyJSON(i); err == nil { + return value + } + return fmt.Sprintf("%#v", i) +} + +type InlinedRequestBodyProperty struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Name *NameAndWireValue `json:"name,omitempty" url:"name,omitempty"` + ValueType *TypeReference `json:"valueType,omitempty" url:"valueType,omitempty"` + + extraProperties map[string]interface{} +} + +func (i *InlinedRequestBodyProperty) GetDocs() *string { + if i == nil { + return nil + } + return i.Docs +} + +func (i *InlinedRequestBodyProperty) GetName() *NameAndWireValue { + if i == nil { + return nil + } + return i.Name +} + +func (i *InlinedRequestBodyProperty) GetValueType() *TypeReference { + if i == nil { + return nil + } + return i.ValueType +} + +func (i *InlinedRequestBodyProperty) GetExtraProperties() map[string]interface{} { + return i.extraProperties +} + +func (i *InlinedRequestBodyProperty) UnmarshalJSON(data []byte) error { + type unmarshaler InlinedRequestBodyProperty + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *i = InlinedRequestBodyProperty(value) + + extraProperties, err := core.ExtractExtraProperties(data, *i) + if err != nil { + return err + } + i.extraProperties = extraProperties + + return nil +} + +func (i *InlinedRequestBodyProperty) String() string { + if value, err := core.StringifyJSON(i); err == nil { + return value + } + return fmt.Sprintf("%#v", i) +} + +type JsonResponse struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + ResponseBodyType *TypeReference `json:"responseBodyType,omitempty" url:"responseBodyType,omitempty"` + + extraProperties map[string]interface{} +} + +func (j *JsonResponse) GetDocs() *string { + if j == nil { + return nil + } + return j.Docs +} + +func (j *JsonResponse) GetResponseBodyType() *TypeReference { + if j == nil { + return nil + } + return j.ResponseBodyType +} + +func (j *JsonResponse) GetExtraProperties() map[string]interface{} { + return j.extraProperties +} + +func (j *JsonResponse) UnmarshalJSON(data []byte) error { + type unmarshaler JsonResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *j = JsonResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *j) + if err != nil { + return err + } + j.extraProperties = extraProperties + + return nil +} + +func (j *JsonResponse) String() string { + if value, err := core.StringifyJSON(j); err == nil { + return value + } + return fmt.Sprintf("%#v", j) +} + +type MaybeStreamingResponse struct { + Condition *StreamCondition `json:"condition,omitempty" url:"condition,omitempty"` + NonStreaming *HttpResponse `json:"nonStreaming,omitempty" url:"nonStreaming,omitempty"` + Streaming *StreamingResponse `json:"streaming,omitempty" url:"streaming,omitempty"` + + extraProperties map[string]interface{} +} + +func (m *MaybeStreamingResponse) GetCondition() *StreamCondition { + if m == nil { + return nil + } + return m.Condition +} + +func (m *MaybeStreamingResponse) GetNonStreaming() *HttpResponse { + if m == nil { + return nil + } + return m.NonStreaming +} + +func (m *MaybeStreamingResponse) GetStreaming() *StreamingResponse { + if m == nil { + return nil + } + return m.Streaming +} + +func (m *MaybeStreamingResponse) GetExtraProperties() map[string]interface{} { + return m.extraProperties +} + +func (m *MaybeStreamingResponse) UnmarshalJSON(data []byte) error { + type unmarshaler MaybeStreamingResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *m = MaybeStreamingResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *m) + if err != nil { + return err + } + m.extraProperties = extraProperties + + return nil +} + +func (m *MaybeStreamingResponse) String() string { + if value, err := core.StringifyJSON(m); err == nil { + return value + } + return fmt.Sprintf("%#v", m) +} + +type PathParameter struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Name *Name `json:"name,omitempty" url:"name,omitempty"` + ValueType *TypeReference `json:"valueType,omitempty" url:"valueType,omitempty"` + Location PathParameterLocation `json:"location" url:"location"` + Variable *VariableId `json:"variable,omitempty" url:"variable,omitempty"` + + extraProperties map[string]interface{} +} + +func (p *PathParameter) GetDocs() *string { + if p == nil { + return nil + } + return p.Docs +} + +func (p *PathParameter) GetName() *Name { + if p == nil { + return nil + } + return p.Name +} + +func (p *PathParameter) GetValueType() *TypeReference { + if p == nil { + return nil + } + return p.ValueType +} + +func (p *PathParameter) GetLocation() PathParameterLocation { + if p == nil { + return "" + } + return p.Location +} + +func (p *PathParameter) GetVariable() *VariableId { + if p == nil { + return nil + } + return p.Variable +} + +func (p *PathParameter) GetExtraProperties() map[string]interface{} { + return p.extraProperties +} + +func (p *PathParameter) UnmarshalJSON(data []byte) error { + type unmarshaler PathParameter + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PathParameter(value) + + extraProperties, err := core.ExtractExtraProperties(data, *p) + if err != nil { + return err + } + p.extraProperties = extraProperties + + return nil +} + +func (p *PathParameter) String() string { + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PathParameterLocation string + +const ( + PathParameterLocationRoot PathParameterLocation = "ROOT" + PathParameterLocationService PathParameterLocation = "SERVICE" + PathParameterLocationEndpoint PathParameterLocation = "ENDPOINT" +) + +func NewPathParameterLocationFromString(s string) (PathParameterLocation, error) { + switch s { + case "ROOT": + return PathParameterLocationRoot, nil + case "SERVICE": + return PathParameterLocationService, nil + case "ENDPOINT": + return PathParameterLocationEndpoint, nil + } + var t PathParameterLocation + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (p PathParameterLocation) Ptr() *PathParameterLocation { + return &p +} + +type QueryParameter struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Availability *Availability `json:"availability,omitempty" url:"availability,omitempty"` + Name *NameAndWireValue `json:"name,omitempty" url:"name,omitempty"` + ValueType *TypeReference `json:"valueType,omitempty" url:"valueType,omitempty"` + AllowMultiple bool `json:"allowMultiple" url:"allowMultiple"` + + extraProperties map[string]interface{} +} + +func (q *QueryParameter) GetDocs() *string { + if q == nil { + return nil + } + return q.Docs +} + +func (q *QueryParameter) GetAvailability() *Availability { + if q == nil { + return nil + } + return q.Availability +} + +func (q *QueryParameter) GetName() *NameAndWireValue { + if q == nil { + return nil + } + return q.Name +} + +func (q *QueryParameter) GetValueType() *TypeReference { + if q == nil { + return nil + } + return q.ValueType +} + +func (q *QueryParameter) GetAllowMultiple() bool { + if q == nil { + return false + } + return q.AllowMultiple +} + +func (q *QueryParameter) GetExtraProperties() map[string]interface{} { + return q.extraProperties +} + +func (q *QueryParameter) UnmarshalJSON(data []byte) error { + type unmarshaler QueryParameter + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *q = QueryParameter(value) + + extraProperties, err := core.ExtractExtraProperties(data, *q) + if err != nil { + return err + } + q.extraProperties = extraProperties + + return nil +} + +func (q *QueryParameter) String() string { + if value, err := core.StringifyJSON(q); err == nil { + return value + } + return fmt.Sprintf("%#v", q) +} + +type ResponseError struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Error *DeclaredErrorName `json:"error,omitempty" url:"error,omitempty"` + + extraProperties map[string]interface{} +} + +func (r *ResponseError) GetDocs() *string { + if r == nil { + return nil + } + return r.Docs +} + +func (r *ResponseError) GetError() *DeclaredErrorName { + if r == nil { + return nil + } + return r.Error +} + +func (r *ResponseError) GetExtraProperties() map[string]interface{} { + return r.extraProperties +} + +func (r *ResponseError) UnmarshalJSON(data []byte) error { + type unmarshaler ResponseError + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *r = ResponseError(value) + + extraProperties, err := core.ExtractExtraProperties(data, *r) + if err != nil { + return err + } + r.extraProperties = extraProperties + + return nil +} + +func (r *ResponseError) String() string { + if value, err := core.StringifyJSON(r); err == nil { + return value + } + return fmt.Sprintf("%#v", r) +} + +type ResponseErrors = []*ResponseError + +type SdkRequest struct { + RequestParameterName *Name `json:"requestParameterName,omitempty" url:"requestParameterName,omitempty"` + Shape *SdkRequestShape `json:"shape,omitempty" url:"shape,omitempty"` + + extraProperties map[string]interface{} +} + +func (s *SdkRequest) GetRequestParameterName() *Name { + if s == nil { + return nil + } + return s.RequestParameterName +} + +func (s *SdkRequest) GetShape() *SdkRequestShape { + if s == nil { + return nil + } + return s.Shape +} + +func (s *SdkRequest) GetExtraProperties() map[string]interface{} { + return s.extraProperties +} + +func (s *SdkRequest) UnmarshalJSON(data []byte) error { + type unmarshaler SdkRequest + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = SdkRequest(value) + + extraProperties, err := core.ExtractExtraProperties(data, *s) + if err != nil { + return err + } + s.extraProperties = extraProperties + + return nil +} + +func (s *SdkRequest) String() string { + if value, err := core.StringifyJSON(s); err == nil { + return value + } + return fmt.Sprintf("%#v", s) +} + +type SdkRequestShape struct { + Type string + JustRequestBody *HttpRequestBodyReference + Wrapper *SdkRequestWrapper +} + +func NewSdkRequestShapeFromJustRequestBody(value *HttpRequestBodyReference) *SdkRequestShape { + return &SdkRequestShape{Type: "justRequestBody", JustRequestBody: value} +} + +func NewSdkRequestShapeFromWrapper(value *SdkRequestWrapper) *SdkRequestShape { + return &SdkRequestShape{Type: "wrapper", Wrapper: value} +} + +func (s *SdkRequestShape) GetType() string { + if s == nil { + return "" + } + return s.Type +} + +func (s *SdkRequestShape) GetJustRequestBody() *HttpRequestBodyReference { + if s == nil { + return nil + } + return s.JustRequestBody +} + +func (s *SdkRequestShape) GetWrapper() *SdkRequestWrapper { + if s == nil { + return nil + } + return s.Wrapper +} + +func (s *SdkRequestShape) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + s.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", s) + } + switch unmarshaler.Type { + case "justRequestBody": + value := new(HttpRequestBodyReference) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + s.JustRequestBody = value + case "wrapper": + value := new(SdkRequestWrapper) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + s.Wrapper = value + } + return nil +} + +func (s SdkRequestShape) MarshalJSON() ([]byte, error) { + switch s.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", s.Type, s) + case "justRequestBody": + return core.MarshalJSONWithExtraProperty(s.JustRequestBody, "type", "justRequestBody") + case "wrapper": + return core.MarshalJSONWithExtraProperty(s.Wrapper, "type", "wrapper") + } +} + +type SdkRequestShapeVisitor interface { + VisitJustRequestBody(*HttpRequestBodyReference) error + VisitWrapper(*SdkRequestWrapper) error +} + +func (s *SdkRequestShape) Accept(visitor SdkRequestShapeVisitor) error { + switch s.Type { + default: + return fmt.Errorf("invalid type %s in %T", s.Type, s) + case "justRequestBody": + return visitor.VisitJustRequestBody(s.JustRequestBody) + case "wrapper": + return visitor.VisitWrapper(s.Wrapper) + } +} + +type SdkRequestWrapper struct { + WrapperName *Name `json:"wrapperName,omitempty" url:"wrapperName,omitempty"` + BodyKey *Name `json:"bodyKey,omitempty" url:"bodyKey,omitempty"` + + extraProperties map[string]interface{} +} + +func (s *SdkRequestWrapper) GetWrapperName() *Name { + if s == nil { + return nil + } + return s.WrapperName +} + +func (s *SdkRequestWrapper) GetBodyKey() *Name { + if s == nil { + return nil + } + return s.BodyKey +} + +func (s *SdkRequestWrapper) GetExtraProperties() map[string]interface{} { + return s.extraProperties +} + +func (s *SdkRequestWrapper) UnmarshalJSON(data []byte) error { + type unmarshaler SdkRequestWrapper + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = SdkRequestWrapper(value) + + extraProperties, err := core.ExtractExtraProperties(data, *s) + if err != nil { + return err + } + s.extraProperties = extraProperties + + return nil +} + +func (s *SdkRequestWrapper) String() string { + if value, err := core.StringifyJSON(s); err == nil { + return value + } + return fmt.Sprintf("%#v", s) +} + +type SdkResponse struct { + Type string + Json *JsonResponse + Streaming *StreamingResponse + MaybeStreaming *MaybeStreamingResponse + FileDownload *FileDownloadResponse +} + +func NewSdkResponseFromJson(value *JsonResponse) *SdkResponse { + return &SdkResponse{Type: "json", Json: value} +} + +func NewSdkResponseFromStreaming(value *StreamingResponse) *SdkResponse { + return &SdkResponse{Type: "streaming", Streaming: value} +} + +func NewSdkResponseFromMaybeStreaming(value *MaybeStreamingResponse) *SdkResponse { + return &SdkResponse{Type: "maybeStreaming", MaybeStreaming: value} +} + +func NewSdkResponseFromFileDownload(value *FileDownloadResponse) *SdkResponse { + return &SdkResponse{Type: "fileDownload", FileDownload: value} +} + +func (s *SdkResponse) GetType() string { + if s == nil { + return "" + } + return s.Type +} + +func (s *SdkResponse) GetJson() *JsonResponse { + if s == nil { + return nil + } + return s.Json +} + +func (s *SdkResponse) GetStreaming() *StreamingResponse { + if s == nil { + return nil + } + return s.Streaming +} + +func (s *SdkResponse) GetMaybeStreaming() *MaybeStreamingResponse { + if s == nil { + return nil + } + return s.MaybeStreaming +} + +func (s *SdkResponse) GetFileDownload() *FileDownloadResponse { + if s == nil { + return nil + } + return s.FileDownload +} + +func (s *SdkResponse) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + s.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", s) + } + switch unmarshaler.Type { + case "json": + value := new(JsonResponse) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + s.Json = value + case "streaming": + value := new(StreamingResponse) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + s.Streaming = value + case "maybeStreaming": + value := new(MaybeStreamingResponse) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + s.MaybeStreaming = value + case "fileDownload": + value := new(FileDownloadResponse) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + s.FileDownload = value + } + return nil +} + +func (s SdkResponse) MarshalJSON() ([]byte, error) { + switch s.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", s.Type, s) + case "json": + return core.MarshalJSONWithExtraProperty(s.Json, "type", "json") + case "streaming": + return core.MarshalJSONWithExtraProperty(s.Streaming, "type", "streaming") + case "maybeStreaming": + return core.MarshalJSONWithExtraProperty(s.MaybeStreaming, "type", "maybeStreaming") + case "fileDownload": + return core.MarshalJSONWithExtraProperty(s.FileDownload, "type", "fileDownload") + } +} + +type SdkResponseVisitor interface { + VisitJson(*JsonResponse) error + VisitStreaming(*StreamingResponse) error + VisitMaybeStreaming(*MaybeStreamingResponse) error + VisitFileDownload(*FileDownloadResponse) error +} + +func (s *SdkResponse) Accept(visitor SdkResponseVisitor) error { + switch s.Type { + default: + return fmt.Errorf("invalid type %s in %T", s.Type, s) + case "json": + return visitor.VisitJson(s.Json) + case "streaming": + return visitor.VisitStreaming(s.Streaming) + case "maybeStreaming": + return visitor.VisitMaybeStreaming(s.MaybeStreaming) + case "fileDownload": + return visitor.VisitFileDownload(s.FileDownload) + } +} + +type StreamCondition struct { + Type string + // The name of a boolean query parameter. If it is true, the response + // should be streamed. Otherwise, it should not be streamed. + QueryParameterKey string + // The name of a boolean property on the request. If it is true, the response + // should be streamed. Otherwise, it should not be streamed. + RequestPropertyKey string +} + +func NewStreamConditionFromQueryParameterKey(value string) *StreamCondition { + return &StreamCondition{Type: "queryParameterKey", QueryParameterKey: value} +} + +func NewStreamConditionFromRequestPropertyKey(value string) *StreamCondition { + return &StreamCondition{Type: "requestPropertyKey", RequestPropertyKey: value} +} + +func (s *StreamCondition) GetType() string { + if s == nil { + return "" + } + return s.Type +} + +func (s *StreamCondition) GetQueryParameterKey() string { + if s == nil { + return "" + } + return s.QueryParameterKey +} + +func (s *StreamCondition) GetRequestPropertyKey() string { + if s == nil { + return "" + } + return s.RequestPropertyKey +} + +func (s *StreamCondition) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + s.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", s) + } + switch unmarshaler.Type { + case "queryParameterKey": + var valueUnmarshaler struct { + QueryParameterKey string `json:"value"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + s.QueryParameterKey = valueUnmarshaler.QueryParameterKey + case "requestPropertyKey": + var valueUnmarshaler struct { + RequestPropertyKey string `json:"value"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + s.RequestPropertyKey = valueUnmarshaler.RequestPropertyKey + } + return nil +} + +func (s StreamCondition) MarshalJSON() ([]byte, error) { + switch s.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", s.Type, s) + case "queryParameterKey": + var marshaler = struct { + Type string `json:"type"` + QueryParameterKey string `json:"value"` + }{ + Type: "queryParameterKey", + QueryParameterKey: s.QueryParameterKey, + } + return json.Marshal(marshaler) + case "requestPropertyKey": + var marshaler = struct { + Type string `json:"type"` + RequestPropertyKey string `json:"value"` + }{ + Type: "requestPropertyKey", + RequestPropertyKey: s.RequestPropertyKey, + } + return json.Marshal(marshaler) + } +} + +type StreamConditionVisitor interface { + VisitQueryParameterKey(string) error + VisitRequestPropertyKey(string) error +} + +func (s *StreamCondition) Accept(visitor StreamConditionVisitor) error { + switch s.Type { + default: + return fmt.Errorf("invalid type %s in %T", s.Type, s) + case "queryParameterKey": + return visitor.VisitQueryParameterKey(s.QueryParameterKey) + case "requestPropertyKey": + return visitor.VisitRequestPropertyKey(s.RequestPropertyKey) + } +} + +type StreamingResponse struct { + DataEventType *TypeReference `json:"dataEventType,omitempty" url:"dataEventType,omitempty"` + Terminator *string `json:"terminator,omitempty" url:"terminator,omitempty"` + + extraProperties map[string]interface{} +} + +func (s *StreamingResponse) GetDataEventType() *TypeReference { + if s == nil { + return nil + } + return s.DataEventType +} + +func (s *StreamingResponse) GetTerminator() *string { + if s == nil { + return nil + } + return s.Terminator +} + +func (s *StreamingResponse) GetExtraProperties() map[string]interface{} { + return s.extraProperties +} + +func (s *StreamingResponse) UnmarshalJSON(data []byte) error { + type unmarshaler StreamingResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = StreamingResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *s) + if err != nil { + return err + } + s.extraProperties = extraProperties + + return nil +} + +func (s *StreamingResponse) String() string { + if value, err := core.StringifyJSON(s); err == nil { + return value + } + return fmt.Sprintf("%#v", s) +} diff --git a/generators/go/internal/testdata/model/ir/fixtures/ir.go b/generators/go/internal/testdata/model/ir/fixtures/ir.go new file mode 100644 index 00000000000..2e9a8877ac1 --- /dev/null +++ b/generators/go/internal/testdata/model/ir/fixtures/ir.go @@ -0,0 +1,629 @@ +// This file was auto-generated by Fern from our API Definition. + +package ir + +import ( + json "encoding/json" + fmt "fmt" + core "sdk/core" +) + +type ErrorDiscriminationByPropertyStrategy struct { + Discriminant *NameAndWireValue `json:"discriminant,omitempty" url:"discriminant,omitempty"` + ContentProperty *NameAndWireValue `json:"contentProperty,omitempty" url:"contentProperty,omitempty"` + + extraProperties map[string]interface{} +} + +func (e *ErrorDiscriminationByPropertyStrategy) GetDiscriminant() *NameAndWireValue { + if e == nil { + return nil + } + return e.Discriminant +} + +func (e *ErrorDiscriminationByPropertyStrategy) GetContentProperty() *NameAndWireValue { + if e == nil { + return nil + } + return e.ContentProperty +} + +func (e *ErrorDiscriminationByPropertyStrategy) GetExtraProperties() map[string]interface{} { + return e.extraProperties +} + +func (e *ErrorDiscriminationByPropertyStrategy) UnmarshalJSON(data []byte) error { + type unmarshaler ErrorDiscriminationByPropertyStrategy + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = ErrorDiscriminationByPropertyStrategy(value) + + extraProperties, err := core.ExtractExtraProperties(data, *e) + if err != nil { + return err + } + e.extraProperties = extraProperties + + return nil +} + +func (e *ErrorDiscriminationByPropertyStrategy) String() string { + if value, err := core.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +type ErrorDiscriminationStrategy struct { + Type string + StatusCode interface{} + Property *ErrorDiscriminationByPropertyStrategy +} + +func NewErrorDiscriminationStrategyFromStatusCode(value interface{}) *ErrorDiscriminationStrategy { + return &ErrorDiscriminationStrategy{Type: "statusCode", StatusCode: value} +} + +func NewErrorDiscriminationStrategyFromProperty(value *ErrorDiscriminationByPropertyStrategy) *ErrorDiscriminationStrategy { + return &ErrorDiscriminationStrategy{Type: "property", Property: value} +} + +func (e *ErrorDiscriminationStrategy) GetType() string { + if e == nil { + return "" + } + return e.Type +} + +func (e *ErrorDiscriminationStrategy) GetStatusCode() interface{} { + if e == nil { + return nil + } + return e.StatusCode +} + +func (e *ErrorDiscriminationStrategy) GetProperty() *ErrorDiscriminationByPropertyStrategy { + if e == nil { + return nil + } + return e.Property +} + +func (e *ErrorDiscriminationStrategy) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + e.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", e) + } + switch unmarshaler.Type { + case "statusCode": + value := make(map[string]interface{}) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + e.StatusCode = value + case "property": + value := new(ErrorDiscriminationByPropertyStrategy) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + e.Property = value + } + return nil +} + +func (e ErrorDiscriminationStrategy) MarshalJSON() ([]byte, error) { + switch e.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", e.Type, e) + case "statusCode": + var marshaler = struct { + Type string `json:"type"` + StatusCode interface{} `json:"statusCode,omitempty"` + }{ + Type: "statusCode", + StatusCode: e.StatusCode, + } + return json.Marshal(marshaler) + case "property": + return core.MarshalJSONWithExtraProperty(e.Property, "type", "property") + } +} + +type ErrorDiscriminationStrategyVisitor interface { + VisitStatusCode(interface{}) error + VisitProperty(*ErrorDiscriminationByPropertyStrategy) error +} + +func (e *ErrorDiscriminationStrategy) Accept(visitor ErrorDiscriminationStrategyVisitor) error { + switch e.Type { + default: + return fmt.Errorf("invalid type %s in %T", e.Type, e) + case "statusCode": + return visitor.VisitStatusCode(e.StatusCode) + case "property": + return visitor.VisitProperty(e.Property) + } +} + +// Complete representation of the API schema +type IntermediateRepresentation struct { + // This is the human readable unique id for the API. + ApiName *Name `json:"apiName,omitempty" url:"apiName,omitempty"` + ApiDisplayName *string `json:"apiDisplayName,omitempty" url:"apiDisplayName,omitempty"` + ApiDocs *string `json:"apiDocs,omitempty" url:"apiDocs,omitempty"` + Auth *ApiAuth `json:"auth,omitempty" url:"auth,omitempty"` + // API Wide headers that are sent on every request + Headers []*HttpHeader `json:"headers,omitempty" url:"headers,omitempty"` + // The types described by this API + Types map[TypeId]*TypeDeclaration `json:"types,omitempty" url:"types,omitempty"` + // The services exposed by this API + Services map[ServiceId]*HttpService `json:"services,omitempty" url:"services,omitempty"` + Errors map[ErrorId]*ErrorDeclaration `json:"errors,omitempty" url:"errors,omitempty"` + Subpackages map[SubpackageId]*Subpackage `json:"subpackages,omitempty" url:"subpackages,omitempty"` + RootPackage *Package `json:"rootPackage,omitempty" url:"rootPackage,omitempty"` + Constants *Constants `json:"constants,omitempty" url:"constants,omitempty"` + Environments *EnvironmentsConfig `json:"environments,omitempty" url:"environments,omitempty"` + BasePath *HttpPath `json:"basePath,omitempty" url:"basePath,omitempty"` + PathParameters []*PathParameter `json:"pathParameters,omitempty" url:"pathParameters,omitempty"` + ErrorDiscriminationStrategy *ErrorDiscriminationStrategy `json:"errorDiscriminationStrategy,omitempty" url:"errorDiscriminationStrategy,omitempty"` + SdkConfig *SdkConfig `json:"sdkConfig,omitempty" url:"sdkConfig,omitempty"` + Variables []*VariableDeclaration `json:"variables,omitempty" url:"variables,omitempty"` + + extraProperties map[string]interface{} +} + +func (i *IntermediateRepresentation) GetApiName() *Name { + if i == nil { + return nil + } + return i.ApiName +} + +func (i *IntermediateRepresentation) GetApiDisplayName() *string { + if i == nil { + return nil + } + return i.ApiDisplayName +} + +func (i *IntermediateRepresentation) GetApiDocs() *string { + if i == nil { + return nil + } + return i.ApiDocs +} + +func (i *IntermediateRepresentation) GetAuth() *ApiAuth { + if i == nil { + return nil + } + return i.Auth +} + +func (i *IntermediateRepresentation) GetHeaders() []*HttpHeader { + if i == nil { + return nil + } + return i.Headers +} + +func (i *IntermediateRepresentation) GetTypes() map[TypeId]*TypeDeclaration { + if i == nil { + return nil + } + return i.Types +} + +func (i *IntermediateRepresentation) GetServices() map[ServiceId]*HttpService { + if i == nil { + return nil + } + return i.Services +} + +func (i *IntermediateRepresentation) GetErrors() map[ErrorId]*ErrorDeclaration { + if i == nil { + return nil + } + return i.Errors +} + +func (i *IntermediateRepresentation) GetSubpackages() map[SubpackageId]*Subpackage { + if i == nil { + return nil + } + return i.Subpackages +} + +func (i *IntermediateRepresentation) GetRootPackage() *Package { + if i == nil { + return nil + } + return i.RootPackage +} + +func (i *IntermediateRepresentation) GetConstants() *Constants { + if i == nil { + return nil + } + return i.Constants +} + +func (i *IntermediateRepresentation) GetEnvironments() *EnvironmentsConfig { + if i == nil { + return nil + } + return i.Environments +} + +func (i *IntermediateRepresentation) GetBasePath() *HttpPath { + if i == nil { + return nil + } + return i.BasePath +} + +func (i *IntermediateRepresentation) GetPathParameters() []*PathParameter { + if i == nil { + return nil + } + return i.PathParameters +} + +func (i *IntermediateRepresentation) GetErrorDiscriminationStrategy() *ErrorDiscriminationStrategy { + if i == nil { + return nil + } + return i.ErrorDiscriminationStrategy +} + +func (i *IntermediateRepresentation) GetSdkConfig() *SdkConfig { + if i == nil { + return nil + } + return i.SdkConfig +} + +func (i *IntermediateRepresentation) GetVariables() []*VariableDeclaration { + if i == nil { + return nil + } + return i.Variables +} + +func (i *IntermediateRepresentation) GetExtraProperties() map[string]interface{} { + return i.extraProperties +} + +func (i *IntermediateRepresentation) UnmarshalJSON(data []byte) error { + type unmarshaler IntermediateRepresentation + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *i = IntermediateRepresentation(value) + + extraProperties, err := core.ExtractExtraProperties(data, *i) + if err != nil { + return err + } + i.extraProperties = extraProperties + + return nil +} + +func (i *IntermediateRepresentation) String() string { + if value, err := core.StringifyJSON(i); err == nil { + return value + } + return fmt.Sprintf("%#v", i) +} + +type Package struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + FernFilepath *FernFilepath `json:"fernFilepath,omitempty" url:"fernFilepath,omitempty"` + Service *ServiceId `json:"service,omitempty" url:"service,omitempty"` + Types []TypeId `json:"types,omitempty" url:"types,omitempty"` + Errors []ErrorId `json:"errors,omitempty" url:"errors,omitempty"` + Subpackages []SubpackageId `json:"subpackages,omitempty" url:"subpackages,omitempty"` + HasEndpointsInTree bool `json:"hasEndpointsInTree" url:"hasEndpointsInTree"` + + extraProperties map[string]interface{} +} + +func (p *Package) GetDocs() *string { + if p == nil { + return nil + } + return p.Docs +} + +func (p *Package) GetFernFilepath() *FernFilepath { + if p == nil { + return nil + } + return p.FernFilepath +} + +func (p *Package) GetService() *ServiceId { + if p == nil { + return nil + } + return p.Service +} + +func (p *Package) GetTypes() []TypeId { + if p == nil { + return nil + } + return p.Types +} + +func (p *Package) GetErrors() []ErrorId { + if p == nil { + return nil + } + return p.Errors +} + +func (p *Package) GetSubpackages() []SubpackageId { + if p == nil { + return nil + } + return p.Subpackages +} + +func (p *Package) GetHasEndpointsInTree() bool { + if p == nil { + return false + } + return p.HasEndpointsInTree +} + +func (p *Package) GetExtraProperties() map[string]interface{} { + return p.extraProperties +} + +func (p *Package) UnmarshalJSON(data []byte) error { + type unmarshaler Package + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = Package(value) + + extraProperties, err := core.ExtractExtraProperties(data, *p) + if err != nil { + return err + } + p.extraProperties = extraProperties + + return nil +} + +func (p *Package) String() string { + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type PlatformHeaders struct { + Language string `json:"language" url:"language"` + SdkName string `json:"sdkName" url:"sdkName"` + SdkVersion string `json:"sdkVersion" url:"sdkVersion"` + + extraProperties map[string]interface{} +} + +func (p *PlatformHeaders) GetLanguage() string { + if p == nil { + return "" + } + return p.Language +} + +func (p *PlatformHeaders) GetSdkName() string { + if p == nil { + return "" + } + return p.SdkName +} + +func (p *PlatformHeaders) GetSdkVersion() string { + if p == nil { + return "" + } + return p.SdkVersion +} + +func (p *PlatformHeaders) GetExtraProperties() map[string]interface{} { + return p.extraProperties +} + +func (p *PlatformHeaders) UnmarshalJSON(data []byte) error { + type unmarshaler PlatformHeaders + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PlatformHeaders(value) + + extraProperties, err := core.ExtractExtraProperties(data, *p) + if err != nil { + return err + } + p.extraProperties = extraProperties + + return nil +} + +func (p *PlatformHeaders) String() string { + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type SdkConfig struct { + IsAuthMandatory bool `json:"isAuthMandatory" url:"isAuthMandatory"` + HasStreamingEndpoints bool `json:"hasStreamingEndpoints" url:"hasStreamingEndpoints"` + PlatformHeaders *PlatformHeaders `json:"platformHeaders,omitempty" url:"platformHeaders,omitempty"` + + extraProperties map[string]interface{} +} + +func (s *SdkConfig) GetIsAuthMandatory() bool { + if s == nil { + return false + } + return s.IsAuthMandatory +} + +func (s *SdkConfig) GetHasStreamingEndpoints() bool { + if s == nil { + return false + } + return s.HasStreamingEndpoints +} + +func (s *SdkConfig) GetPlatformHeaders() *PlatformHeaders { + if s == nil { + return nil + } + return s.PlatformHeaders +} + +func (s *SdkConfig) GetExtraProperties() map[string]interface{} { + return s.extraProperties +} + +func (s *SdkConfig) UnmarshalJSON(data []byte) error { + type unmarshaler SdkConfig + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = SdkConfig(value) + + extraProperties, err := core.ExtractExtraProperties(data, *s) + if err != nil { + return err + } + s.extraProperties = extraProperties + + return nil +} + +func (s *SdkConfig) String() string { + if value, err := core.StringifyJSON(s); err == nil { + return value + } + return fmt.Sprintf("%#v", s) +} + +type Subpackage struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + FernFilepath *FernFilepath `json:"fernFilepath,omitempty" url:"fernFilepath,omitempty"` + Service *ServiceId `json:"service,omitempty" url:"service,omitempty"` + Types []TypeId `json:"types,omitempty" url:"types,omitempty"` + Errors []ErrorId `json:"errors,omitempty" url:"errors,omitempty"` + Subpackages []SubpackageId `json:"subpackages,omitempty" url:"subpackages,omitempty"` + HasEndpointsInTree bool `json:"hasEndpointsInTree" url:"hasEndpointsInTree"` + Name *Name `json:"name,omitempty" url:"name,omitempty"` + + extraProperties map[string]interface{} +} + +func (s *Subpackage) GetDocs() *string { + if s == nil { + return nil + } + return s.Docs +} + +func (s *Subpackage) GetFernFilepath() *FernFilepath { + if s == nil { + return nil + } + return s.FernFilepath +} + +func (s *Subpackage) GetService() *ServiceId { + if s == nil { + return nil + } + return s.Service +} + +func (s *Subpackage) GetTypes() []TypeId { + if s == nil { + return nil + } + return s.Types +} + +func (s *Subpackage) GetErrors() []ErrorId { + if s == nil { + return nil + } + return s.Errors +} + +func (s *Subpackage) GetSubpackages() []SubpackageId { + if s == nil { + return nil + } + return s.Subpackages +} + +func (s *Subpackage) GetHasEndpointsInTree() bool { + if s == nil { + return false + } + return s.HasEndpointsInTree +} + +func (s *Subpackage) GetName() *Name { + if s == nil { + return nil + } + return s.Name +} + +func (s *Subpackage) GetExtraProperties() map[string]interface{} { + return s.extraProperties +} + +func (s *Subpackage) UnmarshalJSON(data []byte) error { + type unmarshaler Subpackage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = Subpackage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *s) + if err != nil { + return err + } + s.extraProperties = extraProperties + + return nil +} + +func (s *Subpackage) String() string { + if value, err := core.StringifyJSON(s); err == nil { + return value + } + return fmt.Sprintf("%#v", s) +} diff --git a/generators/go/internal/testdata/model/ir/fixtures/types.go b/generators/go/internal/testdata/model/ir/fixtures/types.go index 261b9be3e58..3b9710883a2 100644 --- a/generators/go/internal/testdata/model/ir/fixtures/types.go +++ b/generators/go/internal/testdata/model/ir/fixtures/types.go @@ -10,4688 +10,231 @@ import ( time "time" ) -type ApiAuth struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Requirement AuthSchemesRequirement `json:"requirement" url:"requirement"` - Schemes []*AuthScheme `json:"schemes,omitempty" url:"schemes,omitempty"` - - extraProperties map[string]interface{} -} - -func (a *ApiAuth) GetDocs() *string { - if a == nil { - return nil - } - return a.Docs -} - -func (a *ApiAuth) GetRequirement() AuthSchemesRequirement { - if a == nil { - return "" - } - return a.Requirement -} - -func (a *ApiAuth) GetSchemes() []*AuthScheme { - if a == nil { - return nil - } - return a.Schemes -} - -func (a *ApiAuth) GetExtraProperties() map[string]interface{} { - return a.extraProperties -} - -func (a *ApiAuth) UnmarshalJSON(data []byte) error { - type unmarshaler ApiAuth - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *a = ApiAuth(value) - - extraProperties, err := core.ExtractExtraProperties(data, *a) - if err != nil { - return err - } - a.extraProperties = extraProperties - - return nil -} - -func (a *ApiAuth) String() string { - if value, err := core.StringifyJSON(a); err == nil { - return value - } - return fmt.Sprintf("%#v", a) -} - -type AuthScheme struct { - Type string - Bearer *BearerAuthScheme - Basic *BasicAuthScheme - Header *HeaderAuthScheme -} - -func NewAuthSchemeFromBearer(value *BearerAuthScheme) *AuthScheme { - return &AuthScheme{Type: "bearer", Bearer: value} -} - -func NewAuthSchemeFromBasic(value *BasicAuthScheme) *AuthScheme { - return &AuthScheme{Type: "basic", Basic: value} -} - -func NewAuthSchemeFromHeader(value *HeaderAuthScheme) *AuthScheme { - return &AuthScheme{Type: "header", Header: value} -} - -func (a *AuthScheme) GetType() string { - if a == nil { - return "" - } - return a.Type -} - -func (a *AuthScheme) GetBearer() *BearerAuthScheme { - if a == nil { - return nil - } - return a.Bearer -} - -func (a *AuthScheme) GetBasic() *BasicAuthScheme { - if a == nil { - return nil - } - return a.Basic -} - -func (a *AuthScheme) GetHeader() *HeaderAuthScheme { - if a == nil { - return nil - } - return a.Header -} - -func (a *AuthScheme) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"_type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - a.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant _type", a) - } - switch unmarshaler.Type { - case "bearer": - value := new(BearerAuthScheme) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - a.Bearer = value - case "basic": - value := new(BasicAuthScheme) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - a.Basic = value - case "header": - value := new(HeaderAuthScheme) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - a.Header = value - } - return nil -} - -func (a AuthScheme) MarshalJSON() ([]byte, error) { - switch a.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", a.Type, a) - case "bearer": - return core.MarshalJSONWithExtraProperty(a.Bearer, "_type", "bearer") - case "basic": - return core.MarshalJSONWithExtraProperty(a.Basic, "_type", "basic") - case "header": - return core.MarshalJSONWithExtraProperty(a.Header, "_type", "header") - } -} - -type AuthSchemeVisitor interface { - VisitBearer(*BearerAuthScheme) error - VisitBasic(*BasicAuthScheme) error - VisitHeader(*HeaderAuthScheme) error -} - -func (a *AuthScheme) Accept(visitor AuthSchemeVisitor) error { - switch a.Type { - default: - return fmt.Errorf("invalid type %s in %T", a.Type, a) - case "bearer": - return visitor.VisitBearer(a.Bearer) - case "basic": - return visitor.VisitBasic(a.Basic) - case "header": - return visitor.VisitHeader(a.Header) - } -} - -type AuthSchemesRequirement string - -const ( - AuthSchemesRequirementAll AuthSchemesRequirement = "ALL" - AuthSchemesRequirementAny AuthSchemesRequirement = "ANY" -) - -func NewAuthSchemesRequirementFromString(s string) (AuthSchemesRequirement, error) { - switch s { - case "ALL": - return AuthSchemesRequirementAll, nil - case "ANY": - return AuthSchemesRequirementAny, nil - } - var t AuthSchemesRequirement - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (a AuthSchemesRequirement) Ptr() *AuthSchemesRequirement { - return &a -} - -type BasicAuthScheme struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Username *Name `json:"username,omitempty" url:"username,omitempty"` - Password *Name `json:"password,omitempty" url:"password,omitempty"` - - extraProperties map[string]interface{} -} - -func (b *BasicAuthScheme) GetDocs() *string { - if b == nil { - return nil - } - return b.Docs -} - -func (b *BasicAuthScheme) GetUsername() *Name { - if b == nil { - return nil - } - return b.Username -} - -func (b *BasicAuthScheme) GetPassword() *Name { - if b == nil { - return nil - } - return b.Password -} - -func (b *BasicAuthScheme) GetExtraProperties() map[string]interface{} { - return b.extraProperties -} - -func (b *BasicAuthScheme) UnmarshalJSON(data []byte) error { - type unmarshaler BasicAuthScheme - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *b = BasicAuthScheme(value) - - extraProperties, err := core.ExtractExtraProperties(data, *b) - if err != nil { - return err - } - b.extraProperties = extraProperties - - return nil -} - -func (b *BasicAuthScheme) String() string { - if value, err := core.StringifyJSON(b); err == nil { - return value - } - return fmt.Sprintf("%#v", b) -} - -type BearerAuthScheme struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Token *Name `json:"token,omitempty" url:"token,omitempty"` - - extraProperties map[string]interface{} -} - -func (b *BearerAuthScheme) GetDocs() *string { - if b == nil { - return nil - } - return b.Docs -} - -func (b *BearerAuthScheme) GetToken() *Name { - if b == nil { - return nil - } - return b.Token -} - -func (b *BearerAuthScheme) GetExtraProperties() map[string]interface{} { - return b.extraProperties -} - -func (b *BearerAuthScheme) UnmarshalJSON(data []byte) error { - type unmarshaler BearerAuthScheme - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *b = BearerAuthScheme(value) - - extraProperties, err := core.ExtractExtraProperties(data, *b) - if err != nil { - return err - } - b.extraProperties = extraProperties - - return nil -} - -func (b *BearerAuthScheme) String() string { - if value, err := core.StringifyJSON(b); err == nil { - return value - } - return fmt.Sprintf("%#v", b) -} - -type HeaderAuthScheme struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Name *NameAndWireValue `json:"name,omitempty" url:"name,omitempty"` - ValueType *TypeReference `json:"valueType,omitempty" url:"valueType,omitempty"` - Prefix *string `json:"prefix,omitempty" url:"prefix,omitempty"` - - extraProperties map[string]interface{} -} - -func (h *HeaderAuthScheme) GetDocs() *string { - if h == nil { - return nil - } - return h.Docs -} - -func (h *HeaderAuthScheme) GetName() *NameAndWireValue { - if h == nil { - return nil - } - return h.Name -} - -func (h *HeaderAuthScheme) GetValueType() *TypeReference { - if h == nil { - return nil - } - return h.ValueType -} - -func (h *HeaderAuthScheme) GetPrefix() *string { - if h == nil { - return nil - } - return h.Prefix -} - -func (h *HeaderAuthScheme) GetExtraProperties() map[string]interface{} { - return h.extraProperties -} - -func (h *HeaderAuthScheme) UnmarshalJSON(data []byte) error { - type unmarshaler HeaderAuthScheme - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *h = HeaderAuthScheme(value) - - extraProperties, err := core.ExtractExtraProperties(data, *h) - if err != nil { - return err - } - h.extraProperties = extraProperties - - return nil -} - -func (h *HeaderAuthScheme) String() string { - if value, err := core.StringifyJSON(h); err == nil { - return value - } - return fmt.Sprintf("%#v", h) -} - -type Availability struct { - Status AvailabilityStatus `json:"status" url:"status"` - Message *string `json:"message,omitempty" url:"message,omitempty"` - - extraProperties map[string]interface{} -} - -func (a *Availability) GetStatus() AvailabilityStatus { - if a == nil { - return "" - } - return a.Status -} - -func (a *Availability) GetMessage() *string { - if a == nil { - return nil - } - return a.Message -} - -func (a *Availability) GetExtraProperties() map[string]interface{} { - return a.extraProperties -} - -func (a *Availability) UnmarshalJSON(data []byte) error { - type unmarshaler Availability - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *a = Availability(value) - - extraProperties, err := core.ExtractExtraProperties(data, *a) - if err != nil { - return err - } - a.extraProperties = extraProperties - - return nil -} - -func (a *Availability) String() string { - if value, err := core.StringifyJSON(a); err == nil { - return value - } - return fmt.Sprintf("%#v", a) -} - -type AvailabilityStatus string - -const ( - AvailabilityStatusInDevelopment AvailabilityStatus = "IN_DEVELOPMENT" - AvailabilityStatusPreRelease AvailabilityStatus = "PRE_RELEASE" - AvailabilityStatusGeneralAvailability AvailabilityStatus = "GENERAL_AVAILABILITY" - AvailabilityStatusDeprecated AvailabilityStatus = "DEPRECATED" -) - -func NewAvailabilityStatusFromString(s string) (AvailabilityStatus, error) { - switch s { - case "IN_DEVELOPMENT": - return AvailabilityStatusInDevelopment, nil - case "PRE_RELEASE": - return AvailabilityStatusPreRelease, nil - case "GENERAL_AVAILABILITY": - return AvailabilityStatusGeneralAvailability, nil - case "DEPRECATED": - return AvailabilityStatusDeprecated, nil - } - var t AvailabilityStatus - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (a AvailabilityStatus) Ptr() *AvailabilityStatus { - return &a -} - -type Declaration struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Availability *Availability `json:"availability,omitempty" url:"availability,omitempty"` - - extraProperties map[string]interface{} -} - -func (d *Declaration) GetDocs() *string { - if d == nil { - return nil - } - return d.Docs -} - -func (d *Declaration) GetAvailability() *Availability { - if d == nil { - return nil - } - return d.Availability -} - -func (d *Declaration) GetExtraProperties() map[string]interface{} { - return d.extraProperties -} - -func (d *Declaration) UnmarshalJSON(data []byte) error { - type unmarshaler Declaration - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *d = Declaration(value) - - extraProperties, err := core.ExtractExtraProperties(data, *d) - if err != nil { - return err - } - d.extraProperties = extraProperties - - return nil -} - -func (d *Declaration) String() string { - if value, err := core.StringifyJSON(d); err == nil { - return value - } - return fmt.Sprintf("%#v", d) -} - -type ErrorId = string - -type FernFilepath struct { - AllParts []*Name `json:"allParts,omitempty" url:"allParts,omitempty"` - PackagePath []*Name `json:"packagePath,omitempty" url:"packagePath,omitempty"` - File *Name `json:"file,omitempty" url:"file,omitempty"` - - extraProperties map[string]interface{} -} - -func (f *FernFilepath) GetAllParts() []*Name { - if f == nil { - return nil - } - return f.AllParts -} - -func (f *FernFilepath) GetPackagePath() []*Name { - if f == nil { - return nil - } - return f.PackagePath -} - -func (f *FernFilepath) GetFile() *Name { - if f == nil { - return nil - } - return f.File -} - -func (f *FernFilepath) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *FernFilepath) UnmarshalJSON(data []byte) error { - type unmarshaler FernFilepath - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = FernFilepath(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - return nil -} - -func (f *FernFilepath) String() string { - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} - -type Name struct { - OriginalName string `json:"originalName" url:"originalName"` - CamelCase *SafeAndUnsafeString `json:"camelCase,omitempty" url:"camelCase,omitempty"` - PascalCase *SafeAndUnsafeString `json:"pascalCase,omitempty" url:"pascalCase,omitempty"` - SnakeCase *SafeAndUnsafeString `json:"snakeCase,omitempty" url:"snakeCase,omitempty"` - ScreamingSnakeCase *SafeAndUnsafeString `json:"screamingSnakeCase,omitempty" url:"screamingSnakeCase,omitempty"` - - extraProperties map[string]interface{} -} - -func (n *Name) GetOriginalName() string { - if n == nil { - return "" - } - return n.OriginalName -} - -func (n *Name) GetCamelCase() *SafeAndUnsafeString { - if n == nil { - return nil - } - return n.CamelCase -} - -func (n *Name) GetPascalCase() *SafeAndUnsafeString { - if n == nil { - return nil - } - return n.PascalCase -} - -func (n *Name) GetSnakeCase() *SafeAndUnsafeString { - if n == nil { - return nil - } - return n.SnakeCase -} - -func (n *Name) GetScreamingSnakeCase() *SafeAndUnsafeString { - if n == nil { - return nil - } - return n.ScreamingSnakeCase -} - -func (n *Name) GetExtraProperties() map[string]interface{} { - return n.extraProperties -} - -func (n *Name) UnmarshalJSON(data []byte) error { - type unmarshaler Name - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *n = Name(value) - - extraProperties, err := core.ExtractExtraProperties(data, *n) - if err != nil { - return err - } - n.extraProperties = extraProperties - - return nil -} - -func (n *Name) String() string { - if value, err := core.StringifyJSON(n); err == nil { - return value - } - return fmt.Sprintf("%#v", n) -} - -type NameAndWireValue struct { - WireValue string `json:"wireValue" url:"wireValue"` - Name *Name `json:"name,omitempty" url:"name,omitempty"` - - extraProperties map[string]interface{} -} - -func (n *NameAndWireValue) GetWireValue() string { - if n == nil { - return "" - } - return n.WireValue -} - -func (n *NameAndWireValue) GetName() *Name { - if n == nil { - return nil - } - return n.Name -} - -func (n *NameAndWireValue) GetExtraProperties() map[string]interface{} { - return n.extraProperties -} - -func (n *NameAndWireValue) UnmarshalJSON(data []byte) error { - type unmarshaler NameAndWireValue - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *n = NameAndWireValue(value) - - extraProperties, err := core.ExtractExtraProperties(data, *n) - if err != nil { - return err - } - n.extraProperties = extraProperties - - return nil -} - -func (n *NameAndWireValue) String() string { - if value, err := core.StringifyJSON(n); err == nil { - return value - } - return fmt.Sprintf("%#v", n) -} - -type SafeAndUnsafeString struct { - // this name might overlap with reserved keywords of the language being generated - UnsafeName string `json:"unsafeName" url:"unsafeName"` - // this name will NOT overlap with reserved keywords of the language being generated - SafeName string `json:"safeName" url:"safeName"` - - extraProperties map[string]interface{} -} - -func (s *SafeAndUnsafeString) GetUnsafeName() string { - if s == nil { - return "" - } - return s.UnsafeName -} - -func (s *SafeAndUnsafeString) GetSafeName() string { - if s == nil { - return "" - } - return s.SafeName -} - -func (s *SafeAndUnsafeString) GetExtraProperties() map[string]interface{} { - return s.extraProperties -} - -func (s *SafeAndUnsafeString) UnmarshalJSON(data []byte) error { - type unmarshaler SafeAndUnsafeString - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = SafeAndUnsafeString(value) - - extraProperties, err := core.ExtractExtraProperties(data, *s) - if err != nil { - return err - } - s.extraProperties = extraProperties - - return nil -} - -func (s *SafeAndUnsafeString) String() string { - if value, err := core.StringifyJSON(s); err == nil { - return value - } - return fmt.Sprintf("%#v", s) -} - -type ServiceId = string - -type SubpackageId = string - -type TypeId = string - -type WithDocs struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - - extraProperties map[string]interface{} -} - -func (w *WithDocs) GetDocs() *string { - if w == nil { - return nil - } - return w.Docs -} - -func (w *WithDocs) GetExtraProperties() map[string]interface{} { - return w.extraProperties -} - -func (w *WithDocs) UnmarshalJSON(data []byte) error { - type unmarshaler WithDocs - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *w = WithDocs(value) - - extraProperties, err := core.ExtractExtraProperties(data, *w) - if err != nil { - return err - } - w.extraProperties = extraProperties - - return nil -} - -func (w *WithDocs) String() string { - if value, err := core.StringifyJSON(w); err == nil { - return value - } - return fmt.Sprintf("%#v", w) -} - -type WithJsonExample struct { - JsonExample interface{} `json:"jsonExample,omitempty" url:"jsonExample,omitempty"` - - extraProperties map[string]interface{} -} - -func (w *WithJsonExample) GetJsonExample() interface{} { - if w == nil { - return nil - } - return w.JsonExample -} - -func (w *WithJsonExample) GetExtraProperties() map[string]interface{} { - return w.extraProperties -} - -func (w *WithJsonExample) UnmarshalJSON(data []byte) error { - type unmarshaler WithJsonExample - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *w = WithJsonExample(value) - - extraProperties, err := core.ExtractExtraProperties(data, *w) - if err != nil { - return err - } - w.extraProperties = extraProperties - - return nil -} - -func (w *WithJsonExample) String() string { - if value, err := core.StringifyJSON(w); err == nil { - return value - } - return fmt.Sprintf("%#v", w) -} - -type Constants struct { - ErrorInstanceIdKey *NameAndWireValue `json:"errorInstanceIdKey,omitempty" url:"errorInstanceIdKey,omitempty"` - - extraProperties map[string]interface{} -} - -func (c *Constants) GetErrorInstanceIdKey() *NameAndWireValue { - if c == nil { - return nil - } - return c.ErrorInstanceIdKey -} - -func (c *Constants) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *Constants) UnmarshalJSON(data []byte) error { - type unmarshaler Constants - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = Constants(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - return nil -} - -func (c *Constants) String() string { - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type EnvironmentBaseUrlId = string - -type EnvironmentBaseUrlWithId struct { - Id EnvironmentBaseUrlId `json:"id" url:"id"` - Name *Name `json:"name,omitempty" url:"name,omitempty"` - - extraProperties map[string]interface{} -} - -func (e *EnvironmentBaseUrlWithId) GetId() EnvironmentBaseUrlId { - if e == nil { - return "" - } - return e.Id -} - -func (e *EnvironmentBaseUrlWithId) GetName() *Name { - if e == nil { - return nil - } - return e.Name -} - -func (e *EnvironmentBaseUrlWithId) GetExtraProperties() map[string]interface{} { - return e.extraProperties -} - -func (e *EnvironmentBaseUrlWithId) UnmarshalJSON(data []byte) error { - type unmarshaler EnvironmentBaseUrlWithId - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *e = EnvironmentBaseUrlWithId(value) - - extraProperties, err := core.ExtractExtraProperties(data, *e) - if err != nil { - return err - } - e.extraProperties = extraProperties - - return nil -} - -func (e *EnvironmentBaseUrlWithId) String() string { - if value, err := core.StringifyJSON(e); err == nil { - return value - } - return fmt.Sprintf("%#v", e) -} - -type EnvironmentId = string - -type EnvironmentUrl = string - -type Environments struct { - Type string - SingleBaseUrl *SingleBaseUrlEnvironments - MultipleBaseUrls *MultipleBaseUrlsEnvironments -} - -func NewEnvironmentsFromSingleBaseUrl(value *SingleBaseUrlEnvironments) *Environments { - return &Environments{Type: "singleBaseUrl", SingleBaseUrl: value} -} - -func NewEnvironmentsFromMultipleBaseUrls(value *MultipleBaseUrlsEnvironments) *Environments { - return &Environments{Type: "multipleBaseUrls", MultipleBaseUrls: value} -} - -func (e *Environments) GetType() string { - if e == nil { - return "" - } - return e.Type -} - -func (e *Environments) GetSingleBaseUrl() *SingleBaseUrlEnvironments { - if e == nil { - return nil - } - return e.SingleBaseUrl -} - -func (e *Environments) GetMultipleBaseUrls() *MultipleBaseUrlsEnvironments { - if e == nil { - return nil - } - return e.MultipleBaseUrls -} - -func (e *Environments) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - e.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", e) - } - switch unmarshaler.Type { - case "singleBaseUrl": - value := new(SingleBaseUrlEnvironments) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - e.SingleBaseUrl = value - case "multipleBaseUrls": - value := new(MultipleBaseUrlsEnvironments) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - e.MultipleBaseUrls = value - } - return nil -} - -func (e Environments) MarshalJSON() ([]byte, error) { - switch e.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", e.Type, e) - case "singleBaseUrl": - return core.MarshalJSONWithExtraProperty(e.SingleBaseUrl, "type", "singleBaseUrl") - case "multipleBaseUrls": - return core.MarshalJSONWithExtraProperty(e.MultipleBaseUrls, "type", "multipleBaseUrls") - } -} - -type EnvironmentsVisitor interface { - VisitSingleBaseUrl(*SingleBaseUrlEnvironments) error - VisitMultipleBaseUrls(*MultipleBaseUrlsEnvironments) error -} - -func (e *Environments) Accept(visitor EnvironmentsVisitor) error { - switch e.Type { - default: - return fmt.Errorf("invalid type %s in %T", e.Type, e) - case "singleBaseUrl": - return visitor.VisitSingleBaseUrl(e.SingleBaseUrl) - case "multipleBaseUrls": - return visitor.VisitMultipleBaseUrls(e.MultipleBaseUrls) - } -} - -type EnvironmentsConfig struct { - DefaultEnvironment *EnvironmentId `json:"defaultEnvironment,omitempty" url:"defaultEnvironment,omitempty"` - Environments *Environments `json:"environments,omitempty" url:"environments,omitempty"` - - extraProperties map[string]interface{} -} - -func (e *EnvironmentsConfig) GetDefaultEnvironment() *EnvironmentId { - if e == nil { - return nil - } - return e.DefaultEnvironment -} - -func (e *EnvironmentsConfig) GetEnvironments() *Environments { - if e == nil { - return nil - } - return e.Environments -} - -func (e *EnvironmentsConfig) GetExtraProperties() map[string]interface{} { - return e.extraProperties -} - -func (e *EnvironmentsConfig) UnmarshalJSON(data []byte) error { - type unmarshaler EnvironmentsConfig - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *e = EnvironmentsConfig(value) - - extraProperties, err := core.ExtractExtraProperties(data, *e) - if err != nil { - return err - } - e.extraProperties = extraProperties - - return nil -} - -func (e *EnvironmentsConfig) String() string { - if value, err := core.StringifyJSON(e); err == nil { - return value - } - return fmt.Sprintf("%#v", e) -} - -type MultipleBaseUrlsEnvironment struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Id EnvironmentId `json:"id" url:"id"` - Name *Name `json:"name,omitempty" url:"name,omitempty"` - Urls map[EnvironmentBaseUrlId]EnvironmentUrl `json:"urls,omitempty" url:"urls,omitempty"` - - extraProperties map[string]interface{} -} - -func (m *MultipleBaseUrlsEnvironment) GetDocs() *string { - if m == nil { - return nil - } - return m.Docs -} - -func (m *MultipleBaseUrlsEnvironment) GetId() EnvironmentId { - if m == nil { - return "" - } - return m.Id -} - -func (m *MultipleBaseUrlsEnvironment) GetName() *Name { - if m == nil { - return nil - } - return m.Name -} - -func (m *MultipleBaseUrlsEnvironment) GetUrls() map[EnvironmentBaseUrlId]EnvironmentUrl { - if m == nil { - return nil - } - return m.Urls -} - -func (m *MultipleBaseUrlsEnvironment) GetExtraProperties() map[string]interface{} { - return m.extraProperties -} - -func (m *MultipleBaseUrlsEnvironment) UnmarshalJSON(data []byte) error { - type unmarshaler MultipleBaseUrlsEnvironment - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *m = MultipleBaseUrlsEnvironment(value) - - extraProperties, err := core.ExtractExtraProperties(data, *m) - if err != nil { - return err - } - m.extraProperties = extraProperties - - return nil -} - -func (m *MultipleBaseUrlsEnvironment) String() string { - if value, err := core.StringifyJSON(m); err == nil { - return value - } - return fmt.Sprintf("%#v", m) -} - -type MultipleBaseUrlsEnvironments struct { - BaseUrls []*EnvironmentBaseUrlWithId `json:"baseUrls,omitempty" url:"baseUrls,omitempty"` - Environments []*MultipleBaseUrlsEnvironment `json:"environments,omitempty" url:"environments,omitempty"` - - extraProperties map[string]interface{} -} - -func (m *MultipleBaseUrlsEnvironments) GetBaseUrls() []*EnvironmentBaseUrlWithId { - if m == nil { - return nil - } - return m.BaseUrls -} - -func (m *MultipleBaseUrlsEnvironments) GetEnvironments() []*MultipleBaseUrlsEnvironment { - if m == nil { - return nil - } - return m.Environments -} - -func (m *MultipleBaseUrlsEnvironments) GetExtraProperties() map[string]interface{} { - return m.extraProperties -} - -func (m *MultipleBaseUrlsEnvironments) UnmarshalJSON(data []byte) error { - type unmarshaler MultipleBaseUrlsEnvironments - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *m = MultipleBaseUrlsEnvironments(value) - - extraProperties, err := core.ExtractExtraProperties(data, *m) - if err != nil { - return err - } - m.extraProperties = extraProperties - - return nil -} - -func (m *MultipleBaseUrlsEnvironments) String() string { - if value, err := core.StringifyJSON(m); err == nil { - return value - } - return fmt.Sprintf("%#v", m) -} - -type SingleBaseUrlEnvironment struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Id EnvironmentId `json:"id" url:"id"` - Name *Name `json:"name,omitempty" url:"name,omitempty"` - Url EnvironmentUrl `json:"url" url:"url"` - - extraProperties map[string]interface{} -} - -func (s *SingleBaseUrlEnvironment) GetDocs() *string { - if s == nil { - return nil - } - return s.Docs -} - -func (s *SingleBaseUrlEnvironment) GetId() EnvironmentId { - if s == nil { - return "" - } - return s.Id -} - -func (s *SingleBaseUrlEnvironment) GetName() *Name { - if s == nil { - return nil - } - return s.Name -} - -func (s *SingleBaseUrlEnvironment) GetUrl() EnvironmentUrl { - if s == nil { - return "" - } - return s.Url -} - -func (s *SingleBaseUrlEnvironment) GetExtraProperties() map[string]interface{} { - return s.extraProperties -} - -func (s *SingleBaseUrlEnvironment) UnmarshalJSON(data []byte) error { - type unmarshaler SingleBaseUrlEnvironment - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = SingleBaseUrlEnvironment(value) - - extraProperties, err := core.ExtractExtraProperties(data, *s) - if err != nil { - return err - } - s.extraProperties = extraProperties - - return nil -} - -func (s *SingleBaseUrlEnvironment) String() string { - if value, err := core.StringifyJSON(s); err == nil { - return value - } - return fmt.Sprintf("%#v", s) -} - -type SingleBaseUrlEnvironments struct { - Environments []*SingleBaseUrlEnvironment `json:"environments,omitempty" url:"environments,omitempty"` - - extraProperties map[string]interface{} -} - -func (s *SingleBaseUrlEnvironments) GetEnvironments() []*SingleBaseUrlEnvironment { - if s == nil { - return nil - } - return s.Environments -} - -func (s *SingleBaseUrlEnvironments) GetExtraProperties() map[string]interface{} { - return s.extraProperties -} - -func (s *SingleBaseUrlEnvironments) UnmarshalJSON(data []byte) error { - type unmarshaler SingleBaseUrlEnvironments - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = SingleBaseUrlEnvironments(value) - - extraProperties, err := core.ExtractExtraProperties(data, *s) - if err != nil { - return err - } - s.extraProperties = extraProperties - - return nil -} - -func (s *SingleBaseUrlEnvironments) String() string { - if value, err := core.StringifyJSON(s); err == nil { - return value - } - return fmt.Sprintf("%#v", s) -} - -type DeclaredErrorName struct { - ErrorId ErrorId `json:"errorId" url:"errorId"` - FernFilepath *FernFilepath `json:"fernFilepath,omitempty" url:"fernFilepath,omitempty"` - Name *Name `json:"name,omitempty" url:"name,omitempty"` - - extraProperties map[string]interface{} -} - -func (d *DeclaredErrorName) GetErrorId() ErrorId { - if d == nil { - return "" - } - return d.ErrorId -} - -func (d *DeclaredErrorName) GetFernFilepath() *FernFilepath { - if d == nil { - return nil - } - return d.FernFilepath -} - -func (d *DeclaredErrorName) GetName() *Name { - if d == nil { - return nil - } - return d.Name -} - -func (d *DeclaredErrorName) GetExtraProperties() map[string]interface{} { - return d.extraProperties -} - -func (d *DeclaredErrorName) UnmarshalJSON(data []byte) error { - type unmarshaler DeclaredErrorName - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *d = DeclaredErrorName(value) - - extraProperties, err := core.ExtractExtraProperties(data, *d) - if err != nil { - return err - } - d.extraProperties = extraProperties - - return nil -} - -func (d *DeclaredErrorName) String() string { - if value, err := core.StringifyJSON(d); err == nil { - return value - } - return fmt.Sprintf("%#v", d) -} - -type ErrorDeclaration struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Name *DeclaredErrorName `json:"name,omitempty" url:"name,omitempty"` - DiscriminantValue *NameAndWireValue `json:"discriminantValue,omitempty" url:"discriminantValue,omitempty"` - Type *TypeReference `json:"type,omitempty" url:"type,omitempty"` - StatusCode int `json:"statusCode" url:"statusCode"` - - extraProperties map[string]interface{} -} - -func (e *ErrorDeclaration) GetDocs() *string { - if e == nil { - return nil - } - return e.Docs -} - -func (e *ErrorDeclaration) GetName() *DeclaredErrorName { - if e == nil { - return nil - } - return e.Name -} - -func (e *ErrorDeclaration) GetDiscriminantValue() *NameAndWireValue { - if e == nil { - return nil - } - return e.DiscriminantValue -} - -func (e *ErrorDeclaration) GetType() *TypeReference { - if e == nil { - return nil - } - return e.Type -} - -func (e *ErrorDeclaration) GetStatusCode() int { - if e == nil { - return 0 - } - return e.StatusCode -} - -func (e *ErrorDeclaration) GetExtraProperties() map[string]interface{} { - return e.extraProperties -} - -func (e *ErrorDeclaration) UnmarshalJSON(data []byte) error { - type unmarshaler ErrorDeclaration - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *e = ErrorDeclaration(value) - - extraProperties, err := core.ExtractExtraProperties(data, *e) - if err != nil { - return err - } - e.extraProperties = extraProperties - - return nil -} - -func (e *ErrorDeclaration) String() string { - if value, err := core.StringifyJSON(e); err == nil { - return value - } - return fmt.Sprintf("%#v", e) -} - -type ErrorDeclarationDiscriminantValue struct { - Type string - Property *NameAndWireValue - StatusCode interface{} -} - -func NewErrorDeclarationDiscriminantValueFromProperty(value *NameAndWireValue) *ErrorDeclarationDiscriminantValue { - return &ErrorDeclarationDiscriminantValue{Type: "property", Property: value} -} - -func NewErrorDeclarationDiscriminantValueFromStatusCode(value interface{}) *ErrorDeclarationDiscriminantValue { - return &ErrorDeclarationDiscriminantValue{Type: "statusCode", StatusCode: value} -} - -func (e *ErrorDeclarationDiscriminantValue) GetType() string { - if e == nil { - return "" - } - return e.Type -} - -func (e *ErrorDeclarationDiscriminantValue) GetProperty() *NameAndWireValue { - if e == nil { - return nil - } - return e.Property -} - -func (e *ErrorDeclarationDiscriminantValue) GetStatusCode() interface{} { - if e == nil { - return nil - } - return e.StatusCode -} - -func (e *ErrorDeclarationDiscriminantValue) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - e.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", e) - } - switch unmarshaler.Type { - case "property": - value := new(NameAndWireValue) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - e.Property = value - case "statusCode": - value := make(map[string]interface{}) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - e.StatusCode = value - } - return nil -} - -func (e ErrorDeclarationDiscriminantValue) MarshalJSON() ([]byte, error) { - switch e.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", e.Type, e) - case "property": - return core.MarshalJSONWithExtraProperty(e.Property, "type", "property") - case "statusCode": - var marshaler = struct { - Type string `json:"type"` - StatusCode interface{} `json:"statusCode,omitempty"` - }{ - Type: "statusCode", - StatusCode: e.StatusCode, - } - return json.Marshal(marshaler) - } -} - -type ErrorDeclarationDiscriminantValueVisitor interface { - VisitProperty(*NameAndWireValue) error - VisitStatusCode(interface{}) error -} - -func (e *ErrorDeclarationDiscriminantValue) Accept(visitor ErrorDeclarationDiscriminantValueVisitor) error { - switch e.Type { - default: - return fmt.Errorf("invalid type %s in %T", e.Type, e) - case "property": - return visitor.VisitProperty(e.Property) - case "statusCode": - return visitor.VisitStatusCode(e.StatusCode) - } -} - -type DeclaredServiceName struct { - FernFilepath *FernFilepath `json:"fernFilepath,omitempty" url:"fernFilepath,omitempty"` - - extraProperties map[string]interface{} -} - -func (d *DeclaredServiceName) GetFernFilepath() *FernFilepath { - if d == nil { - return nil - } - return d.FernFilepath -} - -func (d *DeclaredServiceName) GetExtraProperties() map[string]interface{} { - return d.extraProperties -} - -func (d *DeclaredServiceName) UnmarshalJSON(data []byte) error { - type unmarshaler DeclaredServiceName - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *d = DeclaredServiceName(value) - - extraProperties, err := core.ExtractExtraProperties(data, *d) - if err != nil { - return err - } - d.extraProperties = extraProperties - - return nil -} - -func (d *DeclaredServiceName) String() string { - if value, err := core.StringifyJSON(d); err == nil { - return value - } - return fmt.Sprintf("%#v", d) -} - -type EndpointName = *Name - -type ExampleEndpointCall struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Name *Name `json:"name,omitempty" url:"name,omitempty"` - Url string `json:"url" url:"url"` - RootPathParameters []*ExamplePathParameter `json:"rootPathParameters,omitempty" url:"rootPathParameters,omitempty"` - ServicePathParameters []*ExamplePathParameter `json:"servicePathParameters,omitempty" url:"servicePathParameters,omitempty"` - EndpointPathParameters []*ExamplePathParameter `json:"endpointPathParameters,omitempty" url:"endpointPathParameters,omitempty"` - ServiceHeaders []*ExampleHeader `json:"serviceHeaders,omitempty" url:"serviceHeaders,omitempty"` - EndpointHeaders []*ExampleHeader `json:"endpointHeaders,omitempty" url:"endpointHeaders,omitempty"` - QueryParameters []*ExampleQueryParameter `json:"queryParameters,omitempty" url:"queryParameters,omitempty"` - Request *ExampleRequestBody `json:"request,omitempty" url:"request,omitempty"` - Response *ExampleResponse `json:"response,omitempty" url:"response,omitempty"` - - extraProperties map[string]interface{} -} - -func (e *ExampleEndpointCall) GetDocs() *string { - if e == nil { - return nil - } - return e.Docs -} - -func (e *ExampleEndpointCall) GetName() *Name { - if e == nil { - return nil - } - return e.Name -} - -func (e *ExampleEndpointCall) GetUrl() string { - if e == nil { - return "" - } - return e.Url -} - -func (e *ExampleEndpointCall) GetRootPathParameters() []*ExamplePathParameter { - if e == nil { - return nil - } - return e.RootPathParameters -} - -func (e *ExampleEndpointCall) GetServicePathParameters() []*ExamplePathParameter { - if e == nil { - return nil - } - return e.ServicePathParameters -} - -func (e *ExampleEndpointCall) GetEndpointPathParameters() []*ExamplePathParameter { - if e == nil { - return nil - } - return e.EndpointPathParameters -} - -func (e *ExampleEndpointCall) GetServiceHeaders() []*ExampleHeader { - if e == nil { - return nil - } - return e.ServiceHeaders -} - -func (e *ExampleEndpointCall) GetEndpointHeaders() []*ExampleHeader { - if e == nil { - return nil - } - return e.EndpointHeaders -} - -func (e *ExampleEndpointCall) GetQueryParameters() []*ExampleQueryParameter { - if e == nil { - return nil - } - return e.QueryParameters -} - -func (e *ExampleEndpointCall) GetRequest() *ExampleRequestBody { - if e == nil { - return nil - } - return e.Request -} - -func (e *ExampleEndpointCall) GetResponse() *ExampleResponse { - if e == nil { - return nil - } - return e.Response -} - -func (e *ExampleEndpointCall) GetExtraProperties() map[string]interface{} { - return e.extraProperties -} - -func (e *ExampleEndpointCall) UnmarshalJSON(data []byte) error { - type unmarshaler ExampleEndpointCall - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *e = ExampleEndpointCall(value) - - extraProperties, err := core.ExtractExtraProperties(data, *e) - if err != nil { - return err - } - e.extraProperties = extraProperties - - return nil -} - -func (e *ExampleEndpointCall) String() string { - if value, err := core.StringifyJSON(e); err == nil { - return value - } - return fmt.Sprintf("%#v", e) -} - -type ExampleEndpointErrorResponse struct { - Error *DeclaredErrorName `json:"error,omitempty" url:"error,omitempty"` - Body *ExampleTypeReference `json:"body,omitempty" url:"body,omitempty"` - - extraProperties map[string]interface{} -} - -func (e *ExampleEndpointErrorResponse) GetError() *DeclaredErrorName { - if e == nil { - return nil - } - return e.Error -} - -func (e *ExampleEndpointErrorResponse) GetBody() *ExampleTypeReference { - if e == nil { - return nil - } - return e.Body -} - -func (e *ExampleEndpointErrorResponse) GetExtraProperties() map[string]interface{} { - return e.extraProperties -} - -func (e *ExampleEndpointErrorResponse) UnmarshalJSON(data []byte) error { - type unmarshaler ExampleEndpointErrorResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *e = ExampleEndpointErrorResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *e) - if err != nil { - return err - } - e.extraProperties = extraProperties - - return nil -} - -func (e *ExampleEndpointErrorResponse) String() string { - if value, err := core.StringifyJSON(e); err == nil { - return value - } - return fmt.Sprintf("%#v", e) -} - -type ExampleEndpointSuccessResponse struct { - Body *ExampleTypeReference `json:"body,omitempty" url:"body,omitempty"` - - extraProperties map[string]interface{} -} - -func (e *ExampleEndpointSuccessResponse) GetBody() *ExampleTypeReference { - if e == nil { - return nil - } - return e.Body -} - -func (e *ExampleEndpointSuccessResponse) GetExtraProperties() map[string]interface{} { - return e.extraProperties -} - -func (e *ExampleEndpointSuccessResponse) UnmarshalJSON(data []byte) error { - type unmarshaler ExampleEndpointSuccessResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *e = ExampleEndpointSuccessResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *e) - if err != nil { - return err - } - e.extraProperties = extraProperties - - return nil -} - -func (e *ExampleEndpointSuccessResponse) String() string { - if value, err := core.StringifyJSON(e); err == nil { - return value - } - return fmt.Sprintf("%#v", e) -} - -type ExampleHeader struct { - WireKey string `json:"wireKey" url:"wireKey"` - Value *ExampleTypeReference `json:"value,omitempty" url:"value,omitempty"` - - extraProperties map[string]interface{} -} - -func (e *ExampleHeader) GetWireKey() string { - if e == nil { - return "" - } - return e.WireKey -} - -func (e *ExampleHeader) GetValue() *ExampleTypeReference { - if e == nil { - return nil - } - return e.Value -} - -func (e *ExampleHeader) GetExtraProperties() map[string]interface{} { - return e.extraProperties -} - -func (e *ExampleHeader) UnmarshalJSON(data []byte) error { - type unmarshaler ExampleHeader - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *e = ExampleHeader(value) - - extraProperties, err := core.ExtractExtraProperties(data, *e) - if err != nil { - return err - } - e.extraProperties = extraProperties - - return nil -} - -func (e *ExampleHeader) String() string { - if value, err := core.StringifyJSON(e); err == nil { - return value - } - return fmt.Sprintf("%#v", e) -} - -type ExampleInlinedRequestBody struct { - JsonExample interface{} `json:"jsonExample,omitempty" url:"jsonExample,omitempty"` - Properties []*ExampleInlinedRequestBodyProperty `json:"properties,omitempty" url:"properties,omitempty"` - - extraProperties map[string]interface{} -} - -func (e *ExampleInlinedRequestBody) GetJsonExample() interface{} { - if e == nil { - return nil - } - return e.JsonExample -} - -func (e *ExampleInlinedRequestBody) GetProperties() []*ExampleInlinedRequestBodyProperty { - if e == nil { - return nil - } - return e.Properties -} - -func (e *ExampleInlinedRequestBody) GetExtraProperties() map[string]interface{} { - return e.extraProperties -} - -func (e *ExampleInlinedRequestBody) UnmarshalJSON(data []byte) error { - type unmarshaler ExampleInlinedRequestBody - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *e = ExampleInlinedRequestBody(value) - - extraProperties, err := core.ExtractExtraProperties(data, *e) - if err != nil { - return err - } - e.extraProperties = extraProperties - - return nil -} - -func (e *ExampleInlinedRequestBody) String() string { - if value, err := core.StringifyJSON(e); err == nil { - return value - } - return fmt.Sprintf("%#v", e) -} - -type ExampleInlinedRequestBodyProperty struct { - WireKey string `json:"wireKey" url:"wireKey"` - Value *ExampleTypeReference `json:"value,omitempty" url:"value,omitempty"` - // this property may have been brought in via extension. originalTypeDeclaration - // is the name of the type that contains this property - OriginalTypeDeclaration *DeclaredTypeName `json:"originalTypeDeclaration,omitempty" url:"originalTypeDeclaration,omitempty"` - - extraProperties map[string]interface{} -} - -func (e *ExampleInlinedRequestBodyProperty) GetWireKey() string { - if e == nil { - return "" - } - return e.WireKey -} - -func (e *ExampleInlinedRequestBodyProperty) GetValue() *ExampleTypeReference { - if e == nil { - return nil - } - return e.Value -} - -func (e *ExampleInlinedRequestBodyProperty) GetOriginalTypeDeclaration() *DeclaredTypeName { - if e == nil { - return nil - } - return e.OriginalTypeDeclaration -} - -func (e *ExampleInlinedRequestBodyProperty) GetExtraProperties() map[string]interface{} { - return e.extraProperties -} - -func (e *ExampleInlinedRequestBodyProperty) UnmarshalJSON(data []byte) error { - type unmarshaler ExampleInlinedRequestBodyProperty - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *e = ExampleInlinedRequestBodyProperty(value) - - extraProperties, err := core.ExtractExtraProperties(data, *e) - if err != nil { - return err - } - e.extraProperties = extraProperties - - return nil -} - -func (e *ExampleInlinedRequestBodyProperty) String() string { - if value, err := core.StringifyJSON(e); err == nil { - return value - } - return fmt.Sprintf("%#v", e) -} - -type ExamplePathParameter struct { - Key string `json:"key" url:"key"` - Value *ExampleTypeReference `json:"value,omitempty" url:"value,omitempty"` - - extraProperties map[string]interface{} -} - -func (e *ExamplePathParameter) GetKey() string { - if e == nil { - return "" - } - return e.Key -} - -func (e *ExamplePathParameter) GetValue() *ExampleTypeReference { - if e == nil { - return nil - } - return e.Value -} - -func (e *ExamplePathParameter) GetExtraProperties() map[string]interface{} { - return e.extraProperties -} - -func (e *ExamplePathParameter) UnmarshalJSON(data []byte) error { - type unmarshaler ExamplePathParameter - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *e = ExamplePathParameter(value) - - extraProperties, err := core.ExtractExtraProperties(data, *e) - if err != nil { - return err - } - e.extraProperties = extraProperties - - return nil -} - -func (e *ExamplePathParameter) String() string { - if value, err := core.StringifyJSON(e); err == nil { - return value - } - return fmt.Sprintf("%#v", e) -} - -type ExampleQueryParameter struct { - WireKey string `json:"wireKey" url:"wireKey"` - Value *ExampleTypeReference `json:"value,omitempty" url:"value,omitempty"` - - extraProperties map[string]interface{} -} - -func (e *ExampleQueryParameter) GetWireKey() string { - if e == nil { - return "" - } - return e.WireKey -} - -func (e *ExampleQueryParameter) GetValue() *ExampleTypeReference { - if e == nil { - return nil - } - return e.Value -} - -func (e *ExampleQueryParameter) GetExtraProperties() map[string]interface{} { - return e.extraProperties -} - -func (e *ExampleQueryParameter) UnmarshalJSON(data []byte) error { - type unmarshaler ExampleQueryParameter - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *e = ExampleQueryParameter(value) - - extraProperties, err := core.ExtractExtraProperties(data, *e) - if err != nil { - return err - } - e.extraProperties = extraProperties - - return nil -} - -func (e *ExampleQueryParameter) String() string { - if value, err := core.StringifyJSON(e); err == nil { - return value - } - return fmt.Sprintf("%#v", e) -} - -type ExampleRequestBody struct { - Type string - InlinedRequestBody *ExampleInlinedRequestBody - Reference *ExampleTypeReference -} - -func NewExampleRequestBodyFromInlinedRequestBody(value *ExampleInlinedRequestBody) *ExampleRequestBody { - return &ExampleRequestBody{Type: "inlinedRequestBody", InlinedRequestBody: value} -} - -func NewExampleRequestBodyFromReference(value *ExampleTypeReference) *ExampleRequestBody { - return &ExampleRequestBody{Type: "reference", Reference: value} -} - -func (e *ExampleRequestBody) GetType() string { - if e == nil { - return "" - } - return e.Type -} - -func (e *ExampleRequestBody) GetInlinedRequestBody() *ExampleInlinedRequestBody { - if e == nil { - return nil - } - return e.InlinedRequestBody -} - -func (e *ExampleRequestBody) GetReference() *ExampleTypeReference { - if e == nil { - return nil - } - return e.Reference -} - -func (e *ExampleRequestBody) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - e.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", e) - } - switch unmarshaler.Type { - case "inlinedRequestBody": - value := new(ExampleInlinedRequestBody) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - e.InlinedRequestBody = value - case "reference": - value := new(ExampleTypeReference) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - e.Reference = value - } - return nil -} - -func (e ExampleRequestBody) MarshalJSON() ([]byte, error) { - switch e.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", e.Type, e) - case "inlinedRequestBody": - return core.MarshalJSONWithExtraProperty(e.InlinedRequestBody, "type", "inlinedRequestBody") - case "reference": - return core.MarshalJSONWithExtraProperty(e.Reference, "type", "reference") - } -} - -type ExampleRequestBodyVisitor interface { - VisitInlinedRequestBody(*ExampleInlinedRequestBody) error - VisitReference(*ExampleTypeReference) error -} - -func (e *ExampleRequestBody) Accept(visitor ExampleRequestBodyVisitor) error { - switch e.Type { - default: - return fmt.Errorf("invalid type %s in %T", e.Type, e) - case "inlinedRequestBody": - return visitor.VisitInlinedRequestBody(e.InlinedRequestBody) - case "reference": - return visitor.VisitReference(e.Reference) - } -} - -type ExampleResponse struct { - Type string - Ok *ExampleEndpointSuccessResponse - Error *ExampleEndpointErrorResponse -} - -func NewExampleResponseFromOk(value *ExampleEndpointSuccessResponse) *ExampleResponse { - return &ExampleResponse{Type: "ok", Ok: value} -} - -func NewExampleResponseFromError(value *ExampleEndpointErrorResponse) *ExampleResponse { - return &ExampleResponse{Type: "error", Error: value} -} - -func (e *ExampleResponse) GetType() string { - if e == nil { - return "" - } - return e.Type -} - -func (e *ExampleResponse) GetOk() *ExampleEndpointSuccessResponse { - if e == nil { - return nil - } - return e.Ok -} - -func (e *ExampleResponse) GetError() *ExampleEndpointErrorResponse { - if e == nil { - return nil - } - return e.Error -} - -func (e *ExampleResponse) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - e.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", e) - } - switch unmarshaler.Type { - case "ok": - value := new(ExampleEndpointSuccessResponse) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - e.Ok = value - case "error": - value := new(ExampleEndpointErrorResponse) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - e.Error = value - } - return nil -} - -func (e ExampleResponse) MarshalJSON() ([]byte, error) { - switch e.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", e.Type, e) - case "ok": - return core.MarshalJSONWithExtraProperty(e.Ok, "type", "ok") - case "error": - return core.MarshalJSONWithExtraProperty(e.Error, "type", "error") - } -} - -type ExampleResponseVisitor interface { - VisitOk(*ExampleEndpointSuccessResponse) error - VisitError(*ExampleEndpointErrorResponse) error -} - -func (e *ExampleResponse) Accept(visitor ExampleResponseVisitor) error { - switch e.Type { - default: - return fmt.Errorf("invalid type %s in %T", e.Type, e) - case "ok": - return visitor.VisitOk(e.Ok) - case "error": - return visitor.VisitError(e.Error) - } -} - -type FileDownloadResponse struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - - extraProperties map[string]interface{} -} - -func (f *FileDownloadResponse) GetDocs() *string { - if f == nil { - return nil - } - return f.Docs -} - -func (f *FileDownloadResponse) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *FileDownloadResponse) UnmarshalJSON(data []byte) error { - type unmarshaler FileDownloadResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = FileDownloadResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - return nil -} - -func (f *FileDownloadResponse) String() string { - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} - -type FileProperty struct { - Key *NameAndWireValue `json:"key,omitempty" url:"key,omitempty"` - IsOptional bool `json:"isOptional" url:"isOptional"` - - extraProperties map[string]interface{} -} - -func (f *FileProperty) GetKey() *NameAndWireValue { - if f == nil { - return nil - } - return f.Key -} - -func (f *FileProperty) GetIsOptional() bool { - if f == nil { - return false - } - return f.IsOptional -} - -func (f *FileProperty) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *FileProperty) UnmarshalJSON(data []byte) error { - type unmarshaler FileProperty - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = FileProperty(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - return nil -} - -func (f *FileProperty) String() string { - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} - -type FileUploadRequest struct { - Name *Name `json:"name,omitempty" url:"name,omitempty"` - Properties []*FileUploadRequestProperty `json:"properties,omitempty" url:"properties,omitempty"` - - extraProperties map[string]interface{} -} - -func (f *FileUploadRequest) GetName() *Name { - if f == nil { - return nil - } - return f.Name -} - -func (f *FileUploadRequest) GetProperties() []*FileUploadRequestProperty { - if f == nil { - return nil - } - return f.Properties -} - -func (f *FileUploadRequest) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *FileUploadRequest) UnmarshalJSON(data []byte) error { - type unmarshaler FileUploadRequest - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = FileUploadRequest(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - return nil -} - -func (f *FileUploadRequest) String() string { - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} - -type FileUploadRequestProperty struct { - Type string - File *FileProperty - BodyProperty *InlinedRequestBodyProperty -} - -func NewFileUploadRequestPropertyFromFile(value *FileProperty) *FileUploadRequestProperty { - return &FileUploadRequestProperty{Type: "file", File: value} -} - -func NewFileUploadRequestPropertyFromBodyProperty(value *InlinedRequestBodyProperty) *FileUploadRequestProperty { - return &FileUploadRequestProperty{Type: "bodyProperty", BodyProperty: value} -} - -func (f *FileUploadRequestProperty) GetType() string { - if f == nil { - return "" - } - return f.Type -} - -func (f *FileUploadRequestProperty) GetFile() *FileProperty { - if f == nil { - return nil - } - return f.File -} - -func (f *FileUploadRequestProperty) GetBodyProperty() *InlinedRequestBodyProperty { - if f == nil { - return nil - } - return f.BodyProperty -} - -func (f *FileUploadRequestProperty) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - f.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", f) - } - switch unmarshaler.Type { - case "file": - value := new(FileProperty) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - f.File = value - case "bodyProperty": - value := new(InlinedRequestBodyProperty) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - f.BodyProperty = value - } - return nil -} - -func (f FileUploadRequestProperty) MarshalJSON() ([]byte, error) { - switch f.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", f.Type, f) - case "file": - return core.MarshalJSONWithExtraProperty(f.File, "type", "file") - case "bodyProperty": - return core.MarshalJSONWithExtraProperty(f.BodyProperty, "type", "bodyProperty") - } -} - -type FileUploadRequestPropertyVisitor interface { - VisitFile(*FileProperty) error - VisitBodyProperty(*InlinedRequestBodyProperty) error -} - -func (f *FileUploadRequestProperty) Accept(visitor FileUploadRequestPropertyVisitor) error { - switch f.Type { - default: - return fmt.Errorf("invalid type %s in %T", f.Type, f) - case "file": - return visitor.VisitFile(f.File) - case "bodyProperty": - return visitor.VisitBodyProperty(f.BodyProperty) - } -} - -type HttpEndpoint struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Availability *Availability `json:"availability,omitempty" url:"availability,omitempty"` - Name EndpointName `json:"name,omitempty" url:"name,omitempty"` - DisplayName *string `json:"displayName,omitempty" url:"displayName,omitempty"` - Method HttpMethod `json:"method" url:"method"` - Headers []*HttpHeader `json:"headers,omitempty" url:"headers,omitempty"` - BaseUrl *EnvironmentBaseUrlId `json:"baseUrl,omitempty" url:"baseUrl,omitempty"` - Path *HttpPath `json:"path,omitempty" url:"path,omitempty"` - FullPath *HttpPath `json:"fullPath,omitempty" url:"fullPath,omitempty"` - PathParameters []*PathParameter `json:"pathParameters,omitempty" url:"pathParameters,omitempty"` - AllPathParameters []*PathParameter `json:"allPathParameters,omitempty" url:"allPathParameters,omitempty"` - QueryParameters []*QueryParameter `json:"queryParameters,omitempty" url:"queryParameters,omitempty"` - RequestBody *HttpRequestBody `json:"requestBody,omitempty" url:"requestBody,omitempty"` - SdkRequest *SdkRequest `json:"sdkRequest,omitempty" url:"sdkRequest,omitempty"` - Response *HttpResponse `json:"response,omitempty" url:"response,omitempty"` - StreamingResponse *StreamingResponse `json:"streamingResponse,omitempty" url:"streamingResponse,omitempty"` - SdkResponse *SdkResponse `json:"sdkResponse,omitempty" url:"sdkResponse,omitempty"` - Errors ResponseErrors `json:"errors,omitempty" url:"errors,omitempty"` - Auth bool `json:"auth" url:"auth"` - Examples []*ExampleEndpointCall `json:"examples,omitempty" url:"examples,omitempty"` - - extraProperties map[string]interface{} -} - -func (h *HttpEndpoint) GetDocs() *string { - if h == nil { - return nil - } - return h.Docs -} - -func (h *HttpEndpoint) GetAvailability() *Availability { - if h == nil { - return nil - } - return h.Availability -} - -func (h *HttpEndpoint) GetName() EndpointName { - if h == nil { - return nil - } - return h.Name -} - -func (h *HttpEndpoint) GetDisplayName() *string { - if h == nil { - return nil - } - return h.DisplayName -} - -func (h *HttpEndpoint) GetMethod() HttpMethod { - if h == nil { - return "" - } - return h.Method -} - -func (h *HttpEndpoint) GetHeaders() []*HttpHeader { - if h == nil { - return nil - } - return h.Headers -} - -func (h *HttpEndpoint) GetBaseUrl() *EnvironmentBaseUrlId { - if h == nil { - return nil - } - return h.BaseUrl -} - -func (h *HttpEndpoint) GetPath() *HttpPath { - if h == nil { - return nil - } - return h.Path -} - -func (h *HttpEndpoint) GetFullPath() *HttpPath { - if h == nil { - return nil - } - return h.FullPath -} - -func (h *HttpEndpoint) GetPathParameters() []*PathParameter { - if h == nil { - return nil - } - return h.PathParameters -} - -func (h *HttpEndpoint) GetAllPathParameters() []*PathParameter { - if h == nil { - return nil - } - return h.AllPathParameters -} - -func (h *HttpEndpoint) GetQueryParameters() []*QueryParameter { - if h == nil { - return nil - } - return h.QueryParameters -} - -func (h *HttpEndpoint) GetRequestBody() *HttpRequestBody { - if h == nil { - return nil - } - return h.RequestBody -} - -func (h *HttpEndpoint) GetSdkRequest() *SdkRequest { - if h == nil { - return nil - } - return h.SdkRequest -} - -func (h *HttpEndpoint) GetResponse() *HttpResponse { - if h == nil { - return nil - } - return h.Response -} - -func (h *HttpEndpoint) GetStreamingResponse() *StreamingResponse { - if h == nil { - return nil - } - return h.StreamingResponse -} - -func (h *HttpEndpoint) GetSdkResponse() *SdkResponse { - if h == nil { - return nil - } - return h.SdkResponse -} - -func (h *HttpEndpoint) GetErrors() ResponseErrors { - if h == nil { - return nil - } - return h.Errors -} - -func (h *HttpEndpoint) GetAuth() bool { - if h == nil { - return false - } - return h.Auth -} - -func (h *HttpEndpoint) GetExamples() []*ExampleEndpointCall { - if h == nil { - return nil - } - return h.Examples -} - -func (h *HttpEndpoint) GetExtraProperties() map[string]interface{} { - return h.extraProperties -} - -func (h *HttpEndpoint) UnmarshalJSON(data []byte) error { - type unmarshaler HttpEndpoint - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *h = HttpEndpoint(value) - - extraProperties, err := core.ExtractExtraProperties(data, *h) - if err != nil { - return err - } - h.extraProperties = extraProperties - - return nil -} - -func (h *HttpEndpoint) String() string { - if value, err := core.StringifyJSON(h); err == nil { - return value - } - return fmt.Sprintf("%#v", h) -} - -type HttpHeader struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Availability *Availability `json:"availability,omitempty" url:"availability,omitempty"` - Name *NameAndWireValue `json:"name,omitempty" url:"name,omitempty"` - ValueType *TypeReference `json:"valueType,omitempty" url:"valueType,omitempty"` - - extraProperties map[string]interface{} -} - -func (h *HttpHeader) GetDocs() *string { - if h == nil { - return nil - } - return h.Docs -} - -func (h *HttpHeader) GetAvailability() *Availability { - if h == nil { - return nil - } - return h.Availability -} - -func (h *HttpHeader) GetName() *NameAndWireValue { - if h == nil { - return nil - } - return h.Name -} - -func (h *HttpHeader) GetValueType() *TypeReference { - if h == nil { - return nil - } - return h.ValueType -} - -func (h *HttpHeader) GetExtraProperties() map[string]interface{} { - return h.extraProperties -} - -func (h *HttpHeader) UnmarshalJSON(data []byte) error { - type unmarshaler HttpHeader - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *h = HttpHeader(value) - - extraProperties, err := core.ExtractExtraProperties(data, *h) - if err != nil { - return err - } - h.extraProperties = extraProperties - - return nil -} - -func (h *HttpHeader) String() string { - if value, err := core.StringifyJSON(h); err == nil { - return value - } - return fmt.Sprintf("%#v", h) -} - -type HttpMethod string - -const ( - HttpMethodGet HttpMethod = "GET" - HttpMethodPost HttpMethod = "POST" - HttpMethodPut HttpMethod = "PUT" - HttpMethodPatch HttpMethod = "PATCH" - HttpMethodDelete HttpMethod = "DELETE" -) - -func NewHttpMethodFromString(s string) (HttpMethod, error) { - switch s { - case "GET": - return HttpMethodGet, nil - case "POST": - return HttpMethodPost, nil - case "PUT": - return HttpMethodPut, nil - case "PATCH": - return HttpMethodPatch, nil - case "DELETE": - return HttpMethodDelete, nil - } - var t HttpMethod - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (h HttpMethod) Ptr() *HttpMethod { - return &h -} - -type HttpPath struct { - Head string `json:"head" url:"head"` - Parts []*HttpPathPart `json:"parts,omitempty" url:"parts,omitempty"` - - extraProperties map[string]interface{} -} - -func (h *HttpPath) GetHead() string { - if h == nil { - return "" - } - return h.Head -} - -func (h *HttpPath) GetParts() []*HttpPathPart { - if h == nil { - return nil - } - return h.Parts -} - -func (h *HttpPath) GetExtraProperties() map[string]interface{} { - return h.extraProperties -} - -func (h *HttpPath) UnmarshalJSON(data []byte) error { - type unmarshaler HttpPath - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *h = HttpPath(value) - - extraProperties, err := core.ExtractExtraProperties(data, *h) - if err != nil { - return err - } - h.extraProperties = extraProperties - - return nil -} - -func (h *HttpPath) String() string { - if value, err := core.StringifyJSON(h); err == nil { - return value - } - return fmt.Sprintf("%#v", h) -} - -type HttpPathPart struct { - PathParameter string `json:"pathParameter" url:"pathParameter"` - Tail string `json:"tail" url:"tail"` - - extraProperties map[string]interface{} -} - -func (h *HttpPathPart) GetPathParameter() string { - if h == nil { - return "" - } - return h.PathParameter -} - -func (h *HttpPathPart) GetTail() string { - if h == nil { - return "" - } - return h.Tail -} - -func (h *HttpPathPart) GetExtraProperties() map[string]interface{} { - return h.extraProperties -} - -func (h *HttpPathPart) UnmarshalJSON(data []byte) error { - type unmarshaler HttpPathPart - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *h = HttpPathPart(value) - - extraProperties, err := core.ExtractExtraProperties(data, *h) - if err != nil { - return err - } - h.extraProperties = extraProperties - - return nil -} - -func (h *HttpPathPart) String() string { - if value, err := core.StringifyJSON(h); err == nil { - return value - } - return fmt.Sprintf("%#v", h) -} - -type HttpRequestBody struct { - Type string - InlinedRequestBody *InlinedRequestBody - Reference *HttpRequestBodyReference - FileUpload *FileUploadRequest -} - -func NewHttpRequestBodyFromInlinedRequestBody(value *InlinedRequestBody) *HttpRequestBody { - return &HttpRequestBody{Type: "inlinedRequestBody", InlinedRequestBody: value} -} - -func NewHttpRequestBodyFromReference(value *HttpRequestBodyReference) *HttpRequestBody { - return &HttpRequestBody{Type: "reference", Reference: value} -} - -func NewHttpRequestBodyFromFileUpload(value *FileUploadRequest) *HttpRequestBody { - return &HttpRequestBody{Type: "fileUpload", FileUpload: value} -} - -func (h *HttpRequestBody) GetType() string { - if h == nil { - return "" - } - return h.Type -} - -func (h *HttpRequestBody) GetInlinedRequestBody() *InlinedRequestBody { - if h == nil { - return nil - } - return h.InlinedRequestBody -} - -func (h *HttpRequestBody) GetReference() *HttpRequestBodyReference { - if h == nil { - return nil - } - return h.Reference -} - -func (h *HttpRequestBody) GetFileUpload() *FileUploadRequest { - if h == nil { - return nil - } - return h.FileUpload -} - -func (h *HttpRequestBody) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - h.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", h) - } - switch unmarshaler.Type { - case "inlinedRequestBody": - value := new(InlinedRequestBody) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - h.InlinedRequestBody = value - case "reference": - value := new(HttpRequestBodyReference) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - h.Reference = value - case "fileUpload": - value := new(FileUploadRequest) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - h.FileUpload = value - } - return nil -} - -func (h HttpRequestBody) MarshalJSON() ([]byte, error) { - switch h.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", h.Type, h) - case "inlinedRequestBody": - return core.MarshalJSONWithExtraProperty(h.InlinedRequestBody, "type", "inlinedRequestBody") - case "reference": - return core.MarshalJSONWithExtraProperty(h.Reference, "type", "reference") - case "fileUpload": - return core.MarshalJSONWithExtraProperty(h.FileUpload, "type", "fileUpload") - } -} - -type HttpRequestBodyVisitor interface { - VisitInlinedRequestBody(*InlinedRequestBody) error - VisitReference(*HttpRequestBodyReference) error - VisitFileUpload(*FileUploadRequest) error -} - -func (h *HttpRequestBody) Accept(visitor HttpRequestBodyVisitor) error { - switch h.Type { - default: - return fmt.Errorf("invalid type %s in %T", h.Type, h) - case "inlinedRequestBody": - return visitor.VisitInlinedRequestBody(h.InlinedRequestBody) - case "reference": - return visitor.VisitReference(h.Reference) - case "fileUpload": - return visitor.VisitFileUpload(h.FileUpload) - } -} - -type HttpRequestBodyReference struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - RequestBodyType *TypeReference `json:"requestBodyType,omitempty" url:"requestBodyType,omitempty"` - - extraProperties map[string]interface{} -} - -func (h *HttpRequestBodyReference) GetDocs() *string { - if h == nil { - return nil - } - return h.Docs -} - -func (h *HttpRequestBodyReference) GetRequestBodyType() *TypeReference { - if h == nil { - return nil - } - return h.RequestBodyType -} - -func (h *HttpRequestBodyReference) GetExtraProperties() map[string]interface{} { - return h.extraProperties -} - -func (h *HttpRequestBodyReference) UnmarshalJSON(data []byte) error { - type unmarshaler HttpRequestBodyReference - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *h = HttpRequestBodyReference(value) - - extraProperties, err := core.ExtractExtraProperties(data, *h) - if err != nil { - return err - } - h.extraProperties = extraProperties - - return nil -} - -func (h *HttpRequestBodyReference) String() string { - if value, err := core.StringifyJSON(h); err == nil { - return value - } - return fmt.Sprintf("%#v", h) -} - -type HttpResponse struct { - Type string - Json *JsonResponse - FileDownload *FileDownloadResponse -} - -func NewHttpResponseFromJson(value *JsonResponse) *HttpResponse { - return &HttpResponse{Type: "json", Json: value} -} - -func NewHttpResponseFromFileDownload(value *FileDownloadResponse) *HttpResponse { - return &HttpResponse{Type: "fileDownload", FileDownload: value} -} - -func (h *HttpResponse) GetType() string { - if h == nil { - return "" - } - return h.Type -} - -func (h *HttpResponse) GetJson() *JsonResponse { - if h == nil { - return nil - } - return h.Json -} - -func (h *HttpResponse) GetFileDownload() *FileDownloadResponse { - if h == nil { - return nil - } - return h.FileDownload -} - -func (h *HttpResponse) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - h.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", h) - } - switch unmarshaler.Type { - case "json": - value := new(JsonResponse) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - h.Json = value - case "fileDownload": - value := new(FileDownloadResponse) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - h.FileDownload = value - } - return nil -} - -func (h HttpResponse) MarshalJSON() ([]byte, error) { - switch h.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", h.Type, h) - case "json": - return core.MarshalJSONWithExtraProperty(h.Json, "type", "json") - case "fileDownload": - return core.MarshalJSONWithExtraProperty(h.FileDownload, "type", "fileDownload") - } -} - -type HttpResponseVisitor interface { - VisitJson(*JsonResponse) error - VisitFileDownload(*FileDownloadResponse) error -} - -func (h *HttpResponse) Accept(visitor HttpResponseVisitor) error { - switch h.Type { - default: - return fmt.Errorf("invalid type %s in %T", h.Type, h) - case "json": - return visitor.VisitJson(h.Json) - case "fileDownload": - return visitor.VisitFileDownload(h.FileDownload) - } -} - -type HttpService struct { - Availability *Availability `json:"availability,omitempty" url:"availability,omitempty"` - Name *DeclaredServiceName `json:"name,omitempty" url:"name,omitempty"` - DisplayName *string `json:"displayName,omitempty" url:"displayName,omitempty"` - BasePath *HttpPath `json:"basePath,omitempty" url:"basePath,omitempty"` - Endpoints []*HttpEndpoint `json:"endpoints,omitempty" url:"endpoints,omitempty"` - Headers []*HttpHeader `json:"headers,omitempty" url:"headers,omitempty"` - PathParameters []*PathParameter `json:"pathParameters,omitempty" url:"pathParameters,omitempty"` - - extraProperties map[string]interface{} -} - -func (h *HttpService) GetAvailability() *Availability { - if h == nil { - return nil - } - return h.Availability -} - -func (h *HttpService) GetName() *DeclaredServiceName { - if h == nil { - return nil - } - return h.Name -} - -func (h *HttpService) GetDisplayName() *string { - if h == nil { - return nil - } - return h.DisplayName -} - -func (h *HttpService) GetBasePath() *HttpPath { - if h == nil { - return nil - } - return h.BasePath -} - -func (h *HttpService) GetEndpoints() []*HttpEndpoint { - if h == nil { - return nil - } - return h.Endpoints -} - -func (h *HttpService) GetHeaders() []*HttpHeader { - if h == nil { - return nil - } - return h.Headers -} - -func (h *HttpService) GetPathParameters() []*PathParameter { - if h == nil { - return nil - } - return h.PathParameters -} - -func (h *HttpService) GetExtraProperties() map[string]interface{} { - return h.extraProperties -} - -func (h *HttpService) UnmarshalJSON(data []byte) error { - type unmarshaler HttpService - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *h = HttpService(value) - - extraProperties, err := core.ExtractExtraProperties(data, *h) - if err != nil { - return err - } - h.extraProperties = extraProperties - - return nil -} - -func (h *HttpService) String() string { - if value, err := core.StringifyJSON(h); err == nil { - return value - } - return fmt.Sprintf("%#v", h) -} - -type InlinedRequestBody struct { - Name *Name `json:"name,omitempty" url:"name,omitempty"` - Extends []*DeclaredTypeName `json:"extends,omitempty" url:"extends,omitempty"` - Properties []*InlinedRequestBodyProperty `json:"properties,omitempty" url:"properties,omitempty"` - - extraProperties map[string]interface{} -} - -func (i *InlinedRequestBody) GetName() *Name { - if i == nil { - return nil - } - return i.Name -} - -func (i *InlinedRequestBody) GetExtends() []*DeclaredTypeName { - if i == nil { - return nil - } - return i.Extends -} - -func (i *InlinedRequestBody) GetProperties() []*InlinedRequestBodyProperty { - if i == nil { - return nil - } - return i.Properties -} - -func (i *InlinedRequestBody) GetExtraProperties() map[string]interface{} { - return i.extraProperties -} - -func (i *InlinedRequestBody) UnmarshalJSON(data []byte) error { - type unmarshaler InlinedRequestBody - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *i = InlinedRequestBody(value) - - extraProperties, err := core.ExtractExtraProperties(data, *i) - if err != nil { - return err - } - i.extraProperties = extraProperties - - return nil -} - -func (i *InlinedRequestBody) String() string { - if value, err := core.StringifyJSON(i); err == nil { - return value - } - return fmt.Sprintf("%#v", i) -} - -type InlinedRequestBodyProperty struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Name *NameAndWireValue `json:"name,omitempty" url:"name,omitempty"` - ValueType *TypeReference `json:"valueType,omitempty" url:"valueType,omitempty"` - - extraProperties map[string]interface{} -} - -func (i *InlinedRequestBodyProperty) GetDocs() *string { - if i == nil { - return nil - } - return i.Docs -} - -func (i *InlinedRequestBodyProperty) GetName() *NameAndWireValue { - if i == nil { - return nil - } - return i.Name -} - -func (i *InlinedRequestBodyProperty) GetValueType() *TypeReference { - if i == nil { - return nil - } - return i.ValueType -} - -func (i *InlinedRequestBodyProperty) GetExtraProperties() map[string]interface{} { - return i.extraProperties -} - -func (i *InlinedRequestBodyProperty) UnmarshalJSON(data []byte) error { - type unmarshaler InlinedRequestBodyProperty - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *i = InlinedRequestBodyProperty(value) - - extraProperties, err := core.ExtractExtraProperties(data, *i) - if err != nil { - return err - } - i.extraProperties = extraProperties - - return nil -} - -func (i *InlinedRequestBodyProperty) String() string { - if value, err := core.StringifyJSON(i); err == nil { - return value - } - return fmt.Sprintf("%#v", i) -} - -type JsonResponse struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - ResponseBodyType *TypeReference `json:"responseBodyType,omitempty" url:"responseBodyType,omitempty"` - - extraProperties map[string]interface{} -} - -func (j *JsonResponse) GetDocs() *string { - if j == nil { - return nil - } - return j.Docs -} - -func (j *JsonResponse) GetResponseBodyType() *TypeReference { - if j == nil { - return nil - } - return j.ResponseBodyType -} - -func (j *JsonResponse) GetExtraProperties() map[string]interface{} { - return j.extraProperties -} - -func (j *JsonResponse) UnmarshalJSON(data []byte) error { - type unmarshaler JsonResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *j = JsonResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *j) - if err != nil { - return err - } - j.extraProperties = extraProperties - - return nil -} - -func (j *JsonResponse) String() string { - if value, err := core.StringifyJSON(j); err == nil { - return value - } - return fmt.Sprintf("%#v", j) -} - -type MaybeStreamingResponse struct { - Condition *StreamCondition `json:"condition,omitempty" url:"condition,omitempty"` - NonStreaming *HttpResponse `json:"nonStreaming,omitempty" url:"nonStreaming,omitempty"` - Streaming *StreamingResponse `json:"streaming,omitempty" url:"streaming,omitempty"` - - extraProperties map[string]interface{} -} - -func (m *MaybeStreamingResponse) GetCondition() *StreamCondition { - if m == nil { - return nil - } - return m.Condition -} - -func (m *MaybeStreamingResponse) GetNonStreaming() *HttpResponse { - if m == nil { - return nil - } - return m.NonStreaming -} - -func (m *MaybeStreamingResponse) GetStreaming() *StreamingResponse { - if m == nil { - return nil - } - return m.Streaming -} - -func (m *MaybeStreamingResponse) GetExtraProperties() map[string]interface{} { - return m.extraProperties -} - -func (m *MaybeStreamingResponse) UnmarshalJSON(data []byte) error { - type unmarshaler MaybeStreamingResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *m = MaybeStreamingResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *m) - if err != nil { - return err - } - m.extraProperties = extraProperties - - return nil -} - -func (m *MaybeStreamingResponse) String() string { - if value, err := core.StringifyJSON(m); err == nil { - return value - } - return fmt.Sprintf("%#v", m) -} - -type PathParameter struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Name *Name `json:"name,omitempty" url:"name,omitempty"` - ValueType *TypeReference `json:"valueType,omitempty" url:"valueType,omitempty"` - Location PathParameterLocation `json:"location" url:"location"` - Variable *VariableId `json:"variable,omitempty" url:"variable,omitempty"` - - extraProperties map[string]interface{} -} - -func (p *PathParameter) GetDocs() *string { - if p == nil { - return nil - } - return p.Docs -} - -func (p *PathParameter) GetName() *Name { - if p == nil { - return nil - } - return p.Name -} - -func (p *PathParameter) GetValueType() *TypeReference { - if p == nil { - return nil - } - return p.ValueType -} - -func (p *PathParameter) GetLocation() PathParameterLocation { - if p == nil { - return "" - } - return p.Location -} - -func (p *PathParameter) GetVariable() *VariableId { - if p == nil { - return nil - } - return p.Variable -} - -func (p *PathParameter) GetExtraProperties() map[string]interface{} { - return p.extraProperties -} - -func (p *PathParameter) UnmarshalJSON(data []byte) error { - type unmarshaler PathParameter - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *p = PathParameter(value) - - extraProperties, err := core.ExtractExtraProperties(data, *p) - if err != nil { - return err - } - p.extraProperties = extraProperties - - return nil -} - -func (p *PathParameter) String() string { - if value, err := core.StringifyJSON(p); err == nil { - return value - } - return fmt.Sprintf("%#v", p) -} - -type PathParameterLocation string - -const ( - PathParameterLocationRoot PathParameterLocation = "ROOT" - PathParameterLocationService PathParameterLocation = "SERVICE" - PathParameterLocationEndpoint PathParameterLocation = "ENDPOINT" -) - -func NewPathParameterLocationFromString(s string) (PathParameterLocation, error) { - switch s { - case "ROOT": - return PathParameterLocationRoot, nil - case "SERVICE": - return PathParameterLocationService, nil - case "ENDPOINT": - return PathParameterLocationEndpoint, nil - } - var t PathParameterLocation - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (p PathParameterLocation) Ptr() *PathParameterLocation { - return &p -} - -type QueryParameter struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Availability *Availability `json:"availability,omitempty" url:"availability,omitempty"` - Name *NameAndWireValue `json:"name,omitempty" url:"name,omitempty"` - ValueType *TypeReference `json:"valueType,omitempty" url:"valueType,omitempty"` - AllowMultiple bool `json:"allowMultiple" url:"allowMultiple"` - - extraProperties map[string]interface{} -} - -func (q *QueryParameter) GetDocs() *string { - if q == nil { - return nil - } - return q.Docs -} - -func (q *QueryParameter) GetAvailability() *Availability { - if q == nil { - return nil - } - return q.Availability -} - -func (q *QueryParameter) GetName() *NameAndWireValue { - if q == nil { - return nil - } - return q.Name -} - -func (q *QueryParameter) GetValueType() *TypeReference { - if q == nil { - return nil - } - return q.ValueType -} - -func (q *QueryParameter) GetAllowMultiple() bool { - if q == nil { - return false - } - return q.AllowMultiple -} - -func (q *QueryParameter) GetExtraProperties() map[string]interface{} { - return q.extraProperties -} - -func (q *QueryParameter) UnmarshalJSON(data []byte) error { - type unmarshaler QueryParameter - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *q = QueryParameter(value) - - extraProperties, err := core.ExtractExtraProperties(data, *q) - if err != nil { - return err - } - q.extraProperties = extraProperties - - return nil -} - -func (q *QueryParameter) String() string { - if value, err := core.StringifyJSON(q); err == nil { - return value - } - return fmt.Sprintf("%#v", q) -} - -type ResponseError struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Error *DeclaredErrorName `json:"error,omitempty" url:"error,omitempty"` - - extraProperties map[string]interface{} -} - -func (r *ResponseError) GetDocs() *string { - if r == nil { - return nil - } - return r.Docs -} - -func (r *ResponseError) GetError() *DeclaredErrorName { - if r == nil { - return nil - } - return r.Error -} - -func (r *ResponseError) GetExtraProperties() map[string]interface{} { - return r.extraProperties -} - -func (r *ResponseError) UnmarshalJSON(data []byte) error { - type unmarshaler ResponseError - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *r = ResponseError(value) - - extraProperties, err := core.ExtractExtraProperties(data, *r) - if err != nil { - return err - } - r.extraProperties = extraProperties - - return nil -} - -func (r *ResponseError) String() string { - if value, err := core.StringifyJSON(r); err == nil { - return value - } - return fmt.Sprintf("%#v", r) -} - -type ResponseErrors = []*ResponseError - -type SdkRequest struct { - RequestParameterName *Name `json:"requestParameterName,omitempty" url:"requestParameterName,omitempty"` - Shape *SdkRequestShape `json:"shape,omitempty" url:"shape,omitempty"` - - extraProperties map[string]interface{} -} - -func (s *SdkRequest) GetRequestParameterName() *Name { - if s == nil { - return nil - } - return s.RequestParameterName -} - -func (s *SdkRequest) GetShape() *SdkRequestShape { - if s == nil { - return nil - } - return s.Shape -} - -func (s *SdkRequest) GetExtraProperties() map[string]interface{} { - return s.extraProperties -} - -func (s *SdkRequest) UnmarshalJSON(data []byte) error { - type unmarshaler SdkRequest - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = SdkRequest(value) - - extraProperties, err := core.ExtractExtraProperties(data, *s) - if err != nil { - return err - } - s.extraProperties = extraProperties - - return nil -} - -func (s *SdkRequest) String() string { - if value, err := core.StringifyJSON(s); err == nil { - return value - } - return fmt.Sprintf("%#v", s) -} - -type SdkRequestShape struct { - Type string - JustRequestBody *HttpRequestBodyReference - Wrapper *SdkRequestWrapper -} - -func NewSdkRequestShapeFromJustRequestBody(value *HttpRequestBodyReference) *SdkRequestShape { - return &SdkRequestShape{Type: "justRequestBody", JustRequestBody: value} -} - -func NewSdkRequestShapeFromWrapper(value *SdkRequestWrapper) *SdkRequestShape { - return &SdkRequestShape{Type: "wrapper", Wrapper: value} -} - -func (s *SdkRequestShape) GetType() string { - if s == nil { - return "" - } - return s.Type -} - -func (s *SdkRequestShape) GetJustRequestBody() *HttpRequestBodyReference { - if s == nil { - return nil - } - return s.JustRequestBody -} - -func (s *SdkRequestShape) GetWrapper() *SdkRequestWrapper { - if s == nil { - return nil - } - return s.Wrapper -} - -func (s *SdkRequestShape) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - s.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", s) - } - switch unmarshaler.Type { - case "justRequestBody": - value := new(HttpRequestBodyReference) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - s.JustRequestBody = value - case "wrapper": - value := new(SdkRequestWrapper) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - s.Wrapper = value - } - return nil -} - -func (s SdkRequestShape) MarshalJSON() ([]byte, error) { - switch s.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", s.Type, s) - case "justRequestBody": - return core.MarshalJSONWithExtraProperty(s.JustRequestBody, "type", "justRequestBody") - case "wrapper": - return core.MarshalJSONWithExtraProperty(s.Wrapper, "type", "wrapper") - } -} - -type SdkRequestShapeVisitor interface { - VisitJustRequestBody(*HttpRequestBodyReference) error - VisitWrapper(*SdkRequestWrapper) error -} - -func (s *SdkRequestShape) Accept(visitor SdkRequestShapeVisitor) error { - switch s.Type { - default: - return fmt.Errorf("invalid type %s in %T", s.Type, s) - case "justRequestBody": - return visitor.VisitJustRequestBody(s.JustRequestBody) - case "wrapper": - return visitor.VisitWrapper(s.Wrapper) - } -} - -type SdkRequestWrapper struct { - WrapperName *Name `json:"wrapperName,omitempty" url:"wrapperName,omitempty"` - BodyKey *Name `json:"bodyKey,omitempty" url:"bodyKey,omitempty"` - - extraProperties map[string]interface{} -} - -func (s *SdkRequestWrapper) GetWrapperName() *Name { - if s == nil { - return nil - } - return s.WrapperName -} - -func (s *SdkRequestWrapper) GetBodyKey() *Name { - if s == nil { - return nil - } - return s.BodyKey -} - -func (s *SdkRequestWrapper) GetExtraProperties() map[string]interface{} { - return s.extraProperties -} - -func (s *SdkRequestWrapper) UnmarshalJSON(data []byte) error { - type unmarshaler SdkRequestWrapper - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = SdkRequestWrapper(value) - - extraProperties, err := core.ExtractExtraProperties(data, *s) - if err != nil { - return err - } - s.extraProperties = extraProperties - - return nil -} - -func (s *SdkRequestWrapper) String() string { - if value, err := core.StringifyJSON(s); err == nil { - return value - } - return fmt.Sprintf("%#v", s) -} - -type SdkResponse struct { - Type string - Json *JsonResponse - Streaming *StreamingResponse - MaybeStreaming *MaybeStreamingResponse - FileDownload *FileDownloadResponse -} - -func NewSdkResponseFromJson(value *JsonResponse) *SdkResponse { - return &SdkResponse{Type: "json", Json: value} -} - -func NewSdkResponseFromStreaming(value *StreamingResponse) *SdkResponse { - return &SdkResponse{Type: "streaming", Streaming: value} -} - -func NewSdkResponseFromMaybeStreaming(value *MaybeStreamingResponse) *SdkResponse { - return &SdkResponse{Type: "maybeStreaming", MaybeStreaming: value} -} - -func NewSdkResponseFromFileDownload(value *FileDownloadResponse) *SdkResponse { - return &SdkResponse{Type: "fileDownload", FileDownload: value} -} - -func (s *SdkResponse) GetType() string { - if s == nil { - return "" - } - return s.Type -} - -func (s *SdkResponse) GetJson() *JsonResponse { - if s == nil { - return nil - } - return s.Json -} - -func (s *SdkResponse) GetStreaming() *StreamingResponse { - if s == nil { - return nil - } - return s.Streaming -} - -func (s *SdkResponse) GetMaybeStreaming() *MaybeStreamingResponse { - if s == nil { - return nil - } - return s.MaybeStreaming -} - -func (s *SdkResponse) GetFileDownload() *FileDownloadResponse { - if s == nil { - return nil - } - return s.FileDownload -} - -func (s *SdkResponse) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - s.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", s) - } - switch unmarshaler.Type { - case "json": - value := new(JsonResponse) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - s.Json = value - case "streaming": - value := new(StreamingResponse) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - s.Streaming = value - case "maybeStreaming": - value := new(MaybeStreamingResponse) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - s.MaybeStreaming = value - case "fileDownload": - value := new(FileDownloadResponse) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - s.FileDownload = value - } - return nil -} - -func (s SdkResponse) MarshalJSON() ([]byte, error) { - switch s.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", s.Type, s) - case "json": - return core.MarshalJSONWithExtraProperty(s.Json, "type", "json") - case "streaming": - return core.MarshalJSONWithExtraProperty(s.Streaming, "type", "streaming") - case "maybeStreaming": - return core.MarshalJSONWithExtraProperty(s.MaybeStreaming, "type", "maybeStreaming") - case "fileDownload": - return core.MarshalJSONWithExtraProperty(s.FileDownload, "type", "fileDownload") - } -} - -type SdkResponseVisitor interface { - VisitJson(*JsonResponse) error - VisitStreaming(*StreamingResponse) error - VisitMaybeStreaming(*MaybeStreamingResponse) error - VisitFileDownload(*FileDownloadResponse) error -} - -func (s *SdkResponse) Accept(visitor SdkResponseVisitor) error { - switch s.Type { - default: - return fmt.Errorf("invalid type %s in %T", s.Type, s) - case "json": - return visitor.VisitJson(s.Json) - case "streaming": - return visitor.VisitStreaming(s.Streaming) - case "maybeStreaming": - return visitor.VisitMaybeStreaming(s.MaybeStreaming) - case "fileDownload": - return visitor.VisitFileDownload(s.FileDownload) - } -} - -type StreamCondition struct { - Type string - // The name of a boolean query parameter. If it is true, the response - // should be streamed. Otherwise, it should not be streamed. - QueryParameterKey string - // The name of a boolean property on the request. If it is true, the response - // should be streamed. Otherwise, it should not be streamed. - RequestPropertyKey string -} - -func NewStreamConditionFromQueryParameterKey(value string) *StreamCondition { - return &StreamCondition{Type: "queryParameterKey", QueryParameterKey: value} -} - -func NewStreamConditionFromRequestPropertyKey(value string) *StreamCondition { - return &StreamCondition{Type: "requestPropertyKey", RequestPropertyKey: value} -} - -func (s *StreamCondition) GetType() string { - if s == nil { - return "" - } - return s.Type -} - -func (s *StreamCondition) GetQueryParameterKey() string { - if s == nil { - return "" - } - return s.QueryParameterKey -} - -func (s *StreamCondition) GetRequestPropertyKey() string { - if s == nil { - return "" - } - return s.RequestPropertyKey -} - -func (s *StreamCondition) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - s.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", s) - } - switch unmarshaler.Type { - case "queryParameterKey": - var valueUnmarshaler struct { - QueryParameterKey string `json:"value"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - s.QueryParameterKey = valueUnmarshaler.QueryParameterKey - case "requestPropertyKey": - var valueUnmarshaler struct { - RequestPropertyKey string `json:"value"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - s.RequestPropertyKey = valueUnmarshaler.RequestPropertyKey - } - return nil -} - -func (s StreamCondition) MarshalJSON() ([]byte, error) { - switch s.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", s.Type, s) - case "queryParameterKey": - var marshaler = struct { - Type string `json:"type"` - QueryParameterKey string `json:"value"` - }{ - Type: "queryParameterKey", - QueryParameterKey: s.QueryParameterKey, - } - return json.Marshal(marshaler) - case "requestPropertyKey": - var marshaler = struct { - Type string `json:"type"` - RequestPropertyKey string `json:"value"` - }{ - Type: "requestPropertyKey", - RequestPropertyKey: s.RequestPropertyKey, - } - return json.Marshal(marshaler) - } -} - -type StreamConditionVisitor interface { - VisitQueryParameterKey(string) error - VisitRequestPropertyKey(string) error -} - -func (s *StreamCondition) Accept(visitor StreamConditionVisitor) error { - switch s.Type { - default: - return fmt.Errorf("invalid type %s in %T", s.Type, s) - case "queryParameterKey": - return visitor.VisitQueryParameterKey(s.QueryParameterKey) - case "requestPropertyKey": - return visitor.VisitRequestPropertyKey(s.RequestPropertyKey) - } -} - -type StreamingResponse struct { - DataEventType *TypeReference `json:"dataEventType,omitempty" url:"dataEventType,omitempty"` - Terminator *string `json:"terminator,omitempty" url:"terminator,omitempty"` - - extraProperties map[string]interface{} -} - -func (s *StreamingResponse) GetDataEventType() *TypeReference { - if s == nil { - return nil - } - return s.DataEventType -} - -func (s *StreamingResponse) GetTerminator() *string { - if s == nil { - return nil - } - return s.Terminator -} - -func (s *StreamingResponse) GetExtraProperties() map[string]interface{} { - return s.extraProperties -} - -func (s *StreamingResponse) UnmarshalJSON(data []byte) error { - type unmarshaler StreamingResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = StreamingResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *s) - if err != nil { - return err - } - s.extraProperties = extraProperties - - return nil -} - -func (s *StreamingResponse) String() string { - if value, err := core.StringifyJSON(s); err == nil { - return value - } - return fmt.Sprintf("%#v", s) -} - -type ErrorDiscriminationByPropertyStrategy struct { - Discriminant *NameAndWireValue `json:"discriminant,omitempty" url:"discriminant,omitempty"` - ContentProperty *NameAndWireValue `json:"contentProperty,omitempty" url:"contentProperty,omitempty"` - - extraProperties map[string]interface{} -} - -func (e *ErrorDiscriminationByPropertyStrategy) GetDiscriminant() *NameAndWireValue { - if e == nil { - return nil - } - return e.Discriminant -} - -func (e *ErrorDiscriminationByPropertyStrategy) GetContentProperty() *NameAndWireValue { - if e == nil { - return nil - } - return e.ContentProperty -} - -func (e *ErrorDiscriminationByPropertyStrategy) GetExtraProperties() map[string]interface{} { - return e.extraProperties -} - -func (e *ErrorDiscriminationByPropertyStrategy) UnmarshalJSON(data []byte) error { - type unmarshaler ErrorDiscriminationByPropertyStrategy - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *e = ErrorDiscriminationByPropertyStrategy(value) - - extraProperties, err := core.ExtractExtraProperties(data, *e) - if err != nil { - return err - } - e.extraProperties = extraProperties - - return nil -} - -func (e *ErrorDiscriminationByPropertyStrategy) String() string { - if value, err := core.StringifyJSON(e); err == nil { - return value - } - return fmt.Sprintf("%#v", e) -} - -type ErrorDiscriminationStrategy struct { - Type string - StatusCode interface{} - Property *ErrorDiscriminationByPropertyStrategy -} - -func NewErrorDiscriminationStrategyFromStatusCode(value interface{}) *ErrorDiscriminationStrategy { - return &ErrorDiscriminationStrategy{Type: "statusCode", StatusCode: value} -} - -func NewErrorDiscriminationStrategyFromProperty(value *ErrorDiscriminationByPropertyStrategy) *ErrorDiscriminationStrategy { - return &ErrorDiscriminationStrategy{Type: "property", Property: value} -} - -func (e *ErrorDiscriminationStrategy) GetType() string { - if e == nil { - return "" - } - return e.Type -} - -func (e *ErrorDiscriminationStrategy) GetStatusCode() interface{} { - if e == nil { - return nil - } - return e.StatusCode -} - -func (e *ErrorDiscriminationStrategy) GetProperty() *ErrorDiscriminationByPropertyStrategy { - if e == nil { - return nil - } - return e.Property -} - -func (e *ErrorDiscriminationStrategy) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - e.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", e) - } - switch unmarshaler.Type { - case "statusCode": - value := make(map[string]interface{}) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - e.StatusCode = value - case "property": - value := new(ErrorDiscriminationByPropertyStrategy) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - e.Property = value - } - return nil -} - -func (e ErrorDiscriminationStrategy) MarshalJSON() ([]byte, error) { - switch e.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", e.Type, e) - case "statusCode": - var marshaler = struct { - Type string `json:"type"` - StatusCode interface{} `json:"statusCode,omitempty"` - }{ - Type: "statusCode", - StatusCode: e.StatusCode, - } - return json.Marshal(marshaler) - case "property": - return core.MarshalJSONWithExtraProperty(e.Property, "type", "property") - } -} - -type ErrorDiscriminationStrategyVisitor interface { - VisitStatusCode(interface{}) error - VisitProperty(*ErrorDiscriminationByPropertyStrategy) error -} - -func (e *ErrorDiscriminationStrategy) Accept(visitor ErrorDiscriminationStrategyVisitor) error { - switch e.Type { - default: - return fmt.Errorf("invalid type %s in %T", e.Type, e) - case "statusCode": - return visitor.VisitStatusCode(e.StatusCode) - case "property": - return visitor.VisitProperty(e.Property) - } -} - -// Complete representation of the API schema -type IntermediateRepresentation struct { - // This is the human readable unique id for the API. - ApiName *Name `json:"apiName,omitempty" url:"apiName,omitempty"` - ApiDisplayName *string `json:"apiDisplayName,omitempty" url:"apiDisplayName,omitempty"` - ApiDocs *string `json:"apiDocs,omitempty" url:"apiDocs,omitempty"` - Auth *ApiAuth `json:"auth,omitempty" url:"auth,omitempty"` - // API Wide headers that are sent on every request - Headers []*HttpHeader `json:"headers,omitempty" url:"headers,omitempty"` - // The types described by this API - Types map[TypeId]*TypeDeclaration `json:"types,omitempty" url:"types,omitempty"` - // The services exposed by this API - Services map[ServiceId]*HttpService `json:"services,omitempty" url:"services,omitempty"` - Errors map[ErrorId]*ErrorDeclaration `json:"errors,omitempty" url:"errors,omitempty"` - Subpackages map[SubpackageId]*Subpackage `json:"subpackages,omitempty" url:"subpackages,omitempty"` - RootPackage *Package `json:"rootPackage,omitempty" url:"rootPackage,omitempty"` - Constants *Constants `json:"constants,omitempty" url:"constants,omitempty"` - Environments *EnvironmentsConfig `json:"environments,omitempty" url:"environments,omitempty"` - BasePath *HttpPath `json:"basePath,omitempty" url:"basePath,omitempty"` - PathParameters []*PathParameter `json:"pathParameters,omitempty" url:"pathParameters,omitempty"` - ErrorDiscriminationStrategy *ErrorDiscriminationStrategy `json:"errorDiscriminationStrategy,omitempty" url:"errorDiscriminationStrategy,omitempty"` - SdkConfig *SdkConfig `json:"sdkConfig,omitempty" url:"sdkConfig,omitempty"` - Variables []*VariableDeclaration `json:"variables,omitempty" url:"variables,omitempty"` - - extraProperties map[string]interface{} -} - -func (i *IntermediateRepresentation) GetApiName() *Name { - if i == nil { - return nil - } - return i.ApiName -} - -func (i *IntermediateRepresentation) GetApiDisplayName() *string { - if i == nil { - return nil - } - return i.ApiDisplayName -} - -func (i *IntermediateRepresentation) GetApiDocs() *string { - if i == nil { - return nil - } - return i.ApiDocs -} - -func (i *IntermediateRepresentation) GetAuth() *ApiAuth { - if i == nil { - return nil - } - return i.Auth -} - -func (i *IntermediateRepresentation) GetHeaders() []*HttpHeader { - if i == nil { - return nil - } - return i.Headers -} - -func (i *IntermediateRepresentation) GetTypes() map[TypeId]*TypeDeclaration { - if i == nil { - return nil - } - return i.Types -} - -func (i *IntermediateRepresentation) GetServices() map[ServiceId]*HttpService { - if i == nil { - return nil - } - return i.Services -} - -func (i *IntermediateRepresentation) GetErrors() map[ErrorId]*ErrorDeclaration { - if i == nil { - return nil - } - return i.Errors -} - -func (i *IntermediateRepresentation) GetSubpackages() map[SubpackageId]*Subpackage { - if i == nil { - return nil - } - return i.Subpackages -} - -func (i *IntermediateRepresentation) GetRootPackage() *Package { - if i == nil { - return nil - } - return i.RootPackage -} - -func (i *IntermediateRepresentation) GetConstants() *Constants { - if i == nil { - return nil - } - return i.Constants -} - -func (i *IntermediateRepresentation) GetEnvironments() *EnvironmentsConfig { - if i == nil { - return nil - } - return i.Environments -} - -func (i *IntermediateRepresentation) GetBasePath() *HttpPath { - if i == nil { - return nil - } - return i.BasePath -} - -func (i *IntermediateRepresentation) GetPathParameters() []*PathParameter { - if i == nil { - return nil - } - return i.PathParameters -} - -func (i *IntermediateRepresentation) GetErrorDiscriminationStrategy() *ErrorDiscriminationStrategy { - if i == nil { - return nil - } - return i.ErrorDiscriminationStrategy -} - -func (i *IntermediateRepresentation) GetSdkConfig() *SdkConfig { - if i == nil { - return nil - } - return i.SdkConfig -} - -func (i *IntermediateRepresentation) GetVariables() []*VariableDeclaration { - if i == nil { - return nil - } - return i.Variables -} - -func (i *IntermediateRepresentation) GetExtraProperties() map[string]interface{} { - return i.extraProperties -} - -func (i *IntermediateRepresentation) UnmarshalJSON(data []byte) error { - type unmarshaler IntermediateRepresentation - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *i = IntermediateRepresentation(value) - - extraProperties, err := core.ExtractExtraProperties(data, *i) - if err != nil { - return err - } - i.extraProperties = extraProperties - - return nil -} - -func (i *IntermediateRepresentation) String() string { - if value, err := core.StringifyJSON(i); err == nil { - return value - } - return fmt.Sprintf("%#v", i) -} - -type Package struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - FernFilepath *FernFilepath `json:"fernFilepath,omitempty" url:"fernFilepath,omitempty"` - Service *ServiceId `json:"service,omitempty" url:"service,omitempty"` - Types []TypeId `json:"types,omitempty" url:"types,omitempty"` - Errors []ErrorId `json:"errors,omitempty" url:"errors,omitempty"` - Subpackages []SubpackageId `json:"subpackages,omitempty" url:"subpackages,omitempty"` - HasEndpointsInTree bool `json:"hasEndpointsInTree" url:"hasEndpointsInTree"` - - extraProperties map[string]interface{} -} - -func (p *Package) GetDocs() *string { - if p == nil { - return nil - } - return p.Docs -} - -func (p *Package) GetFernFilepath() *FernFilepath { - if p == nil { - return nil - } - return p.FernFilepath -} +type DeclaredErrorName struct { + ErrorId ErrorId `json:"errorId" url:"errorId"` + FernFilepath *FernFilepath `json:"fernFilepath,omitempty" url:"fernFilepath,omitempty"` + Name *Name `json:"name,omitempty" url:"name,omitempty"` -func (p *Package) GetService() *ServiceId { - if p == nil { - return nil - } - return p.Service + extraProperties map[string]interface{} } -func (p *Package) GetTypes() []TypeId { - if p == nil { - return nil +func (d *DeclaredErrorName) GetErrorId() ErrorId { + if d == nil { + return "" } - return p.Types + return d.ErrorId } -func (p *Package) GetErrors() []ErrorId { - if p == nil { +func (d *DeclaredErrorName) GetFernFilepath() *FernFilepath { + if d == nil { return nil } - return p.Errors + return d.FernFilepath } -func (p *Package) GetSubpackages() []SubpackageId { - if p == nil { +func (d *DeclaredErrorName) GetName() *Name { + if d == nil { return nil } - return p.Subpackages -} - -func (p *Package) GetHasEndpointsInTree() bool { - if p == nil { - return false - } - return p.HasEndpointsInTree + return d.Name } -func (p *Package) GetExtraProperties() map[string]interface{} { - return p.extraProperties +func (d *DeclaredErrorName) GetExtraProperties() map[string]interface{} { + return d.extraProperties } -func (p *Package) UnmarshalJSON(data []byte) error { - type unmarshaler Package +func (d *DeclaredErrorName) UnmarshalJSON(data []byte) error { + type unmarshaler DeclaredErrorName var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *p = Package(value) + *d = DeclaredErrorName(value) - extraProperties, err := core.ExtractExtraProperties(data, *p) + extraProperties, err := core.ExtractExtraProperties(data, *d) if err != nil { return err } - p.extraProperties = extraProperties + d.extraProperties = extraProperties return nil } -func (p *Package) String() string { - if value, err := core.StringifyJSON(p); err == nil { +func (d *DeclaredErrorName) String() string { + if value, err := core.StringifyJSON(d); err == nil { return value } - return fmt.Sprintf("%#v", p) + return fmt.Sprintf("%#v", d) } -type PlatformHeaders struct { - Language string `json:"language" url:"language"` - SdkName string `json:"sdkName" url:"sdkName"` - SdkVersion string `json:"sdkVersion" url:"sdkVersion"` +type ErrorDeclaration struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Name *DeclaredErrorName `json:"name,omitempty" url:"name,omitempty"` + DiscriminantValue *NameAndWireValue `json:"discriminantValue,omitempty" url:"discriminantValue,omitempty"` + Type *TypeReference `json:"type,omitempty" url:"type,omitempty"` + StatusCode int `json:"statusCode" url:"statusCode"` extraProperties map[string]interface{} } -func (p *PlatformHeaders) GetLanguage() string { - if p == nil { - return "" - } - return p.Language -} - -func (p *PlatformHeaders) GetSdkName() string { - if p == nil { - return "" - } - return p.SdkName -} - -func (p *PlatformHeaders) GetSdkVersion() string { - if p == nil { - return "" - } - return p.SdkVersion -} - -func (p *PlatformHeaders) GetExtraProperties() map[string]interface{} { - return p.extraProperties -} - -func (p *PlatformHeaders) UnmarshalJSON(data []byte) error { - type unmarshaler PlatformHeaders - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *p = PlatformHeaders(value) - - extraProperties, err := core.ExtractExtraProperties(data, *p) - if err != nil { - return err +func (e *ErrorDeclaration) GetDocs() *string { + if e == nil { + return nil } - p.extraProperties = extraProperties - - return nil + return e.Docs } -func (p *PlatformHeaders) String() string { - if value, err := core.StringifyJSON(p); err == nil { - return value +func (e *ErrorDeclaration) GetName() *DeclaredErrorName { + if e == nil { + return nil } - return fmt.Sprintf("%#v", p) -} - -type SdkConfig struct { - IsAuthMandatory bool `json:"isAuthMandatory" url:"isAuthMandatory"` - HasStreamingEndpoints bool `json:"hasStreamingEndpoints" url:"hasStreamingEndpoints"` - PlatformHeaders *PlatformHeaders `json:"platformHeaders,omitempty" url:"platformHeaders,omitempty"` - - extraProperties map[string]interface{} + return e.Name } -func (s *SdkConfig) GetIsAuthMandatory() bool { - if s == nil { - return false +func (e *ErrorDeclaration) GetDiscriminantValue() *NameAndWireValue { + if e == nil { + return nil } - return s.IsAuthMandatory + return e.DiscriminantValue } -func (s *SdkConfig) GetHasStreamingEndpoints() bool { - if s == nil { - return false +func (e *ErrorDeclaration) GetType() *TypeReference { + if e == nil { + return nil } - return s.HasStreamingEndpoints + return e.Type } -func (s *SdkConfig) GetPlatformHeaders() *PlatformHeaders { - if s == nil { - return nil +func (e *ErrorDeclaration) GetStatusCode() int { + if e == nil { + return 0 } - return s.PlatformHeaders + return e.StatusCode } -func (s *SdkConfig) GetExtraProperties() map[string]interface{} { - return s.extraProperties +func (e *ErrorDeclaration) GetExtraProperties() map[string]interface{} { + return e.extraProperties } -func (s *SdkConfig) UnmarshalJSON(data []byte) error { - type unmarshaler SdkConfig +func (e *ErrorDeclaration) UnmarshalJSON(data []byte) error { + type unmarshaler ErrorDeclaration var value unmarshaler if err := json.Unmarshal(data, &value); err != nil { return err } - *s = SdkConfig(value) + *e = ErrorDeclaration(value) - extraProperties, err := core.ExtractExtraProperties(data, *s) + extraProperties, err := core.ExtractExtraProperties(data, *e) if err != nil { return err } - s.extraProperties = extraProperties + e.extraProperties = extraProperties return nil } -func (s *SdkConfig) String() string { - if value, err := core.StringifyJSON(s); err == nil { +func (e *ErrorDeclaration) String() string { + if value, err := core.StringifyJSON(e); err == nil { return value } - return fmt.Sprintf("%#v", s) + return fmt.Sprintf("%#v", e) } -type Subpackage struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - FernFilepath *FernFilepath `json:"fernFilepath,omitempty" url:"fernFilepath,omitempty"` - Service *ServiceId `json:"service,omitempty" url:"service,omitempty"` - Types []TypeId `json:"types,omitempty" url:"types,omitempty"` - Errors []ErrorId `json:"errors,omitempty" url:"errors,omitempty"` - Subpackages []SubpackageId `json:"subpackages,omitempty" url:"subpackages,omitempty"` - HasEndpointsInTree bool `json:"hasEndpointsInTree" url:"hasEndpointsInTree"` - Name *Name `json:"name,omitempty" url:"name,omitempty"` - - extraProperties map[string]interface{} +type ErrorDeclarationDiscriminantValue struct { + Type string + Property *NameAndWireValue + StatusCode interface{} } -func (s *Subpackage) GetDocs() *string { - if s == nil { - return nil - } - return s.Docs +func NewErrorDeclarationDiscriminantValueFromProperty(value *NameAndWireValue) *ErrorDeclarationDiscriminantValue { + return &ErrorDeclarationDiscriminantValue{Type: "property", Property: value} } -func (s *Subpackage) GetFernFilepath() *FernFilepath { - if s == nil { - return nil - } - return s.FernFilepath +func NewErrorDeclarationDiscriminantValueFromStatusCode(value interface{}) *ErrorDeclarationDiscriminantValue { + return &ErrorDeclarationDiscriminantValue{Type: "statusCode", StatusCode: value} } -func (s *Subpackage) GetService() *ServiceId { - if s == nil { - return nil +func (e *ErrorDeclarationDiscriminantValue) GetType() string { + if e == nil { + return "" } - return s.Service + return e.Type } -func (s *Subpackage) GetTypes() []TypeId { - if s == nil { +func (e *ErrorDeclarationDiscriminantValue) GetProperty() *NameAndWireValue { + if e == nil { return nil } - return s.Types + return e.Property } -func (s *Subpackage) GetErrors() []ErrorId { - if s == nil { +func (e *ErrorDeclarationDiscriminantValue) GetStatusCode() interface{} { + if e == nil { return nil } - return s.Errors + return e.StatusCode } -func (s *Subpackage) GetSubpackages() []SubpackageId { - if s == nil { - return nil +func (e *ErrorDeclarationDiscriminantValue) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` } - return s.Subpackages -} - -func (s *Subpackage) GetHasEndpointsInTree() bool { - if s == nil { - return false + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err } - return s.HasEndpointsInTree -} - -func (s *Subpackage) GetName() *Name { - if s == nil { - return nil + e.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", e) } - return s.Name -} - -func (s *Subpackage) GetExtraProperties() map[string]interface{} { - return s.extraProperties -} - -func (s *Subpackage) UnmarshalJSON(data []byte) error { - type unmarshaler Subpackage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err + switch unmarshaler.Type { + case "property": + value := new(NameAndWireValue) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + e.Property = value + case "statusCode": + value := make(map[string]interface{}) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + e.StatusCode = value } - *s = Subpackage(value) + return nil +} - extraProperties, err := core.ExtractExtraProperties(data, *s) - if err != nil { - return err +func (e ErrorDeclarationDiscriminantValue) MarshalJSON() ([]byte, error) { + switch e.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", e.Type, e) + case "property": + return core.MarshalJSONWithExtraProperty(e.Property, "type", "property") + case "statusCode": + var marshaler = struct { + Type string `json:"type"` + StatusCode interface{} `json:"statusCode,omitempty"` + }{ + Type: "statusCode", + StatusCode: e.StatusCode, + } + return json.Marshal(marshaler) } - s.extraProperties = extraProperties +} - return nil +type ErrorDeclarationDiscriminantValueVisitor interface { + VisitProperty(*NameAndWireValue) error + VisitStatusCode(interface{}) error } -func (s *Subpackage) String() string { - if value, err := core.StringifyJSON(s); err == nil { - return value +func (e *ErrorDeclarationDiscriminantValue) Accept(visitor ErrorDeclarationDiscriminantValueVisitor) error { + switch e.Type { + default: + return fmt.Errorf("invalid type %s in %T", e.Type, e) + case "property": + return visitor.VisitProperty(e.Property) + case "statusCode": + return visitor.VisitStatusCode(e.StatusCode) } - return fmt.Sprintf("%#v", s) } type AliasTypeDeclaration struct { @@ -7733,70 +3276,3 @@ func (u *UnionTypeDeclaration) String() string { } return fmt.Sprintf("%#v", u) } - -type VariableDeclaration struct { - Docs *string `json:"docs,omitempty" url:"docs,omitempty"` - Id VariableId `json:"id" url:"id"` - Name *Name `json:"name,omitempty" url:"name,omitempty"` - Type *TypeReference `json:"type,omitempty" url:"type,omitempty"` - - extraProperties map[string]interface{} -} - -func (v *VariableDeclaration) GetDocs() *string { - if v == nil { - return nil - } - return v.Docs -} - -func (v *VariableDeclaration) GetId() VariableId { - if v == nil { - return "" - } - return v.Id -} - -func (v *VariableDeclaration) GetName() *Name { - if v == nil { - return nil - } - return v.Name -} - -func (v *VariableDeclaration) GetType() *TypeReference { - if v == nil { - return nil - } - return v.Type -} - -func (v *VariableDeclaration) GetExtraProperties() map[string]interface{} { - return v.extraProperties -} - -func (v *VariableDeclaration) UnmarshalJSON(data []byte) error { - type unmarshaler VariableDeclaration - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *v = VariableDeclaration(value) - - extraProperties, err := core.ExtractExtraProperties(data, *v) - if err != nil { - return err - } - v.extraProperties = extraProperties - - return nil -} - -func (v *VariableDeclaration) String() string { - if value, err := core.StringifyJSON(v); err == nil { - return value - } - return fmt.Sprintf("%#v", v) -} - -type VariableId = string diff --git a/generators/go/internal/testdata/model/ir/fixtures/variables.go b/generators/go/internal/testdata/model/ir/fixtures/variables.go new file mode 100644 index 00000000000..5d9ded79fb5 --- /dev/null +++ b/generators/go/internal/testdata/model/ir/fixtures/variables.go @@ -0,0 +1,76 @@ +// This file was auto-generated by Fern from our API Definition. + +package ir + +import ( + json "encoding/json" + fmt "fmt" + core "sdk/core" +) + +type VariableDeclaration struct { + Docs *string `json:"docs,omitempty" url:"docs,omitempty"` + Id VariableId `json:"id" url:"id"` + Name *Name `json:"name,omitempty" url:"name,omitempty"` + Type *TypeReference `json:"type,omitempty" url:"type,omitempty"` + + extraProperties map[string]interface{} +} + +func (v *VariableDeclaration) GetDocs() *string { + if v == nil { + return nil + } + return v.Docs +} + +func (v *VariableDeclaration) GetId() VariableId { + if v == nil { + return "" + } + return v.Id +} + +func (v *VariableDeclaration) GetName() *Name { + if v == nil { + return nil + } + return v.Name +} + +func (v *VariableDeclaration) GetType() *TypeReference { + if v == nil { + return nil + } + return v.Type +} + +func (v *VariableDeclaration) GetExtraProperties() map[string]interface{} { + return v.extraProperties +} + +func (v *VariableDeclaration) UnmarshalJSON(data []byte) error { + type unmarshaler VariableDeclaration + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *v = VariableDeclaration(value) + + extraProperties, err := core.ExtractExtraProperties(data, *v) + if err != nil { + return err + } + v.extraProperties = extraProperties + + return nil +} + +func (v *VariableDeclaration) String() string { + if value, err := core.StringifyJSON(v); err == nil { + return value + } + return fmt.Sprintf("%#v", v) +} + +type VariableId = string diff --git a/generators/go/internal/testdata/model/mod/fixtures/bar/types.go b/generators/go/internal/testdata/model/mod/fixtures/bar/bar.go similarity index 100% rename from generators/go/internal/testdata/model/mod/fixtures/bar/types.go rename to generators/go/internal/testdata/model/mod/fixtures/bar/bar.go diff --git a/generators/go/internal/testdata/model/mod/fixtures/types.go b/generators/go/internal/testdata/model/mod/fixtures/foo.go similarity index 100% rename from generators/go/internal/testdata/model/mod/fixtures/types.go rename to generators/go/internal/testdata/model/mod/fixtures/foo.go diff --git a/generators/go/internal/testdata/model/optional/fixtures/types.go b/generators/go/internal/testdata/model/optional/fixtures/imdb.go similarity index 100% rename from generators/go/internal/testdata/model/optional/fixtures/types.go rename to generators/go/internal/testdata/model/optional/fixtures/imdb.go diff --git a/generators/go/internal/testdata/model/packages/fixtures/bar/types.go b/generators/go/internal/testdata/model/packages/fixtures/bar/bar.go similarity index 100% rename from generators/go/internal/testdata/model/packages/fixtures/bar/types.go rename to generators/go/internal/testdata/model/packages/fixtures/bar/bar.go diff --git a/generators/go/internal/testdata/model/packages/fixtures/baz/v1/types.go b/generators/go/internal/testdata/model/packages/fixtures/baz/v1/baz.go similarity index 100% rename from generators/go/internal/testdata/model/packages/fixtures/baz/v1/types.go rename to generators/go/internal/testdata/model/packages/fixtures/baz/v1/baz.go diff --git a/generators/go/internal/testdata/model/packages/fixtures/baz/v2/types.go b/generators/go/internal/testdata/model/packages/fixtures/baz/v2/baz.go similarity index 100% rename from generators/go/internal/testdata/model/packages/fixtures/baz/v2/types.go rename to generators/go/internal/testdata/model/packages/fixtures/baz/v2/baz.go diff --git a/generators/go/internal/testdata/model/packages/fixtures/extra.go b/generators/go/internal/testdata/model/packages/fixtures/extra.go new file mode 100644 index 00000000000..48e6186e8e1 --- /dev/null +++ b/generators/go/internal/testdata/model/packages/fixtures/extra.go @@ -0,0 +1,50 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/fern-api/fern-go/internal/testdata/model/packages/fixtures/core" +) + +type Value struct { + Name string `json:"name" url:"name"` + + extraProperties map[string]interface{} +} + +func (v *Value) GetName() string { + if v == nil { + return "" + } + return v.Name +} + +func (v *Value) GetExtraProperties() map[string]interface{} { + return v.extraProperties +} + +func (v *Value) UnmarshalJSON(data []byte) error { + type unmarshaler Value + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *v = Value(value) + + extraProperties, err := core.ExtractExtraProperties(data, *v) + if err != nil { + return err + } + v.extraProperties = extraProperties + + return nil +} + +func (v *Value) String() string { + if value, err := core.StringifyJSON(v); err == nil { + return value + } + return fmt.Sprintf("%#v", v) +} diff --git a/generators/go/internal/testdata/model/packages/fixtures/foo.go b/generators/go/internal/testdata/model/packages/fixtures/foo.go new file mode 100644 index 00000000000..76af70a017a --- /dev/null +++ b/generators/go/internal/testdata/model/packages/fixtures/foo.go @@ -0,0 +1,67 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + bar "github.com/fern-api/fern-go/internal/testdata/model/packages/fixtures/bar" + core "github.com/fern-api/fern-go/internal/testdata/model/packages/fixtures/core" +) + +type Foo struct { + Name string `json:"name" url:"name"` + Value *Value `json:"value,omitempty" url:"value,omitempty"` + Bar *bar.Bar `json:"bar,omitempty" url:"bar,omitempty"` + + extraProperties map[string]interface{} +} + +func (f *Foo) GetName() string { + if f == nil { + return "" + } + return f.Name +} + +func (f *Foo) GetValue() *Value { + if f == nil { + return nil + } + return f.Value +} + +func (f *Foo) GetBar() *bar.Bar { + if f == nil { + return nil + } + return f.Bar +} + +func (f *Foo) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *Foo) UnmarshalJSON(data []byte) error { + type unmarshaler Foo + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = Foo(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + return nil +} + +func (f *Foo) String() string { + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} diff --git a/generators/go/internal/testdata/model/packages/fixtures/foo/types.go b/generators/go/internal/testdata/model/packages/fixtures/foo/foo.go similarity index 100% rename from generators/go/internal/testdata/model/packages/fixtures/foo/types.go rename to generators/go/internal/testdata/model/packages/fixtures/foo/foo.go diff --git a/generators/go/internal/testdata/model/packages/fixtures/types.go b/generators/go/internal/testdata/model/packages/fixtures/types.go index 3c623857bd0..58863b72718 100644 --- a/generators/go/internal/testdata/model/packages/fixtures/types.go +++ b/generators/go/internal/testdata/model/packages/fixtures/types.go @@ -5,7 +5,6 @@ package api import ( json "encoding/json" fmt "fmt" - bar "github.com/fern-api/fern-go/internal/testdata/model/packages/fixtures/bar" core "github.com/fern-api/fern-go/internal/testdata/model/packages/fixtures/core" ) @@ -49,255 +48,3 @@ func (b *Base) String() string { } return fmt.Sprintf("%#v", b) } - -type Value struct { - Name string `json:"name" url:"name"` - - extraProperties map[string]interface{} -} - -func (v *Value) GetName() string { - if v == nil { - return "" - } - return v.Name -} - -func (v *Value) GetExtraProperties() map[string]interface{} { - return v.extraProperties -} - -func (v *Value) UnmarshalJSON(data []byte) error { - type unmarshaler Value - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *v = Value(value) - - extraProperties, err := core.ExtractExtraProperties(data, *v) - if err != nil { - return err - } - v.extraProperties = extraProperties - - return nil -} - -func (v *Value) String() string { - if value, err := core.StringifyJSON(v); err == nil { - return value - } - return fmt.Sprintf("%#v", v) -} - -type Foo struct { - Name string `json:"name" url:"name"` - Value *Value `json:"value,omitempty" url:"value,omitempty"` - Bar *bar.Bar `json:"bar,omitempty" url:"bar,omitempty"` - - extraProperties map[string]interface{} -} - -func (f *Foo) GetName() string { - if f == nil { - return "" - } - return f.Name -} - -func (f *Foo) GetValue() *Value { - if f == nil { - return nil - } - return f.Value -} - -func (f *Foo) GetBar() *bar.Bar { - if f == nil { - return nil - } - return f.Bar -} - -func (f *Foo) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *Foo) UnmarshalJSON(data []byte) error { - type unmarshaler Foo - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = Foo(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - return nil -} - -func (f *Foo) String() string { - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} - -type Union struct { - Type string - Value *Value - AnotherValue *Value - Bar *bar.Bar - AnotherBar *bar.Bar -} - -func NewUnionFromValue(value *Value) *Union { - return &Union{Type: "value", Value: value} -} - -func NewUnionFromAnotherValue(value *Value) *Union { - return &Union{Type: "anotherValue", AnotherValue: value} -} - -func NewUnionFromBar(value *bar.Bar) *Union { - return &Union{Type: "bar", Bar: value} -} - -func NewUnionFromAnotherBar(value *bar.Bar) *Union { - return &Union{Type: "anotherBar", AnotherBar: value} -} - -func (u *Union) GetType() string { - if u == nil { - return "" - } - return u.Type -} - -func (u *Union) GetValue() *Value { - if u == nil { - return nil - } - return u.Value -} - -func (u *Union) GetAnotherValue() *Value { - if u == nil { - return nil - } - return u.AnotherValue -} - -func (u *Union) GetBar() *bar.Bar { - if u == nil { - return nil - } - return u.Bar -} - -func (u *Union) GetAnotherBar() *bar.Bar { - if u == nil { - return nil - } - return u.AnotherBar -} - -func (u *Union) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - u.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", u) - } - switch unmarshaler.Type { - case "value": - value := new(Value) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - u.Value = value - case "anotherValue": - var valueUnmarshaler struct { - AnotherValue *Value `json:"anotherValue,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - u.AnotherValue = valueUnmarshaler.AnotherValue - case "bar": - value := new(bar.Bar) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - u.Bar = value - case "anotherBar": - var valueUnmarshaler struct { - AnotherBar *bar.Bar `json:"anotherBar,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - u.AnotherBar = valueUnmarshaler.AnotherBar - } - return nil -} - -func (u Union) MarshalJSON() ([]byte, error) { - switch u.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", u.Type, u) - case "value": - return core.MarshalJSONWithExtraProperty(u.Value, "type", "value") - case "anotherValue": - var marshaler = struct { - Type string `json:"type"` - AnotherValue *Value `json:"anotherValue,omitempty"` - }{ - Type: "anotherValue", - AnotherValue: u.AnotherValue, - } - return json.Marshal(marshaler) - case "bar": - return core.MarshalJSONWithExtraProperty(u.Bar, "type", "bar") - case "anotherBar": - var marshaler = struct { - Type string `json:"type"` - AnotherBar *bar.Bar `json:"anotherBar,omitempty"` - }{ - Type: "anotherBar", - AnotherBar: u.AnotherBar, - } - return json.Marshal(marshaler) - } -} - -type UnionVisitor interface { - VisitValue(*Value) error - VisitAnotherValue(*Value) error - VisitBar(*bar.Bar) error - VisitAnotherBar(*bar.Bar) error -} - -func (u *Union) Accept(visitor UnionVisitor) error { - switch u.Type { - default: - return fmt.Errorf("invalid type %s in %T", u.Type, u) - case "value": - return visitor.VisitValue(u.Value) - case "anotherValue": - return visitor.VisitAnotherValue(u.AnotherValue) - case "bar": - return visitor.VisitBar(u.Bar) - case "anotherBar": - return visitor.VisitAnotherBar(u.AnotherBar) - } -} diff --git a/generators/go/internal/testdata/model/packages/fixtures/union.go b/generators/go/internal/testdata/model/packages/fixtures/union.go new file mode 100644 index 00000000000..dd45a7b6a1b --- /dev/null +++ b/generators/go/internal/testdata/model/packages/fixtures/union.go @@ -0,0 +1,164 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + bar "github.com/fern-api/fern-go/internal/testdata/model/packages/fixtures/bar" + core "github.com/fern-api/fern-go/internal/testdata/model/packages/fixtures/core" +) + +type Union struct { + Type string + Value *Value + AnotherValue *Value + Bar *bar.Bar + AnotherBar *bar.Bar +} + +func NewUnionFromValue(value *Value) *Union { + return &Union{Type: "value", Value: value} +} + +func NewUnionFromAnotherValue(value *Value) *Union { + return &Union{Type: "anotherValue", AnotherValue: value} +} + +func NewUnionFromBar(value *bar.Bar) *Union { + return &Union{Type: "bar", Bar: value} +} + +func NewUnionFromAnotherBar(value *bar.Bar) *Union { + return &Union{Type: "anotherBar", AnotherBar: value} +} + +func (u *Union) GetType() string { + if u == nil { + return "" + } + return u.Type +} + +func (u *Union) GetValue() *Value { + if u == nil { + return nil + } + return u.Value +} + +func (u *Union) GetAnotherValue() *Value { + if u == nil { + return nil + } + return u.AnotherValue +} + +func (u *Union) GetBar() *bar.Bar { + if u == nil { + return nil + } + return u.Bar +} + +func (u *Union) GetAnotherBar() *bar.Bar { + if u == nil { + return nil + } + return u.AnotherBar +} + +func (u *Union) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + u.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", u) + } + switch unmarshaler.Type { + case "value": + value := new(Value) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + u.Value = value + case "anotherValue": + var valueUnmarshaler struct { + AnotherValue *Value `json:"anotherValue,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + u.AnotherValue = valueUnmarshaler.AnotherValue + case "bar": + value := new(bar.Bar) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + u.Bar = value + case "anotherBar": + var valueUnmarshaler struct { + AnotherBar *bar.Bar `json:"anotherBar,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + u.AnotherBar = valueUnmarshaler.AnotherBar + } + return nil +} + +func (u Union) MarshalJSON() ([]byte, error) { + switch u.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", u.Type, u) + case "value": + return core.MarshalJSONWithExtraProperty(u.Value, "type", "value") + case "anotherValue": + var marshaler = struct { + Type string `json:"type"` + AnotherValue *Value `json:"anotherValue,omitempty"` + }{ + Type: "anotherValue", + AnotherValue: u.AnotherValue, + } + return json.Marshal(marshaler) + case "bar": + return core.MarshalJSONWithExtraProperty(u.Bar, "type", "bar") + case "anotherBar": + var marshaler = struct { + Type string `json:"type"` + AnotherBar *bar.Bar `json:"anotherBar,omitempty"` + }{ + Type: "anotherBar", + AnotherBar: u.AnotherBar, + } + return json.Marshal(marshaler) + } +} + +type UnionVisitor interface { + VisitValue(*Value) error + VisitAnotherValue(*Value) error + VisitBar(*bar.Bar) error + VisitAnotherBar(*bar.Bar) error +} + +func (u *Union) Accept(visitor UnionVisitor) error { + switch u.Type { + default: + return fmt.Errorf("invalid type %s in %T", u.Type, u) + case "value": + return visitor.VisitValue(u.Value) + case "anotherValue": + return visitor.VisitAnotherValue(u.AnotherValue) + case "bar": + return visitor.VisitBar(u.Bar) + case "anotherBar": + return visitor.VisitAnotherBar(u.AnotherBar) + } +} diff --git a/generators/go/internal/testdata/model/primitive/fixtures/types.go b/generators/go/internal/testdata/model/primitive/fixtures/imdb.go similarity index 100% rename from generators/go/internal/testdata/model/primitive/fixtures/types.go rename to generators/go/internal/testdata/model/primitive/fixtures/imdb.go diff --git a/generators/go/internal/testdata/model/string/fixtures/types.go b/generators/go/internal/testdata/model/string/fixtures/imdb.go similarity index 100% rename from generators/go/internal/testdata/model/string/fixtures/types.go rename to generators/go/internal/testdata/model/string/fixtures/imdb.go diff --git a/generators/go/internal/testdata/model/sum/fixtures/bar/types.go b/generators/go/internal/testdata/model/sum/fixtures/bar/bar.go similarity index 100% rename from generators/go/internal/testdata/model/sum/fixtures/bar/types.go rename to generators/go/internal/testdata/model/sum/fixtures/bar/bar.go diff --git a/generators/go/internal/testdata/model/sum/fixtures/types.go b/generators/go/internal/testdata/model/sum/fixtures/foo.go similarity index 100% rename from generators/go/internal/testdata/model/sum/fixtures/types.go rename to generators/go/internal/testdata/model/sum/fixtures/foo.go diff --git a/generators/go/internal/testdata/model/undiscriminated/fixtures/types.go b/generators/go/internal/testdata/model/undiscriminated/fixtures/imdb.go similarity index 100% rename from generators/go/internal/testdata/model/undiscriminated/fixtures/types.go rename to generators/go/internal/testdata/model/undiscriminated/fixtures/imdb.go diff --git a/generators/go/internal/testdata/model/union/fixtures/types.go b/generators/go/internal/testdata/model/union/fixtures/imdb.go similarity index 100% rename from generators/go/internal/testdata/model/union/fixtures/types.go rename to generators/go/internal/testdata/model/union/fixtures/imdb.go diff --git a/generators/go/internal/testdata/sdk/cycle/fixtures/common/identity/types.go b/generators/go/internal/testdata/sdk/cycle/fixtures/common/identity/common.go similarity index 100% rename from generators/go/internal/testdata/sdk/cycle/fixtures/common/identity/types.go rename to generators/go/internal/testdata/sdk/cycle/fixtures/common/identity/common.go diff --git a/generators/go/internal/testdata/sdk/cycle/fixtures/common/user/types.go b/generators/go/internal/testdata/sdk/cycle/fixtures/common/user/common.go similarity index 100% rename from generators/go/internal/testdata/sdk/cycle/fixtures/common/user/types.go rename to generators/go/internal/testdata/sdk/cycle/fixtures/common/user/common.go diff --git a/generators/go/internal/testdata/sdk/cycle/fixtures/identity/types.go b/generators/go/internal/testdata/sdk/cycle/fixtures/identity/identity.go similarity index 100% rename from generators/go/internal/testdata/sdk/cycle/fixtures/identity/types.go rename to generators/go/internal/testdata/sdk/cycle/fixtures/identity/identity.go diff --git a/generators/go/internal/testdata/sdk/docs/fixtures/types.go b/generators/go/internal/testdata/sdk/docs/fixtures/types.go deleted file mode 100644 index e6f1edd6f54..00000000000 --- a/generators/go/internal/testdata/sdk/docs/fixtures/types.go +++ /dev/null @@ -1,58 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/fern-api/fern-go/internal/testdata/sdk/docs/fixtures/core" -) - -// A user. -type User struct { - Name string `json:"name" url:"name"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (u *User) GetName() string { - if u == nil { - return "" - } - return u.Name -} - -func (u *User) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *User) UnmarshalJSON(data []byte) error { - type unmarshaler User - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = User(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *User) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/generators/go/internal/testdata/sdk/docs/fixtures/user.go b/generators/go/internal/testdata/sdk/docs/fixtures/user.go index 0215afe6a9e..68b6f1e887d 100644 --- a/generators/go/internal/testdata/sdk/docs/fixtures/user.go +++ b/generators/go/internal/testdata/sdk/docs/fixtures/user.go @@ -2,9 +2,64 @@ package api +import ( + json "encoding/json" + fmt "fmt" + core "github.com/fern-api/fern-go/internal/testdata/sdk/docs/fixtures/core" +) + type GetNameRequest struct { // Specifies the endpoint key. XEndpointHeader string `json:"-" url:"-"` // Filters the username. Filter string `json:"-" url:"filter"` } + +// A user. +type User struct { + Name string `json:"name" url:"name"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (u *User) GetName() string { + if u == nil { + return "" + } + return u.Name +} + +func (u *User) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *User) UnmarshalJSON(data []byte) error { + type unmarshaler User + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = User(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *User) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} diff --git a/generators/go/internal/testdata/sdk/error-discrimination/fixtures/types.go b/generators/go/internal/testdata/sdk/error-discrimination/fixtures/user.go similarity index 100% rename from generators/go/internal/testdata/sdk/error-discrimination/fixtures/types.go rename to generators/go/internal/testdata/sdk/error-discrimination/fixtures/user.go diff --git a/generators/go/internal/testdata/sdk/error/fixtures/types.go b/generators/go/internal/testdata/sdk/error/fixtures/user.go similarity index 100% rename from generators/go/internal/testdata/sdk/error/fixtures/types.go rename to generators/go/internal/testdata/sdk/error/fixtures/user.go diff --git a/generators/go/internal/testdata/sdk/packages/fixtures/config/types.go b/generators/go/internal/testdata/sdk/packages/fixtures/config/config.go similarity index 100% rename from generators/go/internal/testdata/sdk/packages/fixtures/config/types.go rename to generators/go/internal/testdata/sdk/packages/fixtures/config/config.go diff --git a/generators/go/internal/testdata/sdk/packages/fixtures/organization/metrics/types.go b/generators/go/internal/testdata/sdk/packages/fixtures/organization/metrics/tag.go similarity index 100% rename from generators/go/internal/testdata/sdk/packages/fixtures/organization/metrics/types.go rename to generators/go/internal/testdata/sdk/packages/fixtures/organization/metrics/tag.go diff --git a/generators/go/internal/testdata/sdk/packages/fixtures/user/notification/types.go b/generators/go/internal/testdata/sdk/packages/fixtures/user/notification/notification.go similarity index 100% rename from generators/go/internal/testdata/sdk/packages/fixtures/user/notification/types.go rename to generators/go/internal/testdata/sdk/packages/fixtures/user/notification/notification.go diff --git a/generators/go/internal/testdata/sdk/packages/fixtures/user/types.go b/generators/go/internal/testdata/sdk/packages/fixtures/user/types.go deleted file mode 100644 index 12ee2c6eddc..00000000000 --- a/generators/go/internal/testdata/sdk/packages/fixtures/user/types.go +++ /dev/null @@ -1,65 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package user - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/fern-api/fern-go/internal/testdata/sdk/packages/fixtures/core" -) - -type User struct { - Id string `json:"id" url:"id"` - Name string `json:"name" url:"name"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (u *User) GetId() string { - if u == nil { - return "" - } - return u.Id -} - -func (u *User) GetName() string { - if u == nil { - return "" - } - return u.Name -} - -func (u *User) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *User) UnmarshalJSON(data []byte) error { - type unmarshaler User - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = User(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *User) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/generators/go/internal/testdata/sdk/packages/fixtures/user/user.go b/generators/go/internal/testdata/sdk/packages/fixtures/user/user.go index 31d6b9ea4e2..9200938ff72 100644 --- a/generators/go/internal/testdata/sdk/packages/fixtures/user/user.go +++ b/generators/go/internal/testdata/sdk/packages/fixtures/user/user.go @@ -2,6 +2,68 @@ package user +import ( + json "encoding/json" + fmt "fmt" + core "github.com/fern-api/fern-go/internal/testdata/sdk/packages/fixtures/core" +) + type CreateUserRequest struct { Name string `json:"name" url:"-"` } + +type User struct { + Id string `json:"id" url:"id"` + Name string `json:"name" url:"name"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (u *User) GetId() string { + if u == nil { + return "" + } + return u.Id +} + +func (u *User) GetName() string { + if u == nil { + return "" + } + return u.Name +} + +func (u *User) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *User) UnmarshalJSON(data []byte) error { + type unmarshaler User + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = User(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *User) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} diff --git a/generators/go/internal/testdata/sdk/post-with-path-params-generics/fixtures/types.go b/generators/go/internal/testdata/sdk/post-with-path-params-generics/fixtures/types.go deleted file mode 100644 index 9b72330c12a..00000000000 --- a/generators/go/internal/testdata/sdk/post-with-path-params-generics/fixtures/types.go +++ /dev/null @@ -1,105 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - core "acme.io/sdk/core" - json "encoding/json" - fmt "fmt" -) - -type Bar struct { - Id string `json:"id" url:"id"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (b *Bar) GetId() string { - if b == nil { - return "" - } - return b.Id -} - -func (b *Bar) GetExtraProperties() map[string]interface{} { - return b.extraProperties -} - -func (b *Bar) UnmarshalJSON(data []byte) error { - type unmarshaler Bar - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *b = Bar(value) - - extraProperties, err := core.ExtractExtraProperties(data, *b) - if err != nil { - return err - } - b.extraProperties = extraProperties - - b._rawJSON = json.RawMessage(data) - return nil -} - -func (b *Bar) String() string { - if len(b._rawJSON) > 0 { - if value, err := core.StringifyJSON(b._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(b); err == nil { - return value - } - return fmt.Sprintf("%#v", b) -} - -type Foo struct { - Id string `json:"id" url:"id"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (f *Foo) GetId() string { - if f == nil { - return "" - } - return f.Id -} - -func (f *Foo) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *Foo) UnmarshalJSON(data []byte) error { - type unmarshaler Foo - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = Foo(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - f._rawJSON = json.RawMessage(data) - return nil -} - -func (f *Foo) String() string { - if len(f._rawJSON) > 0 { - if value, err := core.StringifyJSON(f._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} diff --git a/generators/go/internal/testdata/sdk/post-with-path-params-generics/fixtures/user.go b/generators/go/internal/testdata/sdk/post-with-path-params-generics/fixtures/user.go index 3f33fa6f847..c540b805afa 100644 --- a/generators/go/internal/testdata/sdk/post-with-path-params-generics/fixtures/user.go +++ b/generators/go/internal/testdata/sdk/post-with-path-params-generics/fixtures/user.go @@ -87,6 +87,54 @@ func (s *SetNameRequestV5) MarshalJSON() ([]byte, error) { return json.Marshal("fern") } +type Bar struct { + Id string `json:"id" url:"id"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (b *Bar) GetId() string { + if b == nil { + return "" + } + return b.Id +} + +func (b *Bar) GetExtraProperties() map[string]interface{} { + return b.extraProperties +} + +func (b *Bar) UnmarshalJSON(data []byte) error { + type unmarshaler Bar + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *b = Bar(value) + + extraProperties, err := core.ExtractExtraProperties(data, *b) + if err != nil { + return err + } + b.extraProperties = extraProperties + + b._rawJSON = json.RawMessage(data) + return nil +} + +func (b *Bar) String() string { + if len(b._rawJSON) > 0 { + if value, err := core.StringifyJSON(b._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(b); err == nil { + return value + } + return fmt.Sprintf("%#v", b) +} + type Filter struct { Tag string `json:"tag" url:"tag"` @@ -135,6 +183,54 @@ func (f *Filter) String() string { return fmt.Sprintf("%#v", f) } +type Foo struct { + Id string `json:"id" url:"id"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (f *Foo) GetId() string { + if f == nil { + return "" + } + return f.Id +} + +func (f *Foo) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *Foo) UnmarshalJSON(data []byte) error { + type unmarshaler Foo + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = Foo(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + f._rawJSON = json.RawMessage(data) + return nil +} + +func (f *Foo) String() string { + if len(f._rawJSON) > 0 { + if value, err := core.StringifyJSON(f._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + type SetNameRequestV3Body struct { UserName string `json:"userName" url:"userName"` diff --git a/generators/go/internal/testdata/sdk/post-with-path-params/fixtures/types.go b/generators/go/internal/testdata/sdk/post-with-path-params/fixtures/types.go deleted file mode 100644 index 7749fa60c92..00000000000 --- a/generators/go/internal/testdata/sdk/post-with-path-params/fixtures/types.go +++ /dev/null @@ -1,105 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/fern-api/fern-go/internal/testdata/sdk/post-with-path-params/fixtures/core" -) - -type Bar struct { - Id string `json:"id" url:"id"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (b *Bar) GetId() string { - if b == nil { - return "" - } - return b.Id -} - -func (b *Bar) GetExtraProperties() map[string]interface{} { - return b.extraProperties -} - -func (b *Bar) UnmarshalJSON(data []byte) error { - type unmarshaler Bar - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *b = Bar(value) - - extraProperties, err := core.ExtractExtraProperties(data, *b) - if err != nil { - return err - } - b.extraProperties = extraProperties - - b._rawJSON = json.RawMessage(data) - return nil -} - -func (b *Bar) String() string { - if len(b._rawJSON) > 0 { - if value, err := core.StringifyJSON(b._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(b); err == nil { - return value - } - return fmt.Sprintf("%#v", b) -} - -type Foo struct { - Id string `json:"id" url:"id"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (f *Foo) GetId() string { - if f == nil { - return "" - } - return f.Id -} - -func (f *Foo) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *Foo) UnmarshalJSON(data []byte) error { - type unmarshaler Foo - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = Foo(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - f._rawJSON = json.RawMessage(data) - return nil -} - -func (f *Foo) String() string { - if len(f._rawJSON) > 0 { - if value, err := core.StringifyJSON(f._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} diff --git a/generators/go/internal/testdata/sdk/post-with-path-params/fixtures/user.go b/generators/go/internal/testdata/sdk/post-with-path-params/fixtures/user.go index 29b334cb5f9..ab4e23a1d96 100644 --- a/generators/go/internal/testdata/sdk/post-with-path-params/fixtures/user.go +++ b/generators/go/internal/testdata/sdk/post-with-path-params/fixtures/user.go @@ -114,6 +114,54 @@ func (s *SetNameRequestV5) MarshalJSON() ([]byte, error) { return json.Marshal("fern") } +type Bar struct { + Id string `json:"id" url:"id"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (b *Bar) GetId() string { + if b == nil { + return "" + } + return b.Id +} + +func (b *Bar) GetExtraProperties() map[string]interface{} { + return b.extraProperties +} + +func (b *Bar) UnmarshalJSON(data []byte) error { + type unmarshaler Bar + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *b = Bar(value) + + extraProperties, err := core.ExtractExtraProperties(data, *b) + if err != nil { + return err + } + b.extraProperties = extraProperties + + b._rawJSON = json.RawMessage(data) + return nil +} + +func (b *Bar) String() string { + if len(b._rawJSON) > 0 { + if value, err := core.StringifyJSON(b._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(b); err == nil { + return value + } + return fmt.Sprintf("%#v", b) +} + type Filter struct { Tag string `json:"tag" url:"tag"` @@ -162,6 +210,54 @@ func (f *Filter) String() string { return fmt.Sprintf("%#v", f) } +type Foo struct { + Id string `json:"id" url:"id"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (f *Foo) GetId() string { + if f == nil { + return "" + } + return f.Id +} + +func (f *Foo) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *Foo) UnmarshalJSON(data []byte) error { + type unmarshaler Foo + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = Foo(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + f._rawJSON = json.RawMessage(data) + return nil +} + +func (f *Foo) String() string { + if len(f._rawJSON) > 0 { + if value, err := core.StringifyJSON(f._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + type SetNameRequestV3Body struct { UserName string `json:"userName" url:"userName"` diff --git a/generators/go/sdk/versions.yml b/generators/go/sdk/versions.yml index d35af163c57..4b356de9609 100644 --- a/generators/go/sdk/versions.yml +++ b/generators/go/sdk/versions.yml @@ -1,3 +1,13 @@ +- version: 0.31.0 + changelogEntry: + - type: feat + summary: >- + Improves type file layout with zero impact on backwards compatibility. + + Shared types are now more accurately placed in the `types.go` file, + whereas types referenced by a single service are now placed in a file + that matches the service's filename (e.g. user.go). + irVersion: 53 - version: 0.30.0 changelogEntry: - type: feat diff --git a/packages/cli/cli/versions.yml b/packages/cli/cli/versions.yml index a6298897cae..a26a2a3cc3b 100644 --- a/packages/cli/cli/versions.yml +++ b/packages/cli/cli/versions.yml @@ -1,3 +1,11 @@ +- changelogEntry: + - summary: | + Update the IR's `ServiceTypeReferenceInfo` to include all transitive types + referenced by a service. + type: fix + irVersion: 53 + version: 0.45.0-rc44 + - changelogEntry: - summary: | Support non-standard HTTP code 498; Validate `x-fern-examples` during schema parsing. diff --git a/packages/cli/ete-tests/src/tests/ir/__snapshots__/ir.test.ts.snap b/packages/cli/ete-tests/src/tests/ir/__snapshots__/ir.test.ts.snap index bd1435be8e2..937ce1c0af5 100644 --- a/packages/cli/ete-tests/src/tests/ir/__snapshots__/ir.test.ts.snap +++ b/packages/cli/ete-tests/src/tests/ir/__snapshots__/ir.test.ts.snap @@ -12,11 +12,11 @@ exports[`ir > {"name":"multiple-environment-urls"} 1`] = `"{"fdrApiDefinitionId" exports[`ir > {"name":"navigation-points-to"} 1`] = `"{"fdrApiDefinitionId":null,"apiVersion":null,"apiName":{"originalName":"my-api","camelCase":{"unsafeName":"myApi","safeName":"myApi"},"snakeCase":{"unsafeName":"my_api","safeName":"my_api"},"screamingSnakeCase":{"unsafeName":"MY_API","safeName":"MY_API"},"pascalCase":{"unsafeName":"MyApi","safeName":"MyApi"}},"apiDisplayName":null,"apiDocs":null,"auth":{"requirement":"ALL","schemes":[],"docs":null},"headers":[],"idempotencyHeaders":[],"types":{},"errors":{},"services":{},"constants":{"errorInstanceIdKey":{"name":{"originalName":"errorInstanceId","camelCase":{"unsafeName":"errorInstanceId","safeName":"errorInstanceId"},"snakeCase":{"unsafeName":"error_instance_id","safeName":"error_instance_id"},"screamingSnakeCase":{"unsafeName":"ERROR_INSTANCE_ID","safeName":"ERROR_INSTANCE_ID"},"pascalCase":{"unsafeName":"ErrorInstanceId","safeName":"ErrorInstanceId"}},"wireValue":"errorInstanceId"}},"environments":null,"errorDiscriminationStrategy":{"type":"statusCode"},"basePath":null,"pathParameters":[],"variables":[],"serviceTypeReferenceInfo":{"typesReferencedOnlyByService":{},"sharedTypes":[]},"webhookGroups":{},"websocketChannels":{},"readmeConfig":null,"sourceConfig":null,"publishConfig":null,"subpackages":{"subpackage_subpackage":{"name":{"originalName":"subpackage","camelCase":{"unsafeName":"subpackage","safeName":"subpackage"},"snakeCase":{"unsafeName":"subpackage","safeName":"subpackage"},"screamingSnakeCase":{"unsafeName":"SUBPACKAGE","safeName":"SUBPACKAGE"},"pascalCase":{"unsafeName":"Subpackage","safeName":"Subpackage"}},"fernFilepath":{"allParts":[{"originalName":"subpackage","camelCase":{"unsafeName":"subpackage","safeName":"subpackage"},"snakeCase":{"unsafeName":"subpackage","safeName":"subpackage"},"screamingSnakeCase":{"unsafeName":"SUBPACKAGE","safeName":"SUBPACKAGE"},"pascalCase":{"unsafeName":"Subpackage","safeName":"Subpackage"}}],"packagePath":[{"originalName":"subpackage","camelCase":{"unsafeName":"subpackage","safeName":"subpackage"},"snakeCase":{"unsafeName":"subpackage","safeName":"subpackage"},"screamingSnakeCase":{"unsafeName":"SUBPACKAGE","safeName":"SUBPACKAGE"},"pascalCase":{"unsafeName":"Subpackage","safeName":"Subpackage"}}],"file":null},"service":null,"types":[],"errors":[],"subpackages":["subpackage_subpackage/x"],"navigationConfig":null,"webhooks":null,"websocket":null,"hasEndpointsInTree":false,"docs":null},"subpackage_subpackage/x":{"name":{"originalName":"x","camelCase":{"unsafeName":"x","safeName":"x"},"snakeCase":{"unsafeName":"x","safeName":"x"},"screamingSnakeCase":{"unsafeName":"X","safeName":"X"},"pascalCase":{"unsafeName":"X","safeName":"X"}},"fernFilepath":{"allParts":[{"originalName":"subpackage","camelCase":{"unsafeName":"subpackage","safeName":"subpackage"},"snakeCase":{"unsafeName":"subpackage","safeName":"subpackage"},"screamingSnakeCase":{"unsafeName":"SUBPACKAGE","safeName":"SUBPACKAGE"},"pascalCase":{"unsafeName":"Subpackage","safeName":"Subpackage"}},{"originalName":"x","camelCase":{"unsafeName":"x","safeName":"x"},"snakeCase":{"unsafeName":"x","safeName":"x"},"screamingSnakeCase":{"unsafeName":"X","safeName":"X"},"pascalCase":{"unsafeName":"X","safeName":"X"}}],"packagePath":[{"originalName":"subpackage","camelCase":{"unsafeName":"subpackage","safeName":"subpackage"},"snakeCase":{"unsafeName":"subpackage","safeName":"subpackage"},"screamingSnakeCase":{"unsafeName":"SUBPACKAGE","safeName":"SUBPACKAGE"},"pascalCase":{"unsafeName":"Subpackage","safeName":"Subpackage"}}],"file":{"originalName":"x","camelCase":{"unsafeName":"x","safeName":"x"},"snakeCase":{"unsafeName":"x","safeName":"x"},"screamingSnakeCase":{"unsafeName":"X","safeName":"X"},"pascalCase":{"unsafeName":"X","safeName":"X"}}},"service":null,"types":[],"errors":[],"subpackages":[],"navigationConfig":null,"webhooks":null,"websocket":null,"hasEndpointsInTree":false,"docs":null}},"rootPackage":{"fernFilepath":{"allParts":[],"packagePath":[],"file":null},"websocket":null,"service":null,"types":[],"errors":[],"subpackages":["subpackage_subpackage"],"webhooks":null,"navigationConfig":{"pointsTo":"subpackage_subpackage"},"hasEndpointsInTree":false,"docs":null},"sdkConfig":{"isAuthMandatory":false,"hasStreamingEndpoints":false,"hasPaginatedEndpoints":false,"hasFileDownloadEndpoints":false,"platformHeaders":{"language":"X-Fern-Language","sdkName":"X-Fern-SDK-Name","sdkVersion":"X-Fern-SDK-Version","userAgent":null}}}"`; -exports[`ir > {"name":"nested-example-reference"} 1`] = `"{"fdrApiDefinitionId":null,"apiVersion":null,"apiName":{"originalName":"api","camelCase":{"unsafeName":"api","safeName":"api"},"snakeCase":{"unsafeName":"api","safeName":"api"},"screamingSnakeCase":{"unsafeName":"API","safeName":"API"},"pascalCase":{"unsafeName":"Api","safeName":"Api"}},"apiDisplayName":null,"apiDocs":null,"auth":{"requirement":"ALL","schemes":[{"_type":"basic","username":{"originalName":"clientId","camelCase":{"unsafeName":"clientId","safeName":"clientId"},"snakeCase":{"unsafeName":"client_id","safeName":"client_id"},"screamingSnakeCase":{"unsafeName":"CLIENT_ID","safeName":"CLIENT_ID"},"pascalCase":{"unsafeName":"ClientId","safeName":"ClientId"}},"usernameEnvVar":null,"password":{"originalName":"clientSecret","camelCase":{"unsafeName":"clientSecret","safeName":"clientSecret"},"snakeCase":{"unsafeName":"client_secret","safeName":"client_secret"},"screamingSnakeCase":{"unsafeName":"CLIENT_SECRET","safeName":"CLIENT_SECRET"},"pascalCase":{"unsafeName":"ClientSecret","safeName":"ClientSecret"}},"passwordEnvVar":null,"docs":null}],"docs":null},"headers":[],"idempotencyHeaders":[],"types":{"type_nested:Response":{"inline":false,"name":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Response"},"shape":{"_type":"object","extends":[],"properties":[{"name":{"name":{"originalName":"a","camelCase":{"unsafeName":"a","safeName":"a"},"snakeCase":{"unsafeName":"a","safeName":"a"},"screamingSnakeCase":{"unsafeName":"A","safeName":"A"},"pascalCase":{"unsafeName":"A","safeName":"A"}},"wireValue":"a"},"valueType":{"_type":"container","container":{"_type":"optional","optional":{"_type":"container","container":{"_type":"map","keyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"valueType":{"_type":"named","name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product","default":null,"inline":null}}}}},"availability":null,"docs":null}],"extra-properties":false,"extendedProperties":[]},"referencedTypes":["type_nested:Product"],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null},"type_nested:Product":{"inline":false,"name":{"name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product"},"shape":{"_type":"object","extends":[],"properties":[{"name":{"name":{"originalName":"c","camelCase":{"unsafeName":"c","safeName":"c"},"snakeCase":{"unsafeName":"c","safeName":"c"},"screamingSnakeCase":{"unsafeName":"C","safeName":"C"},"pascalCase":{"unsafeName":"C","safeName":"C"}},"wireValue":"c"},"valueType":{"_type":"container","container":{"_type":"optional","optional":{"_type":"unknown"}}},"availability":null,"docs":null}],"extra-properties":false,"extendedProperties":[]},"referencedTypes":[],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null},"type_nested:StringAlias":{"inline":false,"name":{"name":{"originalName":"StringAlias","camelCase":{"unsafeName":"stringAlias","safeName":"stringAlias"},"snakeCase":{"unsafeName":"string_alias","safeName":"string_alias"},"screamingSnakeCase":{"unsafeName":"STRING_ALIAS","safeName":"STRING_ALIAS"},"pascalCase":{"unsafeName":"StringAlias","safeName":"StringAlias"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:StringAlias"},"shape":{"_type":"alias","aliasOf":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"resolvedType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}}},"referencedTypes":[],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[{"name":{"originalName":"Example","camelCase":{"unsafeName":"example","safeName":"example"},"snakeCase":{"unsafeName":"example","safeName":"example"},"screamingSnakeCase":{"unsafeName":"EXAMPLE","safeName":"EXAMPLE"},"pascalCase":{"unsafeName":"Example","safeName":"Example"}},"shape":{"type":"alias","value":{"shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"hello"}}},"jsonExample":"hello"}},"jsonExample":"hello","docs":null}],"autogeneratedExamples":[],"availability":null,"docs":null}},"errors":{},"services":{"service_nested":{"availability":null,"name":{"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}}},"displayName":null,"basePath":{"head":"/nested","parts":[]},"headers":[],"pathParameters":[],"encoding":{"json":{},"proto":null},"transport":{"type":"http"},"endpoints":[{"id":"endpoint_nested.calculate","name":{"originalName":"calculate","camelCase":{"unsafeName":"calculate","safeName":"calculate"},"snakeCase":{"unsafeName":"calculate","safeName":"calculate"},"screamingSnakeCase":{"unsafeName":"CALCULATE","safeName":"CALCULATE"},"pascalCase":{"unsafeName":"Calculate","safeName":"Calculate"}},"displayName":null,"auth":true,"idempotent":false,"baseUrl":null,"method":"POST","basePath":null,"path":{"head":"","parts":[]},"fullPath":{"head":"/nested","parts":[]},"pathParameters":[],"allPathParameters":[],"queryParameters":[],"headers":[],"requestBody":null,"sdkRequest":null,"response":{"body":{"type":"json","value":{"type":"response","responseBodyType":{"_type":"named","name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Response","default":null,"inline":null},"docs":null}},"status-code":null},"errors":[],"userSpecifiedExamples":[{"example":{"id":"5a6f08f1a5b7c467c617c891b9b6e1f85c3cdaa17c9bc1a56012234eeb809937","name":null,"url":"/nested","rootPathParameters":[],"endpointPathParameters":[],"servicePathParameters":[],"endpointHeaders":[],"serviceHeaders":[],"queryParameters":[],"request":null,"response":{"type":"ok","value":{"type":"body","value":{"shape":{"type":"named","typeName":{"typeId":"type_nested:Response","fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}}},"shape":{"type":"object","properties":[{"name":{"name":{"originalName":"a","camelCase":{"unsafeName":"a","safeName":"a"},"snakeCase":{"unsafeName":"a","safeName":"a"},"screamingSnakeCase":{"unsafeName":"A","safeName":"A"},"pascalCase":{"unsafeName":"A","safeName":"A"}},"wireValue":"a"},"value":{"shape":{"type":"container","container":{"type":"optional","optional":{"shape":{"type":"container","container":{"type":"map","map":[{"key":{"shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"b"}}},"jsonExample":"b"},"value":{"shape":{"type":"named","typeName":{"typeId":"type_nested:Product","fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}}},"shape":{"type":"object","properties":[{"name":{"name":{"originalName":"c","camelCase":{"unsafeName":"c","safeName":"c"},"snakeCase":{"unsafeName":"c","safeName":"c"},"screamingSnakeCase":{"unsafeName":"C","safeName":"C"},"pascalCase":{"unsafeName":"C","safeName":"C"}},"wireValue":"c"},"value":{"shape":{"type":"container","container":{"type":"optional","optional":{"shape":{"type":"unknown","unknown":{"d":{"e":"$11","f":"hello"}}},"jsonExample":{"d":{"e":"$11","f":"hello"}}},"valueType":{"_type":"unknown"}}},"jsonExample":{"d":{"e":"$11","f":"hello"}}},"originalTypeDeclaration":{"typeId":"type_nested:Product","fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}}}}]}},"jsonExample":{"c":{"d":{"e":"$11","f":"hello"}}}}}],"keyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"valueType":{"_type":"named","name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product","default":null,"inline":null}}},"jsonExample":{"b":{"c":{"d":{"e":"$11","f":"hello"}}}}},"valueType":{"_type":"container","container":{"_type":"map","keyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"valueType":{"_type":"named","name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product","default":null,"inline":null}}}}},"jsonExample":{"b":{"c":{"d":{"e":"$11","f":"hello"}}}}},"originalTypeDeclaration":{"typeId":"type_nested:Response","fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}}}}]}},"jsonExample":{"a":{"b":{"c":{"d":{"e":"$11","f":"hello"}}}}}}}},"docs":null},"codeSamples":null}],"autogeneratedExamples":[{"example":{"id":"e91f0ffaa82ef1376271047c051f6c2a66368ac4","url":"/nested","name":null,"endpointHeaders":[],"endpointPathParameters":[],"queryParameters":[],"servicePathParameters":[],"serviceHeaders":[],"rootPathParameters":[],"request":null,"response":{"type":"ok","value":{"type":"body","value":{"shape":{"type":"named","shape":{"type":"object","properties":[{"name":{"name":{"originalName":"a","camelCase":{"unsafeName":"a","safeName":"a"},"snakeCase":{"unsafeName":"a","safeName":"a"},"screamingSnakeCase":{"unsafeName":"A","safeName":"A"},"pascalCase":{"unsafeName":"A","safeName":"A"}},"wireValue":"a"},"originalTypeDeclaration":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Response"},"value":{"shape":{"type":"container","container":{"type":"optional","optional":{"shape":{"type":"container","container":{"type":"map","map":[{"key":{"shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"a"}}},"jsonExample":"a"},"value":{"shape":{"type":"named","shape":{"type":"object","properties":[{"name":{"name":{"originalName":"c","camelCase":{"unsafeName":"c","safeName":"c"},"snakeCase":{"unsafeName":"c","safeName":"c"},"screamingSnakeCase":{"unsafeName":"C","safeName":"C"},"pascalCase":{"unsafeName":"C","safeName":"C"}},"wireValue":"c"},"originalTypeDeclaration":{"name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product"},"value":{"shape":{"type":"container","container":{"type":"optional","optional":{"shape":{"type":"unknown","unknown":{"key":"value"}},"jsonExample":{"key":"value"}},"valueType":{"_type":"unknown"}}},"jsonExample":{"key":"value"}}}]},"typeName":{"name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product"}},"jsonExample":{"c":{"key":"value"}}}}],"keyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"valueType":{"_type":"named","name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product","default":null,"inline":null}}},"jsonExample":{"a":{"c":{"key":"value"}}}},"valueType":{"_type":"container","container":{"_type":"map","keyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"valueType":{"_type":"named","name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product","default":null,"inline":null}}}}},"jsonExample":{"a":{"c":{"key":"value"}}}}}]},"typeName":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Response"}},"jsonExample":{"a":{"a":{"c":{"key":"value"}}}}}}},"docs":null}}],"pagination":null,"transport":null,"availability":null,"docs":null}]}},"constants":{"errorInstanceIdKey":{"name":{"originalName":"errorInstanceId","camelCase":{"unsafeName":"errorInstanceId","safeName":"errorInstanceId"},"snakeCase":{"unsafeName":"error_instance_id","safeName":"error_instance_id"},"screamingSnakeCase":{"unsafeName":"ERROR_INSTANCE_ID","safeName":"ERROR_INSTANCE_ID"},"pascalCase":{"unsafeName":"ErrorInstanceId","safeName":"ErrorInstanceId"}},"wireValue":"errorInstanceId"}},"environments":null,"errorDiscriminationStrategy":{"type":"statusCode"},"basePath":null,"pathParameters":[],"variables":[],"serviceTypeReferenceInfo":{"typesReferencedOnlyByService":{"service_nested":["type_nested:Response"]},"sharedTypes":["type_nested:Product","type_nested:StringAlias"]},"webhookGroups":{},"websocketChannels":{},"readmeConfig":null,"sourceConfig":null,"publishConfig":null,"subpackages":{"subpackage_nested":{"name":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"service":"service_nested","types":["type_nested:Response","type_nested:Product","type_nested:StringAlias"],"errors":[],"subpackages":[],"navigationConfig":null,"webhooks":null,"websocket":null,"hasEndpointsInTree":true,"docs":null}},"rootPackage":{"fernFilepath":{"allParts":[],"packagePath":[],"file":null},"websocket":null,"service":null,"types":[],"errors":[],"subpackages":["subpackage_nested"],"webhooks":null,"navigationConfig":null,"hasEndpointsInTree":true,"docs":null},"sdkConfig":{"isAuthMandatory":true,"hasStreamingEndpoints":false,"hasPaginatedEndpoints":false,"hasFileDownloadEndpoints":false,"platformHeaders":{"language":"X-Fern-Language","sdkName":"X-Fern-SDK-Name","sdkVersion":"X-Fern-SDK-Version","userAgent":null}}}"`; +exports[`ir > {"name":"nested-example-reference"} 1`] = `"{"fdrApiDefinitionId":null,"apiVersion":null,"apiName":{"originalName":"api","camelCase":{"unsafeName":"api","safeName":"api"},"snakeCase":{"unsafeName":"api","safeName":"api"},"screamingSnakeCase":{"unsafeName":"API","safeName":"API"},"pascalCase":{"unsafeName":"Api","safeName":"Api"}},"apiDisplayName":null,"apiDocs":null,"auth":{"requirement":"ALL","schemes":[{"_type":"basic","username":{"originalName":"clientId","camelCase":{"unsafeName":"clientId","safeName":"clientId"},"snakeCase":{"unsafeName":"client_id","safeName":"client_id"},"screamingSnakeCase":{"unsafeName":"CLIENT_ID","safeName":"CLIENT_ID"},"pascalCase":{"unsafeName":"ClientId","safeName":"ClientId"}},"usernameEnvVar":null,"password":{"originalName":"clientSecret","camelCase":{"unsafeName":"clientSecret","safeName":"clientSecret"},"snakeCase":{"unsafeName":"client_secret","safeName":"client_secret"},"screamingSnakeCase":{"unsafeName":"CLIENT_SECRET","safeName":"CLIENT_SECRET"},"pascalCase":{"unsafeName":"ClientSecret","safeName":"ClientSecret"}},"passwordEnvVar":null,"docs":null}],"docs":null},"headers":[],"idempotencyHeaders":[],"types":{"type_nested:Response":{"inline":false,"name":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Response"},"shape":{"_type":"object","extends":[],"properties":[{"name":{"name":{"originalName":"a","camelCase":{"unsafeName":"a","safeName":"a"},"snakeCase":{"unsafeName":"a","safeName":"a"},"screamingSnakeCase":{"unsafeName":"A","safeName":"A"},"pascalCase":{"unsafeName":"A","safeName":"A"}},"wireValue":"a"},"valueType":{"_type":"container","container":{"_type":"optional","optional":{"_type":"container","container":{"_type":"map","keyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"valueType":{"_type":"named","name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product","default":null,"inline":null}}}}},"availability":null,"docs":null}],"extra-properties":false,"extendedProperties":[]},"referencedTypes":["type_nested:Product"],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null},"type_nested:Product":{"inline":false,"name":{"name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product"},"shape":{"_type":"object","extends":[],"properties":[{"name":{"name":{"originalName":"c","camelCase":{"unsafeName":"c","safeName":"c"},"snakeCase":{"unsafeName":"c","safeName":"c"},"screamingSnakeCase":{"unsafeName":"C","safeName":"C"},"pascalCase":{"unsafeName":"C","safeName":"C"}},"wireValue":"c"},"valueType":{"_type":"container","container":{"_type":"optional","optional":{"_type":"unknown"}}},"availability":null,"docs":null}],"extra-properties":false,"extendedProperties":[]},"referencedTypes":[],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null},"type_nested:StringAlias":{"inline":false,"name":{"name":{"originalName":"StringAlias","camelCase":{"unsafeName":"stringAlias","safeName":"stringAlias"},"snakeCase":{"unsafeName":"string_alias","safeName":"string_alias"},"screamingSnakeCase":{"unsafeName":"STRING_ALIAS","safeName":"STRING_ALIAS"},"pascalCase":{"unsafeName":"StringAlias","safeName":"StringAlias"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:StringAlias"},"shape":{"_type":"alias","aliasOf":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"resolvedType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}}},"referencedTypes":[],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[{"name":{"originalName":"Example","camelCase":{"unsafeName":"example","safeName":"example"},"snakeCase":{"unsafeName":"example","safeName":"example"},"screamingSnakeCase":{"unsafeName":"EXAMPLE","safeName":"EXAMPLE"},"pascalCase":{"unsafeName":"Example","safeName":"Example"}},"shape":{"type":"alias","value":{"shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"hello"}}},"jsonExample":"hello"}},"jsonExample":"hello","docs":null}],"autogeneratedExamples":[],"availability":null,"docs":null}},"errors":{},"services":{"service_nested":{"availability":null,"name":{"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}}},"displayName":null,"basePath":{"head":"/nested","parts":[]},"headers":[],"pathParameters":[],"encoding":{"json":{},"proto":null},"transport":{"type":"http"},"endpoints":[{"id":"endpoint_nested.calculate","name":{"originalName":"calculate","camelCase":{"unsafeName":"calculate","safeName":"calculate"},"snakeCase":{"unsafeName":"calculate","safeName":"calculate"},"screamingSnakeCase":{"unsafeName":"CALCULATE","safeName":"CALCULATE"},"pascalCase":{"unsafeName":"Calculate","safeName":"Calculate"}},"displayName":null,"auth":true,"idempotent":false,"baseUrl":null,"method":"POST","basePath":null,"path":{"head":"","parts":[]},"fullPath":{"head":"/nested","parts":[]},"pathParameters":[],"allPathParameters":[],"queryParameters":[],"headers":[],"requestBody":null,"sdkRequest":null,"response":{"body":{"type":"json","value":{"type":"response","responseBodyType":{"_type":"named","name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Response","default":null,"inline":null},"docs":null}},"status-code":null},"errors":[],"userSpecifiedExamples":[{"example":{"id":"5a6f08f1a5b7c467c617c891b9b6e1f85c3cdaa17c9bc1a56012234eeb809937","name":null,"url":"/nested","rootPathParameters":[],"endpointPathParameters":[],"servicePathParameters":[],"endpointHeaders":[],"serviceHeaders":[],"queryParameters":[],"request":null,"response":{"type":"ok","value":{"type":"body","value":{"shape":{"type":"named","typeName":{"typeId":"type_nested:Response","fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}}},"shape":{"type":"object","properties":[{"name":{"name":{"originalName":"a","camelCase":{"unsafeName":"a","safeName":"a"},"snakeCase":{"unsafeName":"a","safeName":"a"},"screamingSnakeCase":{"unsafeName":"A","safeName":"A"},"pascalCase":{"unsafeName":"A","safeName":"A"}},"wireValue":"a"},"value":{"shape":{"type":"container","container":{"type":"optional","optional":{"shape":{"type":"container","container":{"type":"map","map":[{"key":{"shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"b"}}},"jsonExample":"b"},"value":{"shape":{"type":"named","typeName":{"typeId":"type_nested:Product","fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}}},"shape":{"type":"object","properties":[{"name":{"name":{"originalName":"c","camelCase":{"unsafeName":"c","safeName":"c"},"snakeCase":{"unsafeName":"c","safeName":"c"},"screamingSnakeCase":{"unsafeName":"C","safeName":"C"},"pascalCase":{"unsafeName":"C","safeName":"C"}},"wireValue":"c"},"value":{"shape":{"type":"container","container":{"type":"optional","optional":{"shape":{"type":"unknown","unknown":{"d":{"e":"$11","f":"hello"}}},"jsonExample":{"d":{"e":"$11","f":"hello"}}},"valueType":{"_type":"unknown"}}},"jsonExample":{"d":{"e":"$11","f":"hello"}}},"originalTypeDeclaration":{"typeId":"type_nested:Product","fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}}}}]}},"jsonExample":{"c":{"d":{"e":"$11","f":"hello"}}}}}],"keyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"valueType":{"_type":"named","name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product","default":null,"inline":null}}},"jsonExample":{"b":{"c":{"d":{"e":"$11","f":"hello"}}}}},"valueType":{"_type":"container","container":{"_type":"map","keyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"valueType":{"_type":"named","name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product","default":null,"inline":null}}}}},"jsonExample":{"b":{"c":{"d":{"e":"$11","f":"hello"}}}}},"originalTypeDeclaration":{"typeId":"type_nested:Response","fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}}}}]}},"jsonExample":{"a":{"b":{"c":{"d":{"e":"$11","f":"hello"}}}}}}}},"docs":null},"codeSamples":null}],"autogeneratedExamples":[{"example":{"id":"e91f0ffaa82ef1376271047c051f6c2a66368ac4","url":"/nested","name":null,"endpointHeaders":[],"endpointPathParameters":[],"queryParameters":[],"servicePathParameters":[],"serviceHeaders":[],"rootPathParameters":[],"request":null,"response":{"type":"ok","value":{"type":"body","value":{"shape":{"type":"named","shape":{"type":"object","properties":[{"name":{"name":{"originalName":"a","camelCase":{"unsafeName":"a","safeName":"a"},"snakeCase":{"unsafeName":"a","safeName":"a"},"screamingSnakeCase":{"unsafeName":"A","safeName":"A"},"pascalCase":{"unsafeName":"A","safeName":"A"}},"wireValue":"a"},"originalTypeDeclaration":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Response"},"value":{"shape":{"type":"container","container":{"type":"optional","optional":{"shape":{"type":"container","container":{"type":"map","map":[{"key":{"shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"a"}}},"jsonExample":"a"},"value":{"shape":{"type":"named","shape":{"type":"object","properties":[{"name":{"name":{"originalName":"c","camelCase":{"unsafeName":"c","safeName":"c"},"snakeCase":{"unsafeName":"c","safeName":"c"},"screamingSnakeCase":{"unsafeName":"C","safeName":"C"},"pascalCase":{"unsafeName":"C","safeName":"C"}},"wireValue":"c"},"originalTypeDeclaration":{"name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product"},"value":{"shape":{"type":"container","container":{"type":"optional","optional":{"shape":{"type":"unknown","unknown":{"key":"value"}},"jsonExample":{"key":"value"}},"valueType":{"_type":"unknown"}}},"jsonExample":{"key":"value"}}}]},"typeName":{"name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product"}},"jsonExample":{"c":{"key":"value"}}}}],"keyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"valueType":{"_type":"named","name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product","default":null,"inline":null}}},"jsonExample":{"a":{"c":{"key":"value"}}}},"valueType":{"_type":"container","container":{"_type":"map","keyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"valueType":{"_type":"named","name":{"originalName":"Product","camelCase":{"unsafeName":"product","safeName":"product"},"snakeCase":{"unsafeName":"product","safeName":"product"},"screamingSnakeCase":{"unsafeName":"PRODUCT","safeName":"PRODUCT"},"pascalCase":{"unsafeName":"Product","safeName":"Product"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Product","default":null,"inline":null}}}}},"jsonExample":{"a":{"c":{"key":"value"}}}}}]},"typeName":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"typeId":"type_nested:Response"}},"jsonExample":{"a":{"a":{"c":{"key":"value"}}}}}}},"docs":null}}],"pagination":null,"transport":null,"availability":null,"docs":null}]}},"constants":{"errorInstanceIdKey":{"name":{"originalName":"errorInstanceId","camelCase":{"unsafeName":"errorInstanceId","safeName":"errorInstanceId"},"snakeCase":{"unsafeName":"error_instance_id","safeName":"error_instance_id"},"screamingSnakeCase":{"unsafeName":"ERROR_INSTANCE_ID","safeName":"ERROR_INSTANCE_ID"},"pascalCase":{"unsafeName":"ErrorInstanceId","safeName":"ErrorInstanceId"}},"wireValue":"errorInstanceId"}},"environments":null,"errorDiscriminationStrategy":{"type":"statusCode"},"basePath":null,"pathParameters":[],"variables":[],"serviceTypeReferenceInfo":{"typesReferencedOnlyByService":{"service_nested":["type_nested:Response","type_nested:Product"]},"sharedTypes":["type_nested:StringAlias"]},"webhookGroups":{},"websocketChannels":{},"readmeConfig":null,"sourceConfig":null,"publishConfig":null,"subpackages":{"subpackage_nested":{"name":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}},"fernFilepath":{"allParts":[{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}],"packagePath":[],"file":{"originalName":"nested","camelCase":{"unsafeName":"nested","safeName":"nested"},"snakeCase":{"unsafeName":"nested","safeName":"nested"},"screamingSnakeCase":{"unsafeName":"NESTED","safeName":"NESTED"},"pascalCase":{"unsafeName":"Nested","safeName":"Nested"}}},"service":"service_nested","types":["type_nested:Response","type_nested:Product","type_nested:StringAlias"],"errors":[],"subpackages":[],"navigationConfig":null,"webhooks":null,"websocket":null,"hasEndpointsInTree":true,"docs":null}},"rootPackage":{"fernFilepath":{"allParts":[],"packagePath":[],"file":null},"websocket":null,"service":null,"types":[],"errors":[],"subpackages":["subpackage_nested"],"webhooks":null,"navigationConfig":null,"hasEndpointsInTree":true,"docs":null},"sdkConfig":{"isAuthMandatory":true,"hasStreamingEndpoints":false,"hasPaginatedEndpoints":false,"hasFileDownloadEndpoints":false,"platformHeaders":{"language":"X-Fern-Language","sdkName":"X-Fern-SDK-Name","sdkVersion":"X-Fern-SDK-Version","userAgent":null}}}"`; exports[`ir > {"name":"packages"} 1`] = `"{"fdrApiDefinitionId":null,"apiVersion":null,"apiName":{"originalName":"packages","camelCase":{"unsafeName":"packages","safeName":"packages"},"snakeCase":{"unsafeName":"packages","safeName":"packages"},"screamingSnakeCase":{"unsafeName":"PACKAGES","safeName":"PACKAGES"},"pascalCase":{"unsafeName":"Packages","safeName":"Packages"}},"apiDisplayName":null,"apiDocs":null,"auth":{"requirement":"ALL","schemes":[],"docs":null},"headers":[],"idempotencyHeaders":[],"types":{"type_:RootString":{"inline":false,"name":{"name":{"originalName":"RootString","camelCase":{"unsafeName":"rootString","safeName":"rootString"},"snakeCase":{"unsafeName":"root_string","safeName":"root_string"},"screamingSnakeCase":{"unsafeName":"ROOT_STRING","safeName":"ROOT_STRING"},"pascalCase":{"unsafeName":"RootString","safeName":"RootString"}},"fernFilepath":{"allParts":[],"packagePath":[],"file":null},"typeId":"type_:RootString"},"shape":{"_type":"alias","aliasOf":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"resolvedType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}}},"referencedTypes":[],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null},"type_package:PackageString":{"inline":false,"name":{"name":{"originalName":"PackageString","camelCase":{"unsafeName":"packageString","safeName":"packageString"},"snakeCase":{"unsafeName":"package_string","safeName":"package_string"},"screamingSnakeCase":{"unsafeName":"PACKAGE_STRING","safeName":"PACKAGE_STRING"},"pascalCase":{"unsafeName":"PackageString","safeName":"PackageString"}},"fernFilepath":{"allParts":[{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}}],"packagePath":[{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}}],"file":null},"typeId":"type_package:PackageString"},"shape":{"_type":"alias","aliasOf":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"resolvedType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}}},"referencedTypes":[],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null},"type_importer:Foo":{"inline":false,"name":{"name":{"originalName":"Foo","camelCase":{"unsafeName":"foo","safeName":"foo"},"snakeCase":{"unsafeName":"foo","safeName":"foo"},"screamingSnakeCase":{"unsafeName":"FOO","safeName":"FOO"},"pascalCase":{"unsafeName":"Foo","safeName":"Foo"}},"fernFilepath":{"allParts":[{"originalName":"importer","camelCase":{"unsafeName":"importer","safeName":"importer"},"snakeCase":{"unsafeName":"importer","safeName":"importer"},"screamingSnakeCase":{"unsafeName":"IMPORTER","safeName":"IMPORTER"},"pascalCase":{"unsafeName":"Importer","safeName":"Importer"}}],"packagePath":[],"file":{"originalName":"importer","camelCase":{"unsafeName":"importer","safeName":"importer"},"snakeCase":{"unsafeName":"importer","safeName":"importer"},"screamingSnakeCase":{"unsafeName":"IMPORTER","safeName":"IMPORTER"},"pascalCase":{"unsafeName":"Importer","safeName":"Importer"}}},"typeId":"type_importer:Foo"},"shape":{"_type":"object","extends":[],"properties":[{"name":{"name":{"originalName":"root","camelCase":{"unsafeName":"root","safeName":"root"},"snakeCase":{"unsafeName":"root","safeName":"root"},"screamingSnakeCase":{"unsafeName":"ROOT","safeName":"ROOT"},"pascalCase":{"unsafeName":"Root","safeName":"Root"}},"wireValue":"root"},"valueType":{"_type":"named","name":{"originalName":"RootString","camelCase":{"unsafeName":"rootString","safeName":"rootString"},"snakeCase":{"unsafeName":"root_string","safeName":"root_string"},"screamingSnakeCase":{"unsafeName":"ROOT_STRING","safeName":"ROOT_STRING"},"pascalCase":{"unsafeName":"RootString","safeName":"RootString"}},"fernFilepath":{"allParts":[],"packagePath":[],"file":null},"typeId":"type_:RootString","default":null,"inline":null},"availability":null,"docs":null},{"name":{"name":{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}},"wireValue":"package"},"valueType":{"_type":"named","name":{"originalName":"PackageString","camelCase":{"unsafeName":"packageString","safeName":"packageString"},"snakeCase":{"unsafeName":"package_string","safeName":"package_string"},"screamingSnakeCase":{"unsafeName":"PACKAGE_STRING","safeName":"PACKAGE_STRING"},"pascalCase":{"unsafeName":"PackageString","safeName":"PackageString"}},"fernFilepath":{"allParts":[{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}}],"packagePath":[{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}}],"file":null},"typeId":"type_package:PackageString","default":null,"inline":null},"availability":null,"docs":null}],"extra-properties":false,"extendedProperties":[]},"referencedTypes":["type_:RootString","type_package:PackageString"],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null},"type_package/a:A":{"inline":false,"name":{"name":{"originalName":"A","camelCase":{"unsafeName":"a","safeName":"a"},"snakeCase":{"unsafeName":"a","safeName":"a"},"screamingSnakeCase":{"unsafeName":"A","safeName":"A"},"pascalCase":{"unsafeName":"A","safeName":"A"}},"fernFilepath":{"allParts":[{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}},{"originalName":"a","camelCase":{"unsafeName":"a","safeName":"a"},"snakeCase":{"unsafeName":"a","safeName":"a"},"screamingSnakeCase":{"unsafeName":"A","safeName":"A"},"pascalCase":{"unsafeName":"A","safeName":"A"}}],"packagePath":[{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}}],"file":{"originalName":"a","camelCase":{"unsafeName":"a","safeName":"a"},"snakeCase":{"unsafeName":"a","safeName":"a"},"screamingSnakeCase":{"unsafeName":"A","safeName":"A"},"pascalCase":{"unsafeName":"A","safeName":"A"}}},"typeId":"type_package/a:A"},"shape":{"_type":"alias","aliasOf":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"resolvedType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}}},"referencedTypes":[],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null}},"errors":{},"services":{"service_":{"availability":null,"name":{"fernFilepath":{"allParts":[],"packagePath":[],"file":null}},"displayName":null,"basePath":{"head":"/","parts":[]},"headers":[],"pathParameters":[],"encoding":{"json":{},"proto":null},"transport":{"type":"http"},"endpoints":[{"id":"endpoint_.rootEndpoint","name":{"originalName":"rootEndpoint","camelCase":{"unsafeName":"rootEndpoint","safeName":"rootEndpoint"},"snakeCase":{"unsafeName":"root_endpoint","safeName":"root_endpoint"},"screamingSnakeCase":{"unsafeName":"ROOT_ENDPOINT","safeName":"ROOT_ENDPOINT"},"pascalCase":{"unsafeName":"RootEndpoint","safeName":"RootEndpoint"}},"displayName":null,"auth":false,"idempotent":false,"baseUrl":null,"method":"GET","basePath":null,"path":{"head":"","parts":[]},"fullPath":{"head":"","parts":[]},"pathParameters":[],"allPathParameters":[],"queryParameters":[],"headers":[],"requestBody":null,"sdkRequest":null,"response":{"body":null,"status-code":null},"errors":[],"userSpecifiedExamples":[],"autogeneratedExamples":[{"example":{"id":"0151c4f21dcb59ded0264beca4e001f6c9a6203a","url":"","name":null,"endpointHeaders":[],"endpointPathParameters":[],"queryParameters":[],"servicePathParameters":[],"serviceHeaders":[],"rootPathParameters":[],"request":null,"response":{"type":"ok","value":{"type":"body","value":null}},"docs":null}}],"pagination":null,"transport":null,"availability":null,"docs":null}]},"service_package":{"availability":null,"name":{"fernFilepath":{"allParts":[{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}}],"packagePath":[{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}}],"file":null}},"displayName":null,"basePath":{"head":"/","parts":[]},"headers":[],"pathParameters":[],"encoding":{"json":{},"proto":null},"transport":{"type":"http"},"endpoints":[]}},"constants":{"errorInstanceIdKey":{"name":{"originalName":"errorInstanceId","camelCase":{"unsafeName":"errorInstanceId","safeName":"errorInstanceId"},"snakeCase":{"unsafeName":"error_instance_id","safeName":"error_instance_id"},"screamingSnakeCase":{"unsafeName":"ERROR_INSTANCE_ID","safeName":"ERROR_INSTANCE_ID"},"pascalCase":{"unsafeName":"ErrorInstanceId","safeName":"ErrorInstanceId"}},"wireValue":"errorInstanceId"}},"environments":null,"errorDiscriminationStrategy":{"type":"statusCode"},"basePath":null,"pathParameters":[],"variables":[],"serviceTypeReferenceInfo":{"typesReferencedOnlyByService":{},"sharedTypes":["type_:RootString","type_package:PackageString","type_importer:Foo","type_package/a:A"]},"webhookGroups":{},"websocketChannels":{},"readmeConfig":null,"sourceConfig":null,"publishConfig":null,"subpackages":{"subpackage_package":{"name":{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}},"fernFilepath":{"allParts":[{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}}],"packagePath":[{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}}],"file":null},"service":"service_package","types":["type_package:PackageString"],"errors":[],"subpackages":["subpackage_package/b","subpackage_package/a"],"navigationConfig":null,"webhooks":null,"websocket":null,"hasEndpointsInTree":true,"docs":null},"subpackage_importer":{"name":{"originalName":"importer","camelCase":{"unsafeName":"importer","safeName":"importer"},"snakeCase":{"unsafeName":"importer","safeName":"importer"},"screamingSnakeCase":{"unsafeName":"IMPORTER","safeName":"IMPORTER"},"pascalCase":{"unsafeName":"Importer","safeName":"Importer"}},"fernFilepath":{"allParts":[{"originalName":"importer","camelCase":{"unsafeName":"importer","safeName":"importer"},"snakeCase":{"unsafeName":"importer","safeName":"importer"},"screamingSnakeCase":{"unsafeName":"IMPORTER","safeName":"IMPORTER"},"pascalCase":{"unsafeName":"Importer","safeName":"Importer"}}],"packagePath":[],"file":{"originalName":"importer","camelCase":{"unsafeName":"importer","safeName":"importer"},"snakeCase":{"unsafeName":"importer","safeName":"importer"},"screamingSnakeCase":{"unsafeName":"IMPORTER","safeName":"IMPORTER"},"pascalCase":{"unsafeName":"Importer","safeName":"Importer"}}},"service":null,"types":["type_importer:Foo"],"errors":[],"subpackages":[],"navigationConfig":null,"webhooks":null,"websocket":null,"hasEndpointsInTree":false,"docs":"I'm an importer!"},"subpackage_package/a":{"name":{"originalName":"a","camelCase":{"unsafeName":"a","safeName":"a"},"snakeCase":{"unsafeName":"a","safeName":"a"},"screamingSnakeCase":{"unsafeName":"A","safeName":"A"},"pascalCase":{"unsafeName":"A","safeName":"A"}},"fernFilepath":{"allParts":[{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}},{"originalName":"a","camelCase":{"unsafeName":"a","safeName":"a"},"snakeCase":{"unsafeName":"a","safeName":"a"},"screamingSnakeCase":{"unsafeName":"A","safeName":"A"},"pascalCase":{"unsafeName":"A","safeName":"A"}}],"packagePath":[{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}}],"file":{"originalName":"a","camelCase":{"unsafeName":"a","safeName":"a"},"snakeCase":{"unsafeName":"a","safeName":"a"},"screamingSnakeCase":{"unsafeName":"A","safeName":"A"},"pascalCase":{"unsafeName":"A","safeName":"A"}}},"service":null,"types":["type_package/a:A"],"errors":[],"subpackages":[],"navigationConfig":null,"webhooks":null,"websocket":null,"hasEndpointsInTree":false,"docs":null},"subpackage_package/b":{"name":{"originalName":"b","camelCase":{"unsafeName":"b","safeName":"b"},"snakeCase":{"unsafeName":"b","safeName":"b"},"screamingSnakeCase":{"unsafeName":"B","safeName":"B"},"pascalCase":{"unsafeName":"B","safeName":"B"}},"fernFilepath":{"allParts":[{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}},{"originalName":"b","camelCase":{"unsafeName":"b","safeName":"b"},"snakeCase":{"unsafeName":"b","safeName":"b"},"screamingSnakeCase":{"unsafeName":"B","safeName":"B"},"pascalCase":{"unsafeName":"B","safeName":"B"}}],"packagePath":[{"originalName":"package","camelCase":{"unsafeName":"package","safeName":"package"},"snakeCase":{"unsafeName":"package","safeName":"package"},"screamingSnakeCase":{"unsafeName":"PACKAGE","safeName":"PACKAGE"},"pascalCase":{"unsafeName":"Package","safeName":"Package"}}],"file":{"originalName":"b","camelCase":{"unsafeName":"b","safeName":"b"},"snakeCase":{"unsafeName":"b","safeName":"b"},"screamingSnakeCase":{"unsafeName":"B","safeName":"B"},"pascalCase":{"unsafeName":"B","safeName":"B"}}},"service":null,"types":[],"errors":[],"subpackages":[],"navigationConfig":null,"webhooks":null,"websocket":null,"hasEndpointsInTree":false,"docs":null}},"rootPackage":{"fernFilepath":{"allParts":[],"packagePath":[],"file":null},"websocket":null,"service":"service_","types":["type_:RootString"],"errors":[],"subpackages":["subpackage_package","subpackage_importer"],"webhooks":null,"navigationConfig":null,"hasEndpointsInTree":true,"docs":null},"sdkConfig":{"isAuthMandatory":false,"hasStreamingEndpoints":false,"hasPaginatedEndpoints":false,"hasFileDownloadEndpoints":false,"platformHeaders":{"language":"X-Fern-Language","sdkName":"X-Fern-SDK-Name","sdkVersion":"X-Fern-SDK-Version","userAgent":null}}}"`; -exports[`ir > {"name":"response-property"} 1`] = `"{"fdrApiDefinitionId":null,"apiVersion":null,"apiName":{"originalName":"response-property","camelCase":{"unsafeName":"responseProperty","safeName":"responseProperty"},"snakeCase":{"unsafeName":"response_property","safeName":"response_property"},"screamingSnakeCase":{"unsafeName":"RESPONSE_PROPERTY","safeName":"RESPONSE_PROPERTY"},"pascalCase":{"unsafeName":"ResponseProperty","safeName":"ResponseProperty"}},"apiDisplayName":null,"apiDocs":null,"auth":{"requirement":"ALL","schemes":[],"docs":null},"headers":[],"idempotencyHeaders":[],"types":{"type_service:WithDocs":{"inline":false,"name":{"name":{"originalName":"WithDocs","camelCase":{"unsafeName":"withDocs","safeName":"withDocs"},"snakeCase":{"unsafeName":"with_docs","safeName":"with_docs"},"screamingSnakeCase":{"unsafeName":"WITH_DOCS","safeName":"WITH_DOCS"},"pascalCase":{"unsafeName":"WithDocs","safeName":"WithDocs"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:WithDocs"},"shape":{"_type":"object","extends":[],"properties":[{"name":{"name":{"originalName":"docs","camelCase":{"unsafeName":"docs","safeName":"docs"},"snakeCase":{"unsafeName":"docs","safeName":"docs"},"screamingSnakeCase":{"unsafeName":"DOCS","safeName":"DOCS"},"pascalCase":{"unsafeName":"Docs","safeName":"Docs"}},"wireValue":"docs"},"valueType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"availability":null,"docs":null}],"extra-properties":false,"extendedProperties":[]},"referencedTypes":[],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null},"type_service:Movie":{"inline":false,"name":{"name":{"originalName":"Movie","camelCase":{"unsafeName":"movie","safeName":"movie"},"snakeCase":{"unsafeName":"movie","safeName":"movie"},"screamingSnakeCase":{"unsafeName":"MOVIE","safeName":"MOVIE"},"pascalCase":{"unsafeName":"Movie","safeName":"Movie"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Movie"},"shape":{"_type":"object","extends":[],"properties":[{"name":{"name":{"originalName":"id","camelCase":{"unsafeName":"id","safeName":"id"},"snakeCase":{"unsafeName":"id","safeName":"id"},"screamingSnakeCase":{"unsafeName":"ID","safeName":"ID"},"pascalCase":{"unsafeName":"Id","safeName":"Id"}},"wireValue":"id"},"valueType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"availability":null,"docs":null}],"extra-properties":false,"extendedProperties":[]},"referencedTypes":[],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null},"type_service:Response":{"inline":false,"name":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Response"},"shape":{"_type":"object","extends":[{"name":{"originalName":"WithDocs","camelCase":{"unsafeName":"withDocs","safeName":"withDocs"},"snakeCase":{"unsafeName":"with_docs","safeName":"with_docs"},"screamingSnakeCase":{"unsafeName":"WITH_DOCS","safeName":"WITH_DOCS"},"pascalCase":{"unsafeName":"WithDocs","safeName":"WithDocs"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:WithDocs"}],"properties":[{"name":{"name":{"originalName":"data","camelCase":{"unsafeName":"data","safeName":"data"},"snakeCase":{"unsafeName":"data","safeName":"data"},"screamingSnakeCase":{"unsafeName":"DATA","safeName":"DATA"},"pascalCase":{"unsafeName":"Data","safeName":"Data"}},"wireValue":"data"},"valueType":{"_type":"named","name":{"originalName":"Movie","camelCase":{"unsafeName":"movie","safeName":"movie"},"snakeCase":{"unsafeName":"movie","safeName":"movie"},"screamingSnakeCase":{"unsafeName":"MOVIE","safeName":"MOVIE"},"pascalCase":{"unsafeName":"Movie","safeName":"Movie"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Movie","default":null,"inline":null},"availability":null,"docs":null}],"extra-properties":false,"extendedProperties":[{"name":{"name":{"originalName":"docs","camelCase":{"unsafeName":"docs","safeName":"docs"},"snakeCase":{"unsafeName":"docs","safeName":"docs"},"screamingSnakeCase":{"unsafeName":"DOCS","safeName":"DOCS"},"pascalCase":{"unsafeName":"Docs","safeName":"Docs"}},"wireValue":"docs"},"valueType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"availability":null,"docs":null}]},"referencedTypes":["type_service:WithDocs","type_service:Movie"],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null}},"errors":{},"services":{"service_service":{"availability":null,"name":{"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}}},"displayName":null,"basePath":{"head":"","parts":[]},"headers":[],"pathParameters":[],"encoding":{"json":{},"proto":null},"transport":{"type":"http"},"endpoints":[{"id":"endpoint_service.getMovie","name":{"originalName":"getMovie","camelCase":{"unsafeName":"getMovie","safeName":"getMovie"},"snakeCase":{"unsafeName":"get_movie","safeName":"get_movie"},"screamingSnakeCase":{"unsafeName":"GET_MOVIE","safeName":"GET_MOVIE"},"pascalCase":{"unsafeName":"GetMovie","safeName":"GetMovie"}},"displayName":null,"auth":false,"idempotent":false,"baseUrl":null,"method":"POST","basePath":null,"path":{"head":"/movie","parts":[]},"fullPath":{"head":"movie","parts":[]},"pathParameters":[],"allPathParameters":[],"queryParameters":[],"headers":[],"requestBody":{"type":"reference","requestBodyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"contentType":null,"docs":null},"sdkRequest":{"shape":{"type":"justRequestBody","value":{"type":"typeReference","requestBodyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"contentType":null,"docs":null}},"requestParameterName":{"originalName":"request","camelCase":{"unsafeName":"request","safeName":"request"},"snakeCase":{"unsafeName":"request","safeName":"request"},"screamingSnakeCase":{"unsafeName":"REQUEST","safeName":"REQUEST"},"pascalCase":{"unsafeName":"Request","safeName":"Request"}},"streamParameter":null},"response":{"body":{"type":"json","value":{"type":"nestedPropertyAsResponse","responseBodyType":{"_type":"named","name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Response","default":null,"inline":null},"responseProperty":{"name":{"name":{"originalName":"data","camelCase":{"unsafeName":"data","safeName":"data"},"snakeCase":{"unsafeName":"data","safeName":"data"},"screamingSnakeCase":{"unsafeName":"DATA","safeName":"DATA"},"pascalCase":{"unsafeName":"Data","safeName":"Data"}},"wireValue":"data"},"valueType":{"_type":"named","name":{"originalName":"Movie","camelCase":{"unsafeName":"movie","safeName":"movie"},"snakeCase":{"unsafeName":"movie","safeName":"movie"},"screamingSnakeCase":{"unsafeName":"MOVIE","safeName":"MOVIE"},"pascalCase":{"unsafeName":"Movie","safeName":"Movie"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Movie","default":null,"inline":null},"availability":null,"docs":null},"docs":null}},"status-code":null},"errors":[],"userSpecifiedExamples":[],"autogeneratedExamples":[{"example":{"id":"51ecfe336a3cafcb2aee1fe0fb691ea2f698c246","url":"/movie","name":null,"endpointHeaders":[],"endpointPathParameters":[],"queryParameters":[],"servicePathParameters":[],"serviceHeaders":[],"rootPathParameters":[],"request":{"type":"reference","shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"string"}}},"jsonExample":"string"},"response":{"type":"ok","value":{"type":"body","value":{"shape":{"type":"named","shape":{"type":"object","properties":[{"name":{"name":{"originalName":"data","camelCase":{"unsafeName":"data","safeName":"data"},"snakeCase":{"unsafeName":"data","safeName":"data"},"screamingSnakeCase":{"unsafeName":"DATA","safeName":"DATA"},"pascalCase":{"unsafeName":"Data","safeName":"Data"}},"wireValue":"data"},"originalTypeDeclaration":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Response"},"value":{"shape":{"type":"named","shape":{"type":"object","properties":[{"name":{"name":{"originalName":"id","camelCase":{"unsafeName":"id","safeName":"id"},"snakeCase":{"unsafeName":"id","safeName":"id"},"screamingSnakeCase":{"unsafeName":"ID","safeName":"ID"},"pascalCase":{"unsafeName":"Id","safeName":"Id"}},"wireValue":"id"},"originalTypeDeclaration":{"name":{"originalName":"Movie","camelCase":{"unsafeName":"movie","safeName":"movie"},"snakeCase":{"unsafeName":"movie","safeName":"movie"},"screamingSnakeCase":{"unsafeName":"MOVIE","safeName":"MOVIE"},"pascalCase":{"unsafeName":"Movie","safeName":"Movie"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Movie"},"value":{"shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"id"}}},"jsonExample":"id"}}]},"typeName":{"name":{"originalName":"Movie","camelCase":{"unsafeName":"movie","safeName":"movie"},"snakeCase":{"unsafeName":"movie","safeName":"movie"},"screamingSnakeCase":{"unsafeName":"MOVIE","safeName":"MOVIE"},"pascalCase":{"unsafeName":"Movie","safeName":"Movie"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Movie"}},"jsonExample":{"id":"id"}}}]},"typeName":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Response"}},"jsonExample":{"data":{"id":"id"}}}}},"docs":null}}],"pagination":null,"transport":null,"availability":null,"docs":null},{"id":"endpoint_service.getMovieDocs","name":{"originalName":"getMovieDocs","camelCase":{"unsafeName":"getMovieDocs","safeName":"getMovieDocs"},"snakeCase":{"unsafeName":"get_movie_docs","safeName":"get_movie_docs"},"screamingSnakeCase":{"unsafeName":"GET_MOVIE_DOCS","safeName":"GET_MOVIE_DOCS"},"pascalCase":{"unsafeName":"GetMovieDocs","safeName":"GetMovieDocs"}},"displayName":null,"auth":false,"idempotent":false,"baseUrl":null,"method":"POST","basePath":null,"path":{"head":"/movie","parts":[]},"fullPath":{"head":"movie","parts":[]},"pathParameters":[],"allPathParameters":[],"queryParameters":[],"headers":[],"requestBody":{"type":"reference","requestBodyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"contentType":null,"docs":null},"sdkRequest":{"shape":{"type":"justRequestBody","value":{"type":"typeReference","requestBodyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"contentType":null,"docs":null}},"requestParameterName":{"originalName":"request","camelCase":{"unsafeName":"request","safeName":"request"},"snakeCase":{"unsafeName":"request","safeName":"request"},"screamingSnakeCase":{"unsafeName":"REQUEST","safeName":"REQUEST"},"pascalCase":{"unsafeName":"Request","safeName":"Request"}},"streamParameter":null},"response":{"body":{"type":"json","value":{"type":"nestedPropertyAsResponse","responseBodyType":{"_type":"named","name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Response","default":null,"inline":null},"responseProperty":{"name":{"name":{"originalName":"docs","camelCase":{"unsafeName":"docs","safeName":"docs"},"snakeCase":{"unsafeName":"docs","safeName":"docs"},"screamingSnakeCase":{"unsafeName":"DOCS","safeName":"DOCS"},"pascalCase":{"unsafeName":"Docs","safeName":"Docs"}},"wireValue":"docs"},"valueType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"availability":null,"docs":null},"docs":null}},"status-code":null},"errors":[],"userSpecifiedExamples":[],"autogeneratedExamples":[{"example":{"id":"51ecfe336a3cafcb2aee1fe0fb691ea2f698c246","url":"/movie","name":null,"endpointHeaders":[],"endpointPathParameters":[],"queryParameters":[],"servicePathParameters":[],"serviceHeaders":[],"rootPathParameters":[],"request":{"type":"reference","shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"string"}}},"jsonExample":"string"},"response":{"type":"ok","value":{"type":"body","value":{"shape":{"type":"named","shape":{"type":"object","properties":[{"name":{"name":{"originalName":"data","camelCase":{"unsafeName":"data","safeName":"data"},"snakeCase":{"unsafeName":"data","safeName":"data"},"screamingSnakeCase":{"unsafeName":"DATA","safeName":"DATA"},"pascalCase":{"unsafeName":"Data","safeName":"Data"}},"wireValue":"data"},"originalTypeDeclaration":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Response"},"value":{"shape":{"type":"named","shape":{"type":"object","properties":[{"name":{"name":{"originalName":"id","camelCase":{"unsafeName":"id","safeName":"id"},"snakeCase":{"unsafeName":"id","safeName":"id"},"screamingSnakeCase":{"unsafeName":"ID","safeName":"ID"},"pascalCase":{"unsafeName":"Id","safeName":"Id"}},"wireValue":"id"},"originalTypeDeclaration":{"name":{"originalName":"Movie","camelCase":{"unsafeName":"movie","safeName":"movie"},"snakeCase":{"unsafeName":"movie","safeName":"movie"},"screamingSnakeCase":{"unsafeName":"MOVIE","safeName":"MOVIE"},"pascalCase":{"unsafeName":"Movie","safeName":"Movie"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Movie"},"value":{"shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"id"}}},"jsonExample":"id"}}]},"typeName":{"name":{"originalName":"Movie","camelCase":{"unsafeName":"movie","safeName":"movie"},"snakeCase":{"unsafeName":"movie","safeName":"movie"},"screamingSnakeCase":{"unsafeName":"MOVIE","safeName":"MOVIE"},"pascalCase":{"unsafeName":"Movie","safeName":"Movie"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Movie"}},"jsonExample":{"id":"id"}}}]},"typeName":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Response"}},"jsonExample":{"data":{"id":"id"}}}}},"docs":null}}],"pagination":null,"transport":null,"availability":null,"docs":null}]}},"constants":{"errorInstanceIdKey":{"name":{"originalName":"errorInstanceId","camelCase":{"unsafeName":"errorInstanceId","safeName":"errorInstanceId"},"snakeCase":{"unsafeName":"error_instance_id","safeName":"error_instance_id"},"screamingSnakeCase":{"unsafeName":"ERROR_INSTANCE_ID","safeName":"ERROR_INSTANCE_ID"},"pascalCase":{"unsafeName":"ErrorInstanceId","safeName":"ErrorInstanceId"}},"wireValue":"errorInstanceId"}},"environments":null,"errorDiscriminationStrategy":{"type":"statusCode"},"basePath":null,"pathParameters":[],"variables":[],"serviceTypeReferenceInfo":{"typesReferencedOnlyByService":{"service_service":["type_service:Response"]},"sharedTypes":["type_service:WithDocs","type_service:Movie"]},"webhookGroups":{},"websocketChannels":{},"readmeConfig":null,"sourceConfig":null,"publishConfig":null,"subpackages":{"subpackage_service":{"name":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"service":"service_service","types":["type_service:WithDocs","type_service:Movie","type_service:Response"],"errors":[],"subpackages":[],"navigationConfig":null,"webhooks":null,"websocket":null,"hasEndpointsInTree":true,"docs":null}},"rootPackage":{"fernFilepath":{"allParts":[],"packagePath":[],"file":null},"websocket":null,"service":null,"types":[],"errors":[],"subpackages":["subpackage_service"],"webhooks":null,"navigationConfig":null,"hasEndpointsInTree":true,"docs":null},"sdkConfig":{"isAuthMandatory":false,"hasStreamingEndpoints":false,"hasPaginatedEndpoints":false,"hasFileDownloadEndpoints":false,"platformHeaders":{"language":"X-Fern-Language","sdkName":"X-Fern-SDK-Name","sdkVersion":"X-Fern-SDK-Version","userAgent":null}}}"`; +exports[`ir > {"name":"response-property"} 1`] = `"{"fdrApiDefinitionId":null,"apiVersion":null,"apiName":{"originalName":"response-property","camelCase":{"unsafeName":"responseProperty","safeName":"responseProperty"},"snakeCase":{"unsafeName":"response_property","safeName":"response_property"},"screamingSnakeCase":{"unsafeName":"RESPONSE_PROPERTY","safeName":"RESPONSE_PROPERTY"},"pascalCase":{"unsafeName":"ResponseProperty","safeName":"ResponseProperty"}},"apiDisplayName":null,"apiDocs":null,"auth":{"requirement":"ALL","schemes":[],"docs":null},"headers":[],"idempotencyHeaders":[],"types":{"type_service:WithDocs":{"inline":false,"name":{"name":{"originalName":"WithDocs","camelCase":{"unsafeName":"withDocs","safeName":"withDocs"},"snakeCase":{"unsafeName":"with_docs","safeName":"with_docs"},"screamingSnakeCase":{"unsafeName":"WITH_DOCS","safeName":"WITH_DOCS"},"pascalCase":{"unsafeName":"WithDocs","safeName":"WithDocs"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:WithDocs"},"shape":{"_type":"object","extends":[],"properties":[{"name":{"name":{"originalName":"docs","camelCase":{"unsafeName":"docs","safeName":"docs"},"snakeCase":{"unsafeName":"docs","safeName":"docs"},"screamingSnakeCase":{"unsafeName":"DOCS","safeName":"DOCS"},"pascalCase":{"unsafeName":"Docs","safeName":"Docs"}},"wireValue":"docs"},"valueType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"availability":null,"docs":null}],"extra-properties":false,"extendedProperties":[]},"referencedTypes":[],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null},"type_service:Movie":{"inline":false,"name":{"name":{"originalName":"Movie","camelCase":{"unsafeName":"movie","safeName":"movie"},"snakeCase":{"unsafeName":"movie","safeName":"movie"},"screamingSnakeCase":{"unsafeName":"MOVIE","safeName":"MOVIE"},"pascalCase":{"unsafeName":"Movie","safeName":"Movie"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Movie"},"shape":{"_type":"object","extends":[],"properties":[{"name":{"name":{"originalName":"id","camelCase":{"unsafeName":"id","safeName":"id"},"snakeCase":{"unsafeName":"id","safeName":"id"},"screamingSnakeCase":{"unsafeName":"ID","safeName":"ID"},"pascalCase":{"unsafeName":"Id","safeName":"Id"}},"wireValue":"id"},"valueType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"availability":null,"docs":null}],"extra-properties":false,"extendedProperties":[]},"referencedTypes":[],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null},"type_service:Response":{"inline":false,"name":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Response"},"shape":{"_type":"object","extends":[{"name":{"originalName":"WithDocs","camelCase":{"unsafeName":"withDocs","safeName":"withDocs"},"snakeCase":{"unsafeName":"with_docs","safeName":"with_docs"},"screamingSnakeCase":{"unsafeName":"WITH_DOCS","safeName":"WITH_DOCS"},"pascalCase":{"unsafeName":"WithDocs","safeName":"WithDocs"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:WithDocs"}],"properties":[{"name":{"name":{"originalName":"data","camelCase":{"unsafeName":"data","safeName":"data"},"snakeCase":{"unsafeName":"data","safeName":"data"},"screamingSnakeCase":{"unsafeName":"DATA","safeName":"DATA"},"pascalCase":{"unsafeName":"Data","safeName":"Data"}},"wireValue":"data"},"valueType":{"_type":"named","name":{"originalName":"Movie","camelCase":{"unsafeName":"movie","safeName":"movie"},"snakeCase":{"unsafeName":"movie","safeName":"movie"},"screamingSnakeCase":{"unsafeName":"MOVIE","safeName":"MOVIE"},"pascalCase":{"unsafeName":"Movie","safeName":"Movie"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Movie","default":null,"inline":null},"availability":null,"docs":null}],"extra-properties":false,"extendedProperties":[{"name":{"name":{"originalName":"docs","camelCase":{"unsafeName":"docs","safeName":"docs"},"snakeCase":{"unsafeName":"docs","safeName":"docs"},"screamingSnakeCase":{"unsafeName":"DOCS","safeName":"DOCS"},"pascalCase":{"unsafeName":"Docs","safeName":"Docs"}},"wireValue":"docs"},"valueType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"availability":null,"docs":null}]},"referencedTypes":["type_service:WithDocs","type_service:Movie"],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null}},"errors":{},"services":{"service_service":{"availability":null,"name":{"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}}},"displayName":null,"basePath":{"head":"","parts":[]},"headers":[],"pathParameters":[],"encoding":{"json":{},"proto":null},"transport":{"type":"http"},"endpoints":[{"id":"endpoint_service.getMovie","name":{"originalName":"getMovie","camelCase":{"unsafeName":"getMovie","safeName":"getMovie"},"snakeCase":{"unsafeName":"get_movie","safeName":"get_movie"},"screamingSnakeCase":{"unsafeName":"GET_MOVIE","safeName":"GET_MOVIE"},"pascalCase":{"unsafeName":"GetMovie","safeName":"GetMovie"}},"displayName":null,"auth":false,"idempotent":false,"baseUrl":null,"method":"POST","basePath":null,"path":{"head":"/movie","parts":[]},"fullPath":{"head":"movie","parts":[]},"pathParameters":[],"allPathParameters":[],"queryParameters":[],"headers":[],"requestBody":{"type":"reference","requestBodyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"contentType":null,"docs":null},"sdkRequest":{"shape":{"type":"justRequestBody","value":{"type":"typeReference","requestBodyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"contentType":null,"docs":null}},"requestParameterName":{"originalName":"request","camelCase":{"unsafeName":"request","safeName":"request"},"snakeCase":{"unsafeName":"request","safeName":"request"},"screamingSnakeCase":{"unsafeName":"REQUEST","safeName":"REQUEST"},"pascalCase":{"unsafeName":"Request","safeName":"Request"}},"streamParameter":null},"response":{"body":{"type":"json","value":{"type":"nestedPropertyAsResponse","responseBodyType":{"_type":"named","name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Response","default":null,"inline":null},"responseProperty":{"name":{"name":{"originalName":"data","camelCase":{"unsafeName":"data","safeName":"data"},"snakeCase":{"unsafeName":"data","safeName":"data"},"screamingSnakeCase":{"unsafeName":"DATA","safeName":"DATA"},"pascalCase":{"unsafeName":"Data","safeName":"Data"}},"wireValue":"data"},"valueType":{"_type":"named","name":{"originalName":"Movie","camelCase":{"unsafeName":"movie","safeName":"movie"},"snakeCase":{"unsafeName":"movie","safeName":"movie"},"screamingSnakeCase":{"unsafeName":"MOVIE","safeName":"MOVIE"},"pascalCase":{"unsafeName":"Movie","safeName":"Movie"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Movie","default":null,"inline":null},"availability":null,"docs":null},"docs":null}},"status-code":null},"errors":[],"userSpecifiedExamples":[],"autogeneratedExamples":[{"example":{"id":"51ecfe336a3cafcb2aee1fe0fb691ea2f698c246","url":"/movie","name":null,"endpointHeaders":[],"endpointPathParameters":[],"queryParameters":[],"servicePathParameters":[],"serviceHeaders":[],"rootPathParameters":[],"request":{"type":"reference","shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"string"}}},"jsonExample":"string"},"response":{"type":"ok","value":{"type":"body","value":{"shape":{"type":"named","shape":{"type":"object","properties":[{"name":{"name":{"originalName":"data","camelCase":{"unsafeName":"data","safeName":"data"},"snakeCase":{"unsafeName":"data","safeName":"data"},"screamingSnakeCase":{"unsafeName":"DATA","safeName":"DATA"},"pascalCase":{"unsafeName":"Data","safeName":"Data"}},"wireValue":"data"},"originalTypeDeclaration":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Response"},"value":{"shape":{"type":"named","shape":{"type":"object","properties":[{"name":{"name":{"originalName":"id","camelCase":{"unsafeName":"id","safeName":"id"},"snakeCase":{"unsafeName":"id","safeName":"id"},"screamingSnakeCase":{"unsafeName":"ID","safeName":"ID"},"pascalCase":{"unsafeName":"Id","safeName":"Id"}},"wireValue":"id"},"originalTypeDeclaration":{"name":{"originalName":"Movie","camelCase":{"unsafeName":"movie","safeName":"movie"},"snakeCase":{"unsafeName":"movie","safeName":"movie"},"screamingSnakeCase":{"unsafeName":"MOVIE","safeName":"MOVIE"},"pascalCase":{"unsafeName":"Movie","safeName":"Movie"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Movie"},"value":{"shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"id"}}},"jsonExample":"id"}}]},"typeName":{"name":{"originalName":"Movie","camelCase":{"unsafeName":"movie","safeName":"movie"},"snakeCase":{"unsafeName":"movie","safeName":"movie"},"screamingSnakeCase":{"unsafeName":"MOVIE","safeName":"MOVIE"},"pascalCase":{"unsafeName":"Movie","safeName":"Movie"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Movie"}},"jsonExample":{"id":"id"}}}]},"typeName":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Response"}},"jsonExample":{"data":{"id":"id"}}}}},"docs":null}}],"pagination":null,"transport":null,"availability":null,"docs":null},{"id":"endpoint_service.getMovieDocs","name":{"originalName":"getMovieDocs","camelCase":{"unsafeName":"getMovieDocs","safeName":"getMovieDocs"},"snakeCase":{"unsafeName":"get_movie_docs","safeName":"get_movie_docs"},"screamingSnakeCase":{"unsafeName":"GET_MOVIE_DOCS","safeName":"GET_MOVIE_DOCS"},"pascalCase":{"unsafeName":"GetMovieDocs","safeName":"GetMovieDocs"}},"displayName":null,"auth":false,"idempotent":false,"baseUrl":null,"method":"POST","basePath":null,"path":{"head":"/movie","parts":[]},"fullPath":{"head":"movie","parts":[]},"pathParameters":[],"allPathParameters":[],"queryParameters":[],"headers":[],"requestBody":{"type":"reference","requestBodyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"contentType":null,"docs":null},"sdkRequest":{"shape":{"type":"justRequestBody","value":{"type":"typeReference","requestBodyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"contentType":null,"docs":null}},"requestParameterName":{"originalName":"request","camelCase":{"unsafeName":"request","safeName":"request"},"snakeCase":{"unsafeName":"request","safeName":"request"},"screamingSnakeCase":{"unsafeName":"REQUEST","safeName":"REQUEST"},"pascalCase":{"unsafeName":"Request","safeName":"Request"}},"streamParameter":null},"response":{"body":{"type":"json","value":{"type":"nestedPropertyAsResponse","responseBodyType":{"_type":"named","name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Response","default":null,"inline":null},"responseProperty":{"name":{"name":{"originalName":"docs","camelCase":{"unsafeName":"docs","safeName":"docs"},"snakeCase":{"unsafeName":"docs","safeName":"docs"},"screamingSnakeCase":{"unsafeName":"DOCS","safeName":"DOCS"},"pascalCase":{"unsafeName":"Docs","safeName":"Docs"}},"wireValue":"docs"},"valueType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"availability":null,"docs":null},"docs":null}},"status-code":null},"errors":[],"userSpecifiedExamples":[],"autogeneratedExamples":[{"example":{"id":"51ecfe336a3cafcb2aee1fe0fb691ea2f698c246","url":"/movie","name":null,"endpointHeaders":[],"endpointPathParameters":[],"queryParameters":[],"servicePathParameters":[],"serviceHeaders":[],"rootPathParameters":[],"request":{"type":"reference","shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"string"}}},"jsonExample":"string"},"response":{"type":"ok","value":{"type":"body","value":{"shape":{"type":"named","shape":{"type":"object","properties":[{"name":{"name":{"originalName":"data","camelCase":{"unsafeName":"data","safeName":"data"},"snakeCase":{"unsafeName":"data","safeName":"data"},"screamingSnakeCase":{"unsafeName":"DATA","safeName":"DATA"},"pascalCase":{"unsafeName":"Data","safeName":"Data"}},"wireValue":"data"},"originalTypeDeclaration":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Response"},"value":{"shape":{"type":"named","shape":{"type":"object","properties":[{"name":{"name":{"originalName":"id","camelCase":{"unsafeName":"id","safeName":"id"},"snakeCase":{"unsafeName":"id","safeName":"id"},"screamingSnakeCase":{"unsafeName":"ID","safeName":"ID"},"pascalCase":{"unsafeName":"Id","safeName":"Id"}},"wireValue":"id"},"originalTypeDeclaration":{"name":{"originalName":"Movie","camelCase":{"unsafeName":"movie","safeName":"movie"},"snakeCase":{"unsafeName":"movie","safeName":"movie"},"screamingSnakeCase":{"unsafeName":"MOVIE","safeName":"MOVIE"},"pascalCase":{"unsafeName":"Movie","safeName":"Movie"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Movie"},"value":{"shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"id"}}},"jsonExample":"id"}}]},"typeName":{"name":{"originalName":"Movie","camelCase":{"unsafeName":"movie","safeName":"movie"},"snakeCase":{"unsafeName":"movie","safeName":"movie"},"screamingSnakeCase":{"unsafeName":"MOVIE","safeName":"MOVIE"},"pascalCase":{"unsafeName":"Movie","safeName":"Movie"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Movie"}},"jsonExample":{"id":"id"}}}]},"typeName":{"name":{"originalName":"Response","camelCase":{"unsafeName":"response","safeName":"response"},"snakeCase":{"unsafeName":"response","safeName":"response"},"screamingSnakeCase":{"unsafeName":"RESPONSE","safeName":"RESPONSE"},"pascalCase":{"unsafeName":"Response","safeName":"Response"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"typeId":"type_service:Response"}},"jsonExample":{"data":{"id":"id"}}}}},"docs":null}}],"pagination":null,"transport":null,"availability":null,"docs":null}]}},"constants":{"errorInstanceIdKey":{"name":{"originalName":"errorInstanceId","camelCase":{"unsafeName":"errorInstanceId","safeName":"errorInstanceId"},"snakeCase":{"unsafeName":"error_instance_id","safeName":"error_instance_id"},"screamingSnakeCase":{"unsafeName":"ERROR_INSTANCE_ID","safeName":"ERROR_INSTANCE_ID"},"pascalCase":{"unsafeName":"ErrorInstanceId","safeName":"ErrorInstanceId"}},"wireValue":"errorInstanceId"}},"environments":null,"errorDiscriminationStrategy":{"type":"statusCode"},"basePath":null,"pathParameters":[],"variables":[],"serviceTypeReferenceInfo":{"typesReferencedOnlyByService":{"service_service":["type_service:WithDocs","type_service:Movie","type_service:Response"]},"sharedTypes":[]},"webhookGroups":{},"websocketChannels":{},"readmeConfig":null,"sourceConfig":null,"publishConfig":null,"subpackages":{"subpackage_service":{"name":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}},"fernFilepath":{"allParts":[{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}],"packagePath":[],"file":{"originalName":"service","camelCase":{"unsafeName":"service","safeName":"service"},"snakeCase":{"unsafeName":"service","safeName":"service"},"screamingSnakeCase":{"unsafeName":"SERVICE","safeName":"SERVICE"},"pascalCase":{"unsafeName":"Service","safeName":"Service"}}},"service":"service_service","types":["type_service:WithDocs","type_service:Movie","type_service:Response"],"errors":[],"subpackages":[],"navigationConfig":null,"webhooks":null,"websocket":null,"hasEndpointsInTree":true,"docs":null}},"rootPackage":{"fernFilepath":{"allParts":[],"packagePath":[],"file":null},"websocket":null,"service":null,"types":[],"errors":[],"subpackages":["subpackage_service"],"webhooks":null,"navigationConfig":null,"hasEndpointsInTree":true,"docs":null},"sdkConfig":{"isAuthMandatory":false,"hasStreamingEndpoints":false,"hasPaginatedEndpoints":false,"hasFileDownloadEndpoints":false,"platformHeaders":{"language":"X-Fern-Language","sdkName":"X-Fern-SDK-Name","sdkVersion":"X-Fern-SDK-Version","userAgent":null}}}"`; exports[`ir > {"name":"simple","audiences":["internal"]} 1`] = `"{"fdrApiDefinitionId":null,"apiVersion":null,"apiName":{"originalName":"my-api","camelCase":{"unsafeName":"myApi","safeName":"myApi"},"snakeCase":{"unsafeName":"my_api","safeName":"my_api"},"screamingSnakeCase":{"unsafeName":"MY_API","safeName":"MY_API"},"pascalCase":{"unsafeName":"MyApi","safeName":"MyApi"}},"apiDisplayName":null,"apiDocs":"foo bar baz","auth":{"requirement":"ALL","schemes":[],"docs":null},"headers":[{"name":{"name":{"originalName":"apiVersion","camelCase":{"unsafeName":"apiVersion","safeName":"apiVersion"},"snakeCase":{"unsafeName":"api_version","safeName":"api_version"},"screamingSnakeCase":{"unsafeName":"API_VERSION","safeName":"API_VERSION"},"pascalCase":{"unsafeName":"ApiVersion","safeName":"ApiVersion"}},"wireValue":"X-API-VERSION"},"valueType":{"_type":"container","container":{"_type":"optional","optional":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}}}},"env":null,"availability":null,"docs":null}],"idempotencyHeaders":[],"types":{"type_commons:Internal":{"inline":false,"name":{"name":{"originalName":"Internal","camelCase":{"unsafeName":"internal","safeName":"internal"},"snakeCase":{"unsafeName":"internal","safeName":"internal"},"screamingSnakeCase":{"unsafeName":"INTERNAL","safeName":"INTERNAL"},"pascalCase":{"unsafeName":"Internal","safeName":"Internal"}},"fernFilepath":{"allParts":[{"originalName":"commons","camelCase":{"unsafeName":"commons","safeName":"commons"},"snakeCase":{"unsafeName":"commons","safeName":"commons"},"screamingSnakeCase":{"unsafeName":"COMMONS","safeName":"COMMONS"},"pascalCase":{"unsafeName":"Commons","safeName":"Commons"}}],"packagePath":[],"file":{"originalName":"commons","camelCase":{"unsafeName":"commons","safeName":"commons"},"snakeCase":{"unsafeName":"commons","safeName":"commons"},"screamingSnakeCase":{"unsafeName":"COMMONS","safeName":"COMMONS"},"pascalCase":{"unsafeName":"Commons","safeName":"Commons"}}},"typeId":"type_commons:Internal"},"shape":{"_type":"object","extends":[],"properties":[{"name":{"name":{"originalName":"name","camelCase":{"unsafeName":"name","safeName":"name"},"snakeCase":{"unsafeName":"name","safeName":"name"},"screamingSnakeCase":{"unsafeName":"NAME","safeName":"NAME"},"pascalCase":{"unsafeName":"Name","safeName":"Name"}},"wireValue":"name"},"valueType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"availability":null,"docs":null}],"extra-properties":false,"extendedProperties":[]},"referencedTypes":[],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null},"type_imdb:UnknownRequest":{"inline":false,"name":{"name":{"originalName":"UnknownRequest","camelCase":{"unsafeName":"unknownRequest","safeName":"unknownRequest"},"snakeCase":{"unsafeName":"unknown_request","safeName":"unknown_request"},"screamingSnakeCase":{"unsafeName":"UNKNOWN_REQUEST","safeName":"UNKNOWN_REQUEST"},"pascalCase":{"unsafeName":"UnknownRequest","safeName":"UnknownRequest"}},"fernFilepath":{"allParts":[{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}}],"packagePath":[],"file":{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}}},"typeId":"type_imdb:UnknownRequest"},"shape":{"_type":"object","extends":[],"properties":[{"name":{"name":{"originalName":"unknown","camelCase":{"unsafeName":"unknown","safeName":"unknown"},"snakeCase":{"unsafeName":"unknown","safeName":"unknown"},"screamingSnakeCase":{"unsafeName":"UNKNOWN","safeName":"UNKNOWN"},"pascalCase":{"unsafeName":"Unknown","safeName":"Unknown"}},"wireValue":"unknown"},"valueType":{"_type":"unknown"},"availability":null,"docs":null}],"extra-properties":false,"extendedProperties":[]},"referencedTypes":[],"encoding":{"json":{},"proto":null},"source":null,"userProvidedExamples":[],"autogeneratedExamples":[],"availability":null,"docs":null}},"errors":{"error_commons:BadRequestError":{"name":{"name":{"originalName":"BadRequestError","camelCase":{"unsafeName":"badRequestError","safeName":"badRequestError"},"snakeCase":{"unsafeName":"bad_request_error","safeName":"bad_request_error"},"screamingSnakeCase":{"unsafeName":"BAD_REQUEST_ERROR","safeName":"BAD_REQUEST_ERROR"},"pascalCase":{"unsafeName":"BadRequestError","safeName":"BadRequestError"}},"fernFilepath":{"allParts":[{"originalName":"commons","camelCase":{"unsafeName":"commons","safeName":"commons"},"snakeCase":{"unsafeName":"commons","safeName":"commons"},"screamingSnakeCase":{"unsafeName":"COMMONS","safeName":"COMMONS"},"pascalCase":{"unsafeName":"Commons","safeName":"Commons"}}],"packagePath":[],"file":{"originalName":"commons","camelCase":{"unsafeName":"commons","safeName":"commons"},"snakeCase":{"unsafeName":"commons","safeName":"commons"},"screamingSnakeCase":{"unsafeName":"COMMONS","safeName":"COMMONS"},"pascalCase":{"unsafeName":"Commons","safeName":"Commons"}}},"errorId":"error_commons:BadRequestError"},"discriminantValue":{"name":{"originalName":"BadRequestError","camelCase":{"unsafeName":"badRequestError","safeName":"badRequestError"},"snakeCase":{"unsafeName":"bad_request_error","safeName":"bad_request_error"},"screamingSnakeCase":{"unsafeName":"BAD_REQUEST_ERROR","safeName":"BAD_REQUEST_ERROR"},"pascalCase":{"unsafeName":"BadRequestError","safeName":"BadRequestError"}},"wireValue":"BadRequestError"},"statusCode":400,"type":null,"examples":[],"docs":null}},"services":{"service_imdb":{"availability":null,"name":{"fernFilepath":{"allParts":[{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}}],"packagePath":[],"file":{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}}}},"displayName":null,"basePath":{"head":"/movies","parts":[]},"headers":[],"pathParameters":[],"encoding":{"json":{},"proto":null},"transport":{"type":"http"},"endpoints":[{"id":"endpoint_imdb.internalEndpoint","name":{"originalName":"internalEndpoint","camelCase":{"unsafeName":"internalEndpoint","safeName":"internalEndpoint"},"snakeCase":{"unsafeName":"internal_endpoint","safeName":"internal_endpoint"},"screamingSnakeCase":{"unsafeName":"INTERNAL_ENDPOINT","safeName":"INTERNAL_ENDPOINT"},"pascalCase":{"unsafeName":"InternalEndpoint","safeName":"InternalEndpoint"}},"displayName":null,"auth":false,"idempotent":false,"baseUrl":null,"method":"POST","basePath":null,"path":{"head":"","parts":[]},"fullPath":{"head":"/test/","parts":[{"pathParameter":"rootPathParam","tail":"/movies"}]},"pathParameters":[],"allPathParameters":[{"name":{"originalName":"rootPathParam","camelCase":{"unsafeName":"rootPathParam","safeName":"rootPathParam"},"snakeCase":{"unsafeName":"root_path_param","safeName":"root_path_param"},"screamingSnakeCase":{"unsafeName":"ROOT_PATH_PARAM","safeName":"ROOT_PATH_PARAM"},"pascalCase":{"unsafeName":"RootPathParam","safeName":"RootPathParam"}},"valueType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"location":"ROOT","variable":null,"docs":null}],"queryParameters":[],"headers":[],"requestBody":{"type":"reference","requestBodyType":{"_type":"named","name":{"originalName":"UnknownRequest","camelCase":{"unsafeName":"unknownRequest","safeName":"unknownRequest"},"snakeCase":{"unsafeName":"unknown_request","safeName":"unknown_request"},"screamingSnakeCase":{"unsafeName":"UNKNOWN_REQUEST","safeName":"UNKNOWN_REQUEST"},"pascalCase":{"unsafeName":"UnknownRequest","safeName":"UnknownRequest"}},"fernFilepath":{"allParts":[{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}}],"packagePath":[],"file":{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}}},"typeId":"type_imdb:UnknownRequest","default":null,"inline":null},"contentType":null,"docs":null},"sdkRequest":{"shape":{"type":"justRequestBody","value":{"type":"typeReference","requestBodyType":{"_type":"named","name":{"originalName":"UnknownRequest","camelCase":{"unsafeName":"unknownRequest","safeName":"unknownRequest"},"snakeCase":{"unsafeName":"unknown_request","safeName":"unknown_request"},"screamingSnakeCase":{"unsafeName":"UNKNOWN_REQUEST","safeName":"UNKNOWN_REQUEST"},"pascalCase":{"unsafeName":"UnknownRequest","safeName":"UnknownRequest"}},"fernFilepath":{"allParts":[{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}}],"packagePath":[],"file":{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}}},"typeId":"type_imdb:UnknownRequest","default":null,"inline":null},"contentType":null,"docs":null}},"requestParameterName":{"originalName":"request","camelCase":{"unsafeName":"request","safeName":"request"},"snakeCase":{"unsafeName":"request","safeName":"request"},"screamingSnakeCase":{"unsafeName":"REQUEST","safeName":"REQUEST"},"pascalCase":{"unsafeName":"Request","safeName":"Request"}},"streamParameter":null},"response":{"body":{"type":"json","value":{"type":"response","responseBodyType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"docs":null}},"status-code":null},"errors":[{"error":{"name":{"originalName":"BadRequestError","camelCase":{"unsafeName":"badRequestError","safeName":"badRequestError"},"snakeCase":{"unsafeName":"bad_request_error","safeName":"bad_request_error"},"screamingSnakeCase":{"unsafeName":"BAD_REQUEST_ERROR","safeName":"BAD_REQUEST_ERROR"},"pascalCase":{"unsafeName":"BadRequestError","safeName":"BadRequestError"}},"fernFilepath":{"allParts":[{"originalName":"commons","camelCase":{"unsafeName":"commons","safeName":"commons"},"snakeCase":{"unsafeName":"commons","safeName":"commons"},"screamingSnakeCase":{"unsafeName":"COMMONS","safeName":"COMMONS"},"pascalCase":{"unsafeName":"Commons","safeName":"Commons"}}],"packagePath":[],"file":{"originalName":"commons","camelCase":{"unsafeName":"commons","safeName":"commons"},"snakeCase":{"unsafeName":"commons","safeName":"commons"},"screamingSnakeCase":{"unsafeName":"COMMONS","safeName":"COMMONS"},"pascalCase":{"unsafeName":"Commons","safeName":"Commons"}}},"errorId":"error_commons:BadRequestError"},"docs":null}],"userSpecifiedExamples":[],"autogeneratedExamples":[{"example":{"id":"6ddea0588fd84ef0a9732ab58c4e1d50078da707","url":"/test/rootPathParam/movies","name":null,"endpointHeaders":[],"endpointPathParameters":[],"queryParameters":[],"servicePathParameters":[],"serviceHeaders":[],"rootPathParameters":[{"name":{"originalName":"rootPathParam","camelCase":{"unsafeName":"rootPathParam","safeName":"rootPathParam"},"snakeCase":{"unsafeName":"root_path_param","safeName":"root_path_param"},"screamingSnakeCase":{"unsafeName":"ROOT_PATH_PARAM","safeName":"ROOT_PATH_PARAM"},"pascalCase":{"unsafeName":"RootPathParam","safeName":"RootPathParam"}},"value":{"shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"rootPathParam"}}},"jsonExample":"rootPathParam"}}],"request":{"type":"reference","shape":{"type":"named","shape":{"type":"object","properties":[{"name":{"name":{"originalName":"unknown","camelCase":{"unsafeName":"unknown","safeName":"unknown"},"snakeCase":{"unsafeName":"unknown","safeName":"unknown"},"screamingSnakeCase":{"unsafeName":"UNKNOWN","safeName":"UNKNOWN"},"pascalCase":{"unsafeName":"Unknown","safeName":"Unknown"}},"wireValue":"unknown"},"originalTypeDeclaration":{"name":{"originalName":"UnknownRequest","camelCase":{"unsafeName":"unknownRequest","safeName":"unknownRequest"},"snakeCase":{"unsafeName":"unknown_request","safeName":"unknown_request"},"screamingSnakeCase":{"unsafeName":"UNKNOWN_REQUEST","safeName":"UNKNOWN_REQUEST"},"pascalCase":{"unsafeName":"UnknownRequest","safeName":"UnknownRequest"}},"fernFilepath":{"allParts":[{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}}],"packagePath":[],"file":{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}}},"typeId":"type_imdb:UnknownRequest"},"value":{"shape":{"type":"unknown","unknown":{"key":"value"}},"jsonExample":{"key":"value"}}}]},"typeName":{"name":{"originalName":"UnknownRequest","camelCase":{"unsafeName":"unknownRequest","safeName":"unknownRequest"},"snakeCase":{"unsafeName":"unknown_request","safeName":"unknown_request"},"screamingSnakeCase":{"unsafeName":"UNKNOWN_REQUEST","safeName":"UNKNOWN_REQUEST"},"pascalCase":{"unsafeName":"UnknownRequest","safeName":"UnknownRequest"}},"fernFilepath":{"allParts":[{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}}],"packagePath":[],"file":{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}}},"typeId":"type_imdb:UnknownRequest"}},"jsonExample":{"unknown":{"key":"value"}}},"response":{"type":"ok","value":{"type":"body","value":{"shape":{"type":"primitive","primitive":{"type":"string","string":{"original":"string"}}},"jsonExample":"string"}}},"docs":null}}],"pagination":null,"transport":null,"availability":null,"docs":null}]}},"constants":{"errorInstanceIdKey":{"name":{"originalName":"errorInstanceId","camelCase":{"unsafeName":"errorInstanceId","safeName":"errorInstanceId"},"snakeCase":{"unsafeName":"error_instance_id","safeName":"error_instance_id"},"screamingSnakeCase":{"unsafeName":"ERROR_INSTANCE_ID","safeName":"ERROR_INSTANCE_ID"},"pascalCase":{"unsafeName":"ErrorInstanceId","safeName":"ErrorInstanceId"}},"wireValue":"errorInstanceId"}},"environments":null,"errorDiscriminationStrategy":{"type":"property","discriminant":{"name":{"originalName":"error","camelCase":{"unsafeName":"error","safeName":"error"},"snakeCase":{"unsafeName":"error","safeName":"error"},"screamingSnakeCase":{"unsafeName":"ERROR","safeName":"ERROR"},"pascalCase":{"unsafeName":"Error","safeName":"Error"}},"wireValue":"error"},"contentProperty":{"name":{"originalName":"content","camelCase":{"unsafeName":"content","safeName":"content"},"snakeCase":{"unsafeName":"content","safeName":"content"},"screamingSnakeCase":{"unsafeName":"CONTENT","safeName":"CONTENT"},"pascalCase":{"unsafeName":"Content","safeName":"Content"}},"wireValue":"content"}},"basePath":{"head":"/test/","parts":[{"pathParameter":"rootPathParam","tail":""}]},"pathParameters":[{"name":{"originalName":"rootPathParam","camelCase":{"unsafeName":"rootPathParam","safeName":"rootPathParam"},"snakeCase":{"unsafeName":"root_path_param","safeName":"root_path_param"},"screamingSnakeCase":{"unsafeName":"ROOT_PATH_PARAM","safeName":"ROOT_PATH_PARAM"},"pascalCase":{"unsafeName":"RootPathParam","safeName":"RootPathParam"}},"valueType":{"_type":"primitive","primitive":{"v1":"STRING","v2":{"type":"string","default":null,"validation":null}}},"location":"ROOT","variable":null,"docs":null}],"variables":[],"serviceTypeReferenceInfo":{"sharedTypes":["type_commons:Internal"],"typesReferencedOnlyByService":{"service_imdb":["type_imdb:UnknownRequest"]}},"webhookGroups":{},"websocketChannels":{},"readmeConfig":null,"sourceConfig":null,"publishConfig":null,"subpackages":{"subpackage_commons":{"name":{"originalName":"commons","camelCase":{"unsafeName":"commons","safeName":"commons"},"snakeCase":{"unsafeName":"commons","safeName":"commons"},"screamingSnakeCase":{"unsafeName":"COMMONS","safeName":"COMMONS"},"pascalCase":{"unsafeName":"Commons","safeName":"Commons"}},"fernFilepath":{"allParts":[{"originalName":"commons","camelCase":{"unsafeName":"commons","safeName":"commons"},"snakeCase":{"unsafeName":"commons","safeName":"commons"},"screamingSnakeCase":{"unsafeName":"COMMONS","safeName":"COMMONS"},"pascalCase":{"unsafeName":"Commons","safeName":"Commons"}}],"packagePath":[],"file":{"originalName":"commons","camelCase":{"unsafeName":"commons","safeName":"commons"},"snakeCase":{"unsafeName":"commons","safeName":"commons"},"screamingSnakeCase":{"unsafeName":"COMMONS","safeName":"COMMONS"},"pascalCase":{"unsafeName":"Commons","safeName":"Commons"}}},"service":null,"types":["type_commons:Internal"],"errors":["error_commons:BadRequestError"],"subpackages":[],"navigationConfig":null,"webhooks":null,"websocket":null,"hasEndpointsInTree":false,"docs":null},"subpackage_imdb":{"name":{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}},"fernFilepath":{"allParts":[{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}}],"packagePath":[],"file":{"originalName":"imdb","camelCase":{"unsafeName":"imdb","safeName":"imdb"},"snakeCase":{"unsafeName":"imdb","safeName":"imdb"},"screamingSnakeCase":{"unsafeName":"IMDB","safeName":"IMDB"},"pascalCase":{"unsafeName":"Imdb","safeName":"Imdb"}}},"service":"service_imdb","types":["type_imdb:UnknownRequest"],"errors":[],"subpackages":[],"navigationConfig":null,"webhooks":null,"websocket":null,"hasEndpointsInTree":true,"docs":null}},"rootPackage":{"fernFilepath":{"allParts":[],"packagePath":[],"file":null},"websocket":null,"service":null,"types":[],"errors":[],"subpackages":["subpackage_commons","subpackage_imdb"],"webhooks":null,"navigationConfig":null,"hasEndpointsInTree":true,"docs":null},"sdkConfig":{"isAuthMandatory":false,"hasStreamingEndpoints":false,"hasPaginatedEndpoints":false,"hasFileDownloadEndpoints":false,"platformHeaders":{"language":"X-Fern-Language","sdkName":"X-Fern-SDK-Name","sdkVersion":"X-Fern-SDK-Version","userAgent":null}}}"`; diff --git a/packages/cli/generation/ir-generator/src/__test__/irs/environmentAudiences.json b/packages/cli/generation/ir-generator/src/__test__/irs/environmentAudiences.json index 1517cfb14c9..7f302004d53 100644 --- a/packages/cli/generation/ir-generator/src/__test__/irs/environmentAudiences.json +++ b/packages/cli/generation/ir-generator/src/__test__/irs/environmentAudiences.json @@ -4418,12 +4418,12 @@ "service_imdb": [ "type_imdb:MovieId", "type_imdb:Movie", - "type_imdb:CreateMovieRequest" + "type_imdb:CreateMovieRequest", + "type_imdb:Cast", + "type_imdb:Name" ] }, "sharedTypes": [ - "type_imdb:Cast", - "type_imdb:Name", "type_webhooks:User" ] }, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/code-samples-open-api.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/code-samples-open-api.json index dababa71fc7..41f947c2b0a 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/code-samples-open-api.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/code-samples-open-api.json @@ -1883,12 +1883,11 @@ "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { "service_": [ - "type_:TelemetryResponse" + "type_:TelemetryResponse", + "type_:TelemetryData" ] }, - "sharedTypes": [ - "type_:TelemetryData" - ] + "sharedTypes": [] }, "webhookGroups": {}, "websocketChannels": {}, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/enum-casing.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/enum-casing.json index 8aad5d2059e..abfe261141f 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/enum-casing.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/enum-casing.json @@ -1491,11 +1491,11 @@ "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { "service_": [ + "type_:ExampleResponseStatus", "type_:ExampleResponse" ] }, "sharedTypes": [ - "type_:ExampleResponseStatus", "type_:GrantTypeEnum" ] }, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/inline-schema-reference.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/inline-schema-reference.json index 999dcbd4639..3254563bda2 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/inline-schema-reference.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/inline-schema-reference.json @@ -1059,14 +1059,13 @@ "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { "service_": [ - "type_:GetExampleResponse" + "type_:NotFound", + "type_:GetExampleResponse", + "type_:Schema1", + "type_:Schema2" ] }, - "sharedTypes": [ - "type_:NotFound", - "type_:Schema1", - "type_:Schema2" - ] + "sharedTypes": [] }, "webhookGroups": {}, "websocketChannels": {}, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/names.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/names.json index 0f93fd90d86..163ade7a393 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/names.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions-openapi/names.json @@ -3203,12 +3203,11 @@ "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { "service_telemetry": [ - "type_telemetry:TelemetryGetTelemetryDataResponse" + "type_telemetry:TelemetryGetTelemetryDataResponse", + "type_infra/telemetry:TelemetryData" ] }, - "sharedTypes": [ - "type_infra/telemetry:TelemetryData" - ] + "sharedTypes": [] }, "webhookGroups": {}, "websocketChannels": {}, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/alias-extends.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/alias-extends.json index 030eafda699..f9f8062bfae 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/alias-extends.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/alias-extends.json @@ -1135,11 +1135,11 @@ "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { "service_": [ - "type_:AliasType" + "type_:AliasType", + "type_:Parent" ] }, "sharedTypes": [ - "type_:Parent", "type_:Child" ] }, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/audiences.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/audiences.json index 0be3f9eeae9..5b891631c2a 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/audiences.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/audiences.json @@ -4202,21 +4202,21 @@ "variables": [], "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { + "service_foo": [ + "type_commons:Imported", + "type_foo:ImportingType", + "type_foo:OptionalString" + ], "service_folder-a/service": [ - "type_folder-a/service:Response" + "type_folder-a/service:Response", + "type_folder-b/common:Foo", + "type_folder-c/common:FolderCFoo" ], "service_folder-d/service": [ "type_folder-d/service:Response" - ], - "service_foo": [ - "type_foo:ImportingType", - "type_foo:OptionalString" ] }, "sharedTypes": [ - "type_commons:Imported", - "type_folder-b/common:Foo", - "type_folder-c/common:FolderCFoo", "type_foo:FilteredType" ] }, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/cross-package-type-names.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/cross-package-type-names.json index f3ea7637df9..510afd51113 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/cross-package-type-names.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/cross-package-type-names.json @@ -4818,19 +4818,19 @@ "variables": [], "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { + "service_foo": [ + "type_commons:Imported", + "type_foo:ImportingType", + "type_foo:OptionalString" + ], "service_folder-a/service": [ "type_folder-a/service:Response" ], "service_folder-d/service": [ "type_folder-d/service:Response" - ], - "service_foo": [ - "type_foo:ImportingType", - "type_foo:OptionalString" ] }, "sharedTypes": [ - "type_commons:Imported", "type_folder-b/common:Foo", "type_folder-c/common:Foo" ] diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/csharp-grpc-proto-exhaustive.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/csharp-grpc-proto-exhaustive.json index 5578d6d5136..f3cff92d830 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/csharp-grpc-proto-exhaustive.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/csharp-grpc-proto-exhaustive.json @@ -23728,27 +23728,29 @@ "pathParameters": [], "variables": [], "serviceTypeReferenceInfo": { - "typesReferencedOnlyByService": {}, - "sharedTypes": [ - "type_:Column", - "type_:UploadResponse", - "type_:Metadata", - "type_:DeleteResponse", - "type_:DescribeResponse", - "type_:FetchResponse", - "type_:ListResponse", - "type_:QueryColumn", - "type_:IndexedData", - "type_:QueryResponse", - "type_:UpdateResponse", - "type_:ListElement", - "type_:NamespaceSummary", - "type_:Pagination", - "type_:QueryResult", - "type_:ScoredColumn", - "type_:Usage", - "type_:MetadataValue" - ] + "typesReferencedOnlyByService": { + "service_dataservice": [ + "type_:Column", + "type_:DeleteResponse", + "type_:DescribeResponse", + "type_:FetchResponse", + "type_:IndexedData", + "type_:ListElement", + "type_:ListResponse", + "type_:NamespaceSummary", + "type_:Pagination", + "type_:QueryColumn", + "type_:QueryResponse", + "type_:QueryResult", + "type_:ScoredColumn", + "type_:UpdateResponse", + "type_:UploadResponse", + "type_:Usage", + "type_:Metadata", + "type_:MetadataValue" + ] + }, + "sharedTypes": [] }, "webhookGroups": {}, "websocketChannels": {}, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/csharp-grpc-proto.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/csharp-grpc-proto.json index b49d8cbc684..14a81ab53d1 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/csharp-grpc-proto.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/csharp-grpc-proto.json @@ -3047,13 +3047,15 @@ "pathParameters": [], "variables": [], "serviceTypeReferenceInfo": { - "typesReferencedOnlyByService": {}, - "sharedTypes": [ - "type_:Metadata", - "type_:CreateResponse", - "type_:UserModel", - "type_:MetadataValue" - ] + "typesReferencedOnlyByService": { + "service_userservice": [ + "type_:CreateResponse", + "type_:UserModel", + "type_:Metadata", + "type_:MetadataValue" + ] + }, + "sharedTypes": [] }, "webhookGroups": {}, "websocketChannels": {}, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/examples.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/examples.json index 55737a814f2..d44fc8ed566 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/examples.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/examples.json @@ -37183,42 +37183,42 @@ "variables": [], "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { - "service_": [ - "type_:Type", - "type_:Identifier" + "service_service": [ + "type_commons/types:Tag", + "type_commons/types:Metadata", + "type_commons/types:EventInfo", + "type_commons/types:Data", + "type_types:MovieId", + "type_types:Movie", + "type_types:CastMember", + "type_types:Actor", + "type_types:Actress", + "type_types:StuntDouble", + "type_types:ExtendedMovie", + "type_types:Moment", + "type_types:Directory", + "type_types:Node", + "type_types:Tree", + "type_types:Metadata", + "type_types:MigrationStatus", + "type_types:Migration", + "type_types:Response", + "type_types:Test", + "type_types:Entity", + "type_types:BigEntity" ] }, "sharedTypes": [ + "type_:Type", + "type_:Identifier", "type_:BasicType", "type_:ComplexType", - "type_commons/types:Tag", - "type_commons/types:Metadata", - "type_commons/types:EventInfo", - "type_commons/types:Data", - "type_types:Exception", "type_file/service:Filename", "type_types:File", - "type_types:MovieId", - "type_types:Movie", - "type_types:Metadata", - "type_types:BigEntity", - "type_types:Response", - "type_types:CastMember", - "type_types:Actor", - "type_types:Actress", - "type_types:StuntDouble", - "type_types:ExtendedMovie", - "type_types:Moment", - "type_types:Directory", - "type_types:Node", - "type_types:Tree", + "type_types:Exception", "type_types:ExceptionInfo", - "type_types:MigrationStatus", - "type_types:Migration", "type_types:Request", - "type_types:ResponseType", - "type_types:Test", - "type_types:Entity" + "type_types:ResponseType" ] }, "webhookGroups": {}, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/exhaustive.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/exhaustive.json index 4271795b52b..49f8e0935f4 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/exhaustive.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/exhaustive.json @@ -65831,20 +65831,27 @@ "pathParameters": [], "variables": [], "serviceTypeReferenceInfo": { - "typesReferencedOnlyByService": {}, + "typesReferencedOnlyByService": { + "service_endpoints/enum": [ + "type_types/enum:WeatherReport" + ], + "service_endpoints/object": [ + "type_types/object:ObjectWithMapOfMap", + "type_types/object:NestedObjectWithOptionalField", + "type_types/object:NestedObjectWithRequiredField" + ], + "service_endpoints/union": [ + "type_types/union:Animal", + "type_types/union:Dog", + "type_types/union:Cat" + ] + }, "sharedTypes": [ - "type_types/object:ObjectWithRequiredField", - "type_types/object:ObjectWithOptionalField", - "type_types/enum:WeatherReport", - "type_types/object:ObjectWithMapOfMap", - "type_types/object:NestedObjectWithOptionalField", - "type_types/object:NestedObjectWithRequiredField", - "type_types/union:Animal", "type_general-errors:BadObjectRequestInfo", + "type_types/object:ObjectWithOptionalField", + "type_types/object:ObjectWithRequiredField", "type_types/object:DoubleOptional", - "type_types/object:OptionalAlias", - "type_types/union:Dog", - "type_types/union:Cat" + "type_types/object:OptionalAlias" ] }, "webhookGroups": {}, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/extends.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/extends.json index dcb7a7de56c..c8df69fbf4a 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/extends.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/extends.json @@ -1658,12 +1658,12 @@ "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { "service_": [ - "type_:ExampleType" + "type_:ExampleType", + "type_:Docs" ] }, "sharedTypes": [ "type_:NestedType", - "type_:Docs", "type_:JSON" ] }, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/literal.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/literal.json index 538ffa48a7d..2fd3edabb70 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/literal.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/literal.json @@ -11657,18 +11657,18 @@ "typesReferencedOnlyByService": { "service_inlined": [ "type_inlined:SomeAliasedLiteral", - "type_inlined:ATopLevelLiteral" + "type_inlined:ATopLevelLiteral", + "type_inlined:ANestedLiteral" ], "service_reference": [ - "type_reference:SendRequest" + "type_reference:SendRequest", + "type_reference:ContainerObject", + "type_reference:NestedObjectWithLiterals", + "type_reference:SomeLiteral" ] }, "sharedTypes": [ - "type_:SendResponse", - "type_inlined:ANestedLiteral", - "type_reference:ContainerObject", - "type_reference:NestedObjectWithLiterals", - "type_reference:SomeLiteral" + "type_:SendResponse" ] }, "webhookGroups": {}, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/mixed-case.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/mixed-case.json index cd150c1dcb2..35735bfe8cf 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/mixed-case.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/mixed-case.json @@ -6725,14 +6725,14 @@ "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { "service_service": [ + "type_service:Organization", + "type_service:User", + "type_service:ResourceStatus", "type_service:Resource" ] }, "sharedTypes": [ - "type_service:Organization", - "type_service:User", - "type_service:NestedUser", - "type_service:ResourceStatus" + "type_service:NestedUser" ] }, "webhookGroups": {}, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/mixed-file-directory.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/mixed-file-directory.json index 2488dffdcab..ae757030344 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/mixed-file-directory.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/mixed-file-directory.json @@ -6889,22 +6889,21 @@ "variables": [], "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { - "service_user/events/metadata": [ - "type_:Id", - "type_user/events/metadata:Metadata" - ], "service_organization": [ "type_organization:Organization", "type_organization:CreateOrganizationRequest" ], - "service_user": [ - "type_user:User" - ], "service_user/events": [ "type_user/events:Event" + ], + "service_user/events/metadata": [ + "type_user/events/metadata:Metadata" ] }, - "sharedTypes": [] + "sharedTypes": [ + "type_:Id", + "type_user:User" + ] }, "webhookGroups": {}, "websocketChannels": {}, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/pagination.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/pagination.json index 00258f65921..1f8c8a0a5bd 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/pagination.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/pagination.json @@ -22110,25 +22110,24 @@ "typesReferencedOnlyByService": { "service_users": [ "type_:UsernameCursor", + "type_:UsernamePage", "type_users:Order", "type_users:WithPage", "type_users:WithCursor", + "type_users:UserListContainer", + "type_users:UserPage", + "type_users:UserOptionalListContainer", + "type_users:UserOptionalListPage", "type_users:UsernameContainer", "type_users:ListUsersExtendedResponse", "type_users:ListUsersExtendedOptionalListResponse", - "type_users:ListUsersPaginationResponse" + "type_users:ListUsersPaginationResponse", + "type_users:Page", + "type_users:NextPage", + "type_users:User" ] }, - "sharedTypes": [ - "type_:UsernamePage", - "type_users:UserListContainer", - "type_users:UserPage", - "type_users:UserOptionalListContainer", - "type_users:UserOptionalListPage", - "type_users:Page", - "type_users:NextPage", - "type_users:User" - ] + "sharedTypes": [] }, "webhookGroups": {}, "websocketChannels": {}, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/response-property.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/response-property.json index 65bd0f04e4d..c07685cc6a0 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/response-property.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/response-property.json @@ -5658,15 +5658,14 @@ "service_service": [ "type_:StringResponse", "type_:OptionalStringResponse", + "type_:WithMetadata", + "type_service:WithDocs", "type_service:OptionalWithDocs", + "type_service:Movie", "type_service:Response" ] }, - "sharedTypes": [ - "type_:WithMetadata", - "type_service:WithDocs", - "type_service:Movie" - ] + "sharedTypes": [] }, "webhookGroups": {}, "websocketChannels": {}, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/simple-fhir.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/simple-fhir.json index dbc74970701..ae45706a7b9 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/simple-fhir.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/simple-fhir.json @@ -3485,17 +3485,16 @@ "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { "service_": [ - "type_:Account" + "type_:Memo", + "type_:BaseResource", + "type_:ResourceList", + "type_:Account", + "type_:Patient", + "type_:Practitioner", + "type_:Script" ] }, - "sharedTypes": [ - "type_:Memo", - "type_:BaseResource", - "type_:ResourceList", - "type_:Patient", - "type_:Practitioner", - "type_:Script" - ] + "sharedTypes": [] }, "webhookGroups": {}, "websocketChannels": {}, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/trace.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/trace.json index b6deec7516c..7c5371ae82e 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/trace.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/trace.json @@ -438429,84 +438429,166 @@ "variables": [], "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { + "service_playlist": [ + "type_commons:UserId", + "type_playlist:PlaylistId", + "type_playlist:Playlist", + "type_playlist:PlaylistCreateRequest", + "type_playlist:UpdatePlaylistRequest" + ], + "service_admin": [ + "type_commons:DebugVariableValue", + "type_commons:GenericValue", + "type_commons:BinaryTreeNodeAndTreeValue", + "type_commons:SinglyLinkedListNodeAndListValue", + "type_commons:DoublyLinkedListNodeAndListValue", + "type_commons:DebugMapValue", + "type_commons:DebugKeyValuePairs", + "type_submission:SubmissionId", + "type_submission:RunningSubmissionState", + "type_submission:ErrorInfo", + "type_submission:CompileError", + "type_submission:RuntimeError", + "type_submission:InternalError", + "type_submission:WorkspaceRunDetails", + "type_submission:TestCaseGrade", + "type_submission:TestCaseHiddenGrade", + "type_submission:TestCaseNonHiddenGrade", + "type_submission:TestCaseResultWithStdout", + "type_submission:TestCaseResult", + "type_submission:ActualResult", + "type_submission:ExceptionV2", + "type_submission:ExceptionInfo", + "type_submission:TraceResponse", + "type_submission:TraceResponseV2", + "type_submission:TracedFile", + "type_submission:ExpressionLocation", + "type_submission:StackInformation", + "type_submission:StackFrame", + "type_submission:Scope", + "type_submission:TestSubmissionUpdate", + "type_submission:TestSubmissionUpdateInfo", + "type_submission:WorkspaceSubmissionUpdate", + "type_submission:WorkspaceSubmissionUpdateInfo", + "type_submission:GradedTestCaseUpdate", + "type_submission:RecordedTestCaseUpdate", + "type_submission:WorkspaceTracedUpdate", + "type_submission:WorkspaceSubmissionStatus", + "type_submission:TestSubmissionStatus", + "type_submission:SubmissionStatusForTestCase", + "type_submission:TracedTestCase" + ], "service_problem": [ - "type_commons:VariableType", + "type_commons:TestCase", + "type_commons:TestCaseWithExpectedResult", + "type_commons:FileInfo", + "type_problem:ProblemFiles", "type_problem:VariableTypeAndName", "type_problem:CreateProblemRequest", "type_problem:CreateProblemResponse", "type_problem:UpdateProblemResponse", + "type_problem:CreateProblemError", + "type_problem:GenericCreateProblemError", "type_problem:GetDefaultStarterFilesResponse" ], "service_migration": [ + "type_migration:MigrationStatus", "type_migration:Migration" ], - "service_playlist": [ - "type_playlist:PlaylistId", - "type_playlist:Playlist", - "type_playlist:PlaylistCreateRequest", - "type_playlist:UpdatePlaylistRequest" - ], "service_submission": [ "type_submission:ExecutionSessionResponse", + "type_submission:ExecutionSessionStatus", + "type_submission:ExecutionSessionState", "type_submission:GetExecutionSessionStateResponse" ], "service_v2/problem": [ + "type_v2/problem:TestCaseTemplateId", + "type_v2/problem:ParameterId", "type_v2/problem:ProblemInfoV2", - "type_v2/problem:LightweightProblemInfoV2" + "type_v2/problem:LightweightProblemInfoV2", + "type_v2/problem:TestCaseV2", + "type_v2/problem:TestCaseExpects", + "type_v2/problem:TestCaseImplementationReference", + "type_v2/problem:BasicTestCaseTemplate", + "type_v2/problem:TestCaseTemplate", + "type_v2/problem:TestCaseImplementation", + "type_v2/problem:TestCaseFunction", + "type_v2/problem:TestCaseWithActualResultImplementation", + "type_v2/problem:VoidFunctionDefinition", + "type_v2/problem:Parameter", + "type_v2/problem:NonVoidFunctionDefinition", + "type_v2/problem:NonVoidFunctionSignature", + "type_v2/problem:AssertCorrectnessCheck", + "type_v2/problem:DeepEqualityCorrectnessCheck", + "type_v2/problem:VoidFunctionDefinitionThatTakesActualResult", + "type_v2/problem:TestCaseImplementationDescription", + "type_v2/problem:TestCaseImplementationDescriptionBoard", + "type_v2/problem:TestCaseMetadata", + "type_v2/problem:FunctionImplementationForMultipleLanguages", + "type_v2/problem:FunctionImplementation", + "type_v2/problem:GeneratedFiles", + "type_v2/problem:CustomFiles", + "type_v2/problem:BasicCustomFiles", + "type_v2/problem:Files", + "type_v2/problem:FileInfoV2" ], "service_v2/v3/problem": [ + "type_v2/v3/problem:TestCaseTemplateId", + "type_v2/v3/problem:TestCaseId", + "type_v2/v3/problem:ParameterId", "type_v2/v3/problem:ProblemInfoV2", - "type_v2/v3/problem:LightweightProblemInfoV2" + "type_v2/v3/problem:LightweightProblemInfoV2", + "type_v2/v3/problem:TestCaseV2", + "type_v2/v3/problem:TestCaseExpects", + "type_v2/v3/problem:TestCaseImplementationReference", + "type_v2/v3/problem:BasicTestCaseTemplate", + "type_v2/v3/problem:TestCaseTemplate", + "type_v2/v3/problem:TestCaseImplementation", + "type_v2/v3/problem:TestCaseFunction", + "type_v2/v3/problem:TestCaseWithActualResultImplementation", + "type_v2/v3/problem:VoidFunctionDefinition", + "type_v2/v3/problem:Parameter", + "type_v2/v3/problem:NonVoidFunctionDefinition", + "type_v2/v3/problem:NonVoidFunctionSignature", + "type_v2/v3/problem:AssertCorrectnessCheck", + "type_v2/v3/problem:DeepEqualityCorrectnessCheck", + "type_v2/v3/problem:VoidFunctionDefinitionThatTakesActualResult", + "type_v2/v3/problem:TestCaseImplementationDescription", + "type_v2/v3/problem:TestCaseImplementationDescriptionBoard", + "type_v2/v3/problem:TestCaseMetadata", + "type_v2/v3/problem:FunctionImplementationForMultipleLanguages", + "type_v2/v3/problem:FunctionImplementation", + "type_v2/v3/problem:GeneratedFiles", + "type_v2/v3/problem:CustomFiles", + "type_v2/v3/problem:BasicCustomFiles", + "type_v2/v3/problem:Files", + "type_v2/v3/problem:FileInfoV2" ] }, "sharedTypes": [ "type_admin:Test", - "type_submission:SubmissionId", - "type_submission:TestSubmissionStatus", - "type_submission:TestSubmissionUpdate", - "type_submission:WorkspaceSubmissionStatus", - "type_submission:WorkspaceSubmissionUpdate", - "type_submission:TestCaseResultWithStdout", - "type_submission:TraceResponse", - "type_v2/problem:TestCaseId", - "type_submission:TraceResponseV2", - "type_submission:WorkspaceRunDetails", - "type_commons:UserId", "type_commons:ProblemId", "type_commons:NodeId", + "type_commons:VariableType", "type_commons:ListType", "type_commons:MapType", "type_commons:VariableValue", - "type_commons:DebugVariableValue", - "type_commons:GenericValue", "type_commons:MapValue", "type_commons:KeyValuePair", "type_commons:BinaryTreeValue", "type_commons:BinaryTreeNodeValue", - "type_commons:BinaryTreeNodeAndTreeValue", "type_commons:SinglyLinkedListValue", "type_commons:SinglyLinkedListNodeValue", - "type_commons:SinglyLinkedListNodeAndListValue", "type_commons:DoublyLinkedListValue", "type_commons:DoublyLinkedListNodeValue", - "type_commons:DoublyLinkedListNodeAndListValue", - "type_commons:DebugMapValue", - "type_commons:DebugKeyValuePairs", - "type_commons:TestCase", - "type_commons:TestCaseWithExpectedResult", - "type_commons:FileInfo", "type_commons:Language", "type_lang-server:LangServerRequest", "type_lang-server:LangServerResponse", - "type_migration:MigrationStatus", "type_playlist:PlaylistIdNotFoundErrorBody", "type_playlist:ReservedKeywordEnum", "type_problem:ProblemInfo", "type_problem:ProblemDescription", "type_problem:ProblemDescriptionBoard", - "type_problem:ProblemFiles", - "type_problem:CreateProblemError", - "type_problem:GenericCreateProblemError", "type_submission:ShareId", "type_submission:SubmissionRequest", "type_submission:InitializeProblemRequest", @@ -438519,26 +438601,14 @@ "type_submission:CodeExecutionUpdate", "type_submission:BuildingExecutorResponse", "type_submission:RunningResponse", - "type_submission:RunningSubmissionState", "type_submission:ErroredResponse", - "type_submission:ErrorInfo", - "type_submission:CompileError", - "type_submission:RuntimeError", - "type_submission:InternalError", "type_submission:StoppedResponse", "type_submission:WorkspaceRanResponse", "type_submission:GradedResponse", "type_submission:GradedResponseV2", - "type_submission:TestCaseGrade", - "type_submission:TestCaseHiddenGrade", - "type_submission:TestCaseNonHiddenGrade", "type_submission:RecordedResponseNotification", "type_submission:RecordingResponseNotification", "type_submission:LightweightStackframeInformation", - "type_submission:TestCaseResult", - "type_submission:ActualResult", - "type_submission:ExceptionV2", - "type_submission:ExceptionInfo", "type_submission:InvalidRequestResponse", "type_submission:InvalidRequestCause", "type_submission:ExistingSubmissionExecuting", @@ -438549,63 +438619,23 @@ "type_submission:FinishedResponse", "type_submission:StdoutResponse", "type_submission:StderrResponse", - "type_submission:TracedFile", - "type_submission:ExpressionLocation", - "type_submission:StackInformation", - "type_submission:StackFrame", - "type_submission:Scope", - "type_submission:ExecutionSessionStatus", "type_submission:SubmissionStatusV2", "type_submission:TestSubmissionStatusV2", "type_submission:WorkspaceSubmissionStatusV2", - "type_submission:TestSubmissionUpdateInfo", - "type_submission:WorkspaceSubmissionUpdateInfo", - "type_submission:GradedTestCaseUpdate", - "type_submission:RecordedTestCaseUpdate", - "type_submission:WorkspaceTracedUpdate", "type_submission:SubmissionTypeState", "type_submission:WorkspaceSubmissionState", "type_submission:TestSubmissionState", - "type_submission:SubmissionStatusForTestCase", - "type_submission:TracedTestCase", "type_submission:TraceResponsesPage", "type_submission:TraceResponsesPageV2", "type_submission:GetTraceResponsesPageRequest", "type_submission:WorkspaceStarterFilesResponse", "type_submission:WorkspaceStarterFilesResponseV2", "type_submission:WorkspaceFiles", - "type_submission:ExecutionSessionState", "type_submission:GetSubmissionStateResponse", - "type_v2/problem:TestCaseTemplateId", - "type_v2/problem:ParameterId", + "type_v2/problem:TestCaseId", "type_v2/problem:CreateProblemRequestV2", - "type_v2/problem:TestCaseV2", - "type_v2/problem:TestCaseExpects", - "type_v2/problem:TestCaseImplementationReference", - "type_v2/problem:BasicTestCaseTemplate", - "type_v2/problem:TestCaseTemplate", - "type_v2/problem:TestCaseImplementation", - "type_v2/problem:TestCaseFunction", - "type_v2/problem:TestCaseWithActualResultImplementation", - "type_v2/problem:VoidFunctionDefinition", - "type_v2/problem:Parameter", - "type_v2/problem:NonVoidFunctionDefinition", "type_v2/problem:VoidFunctionSignature", - "type_v2/problem:NonVoidFunctionSignature", "type_v2/problem:VoidFunctionSignatureThatTakesActualResult", - "type_v2/problem:AssertCorrectnessCheck", - "type_v2/problem:DeepEqualityCorrectnessCheck", - "type_v2/problem:VoidFunctionDefinitionThatTakesActualResult", - "type_v2/problem:TestCaseImplementationDescription", - "type_v2/problem:TestCaseImplementationDescriptionBoard", - "type_v2/problem:TestCaseMetadata", - "type_v2/problem:FunctionImplementationForMultipleLanguages", - "type_v2/problem:FunctionImplementation", - "type_v2/problem:GeneratedFiles", - "type_v2/problem:CustomFiles", - "type_v2/problem:BasicCustomFiles", - "type_v2/problem:Files", - "type_v2/problem:FileInfoV2", "type_v2/problem:DefaultProvidedFile", "type_v2/problem:FunctionSignature", "type_v2/problem:GetFunctionSignatureRequest", @@ -438614,37 +438644,9 @@ "type_v2/problem:GetBasicSolutionFileResponse", "type_v2/problem:GetGeneratedTestCaseFileRequest", "type_v2/problem:GetGeneratedTestCaseTemplateFileRequest", - "type_v2/v3/problem:TestCaseTemplateId", - "type_v2/v3/problem:TestCaseId", - "type_v2/v3/problem:ParameterId", "type_v2/v3/problem:CreateProblemRequestV2", - "type_v2/v3/problem:TestCaseV2", - "type_v2/v3/problem:TestCaseExpects", - "type_v2/v3/problem:TestCaseImplementationReference", - "type_v2/v3/problem:BasicTestCaseTemplate", - "type_v2/v3/problem:TestCaseTemplate", - "type_v2/v3/problem:TestCaseImplementation", - "type_v2/v3/problem:TestCaseFunction", - "type_v2/v3/problem:TestCaseWithActualResultImplementation", - "type_v2/v3/problem:VoidFunctionDefinition", - "type_v2/v3/problem:Parameter", - "type_v2/v3/problem:NonVoidFunctionDefinition", "type_v2/v3/problem:VoidFunctionSignature", - "type_v2/v3/problem:NonVoidFunctionSignature", "type_v2/v3/problem:VoidFunctionSignatureThatTakesActualResult", - "type_v2/v3/problem:AssertCorrectnessCheck", - "type_v2/v3/problem:DeepEqualityCorrectnessCheck", - "type_v2/v3/problem:VoidFunctionDefinitionThatTakesActualResult", - "type_v2/v3/problem:TestCaseImplementationDescription", - "type_v2/v3/problem:TestCaseImplementationDescriptionBoard", - "type_v2/v3/problem:TestCaseMetadata", - "type_v2/v3/problem:FunctionImplementationForMultipleLanguages", - "type_v2/v3/problem:FunctionImplementation", - "type_v2/v3/problem:GeneratedFiles", - "type_v2/v3/problem:CustomFiles", - "type_v2/v3/problem:BasicCustomFiles", - "type_v2/v3/problem:Files", - "type_v2/v3/problem:FileInfoV2", "type_v2/v3/problem:DefaultProvidedFile", "type_v2/v3/problem:FunctionSignature", "type_v2/v3/problem:GetFunctionSignatureRequest", diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/undiscriminated-unions.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/undiscriminated-unions.json index 48033969cad..16c6edf30c4 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/undiscriminated-unions.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/undiscriminated-unions.json @@ -3321,13 +3321,13 @@ "typesReferencedOnlyByService": { "service_union": [ "type_union:MyUnion", - "type_union:Metadata" + "type_union:Metadata", + "type_union:Key", + "type_union:KeyType" ] }, "sharedTypes": [ - "type_union:TypeWithOptionalUnion", - "type_union:Key", - "type_union:KeyType" + "type_union:TypeWithOptionalUnion" ] }, "webhookGroups": {}, diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/unions.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/unions.json index 30e0db46f0e..beb4272005d 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/unions.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/unions.json @@ -4833,7 +4833,9 @@ "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { "service_union": [ - "type_union:Shape" + "type_union:Shape", + "type_union:Circle", + "type_union:Square" ] }, "sharedTypes": [ @@ -4849,9 +4851,7 @@ "type_types:UnionWithSingleElement", "type_types:Foo", "type_types:Bar", - "type_union:GetShapeRequest", - "type_union:Circle", - "type_union:Square" + "type_union:GetShapeRequest" ] }, "webhookGroups": {}, diff --git a/packages/cli/generation/ir-generator/src/filtered-ir/IrGraph.ts b/packages/cli/generation/ir-generator/src/filtered-ir/IrGraph.ts index 6d94a5c8cbb..62d354b627b 100644 --- a/packages/cli/generation/ir-generator/src/filtered-ir/IrGraph.ts +++ b/packages/cli/generation/ir-generator/src/filtered-ir/IrGraph.ts @@ -119,6 +119,11 @@ export class IrGraph { } public getTypesReferencedByService(): Record> { + for (const endpoint of Object.values(this.endpoints)) { + for (const typeId of endpoint.referencedTypes) { + this.markTypeForService(typeId, endpoint.serviceId); + } + } return this.typesReferencedByService; } @@ -261,11 +266,9 @@ export class IrGraph { referencedErrors.add(IdGenerator.generateErrorId(responseError.error)); referencedSubpackages.add(responseError.error.fernFilepath); }); - for (const typeId of referencedTypes) { - this.markTypeForService(typeId, serviceId); - } this.endpoints[endpointId] = { endpointId, + serviceId, referencedTypes, referencedErrors, referencedSubpackages @@ -462,11 +465,16 @@ export class IrGraph { } private markTypeForService(typeId: TypeId, serviceId: ServiceId): void { - const services = this.typesReferencedByService[typeId]; - if (services == null) { - this.typesReferencedByService[typeId] = new Set(serviceId); - } else { - services.add(serviceId); + const types = (this.typesReferencedByService[typeId] ??= new Set()); + if (types.has(serviceId)) { + return; + } + + types.add(serviceId); + + const typeNode = this.getTypeNode(typeId); + for (const descendantTypeId of typeNode.allDescendants) { + this.markTypeForService(descendantTypeId, serviceId); } } diff --git a/packages/cli/generation/ir-generator/src/filtered-ir/ids.ts b/packages/cli/generation/ir-generator/src/filtered-ir/ids.ts index dd114889a7d..a839dea4a9c 100644 --- a/packages/cli/generation/ir-generator/src/filtered-ir/ids.ts +++ b/packages/cli/generation/ir-generator/src/filtered-ir/ids.ts @@ -55,6 +55,7 @@ export interface ErrorNode { export interface EndpointNode { endpointId: EndpointId; + serviceId: ServiceId; referencedErrors: Set; referencedTypes: Set; referencedSubpackages: Set; diff --git a/packages/cli/generation/ir-migrations/src/migrations/v23-to-v22/__test__/__snapshots__/migrateFromV23ToV22.test.ts.snap b/packages/cli/generation/ir-migrations/src/migrations/v23-to-v22/__test__/__snapshots__/migrateFromV23ToV22.test.ts.snap index 81ab420c6a2..d9ec478dd62 100644 --- a/packages/cli/generation/ir-migrations/src/migrations/v23-to-v22/__test__/__snapshots__/migrateFromV23ToV22.test.ts.snap +++ b/packages/cli/generation/ir-migrations/src/migrations/v23-to-v22/__test__/__snapshots__/migrateFromV23ToV22.test.ts.snap @@ -1722,17 +1722,24 @@ exports[`migrateFromV23ToV22 > migrates extensive 1`] = ` }, "serviceTypeReferenceInfo": { "sharedTypes": [ - "type_types/object:ObjectWithRequiredField", - "type_types/enum:WeatherReport", - "type_types/object:ObjectWithOptionalField", - "type_types/object:NestedObjectWithOptionalField", - "type_types/object:NestedObjectWithRequiredField", - "type_types/union:Animal", "type_general-errors:BadObjectRequestInfo", - "type_types/union:Dog", - "type_types/union:Cat", + "type_types/object:ObjectWithOptionalField", + "type_types/object:ObjectWithRequiredField", ], - "typesReferencedOnlyByService": {}, + "typesReferencedOnlyByService": { + "service_endpoints/enum": [ + "type_types/enum:WeatherReport", + ], + "service_endpoints/object": [ + "type_types/object:NestedObjectWithOptionalField", + "type_types/object:NestedObjectWithRequiredField", + ], + "service_endpoints/union": [ + "type_types/union:Animal", + "type_types/union:Dog", + "type_types/union:Cat", + ], + }, }, "services": { "service_endpoints/container": { diff --git a/packages/cli/generation/ir-migrations/src/migrations/v35-to-v34/__test__/__snapshots__/migrateFromV35ToV34.test.ts.snap b/packages/cli/generation/ir-migrations/src/migrations/v35-to-v34/__test__/__snapshots__/migrateFromV35ToV34.test.ts.snap index a7616348824..fa60998ebf1 100644 --- a/packages/cli/generation/ir-migrations/src/migrations/v35-to-v34/__test__/__snapshots__/migrateFromV35ToV34.test.ts.snap +++ b/packages/cli/generation/ir-migrations/src/migrations/v35-to-v34/__test__/__snapshots__/migrateFromV35ToV34.test.ts.snap @@ -90,11 +90,10 @@ exports[`migrateFromV35ToV34 > snapshot 1`] = ` }, }, "serviceTypeReferenceInfo": { - "sharedTypes": [ - "type_service:User", - ], + "sharedTypes": [], "typesReferencedOnlyByService": { "service_service": [ + "type_service:User", "type_service:ListUsersResponse", ], }, diff --git a/packages/cli/generation/ir-migrations/src/migrations/v36-to-v35/__test__/__snapshots__/migrateFromV36ToV35.test.ts.snap b/packages/cli/generation/ir-migrations/src/migrations/v36-to-v35/__test__/__snapshots__/migrateFromV36ToV35.test.ts.snap index 9f25a26bcec..f4d311621a3 100644 --- a/packages/cli/generation/ir-migrations/src/migrations/v36-to-v35/__test__/__snapshots__/migrateFromV36ToV35.test.ts.snap +++ b/packages/cli/generation/ir-migrations/src/migrations/v36-to-v35/__test__/__snapshots__/migrateFromV36ToV35.test.ts.snap @@ -90,11 +90,10 @@ exports[`migrateFromV36ToV35 > snapshot 1`] = ` }, }, "serviceTypeReferenceInfo": { - "sharedTypes": [ - "type_service:User", - ], + "sharedTypes": [], "typesReferencedOnlyByService": { "service_service": [ + "type_service:User", "type_service:ListUsersResponse", ], }, diff --git a/packages/cli/generation/ir-migrations/src/migrations/v48-to-v47/__test__/__snapshots__/migrateFromV48ToV47.test.ts.snap b/packages/cli/generation/ir-migrations/src/migrations/v48-to-v47/__test__/__snapshots__/migrateFromV48ToV47.test.ts.snap index 43f51ceef9a..07b3b5eb48f 100644 --- a/packages/cli/generation/ir-migrations/src/migrations/v48-to-v47/__test__/__snapshots__/migrateFromV48ToV47.test.ts.snap +++ b/packages/cli/generation/ir-migrations/src/migrations/v48-to-v47/__test__/__snapshots__/migrateFromV48ToV47.test.ts.snap @@ -117,11 +117,10 @@ exports[`migrateFromV48ToV47 > remove-all-pagination 1`] = ` }, }, "serviceTypeReferenceInfo": { - "sharedTypes": [ - "type_service:User", - ], + "sharedTypes": [], "typesReferencedOnlyByService": { "service_service": [ + "type_service:User", "type_service:ListUsersResponse", ], }, @@ -1583,11 +1582,10 @@ exports[`migrateFromV48ToV47 > simple 1`] = ` }, }, "serviceTypeReferenceInfo": { - "sharedTypes": [ - "type_service:User", - ], + "sharedTypes": [], "typesReferencedOnlyByService": { "service_service": [ + "type_service:User", "type_service:ListUsersResponse", ], }, diff --git a/packages/cli/generation/ir-migrations/src/migrations/v52-to-v51/__test__/__snapshots__/migrateFromV52ToV51.test.ts.snap b/packages/cli/generation/ir-migrations/src/migrations/v52-to-v51/__test__/__snapshots__/migrateFromV52ToV51.test.ts.snap index edaf34b6b83..e45d69c539b 100644 --- a/packages/cli/generation/ir-migrations/src/migrations/v52-to-v51/__test__/__snapshots__/migrateFromV52ToV51.test.ts.snap +++ b/packages/cli/generation/ir-migrations/src/migrations/v52-to-v51/__test__/__snapshots__/migrateFromV52ToV51.test.ts.snap @@ -118,12 +118,11 @@ exports[`migrateFromV52ToV51 > simple 1`] = ` }, }, "serviceTypeReferenceInfo": { - "sharedTypes": [ - "type_service:User", - ], + "sharedTypes": [], "typesReferencedOnlyByService": { "service_service": [ "type_service:UserType", + "type_service:User", "type_service:ListUsersResponse", ], }, diff --git a/packages/cli/generation/ir-migrations/src/migrations/v53-to-v52/__test__/__snapshots__/migrateFromV53ToV52.test.ts.snap b/packages/cli/generation/ir-migrations/src/migrations/v53-to-v52/__test__/__snapshots__/migrateFromV53ToV52.test.ts.snap index a12f48f2bd8..a008c9e63bf 100644 --- a/packages/cli/generation/ir-migrations/src/migrations/v53-to-v52/__test__/__snapshots__/migrateFromV53ToV52.test.ts.snap +++ b/packages/cli/generation/ir-migrations/src/migrations/v53-to-v52/__test__/__snapshots__/migrateFromV53ToV52.test.ts.snap @@ -118,12 +118,11 @@ exports[`migrateFromV53ToV52 > simple 1`] = ` }, }, "serviceTypeReferenceInfo": { - "sharedTypes": [ - "type_service:User", - ], + "sharedTypes": [], "typesReferencedOnlyByService": { "service_service": [ "type_service:UserType", + "type_service:User", "type_service:ListUsersResponse", ], }, diff --git a/seed/go-fiber/examples/file/types.go b/seed/go-fiber/audiences/commons.go similarity index 62% rename from seed/go-fiber/examples/file/types.go rename to seed/go-fiber/audiences/commons.go index edc509f893e..b214fff131d 100644 --- a/seed/go-fiber/examples/file/types.go +++ b/seed/go-fiber/audiences/commons.go @@ -1,5 +1,5 @@ // This file was auto-generated by Fern from our API Definition. -package file +package audiences -type Filename = string +type Imported = string diff --git a/seed/go-fiber/audiences/folderb/types.go b/seed/go-fiber/audiences/folderb/common.go similarity index 100% rename from seed/go-fiber/audiences/folderb/types.go rename to seed/go-fiber/audiences/folderb/common.go diff --git a/seed/go-fiber/audiences/folderc/types.go b/seed/go-fiber/audiences/folderc/common.go similarity index 100% rename from seed/go-fiber/audiences/folderc/types.go rename to seed/go-fiber/audiences/folderc/common.go diff --git a/seed/go-fiber/audiences/foo.go b/seed/go-fiber/audiences/foo.go index 88a1ad56e8b..211f2557212 100644 --- a/seed/go-fiber/audiences/foo.go +++ b/seed/go-fiber/audiences/foo.go @@ -14,6 +14,55 @@ type FindRequest struct { PrivateProperty *int `json:"privateProperty,omitempty" url:"-"` } +type FilteredType struct { + PublicProperty *string `json:"public_property,omitempty" url:"public_property,omitempty"` + PrivateProperty int `json:"private_property" url:"private_property"` + + extraProperties map[string]interface{} +} + +func (f *FilteredType) GetPublicProperty() *string { + if f == nil { + return nil + } + return f.PublicProperty +} + +func (f *FilteredType) GetPrivateProperty() int { + if f == nil { + return 0 + } + return f.PrivateProperty +} + +func (f *FilteredType) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *FilteredType) UnmarshalJSON(data []byte) error { + type unmarshaler FilteredType + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = FilteredType(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + return nil +} + +func (f *FilteredType) String() string { + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + type ImportingType struct { Imported Imported `json:"imported" url:"imported"` diff --git a/seed/go-fiber/audiences/types.go b/seed/go-fiber/audiences/types.go deleted file mode 100644 index 706ef88eb6c..00000000000 --- a/seed/go-fiber/audiences/types.go +++ /dev/null @@ -1,60 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package audiences - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/audiences/fern/core" -) - -type Imported = string - -type FilteredType struct { - PublicProperty *string `json:"public_property,omitempty" url:"public_property,omitempty"` - PrivateProperty int `json:"private_property" url:"private_property"` - - extraProperties map[string]interface{} -} - -func (f *FilteredType) GetPublicProperty() *string { - if f == nil { - return nil - } - return f.PublicProperty -} - -func (f *FilteredType) GetPrivateProperty() int { - if f == nil { - return 0 - } - return f.PrivateProperty -} - -func (f *FilteredType) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *FilteredType) UnmarshalJSON(data []byte) error { - type unmarshaler FilteredType - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = FilteredType(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - return nil -} - -func (f *FilteredType) String() string { - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} diff --git a/seed/go-fiber/circular-references-advanced/a.go b/seed/go-fiber/circular-references-advanced/a.go new file mode 100644 index 00000000000..90d8f431f71 --- /dev/null +++ b/seed/go-fiber/circular-references-advanced/a.go @@ -0,0 +1,50 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/circular-references-advanced/fern/core" +) + +type A struct { + S string `json:"s" url:"s"` + + extraProperties map[string]interface{} +} + +func (a *A) GetS() string { + if a == nil { + return "" + } + return a.S +} + +func (a *A) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *A) UnmarshalJSON(data []byte) error { + type unmarshaler A + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *a = A(value) + + extraProperties, err := core.ExtractExtraProperties(data, *a) + if err != nil { + return err + } + a.extraProperties = extraProperties + + return nil +} + +func (a *A) String() string { + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} diff --git a/seed/go-fiber/circular-references-advanced/ast.go b/seed/go-fiber/circular-references-advanced/ast.go new file mode 100644 index 00000000000..b053cf04ef7 --- /dev/null +++ b/seed/go-fiber/circular-references-advanced/ast.go @@ -0,0 +1,354 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/circular-references-advanced/fern/core" +) + +type ContainerValue struct { + Type string + List []*FieldValue + Optional *FieldValue +} + +func NewContainerValueFromList(value []*FieldValue) *ContainerValue { + return &ContainerValue{Type: "list", List: value} +} + +func NewContainerValueFromOptional(value *FieldValue) *ContainerValue { + return &ContainerValue{Type: "optional", Optional: value} +} + +func (c *ContainerValue) GetType() string { + if c == nil { + return "" + } + return c.Type +} + +func (c *ContainerValue) GetList() []*FieldValue { + if c == nil { + return nil + } + return c.List +} + +func (c *ContainerValue) GetOptional() *FieldValue { + if c == nil { + return nil + } + return c.Optional +} + +func (c *ContainerValue) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + c.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", c) + } + switch unmarshaler.Type { + case "list": + var valueUnmarshaler struct { + List []*FieldValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + c.List = valueUnmarshaler.List + case "optional": + var valueUnmarshaler struct { + Optional *FieldValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + c.Optional = valueUnmarshaler.Optional + } + return nil +} + +func (c ContainerValue) MarshalJSON() ([]byte, error) { + switch c.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", c.Type, c) + case "list": + var marshaler = struct { + Type string `json:"type"` + List []*FieldValue `json:"value,omitempty"` + }{ + Type: "list", + List: c.List, + } + return json.Marshal(marshaler) + case "optional": + var marshaler = struct { + Type string `json:"type"` + Optional *FieldValue `json:"value,omitempty"` + }{ + Type: "optional", + Optional: c.Optional, + } + return json.Marshal(marshaler) + } +} + +type ContainerValueVisitor interface { + VisitList([]*FieldValue) error + VisitOptional(*FieldValue) error +} + +func (c *ContainerValue) Accept(visitor ContainerValueVisitor) error { + switch c.Type { + default: + return fmt.Errorf("invalid type %s in %T", c.Type, c) + case "list": + return visitor.VisitList(c.List) + case "optional": + return visitor.VisitOptional(c.Optional) + } +} + +type FieldName = string + +type FieldValue struct { + Type string + PrimitiveValue PrimitiveValue + ObjectValue *ObjectValue + ContainerValue *ContainerValue +} + +func NewFieldValueFromPrimitiveValue(value PrimitiveValue) *FieldValue { + return &FieldValue{Type: "primitive_value", PrimitiveValue: value} +} + +func NewFieldValueFromObjectValue(value *ObjectValue) *FieldValue { + return &FieldValue{Type: "object_value", ObjectValue: value} +} + +func NewFieldValueFromContainerValue(value *ContainerValue) *FieldValue { + return &FieldValue{Type: "container_value", ContainerValue: value} +} + +func (f *FieldValue) GetType() string { + if f == nil { + return "" + } + return f.Type +} + +func (f *FieldValue) GetPrimitiveValue() PrimitiveValue { + if f == nil { + return "" + } + return f.PrimitiveValue +} + +func (f *FieldValue) GetObjectValue() *ObjectValue { + if f == nil { + return nil + } + return f.ObjectValue +} + +func (f *FieldValue) GetContainerValue() *ContainerValue { + if f == nil { + return nil + } + return f.ContainerValue +} + +func (f *FieldValue) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + f.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", f) + } + switch unmarshaler.Type { + case "primitive_value": + var valueUnmarshaler struct { + PrimitiveValue PrimitiveValue `json:"value"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + f.PrimitiveValue = valueUnmarshaler.PrimitiveValue + case "object_value": + value := new(ObjectValue) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + f.ObjectValue = value + case "container_value": + var valueUnmarshaler struct { + ContainerValue *ContainerValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + f.ContainerValue = valueUnmarshaler.ContainerValue + } + return nil +} + +func (f FieldValue) MarshalJSON() ([]byte, error) { + switch f.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", f.Type, f) + case "primitive_value": + var marshaler = struct { + Type string `json:"type"` + PrimitiveValue PrimitiveValue `json:"value"` + }{ + Type: "primitive_value", + PrimitiveValue: f.PrimitiveValue, + } + return json.Marshal(marshaler) + case "object_value": + return core.MarshalJSONWithExtraProperty(f.ObjectValue, "type", "object_value") + case "container_value": + var marshaler = struct { + Type string `json:"type"` + ContainerValue *ContainerValue `json:"value,omitempty"` + }{ + Type: "container_value", + ContainerValue: f.ContainerValue, + } + return json.Marshal(marshaler) + } +} + +type FieldValueVisitor interface { + VisitPrimitiveValue(PrimitiveValue) error + VisitObjectValue(*ObjectValue) error + VisitContainerValue(*ContainerValue) error +} + +func (f *FieldValue) Accept(visitor FieldValueVisitor) error { + switch f.Type { + default: + return fmt.Errorf("invalid type %s in %T", f.Type, f) + case "primitive_value": + return visitor.VisitPrimitiveValue(f.PrimitiveValue) + case "object_value": + return visitor.VisitObjectValue(f.ObjectValue) + case "container_value": + return visitor.VisitContainerValue(f.ContainerValue) + } +} + +// This type allows us to test a circular reference with a union type (see FieldValue). +type ObjectFieldValue struct { + Name FieldName `json:"name" url:"name"` + Value *FieldValue `json:"value,omitempty" url:"value,omitempty"` + + extraProperties map[string]interface{} +} + +func (o *ObjectFieldValue) GetName() FieldName { + if o == nil { + return "" + } + return o.Name +} + +func (o *ObjectFieldValue) GetValue() *FieldValue { + if o == nil { + return nil + } + return o.Value +} + +func (o *ObjectFieldValue) GetExtraProperties() map[string]interface{} { + return o.extraProperties +} + +func (o *ObjectFieldValue) UnmarshalJSON(data []byte) error { + type unmarshaler ObjectFieldValue + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *o = ObjectFieldValue(value) + + extraProperties, err := core.ExtractExtraProperties(data, *o) + if err != nil { + return err + } + o.extraProperties = extraProperties + + return nil +} + +func (o *ObjectFieldValue) String() string { + if value, err := core.StringifyJSON(o); err == nil { + return value + } + return fmt.Sprintf("%#v", o) +} + +type ObjectValue struct { + extraProperties map[string]interface{} +} + +func (o *ObjectValue) GetExtraProperties() map[string]interface{} { + return o.extraProperties +} + +func (o *ObjectValue) UnmarshalJSON(data []byte) error { + type unmarshaler ObjectValue + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *o = ObjectValue(value) + + extraProperties, err := core.ExtractExtraProperties(data, *o) + if err != nil { + return err + } + o.extraProperties = extraProperties + + return nil +} + +func (o *ObjectValue) String() string { + if value, err := core.StringifyJSON(o); err == nil { + return value + } + return fmt.Sprintf("%#v", o) +} + +type PrimitiveValue string + +const ( + PrimitiveValueString PrimitiveValue = "STRING" + PrimitiveValueNumber PrimitiveValue = "NUMBER" +) + +func NewPrimitiveValueFromString(s string) (PrimitiveValue, error) { + switch s { + case "STRING": + return PrimitiveValueString, nil + case "NUMBER": + return PrimitiveValueNumber, nil + } + var t PrimitiveValue + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (p PrimitiveValue) Ptr() *PrimitiveValue { + return &p +} diff --git a/seed/go-fiber/circular-references-advanced/types.go b/seed/go-fiber/circular-references-advanced/types.go index f1b9abb4f31..7eb351b730c 100644 --- a/seed/go-fiber/circular-references-advanced/types.go +++ b/seed/go-fiber/circular-references-advanced/types.go @@ -89,389 +89,3 @@ func (r *RootType) String() string { } return fmt.Sprintf("%#v", r) } - -type A struct { - S string `json:"s" url:"s"` - - extraProperties map[string]interface{} -} - -func (a *A) GetS() string { - if a == nil { - return "" - } - return a.S -} - -func (a *A) GetExtraProperties() map[string]interface{} { - return a.extraProperties -} - -func (a *A) UnmarshalJSON(data []byte) error { - type unmarshaler A - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *a = A(value) - - extraProperties, err := core.ExtractExtraProperties(data, *a) - if err != nil { - return err - } - a.extraProperties = extraProperties - - return nil -} - -func (a *A) String() string { - if value, err := core.StringifyJSON(a); err == nil { - return value - } - return fmt.Sprintf("%#v", a) -} - -type ContainerValue struct { - Type string - List []*FieldValue - Optional *FieldValue -} - -func NewContainerValueFromList(value []*FieldValue) *ContainerValue { - return &ContainerValue{Type: "list", List: value} -} - -func NewContainerValueFromOptional(value *FieldValue) *ContainerValue { - return &ContainerValue{Type: "optional", Optional: value} -} - -func (c *ContainerValue) GetType() string { - if c == nil { - return "" - } - return c.Type -} - -func (c *ContainerValue) GetList() []*FieldValue { - if c == nil { - return nil - } - return c.List -} - -func (c *ContainerValue) GetOptional() *FieldValue { - if c == nil { - return nil - } - return c.Optional -} - -func (c *ContainerValue) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - c.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", c) - } - switch unmarshaler.Type { - case "list": - var valueUnmarshaler struct { - List []*FieldValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - c.List = valueUnmarshaler.List - case "optional": - var valueUnmarshaler struct { - Optional *FieldValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - c.Optional = valueUnmarshaler.Optional - } - return nil -} - -func (c ContainerValue) MarshalJSON() ([]byte, error) { - switch c.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", c.Type, c) - case "list": - var marshaler = struct { - Type string `json:"type"` - List []*FieldValue `json:"value,omitempty"` - }{ - Type: "list", - List: c.List, - } - return json.Marshal(marshaler) - case "optional": - var marshaler = struct { - Type string `json:"type"` - Optional *FieldValue `json:"value,omitempty"` - }{ - Type: "optional", - Optional: c.Optional, - } - return json.Marshal(marshaler) - } -} - -type ContainerValueVisitor interface { - VisitList([]*FieldValue) error - VisitOptional(*FieldValue) error -} - -func (c *ContainerValue) Accept(visitor ContainerValueVisitor) error { - switch c.Type { - default: - return fmt.Errorf("invalid type %s in %T", c.Type, c) - case "list": - return visitor.VisitList(c.List) - case "optional": - return visitor.VisitOptional(c.Optional) - } -} - -type FieldName = string - -type FieldValue struct { - Type string - PrimitiveValue PrimitiveValue - ObjectValue *ObjectValue - ContainerValue *ContainerValue -} - -func NewFieldValueFromPrimitiveValue(value PrimitiveValue) *FieldValue { - return &FieldValue{Type: "primitive_value", PrimitiveValue: value} -} - -func NewFieldValueFromObjectValue(value *ObjectValue) *FieldValue { - return &FieldValue{Type: "object_value", ObjectValue: value} -} - -func NewFieldValueFromContainerValue(value *ContainerValue) *FieldValue { - return &FieldValue{Type: "container_value", ContainerValue: value} -} - -func (f *FieldValue) GetType() string { - if f == nil { - return "" - } - return f.Type -} - -func (f *FieldValue) GetPrimitiveValue() PrimitiveValue { - if f == nil { - return "" - } - return f.PrimitiveValue -} - -func (f *FieldValue) GetObjectValue() *ObjectValue { - if f == nil { - return nil - } - return f.ObjectValue -} - -func (f *FieldValue) GetContainerValue() *ContainerValue { - if f == nil { - return nil - } - return f.ContainerValue -} - -func (f *FieldValue) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - f.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", f) - } - switch unmarshaler.Type { - case "primitive_value": - var valueUnmarshaler struct { - PrimitiveValue PrimitiveValue `json:"value"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - f.PrimitiveValue = valueUnmarshaler.PrimitiveValue - case "object_value": - value := new(ObjectValue) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - f.ObjectValue = value - case "container_value": - var valueUnmarshaler struct { - ContainerValue *ContainerValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - f.ContainerValue = valueUnmarshaler.ContainerValue - } - return nil -} - -func (f FieldValue) MarshalJSON() ([]byte, error) { - switch f.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", f.Type, f) - case "primitive_value": - var marshaler = struct { - Type string `json:"type"` - PrimitiveValue PrimitiveValue `json:"value"` - }{ - Type: "primitive_value", - PrimitiveValue: f.PrimitiveValue, - } - return json.Marshal(marshaler) - case "object_value": - return core.MarshalJSONWithExtraProperty(f.ObjectValue, "type", "object_value") - case "container_value": - var marshaler = struct { - Type string `json:"type"` - ContainerValue *ContainerValue `json:"value,omitempty"` - }{ - Type: "container_value", - ContainerValue: f.ContainerValue, - } - return json.Marshal(marshaler) - } -} - -type FieldValueVisitor interface { - VisitPrimitiveValue(PrimitiveValue) error - VisitObjectValue(*ObjectValue) error - VisitContainerValue(*ContainerValue) error -} - -func (f *FieldValue) Accept(visitor FieldValueVisitor) error { - switch f.Type { - default: - return fmt.Errorf("invalid type %s in %T", f.Type, f) - case "primitive_value": - return visitor.VisitPrimitiveValue(f.PrimitiveValue) - case "object_value": - return visitor.VisitObjectValue(f.ObjectValue) - case "container_value": - return visitor.VisitContainerValue(f.ContainerValue) - } -} - -// This type allows us to test a circular reference with a union type (see FieldValue). -type ObjectFieldValue struct { - Name FieldName `json:"name" url:"name"` - Value *FieldValue `json:"value,omitempty" url:"value,omitempty"` - - extraProperties map[string]interface{} -} - -func (o *ObjectFieldValue) GetName() FieldName { - if o == nil { - return "" - } - return o.Name -} - -func (o *ObjectFieldValue) GetValue() *FieldValue { - if o == nil { - return nil - } - return o.Value -} - -func (o *ObjectFieldValue) GetExtraProperties() map[string]interface{} { - return o.extraProperties -} - -func (o *ObjectFieldValue) UnmarshalJSON(data []byte) error { - type unmarshaler ObjectFieldValue - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *o = ObjectFieldValue(value) - - extraProperties, err := core.ExtractExtraProperties(data, *o) - if err != nil { - return err - } - o.extraProperties = extraProperties - - return nil -} - -func (o *ObjectFieldValue) String() string { - if value, err := core.StringifyJSON(o); err == nil { - return value - } - return fmt.Sprintf("%#v", o) -} - -type ObjectValue struct { - extraProperties map[string]interface{} -} - -func (o *ObjectValue) GetExtraProperties() map[string]interface{} { - return o.extraProperties -} - -func (o *ObjectValue) UnmarshalJSON(data []byte) error { - type unmarshaler ObjectValue - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *o = ObjectValue(value) - - extraProperties, err := core.ExtractExtraProperties(data, *o) - if err != nil { - return err - } - o.extraProperties = extraProperties - - return nil -} - -func (o *ObjectValue) String() string { - if value, err := core.StringifyJSON(o); err == nil { - return value - } - return fmt.Sprintf("%#v", o) -} - -type PrimitiveValue string - -const ( - PrimitiveValueString PrimitiveValue = "STRING" - PrimitiveValueNumber PrimitiveValue = "NUMBER" -) - -func NewPrimitiveValueFromString(s string) (PrimitiveValue, error) { - switch s { - case "STRING": - return PrimitiveValueString, nil - case "NUMBER": - return PrimitiveValueNumber, nil - } - var t PrimitiveValue - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (p PrimitiveValue) Ptr() *PrimitiveValue { - return &p -} diff --git a/seed/go-fiber/circular-references/a.go b/seed/go-fiber/circular-references/a.go new file mode 100644 index 00000000000..f8e88eda5fe --- /dev/null +++ b/seed/go-fiber/circular-references/a.go @@ -0,0 +1,50 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/circular-references/fern/core" +) + +type A struct { + S string `json:"s" url:"s"` + + extraProperties map[string]interface{} +} + +func (a *A) GetS() string { + if a == nil { + return "" + } + return a.S +} + +func (a *A) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *A) UnmarshalJSON(data []byte) error { + type unmarshaler A + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *a = A(value) + + extraProperties, err := core.ExtractExtraProperties(data, *a) + if err != nil { + return err + } + a.extraProperties = extraProperties + + return nil +} + +func (a *A) String() string { + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} diff --git a/seed/go-fiber/circular-references/ast.go b/seed/go-fiber/circular-references/ast.go new file mode 100644 index 00000000000..c1d10703c8e --- /dev/null +++ b/seed/go-fiber/circular-references/ast.go @@ -0,0 +1,447 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/circular-references/fern/core" +) + +type ContainerValue struct { + Type string + List []*FieldValue + Optional *FieldValue +} + +func NewContainerValueFromList(value []*FieldValue) *ContainerValue { + return &ContainerValue{Type: "list", List: value} +} + +func NewContainerValueFromOptional(value *FieldValue) *ContainerValue { + return &ContainerValue{Type: "optional", Optional: value} +} + +func (c *ContainerValue) GetType() string { + if c == nil { + return "" + } + return c.Type +} + +func (c *ContainerValue) GetList() []*FieldValue { + if c == nil { + return nil + } + return c.List +} + +func (c *ContainerValue) GetOptional() *FieldValue { + if c == nil { + return nil + } + return c.Optional +} + +func (c *ContainerValue) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + c.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", c) + } + switch unmarshaler.Type { + case "list": + var valueUnmarshaler struct { + List []*FieldValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + c.List = valueUnmarshaler.List + case "optional": + var valueUnmarshaler struct { + Optional *FieldValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + c.Optional = valueUnmarshaler.Optional + } + return nil +} + +func (c ContainerValue) MarshalJSON() ([]byte, error) { + switch c.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", c.Type, c) + case "list": + var marshaler = struct { + Type string `json:"type"` + List []*FieldValue `json:"value,omitempty"` + }{ + Type: "list", + List: c.List, + } + return json.Marshal(marshaler) + case "optional": + var marshaler = struct { + Type string `json:"type"` + Optional *FieldValue `json:"value,omitempty"` + }{ + Type: "optional", + Optional: c.Optional, + } + return json.Marshal(marshaler) + } +} + +type ContainerValueVisitor interface { + VisitList([]*FieldValue) error + VisitOptional(*FieldValue) error +} + +func (c *ContainerValue) Accept(visitor ContainerValueVisitor) error { + switch c.Type { + default: + return fmt.Errorf("invalid type %s in %T", c.Type, c) + case "list": + return visitor.VisitList(c.List) + case "optional": + return visitor.VisitOptional(c.Optional) + } +} + +type FieldValue struct { + Type string + PrimitiveValue PrimitiveValue + ObjectValue *ObjectValue + ContainerValue *ContainerValue +} + +func NewFieldValueFromPrimitiveValue(value PrimitiveValue) *FieldValue { + return &FieldValue{Type: "primitive_value", PrimitiveValue: value} +} + +func NewFieldValueFromObjectValue(value *ObjectValue) *FieldValue { + return &FieldValue{Type: "object_value", ObjectValue: value} +} + +func NewFieldValueFromContainerValue(value *ContainerValue) *FieldValue { + return &FieldValue{Type: "container_value", ContainerValue: value} +} + +func (f *FieldValue) GetType() string { + if f == nil { + return "" + } + return f.Type +} + +func (f *FieldValue) GetPrimitiveValue() PrimitiveValue { + if f == nil { + return "" + } + return f.PrimitiveValue +} + +func (f *FieldValue) GetObjectValue() *ObjectValue { + if f == nil { + return nil + } + return f.ObjectValue +} + +func (f *FieldValue) GetContainerValue() *ContainerValue { + if f == nil { + return nil + } + return f.ContainerValue +} + +func (f *FieldValue) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + f.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", f) + } + switch unmarshaler.Type { + case "primitive_value": + var valueUnmarshaler struct { + PrimitiveValue PrimitiveValue `json:"value"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + f.PrimitiveValue = valueUnmarshaler.PrimitiveValue + case "object_value": + value := new(ObjectValue) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + f.ObjectValue = value + case "container_value": + var valueUnmarshaler struct { + ContainerValue *ContainerValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + f.ContainerValue = valueUnmarshaler.ContainerValue + } + return nil +} + +func (f FieldValue) MarshalJSON() ([]byte, error) { + switch f.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", f.Type, f) + case "primitive_value": + var marshaler = struct { + Type string `json:"type"` + PrimitiveValue PrimitiveValue `json:"value"` + }{ + Type: "primitive_value", + PrimitiveValue: f.PrimitiveValue, + } + return json.Marshal(marshaler) + case "object_value": + return core.MarshalJSONWithExtraProperty(f.ObjectValue, "type", "object_value") + case "container_value": + var marshaler = struct { + Type string `json:"type"` + ContainerValue *ContainerValue `json:"value,omitempty"` + }{ + Type: "container_value", + ContainerValue: f.ContainerValue, + } + return json.Marshal(marshaler) + } +} + +type FieldValueVisitor interface { + VisitPrimitiveValue(PrimitiveValue) error + VisitObjectValue(*ObjectValue) error + VisitContainerValue(*ContainerValue) error +} + +func (f *FieldValue) Accept(visitor FieldValueVisitor) error { + switch f.Type { + default: + return fmt.Errorf("invalid type %s in %T", f.Type, f) + case "primitive_value": + return visitor.VisitPrimitiveValue(f.PrimitiveValue) + case "object_value": + return visitor.VisitObjectValue(f.ObjectValue) + case "container_value": + return visitor.VisitContainerValue(f.ContainerValue) + } +} + +type JsonLike struct { + JsonLikeList []*JsonLike + StringJsonLikeMap map[string]*JsonLike + String string + Integer int + Boolean bool + + typ string +} + +func NewJsonLikeFromJsonLikeList(value []*JsonLike) *JsonLike { + return &JsonLike{typ: "JsonLikeList", JsonLikeList: value} +} + +func NewJsonLikeFromStringJsonLikeMap(value map[string]*JsonLike) *JsonLike { + return &JsonLike{typ: "StringJsonLikeMap", StringJsonLikeMap: value} +} + +func NewJsonLikeFromString(value string) *JsonLike { + return &JsonLike{typ: "String", String: value} +} + +func NewJsonLikeFromInteger(value int) *JsonLike { + return &JsonLike{typ: "Integer", Integer: value} +} + +func NewJsonLikeFromBoolean(value bool) *JsonLike { + return &JsonLike{typ: "Boolean", Boolean: value} +} + +func (j *JsonLike) GetJsonLikeList() []*JsonLike { + if j == nil { + return nil + } + return j.JsonLikeList +} + +func (j *JsonLike) GetStringJsonLikeMap() map[string]*JsonLike { + if j == nil { + return nil + } + return j.StringJsonLikeMap +} + +func (j *JsonLike) GetString() string { + if j == nil { + return "" + } + return j.String +} + +func (j *JsonLike) GetInteger() int { + if j == nil { + return 0 + } + return j.Integer +} + +func (j *JsonLike) GetBoolean() bool { + if j == nil { + return false + } + return j.Boolean +} + +func (j *JsonLike) UnmarshalJSON(data []byte) error { + var valueJsonLikeList []*JsonLike + if err := json.Unmarshal(data, &valueJsonLikeList); err == nil { + j.typ = "JsonLikeList" + j.JsonLikeList = valueJsonLikeList + return nil + } + var valueStringJsonLikeMap map[string]*JsonLike + if err := json.Unmarshal(data, &valueStringJsonLikeMap); err == nil { + j.typ = "StringJsonLikeMap" + j.StringJsonLikeMap = valueStringJsonLikeMap + return nil + } + var valueString string + if err := json.Unmarshal(data, &valueString); err == nil { + j.typ = "String" + j.String = valueString + return nil + } + var valueInteger int + if err := json.Unmarshal(data, &valueInteger); err == nil { + j.typ = "Integer" + j.Integer = valueInteger + return nil + } + var valueBoolean bool + if err := json.Unmarshal(data, &valueBoolean); err == nil { + j.typ = "Boolean" + j.Boolean = valueBoolean + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, j) +} + +func (j JsonLike) MarshalJSON() ([]byte, error) { + if j.typ == "JsonLikeList" || j.JsonLikeList != nil { + return json.Marshal(j.JsonLikeList) + } + if j.typ == "StringJsonLikeMap" || j.StringJsonLikeMap != nil { + return json.Marshal(j.StringJsonLikeMap) + } + if j.typ == "String" || j.String != "" { + return json.Marshal(j.String) + } + if j.typ == "Integer" || j.Integer != 0 { + return json.Marshal(j.Integer) + } + if j.typ == "Boolean" || j.Boolean != false { + return json.Marshal(j.Boolean) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", j) +} + +type JsonLikeVisitor interface { + VisitJsonLikeList([]*JsonLike) error + VisitStringJsonLikeMap(map[string]*JsonLike) error + VisitString(string) error + VisitInteger(int) error + VisitBoolean(bool) error +} + +func (j *JsonLike) Accept(visitor JsonLikeVisitor) error { + if j.typ == "JsonLikeList" || j.JsonLikeList != nil { + return visitor.VisitJsonLikeList(j.JsonLikeList) + } + if j.typ == "StringJsonLikeMap" || j.StringJsonLikeMap != nil { + return visitor.VisitStringJsonLikeMap(j.StringJsonLikeMap) + } + if j.typ == "String" || j.String != "" { + return visitor.VisitString(j.String) + } + if j.typ == "Integer" || j.Integer != 0 { + return visitor.VisitInteger(j.Integer) + } + if j.typ == "Boolean" || j.Boolean != false { + return visitor.VisitBoolean(j.Boolean) + } + return fmt.Errorf("type %T does not include a non-empty union type", j) +} + +type ObjectValue struct { + extraProperties map[string]interface{} +} + +func (o *ObjectValue) GetExtraProperties() map[string]interface{} { + return o.extraProperties +} + +func (o *ObjectValue) UnmarshalJSON(data []byte) error { + type unmarshaler ObjectValue + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *o = ObjectValue(value) + + extraProperties, err := core.ExtractExtraProperties(data, *o) + if err != nil { + return err + } + o.extraProperties = extraProperties + + return nil +} + +func (o *ObjectValue) String() string { + if value, err := core.StringifyJSON(o); err == nil { + return value + } + return fmt.Sprintf("%#v", o) +} + +type PrimitiveValue string + +const ( + PrimitiveValueString PrimitiveValue = "STRING" + PrimitiveValueNumber PrimitiveValue = "NUMBER" +) + +func NewPrimitiveValueFromString(s string) (PrimitiveValue, error) { + switch s { + case "STRING": + return PrimitiveValueString, nil + case "NUMBER": + return PrimitiveValueNumber, nil + } + var t PrimitiveValue + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (p PrimitiveValue) Ptr() *PrimitiveValue { + return &p +} diff --git a/seed/go-fiber/circular-references/types.go b/seed/go-fiber/circular-references/types.go index 9f877505669..7e33a17438c 100644 --- a/seed/go-fiber/circular-references/types.go +++ b/seed/go-fiber/circular-references/types.go @@ -89,482 +89,3 @@ func (r *RootType) String() string { } return fmt.Sprintf("%#v", r) } - -type A struct { - S string `json:"s" url:"s"` - - extraProperties map[string]interface{} -} - -func (a *A) GetS() string { - if a == nil { - return "" - } - return a.S -} - -func (a *A) GetExtraProperties() map[string]interface{} { - return a.extraProperties -} - -func (a *A) UnmarshalJSON(data []byte) error { - type unmarshaler A - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *a = A(value) - - extraProperties, err := core.ExtractExtraProperties(data, *a) - if err != nil { - return err - } - a.extraProperties = extraProperties - - return nil -} - -func (a *A) String() string { - if value, err := core.StringifyJSON(a); err == nil { - return value - } - return fmt.Sprintf("%#v", a) -} - -type ContainerValue struct { - Type string - List []*FieldValue - Optional *FieldValue -} - -func NewContainerValueFromList(value []*FieldValue) *ContainerValue { - return &ContainerValue{Type: "list", List: value} -} - -func NewContainerValueFromOptional(value *FieldValue) *ContainerValue { - return &ContainerValue{Type: "optional", Optional: value} -} - -func (c *ContainerValue) GetType() string { - if c == nil { - return "" - } - return c.Type -} - -func (c *ContainerValue) GetList() []*FieldValue { - if c == nil { - return nil - } - return c.List -} - -func (c *ContainerValue) GetOptional() *FieldValue { - if c == nil { - return nil - } - return c.Optional -} - -func (c *ContainerValue) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - c.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", c) - } - switch unmarshaler.Type { - case "list": - var valueUnmarshaler struct { - List []*FieldValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - c.List = valueUnmarshaler.List - case "optional": - var valueUnmarshaler struct { - Optional *FieldValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - c.Optional = valueUnmarshaler.Optional - } - return nil -} - -func (c ContainerValue) MarshalJSON() ([]byte, error) { - switch c.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", c.Type, c) - case "list": - var marshaler = struct { - Type string `json:"type"` - List []*FieldValue `json:"value,omitempty"` - }{ - Type: "list", - List: c.List, - } - return json.Marshal(marshaler) - case "optional": - var marshaler = struct { - Type string `json:"type"` - Optional *FieldValue `json:"value,omitempty"` - }{ - Type: "optional", - Optional: c.Optional, - } - return json.Marshal(marshaler) - } -} - -type ContainerValueVisitor interface { - VisitList([]*FieldValue) error - VisitOptional(*FieldValue) error -} - -func (c *ContainerValue) Accept(visitor ContainerValueVisitor) error { - switch c.Type { - default: - return fmt.Errorf("invalid type %s in %T", c.Type, c) - case "list": - return visitor.VisitList(c.List) - case "optional": - return visitor.VisitOptional(c.Optional) - } -} - -type FieldValue struct { - Type string - PrimitiveValue PrimitiveValue - ObjectValue *ObjectValue - ContainerValue *ContainerValue -} - -func NewFieldValueFromPrimitiveValue(value PrimitiveValue) *FieldValue { - return &FieldValue{Type: "primitive_value", PrimitiveValue: value} -} - -func NewFieldValueFromObjectValue(value *ObjectValue) *FieldValue { - return &FieldValue{Type: "object_value", ObjectValue: value} -} - -func NewFieldValueFromContainerValue(value *ContainerValue) *FieldValue { - return &FieldValue{Type: "container_value", ContainerValue: value} -} - -func (f *FieldValue) GetType() string { - if f == nil { - return "" - } - return f.Type -} - -func (f *FieldValue) GetPrimitiveValue() PrimitiveValue { - if f == nil { - return "" - } - return f.PrimitiveValue -} - -func (f *FieldValue) GetObjectValue() *ObjectValue { - if f == nil { - return nil - } - return f.ObjectValue -} - -func (f *FieldValue) GetContainerValue() *ContainerValue { - if f == nil { - return nil - } - return f.ContainerValue -} - -func (f *FieldValue) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - f.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", f) - } - switch unmarshaler.Type { - case "primitive_value": - var valueUnmarshaler struct { - PrimitiveValue PrimitiveValue `json:"value"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - f.PrimitiveValue = valueUnmarshaler.PrimitiveValue - case "object_value": - value := new(ObjectValue) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - f.ObjectValue = value - case "container_value": - var valueUnmarshaler struct { - ContainerValue *ContainerValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - f.ContainerValue = valueUnmarshaler.ContainerValue - } - return nil -} - -func (f FieldValue) MarshalJSON() ([]byte, error) { - switch f.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", f.Type, f) - case "primitive_value": - var marshaler = struct { - Type string `json:"type"` - PrimitiveValue PrimitiveValue `json:"value"` - }{ - Type: "primitive_value", - PrimitiveValue: f.PrimitiveValue, - } - return json.Marshal(marshaler) - case "object_value": - return core.MarshalJSONWithExtraProperty(f.ObjectValue, "type", "object_value") - case "container_value": - var marshaler = struct { - Type string `json:"type"` - ContainerValue *ContainerValue `json:"value,omitempty"` - }{ - Type: "container_value", - ContainerValue: f.ContainerValue, - } - return json.Marshal(marshaler) - } -} - -type FieldValueVisitor interface { - VisitPrimitiveValue(PrimitiveValue) error - VisitObjectValue(*ObjectValue) error - VisitContainerValue(*ContainerValue) error -} - -func (f *FieldValue) Accept(visitor FieldValueVisitor) error { - switch f.Type { - default: - return fmt.Errorf("invalid type %s in %T", f.Type, f) - case "primitive_value": - return visitor.VisitPrimitiveValue(f.PrimitiveValue) - case "object_value": - return visitor.VisitObjectValue(f.ObjectValue) - case "container_value": - return visitor.VisitContainerValue(f.ContainerValue) - } -} - -type JsonLike struct { - JsonLikeList []*JsonLike - StringJsonLikeMap map[string]*JsonLike - String string - Integer int - Boolean bool - - typ string -} - -func NewJsonLikeFromJsonLikeList(value []*JsonLike) *JsonLike { - return &JsonLike{typ: "JsonLikeList", JsonLikeList: value} -} - -func NewJsonLikeFromStringJsonLikeMap(value map[string]*JsonLike) *JsonLike { - return &JsonLike{typ: "StringJsonLikeMap", StringJsonLikeMap: value} -} - -func NewJsonLikeFromString(value string) *JsonLike { - return &JsonLike{typ: "String", String: value} -} - -func NewJsonLikeFromInteger(value int) *JsonLike { - return &JsonLike{typ: "Integer", Integer: value} -} - -func NewJsonLikeFromBoolean(value bool) *JsonLike { - return &JsonLike{typ: "Boolean", Boolean: value} -} - -func (j *JsonLike) GetJsonLikeList() []*JsonLike { - if j == nil { - return nil - } - return j.JsonLikeList -} - -func (j *JsonLike) GetStringJsonLikeMap() map[string]*JsonLike { - if j == nil { - return nil - } - return j.StringJsonLikeMap -} - -func (j *JsonLike) GetString() string { - if j == nil { - return "" - } - return j.String -} - -func (j *JsonLike) GetInteger() int { - if j == nil { - return 0 - } - return j.Integer -} - -func (j *JsonLike) GetBoolean() bool { - if j == nil { - return false - } - return j.Boolean -} - -func (j *JsonLike) UnmarshalJSON(data []byte) error { - var valueJsonLikeList []*JsonLike - if err := json.Unmarshal(data, &valueJsonLikeList); err == nil { - j.typ = "JsonLikeList" - j.JsonLikeList = valueJsonLikeList - return nil - } - var valueStringJsonLikeMap map[string]*JsonLike - if err := json.Unmarshal(data, &valueStringJsonLikeMap); err == nil { - j.typ = "StringJsonLikeMap" - j.StringJsonLikeMap = valueStringJsonLikeMap - return nil - } - var valueString string - if err := json.Unmarshal(data, &valueString); err == nil { - j.typ = "String" - j.String = valueString - return nil - } - var valueInteger int - if err := json.Unmarshal(data, &valueInteger); err == nil { - j.typ = "Integer" - j.Integer = valueInteger - return nil - } - var valueBoolean bool - if err := json.Unmarshal(data, &valueBoolean); err == nil { - j.typ = "Boolean" - j.Boolean = valueBoolean - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, j) -} - -func (j JsonLike) MarshalJSON() ([]byte, error) { - if j.typ == "JsonLikeList" || j.JsonLikeList != nil { - return json.Marshal(j.JsonLikeList) - } - if j.typ == "StringJsonLikeMap" || j.StringJsonLikeMap != nil { - return json.Marshal(j.StringJsonLikeMap) - } - if j.typ == "String" || j.String != "" { - return json.Marshal(j.String) - } - if j.typ == "Integer" || j.Integer != 0 { - return json.Marshal(j.Integer) - } - if j.typ == "Boolean" || j.Boolean != false { - return json.Marshal(j.Boolean) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", j) -} - -type JsonLikeVisitor interface { - VisitJsonLikeList([]*JsonLike) error - VisitStringJsonLikeMap(map[string]*JsonLike) error - VisitString(string) error - VisitInteger(int) error - VisitBoolean(bool) error -} - -func (j *JsonLike) Accept(visitor JsonLikeVisitor) error { - if j.typ == "JsonLikeList" || j.JsonLikeList != nil { - return visitor.VisitJsonLikeList(j.JsonLikeList) - } - if j.typ == "StringJsonLikeMap" || j.StringJsonLikeMap != nil { - return visitor.VisitStringJsonLikeMap(j.StringJsonLikeMap) - } - if j.typ == "String" || j.String != "" { - return visitor.VisitString(j.String) - } - if j.typ == "Integer" || j.Integer != 0 { - return visitor.VisitInteger(j.Integer) - } - if j.typ == "Boolean" || j.Boolean != false { - return visitor.VisitBoolean(j.Boolean) - } - return fmt.Errorf("type %T does not include a non-empty union type", j) -} - -type ObjectValue struct { - extraProperties map[string]interface{} -} - -func (o *ObjectValue) GetExtraProperties() map[string]interface{} { - return o.extraProperties -} - -func (o *ObjectValue) UnmarshalJSON(data []byte) error { - type unmarshaler ObjectValue - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *o = ObjectValue(value) - - extraProperties, err := core.ExtractExtraProperties(data, *o) - if err != nil { - return err - } - o.extraProperties = extraProperties - - return nil -} - -func (o *ObjectValue) String() string { - if value, err := core.StringifyJSON(o); err == nil { - return value - } - return fmt.Sprintf("%#v", o) -} - -type PrimitiveValue string - -const ( - PrimitiveValueString PrimitiveValue = "STRING" - PrimitiveValueNumber PrimitiveValue = "NUMBER" -) - -func NewPrimitiveValueFromString(s string) (PrimitiveValue, error) { - switch s { - case "STRING": - return PrimitiveValueString, nil - case "NUMBER": - return PrimitiveValueNumber, nil - } - var t PrimitiveValue - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (p PrimitiveValue) Ptr() *PrimitiveValue { - return &p -} diff --git a/seed/go-fiber/cross-package-type-names/types.go b/seed/go-fiber/cross-package-type-names/commons.go similarity index 100% rename from seed/go-fiber/cross-package-type-names/types.go rename to seed/go-fiber/cross-package-type-names/commons.go diff --git a/seed/go-fiber/cross-package-type-names/folderb/types.go b/seed/go-fiber/cross-package-type-names/folderb/common.go similarity index 100% rename from seed/go-fiber/cross-package-type-names/folderb/types.go rename to seed/go-fiber/cross-package-type-names/folderb/common.go diff --git a/seed/go-fiber/cross-package-type-names/folderc/types.go b/seed/go-fiber/cross-package-type-names/folderc/common.go similarity index 100% rename from seed/go-fiber/cross-package-type-names/folderc/types.go rename to seed/go-fiber/cross-package-type-names/folderc/common.go diff --git a/seed/go-fiber/examples/file/service.go b/seed/go-fiber/examples/file/service.go index 5253d0234d9..2e5e2077c17 100644 --- a/seed/go-fiber/examples/file/service.go +++ b/seed/go-fiber/examples/file/service.go @@ -4,3 +4,5 @@ package file type GetFileRequest struct { } + +type Filename = string diff --git a/seed/go-fiber/exhaustive/.mock/definition/endpoints/content-type.yml b/seed/go-fiber/exhaustive/.mock/definition/endpoints/content-type.yml new file mode 100644 index 00000000000..7c54e39fa5a --- /dev/null +++ b/seed/go-fiber/exhaustive/.mock/definition/endpoints/content-type.yml @@ -0,0 +1,19 @@ +imports: + objects: ../types/object.yml + +service: + auth: true + base-path: /foo + endpoints: + postJsonPatchContentType: + path: /bar + method: POST + request: + body: objects.ObjectWithOptionalField + content-type: application/json-patch+json + postJsonPatchContentWithCharsetType: + path: /baz + method: POST + request: + body: objects.ObjectWithOptionalField + content-type: application/json-patch+json; charset=utf-8 diff --git a/seed/go-fiber/exhaustive/types.go b/seed/go-fiber/exhaustive/general_errors.go similarity index 100% rename from seed/go-fiber/exhaustive/types.go rename to seed/go-fiber/exhaustive/general_errors.go diff --git a/seed/go-fiber/exhaustive/types/enum.go b/seed/go-fiber/exhaustive/types/enum.go new file mode 100644 index 00000000000..d6da74c7932 --- /dev/null +++ b/seed/go-fiber/exhaustive/types/enum.go @@ -0,0 +1,35 @@ +// This file was auto-generated by Fern from our API Definition. + +package types + +import ( + fmt "fmt" +) + +type WeatherReport string + +const ( + WeatherReportSunny WeatherReport = "SUNNY" + WeatherReportCloudy WeatherReport = "CLOUDY" + WeatherReportRaining WeatherReport = "RAINING" + WeatherReportSnowing WeatherReport = "SNOWING" +) + +func NewWeatherReportFromString(s string) (WeatherReport, error) { + switch s { + case "SUNNY": + return WeatherReportSunny, nil + case "CLOUDY": + return WeatherReportCloudy, nil + case "RAINING": + return WeatherReportRaining, nil + case "SNOWING": + return WeatherReportSnowing, nil + } + var t WeatherReport + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (w WeatherReport) Ptr() *WeatherReport { + return &w +} diff --git a/seed/go-fiber/exhaustive/types/types.go b/seed/go-fiber/exhaustive/types/object.go similarity index 68% rename from seed/go-fiber/exhaustive/types/types.go rename to seed/go-fiber/exhaustive/types/object.go index 618e04b2c04..bdf2d03b93b 100644 --- a/seed/go-fiber/exhaustive/types/types.go +++ b/seed/go-fiber/exhaustive/types/object.go @@ -10,34 +10,6 @@ import ( time "time" ) -type WeatherReport string - -const ( - WeatherReportSunny WeatherReport = "SUNNY" - WeatherReportCloudy WeatherReport = "CLOUDY" - WeatherReportRaining WeatherReport = "RAINING" - WeatherReportSnowing WeatherReport = "SNOWING" -) - -func NewWeatherReportFromString(s string) (WeatherReport, error) { - switch s { - case "SUNNY": - return WeatherReportSunny, nil - case "CLOUDY": - return WeatherReportCloudy, nil - case "RAINING": - return WeatherReportRaining, nil - case "SNOWING": - return WeatherReportSnowing, nil - } - var t WeatherReport - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (w WeatherReport) Ptr() *WeatherReport { - return &w -} - type DoubleOptional struct { OptionalAlias *OptionalAlias `json:"optionalAlias,omitempty" url:"optionalAlias,omitempty"` @@ -420,191 +392,3 @@ func (o *ObjectWithRequiredField) String() string { } type OptionalAlias = *string - -type Animal struct { - Animal string - Dog *Dog - Cat *Cat -} - -func NewAnimalFromDog(value *Dog) *Animal { - return &Animal{Animal: "dog", Dog: value} -} - -func NewAnimalFromCat(value *Cat) *Animal { - return &Animal{Animal: "cat", Cat: value} -} - -func (a *Animal) GetAnimal() string { - if a == nil { - return "" - } - return a.Animal -} - -func (a *Animal) GetDog() *Dog { - if a == nil { - return nil - } - return a.Dog -} - -func (a *Animal) GetCat() *Cat { - if a == nil { - return nil - } - return a.Cat -} - -func (a *Animal) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Animal string `json:"animal"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - a.Animal = unmarshaler.Animal - if unmarshaler.Animal == "" { - return fmt.Errorf("%T did not include discriminant animal", a) - } - switch unmarshaler.Animal { - case "dog": - value := new(Dog) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - a.Dog = value - case "cat": - value := new(Cat) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - a.Cat = value - } - return nil -} - -func (a Animal) MarshalJSON() ([]byte, error) { - switch a.Animal { - default: - return nil, fmt.Errorf("invalid type %s in %T", a.Animal, a) - case "dog": - return core.MarshalJSONWithExtraProperty(a.Dog, "animal", "dog") - case "cat": - return core.MarshalJSONWithExtraProperty(a.Cat, "animal", "cat") - } -} - -type AnimalVisitor interface { - VisitDog(*Dog) error - VisitCat(*Cat) error -} - -func (a *Animal) Accept(visitor AnimalVisitor) error { - switch a.Animal { - default: - return fmt.Errorf("invalid type %s in %T", a.Animal, a) - case "dog": - return visitor.VisitDog(a.Dog) - case "cat": - return visitor.VisitCat(a.Cat) - } -} - -type Cat struct { - Name string `json:"name" url:"name"` - LikesToMeow bool `json:"likesToMeow" url:"likesToMeow"` - - extraProperties map[string]interface{} -} - -func (c *Cat) GetName() string { - if c == nil { - return "" - } - return c.Name -} - -func (c *Cat) GetLikesToMeow() bool { - if c == nil { - return false - } - return c.LikesToMeow -} - -func (c *Cat) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *Cat) UnmarshalJSON(data []byte) error { - type unmarshaler Cat - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = Cat(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - return nil -} - -func (c *Cat) String() string { - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type Dog struct { - Name string `json:"name" url:"name"` - LikesToWoof bool `json:"likesToWoof" url:"likesToWoof"` - - extraProperties map[string]interface{} -} - -func (d *Dog) GetName() string { - if d == nil { - return "" - } - return d.Name -} - -func (d *Dog) GetLikesToWoof() bool { - if d == nil { - return false - } - return d.LikesToWoof -} - -func (d *Dog) GetExtraProperties() map[string]interface{} { - return d.extraProperties -} - -func (d *Dog) UnmarshalJSON(data []byte) error { - type unmarshaler Dog - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *d = Dog(value) - - extraProperties, err := core.ExtractExtraProperties(data, *d) - if err != nil { - return err - } - d.extraProperties = extraProperties - - return nil -} - -func (d *Dog) String() string { - if value, err := core.StringifyJSON(d); err == nil { - return value - } - return fmt.Sprintf("%#v", d) -} diff --git a/seed/go-fiber/exhaustive/types/union.go b/seed/go-fiber/exhaustive/types/union.go new file mode 100644 index 00000000000..8ca6406b032 --- /dev/null +++ b/seed/go-fiber/exhaustive/types/union.go @@ -0,0 +1,197 @@ +// This file was auto-generated by Fern from our API Definition. + +package types + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/exhaustive/fern/core" +) + +type Animal struct { + Animal string + Dog *Dog + Cat *Cat +} + +func NewAnimalFromDog(value *Dog) *Animal { + return &Animal{Animal: "dog", Dog: value} +} + +func NewAnimalFromCat(value *Cat) *Animal { + return &Animal{Animal: "cat", Cat: value} +} + +func (a *Animal) GetAnimal() string { + if a == nil { + return "" + } + return a.Animal +} + +func (a *Animal) GetDog() *Dog { + if a == nil { + return nil + } + return a.Dog +} + +func (a *Animal) GetCat() *Cat { + if a == nil { + return nil + } + return a.Cat +} + +func (a *Animal) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Animal string `json:"animal"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + a.Animal = unmarshaler.Animal + if unmarshaler.Animal == "" { + return fmt.Errorf("%T did not include discriminant animal", a) + } + switch unmarshaler.Animal { + case "dog": + value := new(Dog) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + a.Dog = value + case "cat": + value := new(Cat) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + a.Cat = value + } + return nil +} + +func (a Animal) MarshalJSON() ([]byte, error) { + switch a.Animal { + default: + return nil, fmt.Errorf("invalid type %s in %T", a.Animal, a) + case "dog": + return core.MarshalJSONWithExtraProperty(a.Dog, "animal", "dog") + case "cat": + return core.MarshalJSONWithExtraProperty(a.Cat, "animal", "cat") + } +} + +type AnimalVisitor interface { + VisitDog(*Dog) error + VisitCat(*Cat) error +} + +func (a *Animal) Accept(visitor AnimalVisitor) error { + switch a.Animal { + default: + return fmt.Errorf("invalid type %s in %T", a.Animal, a) + case "dog": + return visitor.VisitDog(a.Dog) + case "cat": + return visitor.VisitCat(a.Cat) + } +} + +type Cat struct { + Name string `json:"name" url:"name"` + LikesToMeow bool `json:"likesToMeow" url:"likesToMeow"` + + extraProperties map[string]interface{} +} + +func (c *Cat) GetName() string { + if c == nil { + return "" + } + return c.Name +} + +func (c *Cat) GetLikesToMeow() bool { + if c == nil { + return false + } + return c.LikesToMeow +} + +func (c *Cat) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *Cat) UnmarshalJSON(data []byte) error { + type unmarshaler Cat + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = Cat(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + return nil +} + +func (c *Cat) String() string { + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type Dog struct { + Name string `json:"name" url:"name"` + LikesToWoof bool `json:"likesToWoof" url:"likesToWoof"` + + extraProperties map[string]interface{} +} + +func (d *Dog) GetName() string { + if d == nil { + return "" + } + return d.Name +} + +func (d *Dog) GetLikesToWoof() bool { + if d == nil { + return false + } + return d.LikesToWoof +} + +func (d *Dog) GetExtraProperties() map[string]interface{} { + return d.extraProperties +} + +func (d *Dog) UnmarshalJSON(data []byte) error { + type unmarshaler Dog + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = Dog(value) + + extraProperties, err := core.ExtractExtraProperties(data, *d) + if err != nil { + return err + } + d.extraProperties = extraProperties + + return nil +} + +func (d *Dog) String() string { + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} diff --git a/seed/go-fiber/grpc-proto-exhaustive/dataservice.go b/seed/go-fiber/grpc-proto-exhaustive/dataservice.go index b4278090caa..5561334298d 100644 --- a/seed/go-fiber/grpc-proto-exhaustive/dataservice.go +++ b/seed/go-fiber/grpc-proto-exhaustive/dataservice.go @@ -2,6 +2,12 @@ package api +import ( + json "encoding/json" + fmt "fmt" + core "github.com/grpc-proto-exhaustive/fern/core" +) + type DeleteRequest struct { Ids []string `json:"ids,omitempty" url:"-"` DeleteAll *bool `json:"deleteAll,omitempty" url:"-"` @@ -37,6 +43,1001 @@ type QueryRequest struct { IndexedData *IndexedData `json:"indexedData,omitempty" url:"-"` } +type Column struct { + Id string `json:"id" url:"id"` + Values []float64 `json:"values,omitempty" url:"values,omitempty"` + Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` + IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` + + extraProperties map[string]interface{} +} + +func (c *Column) GetId() string { + if c == nil { + return "" + } + return c.Id +} + +func (c *Column) GetValues() []float64 { + if c == nil { + return nil + } + return c.Values +} + +func (c *Column) GetMetadata() *Metadata { + if c == nil { + return nil + } + return c.Metadata +} + +func (c *Column) GetIndexedData() *IndexedData { + if c == nil { + return nil + } + return c.IndexedData +} + +func (c *Column) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *Column) UnmarshalJSON(data []byte) error { + type unmarshaler Column + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = Column(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + return nil +} + +func (c *Column) String() string { + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type DeleteResponse struct { + extraProperties map[string]interface{} +} + +func (d *DeleteResponse) GetExtraProperties() map[string]interface{} { + return d.extraProperties +} + +func (d *DeleteResponse) UnmarshalJSON(data []byte) error { + type unmarshaler DeleteResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DeleteResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *d) + if err != nil { + return err + } + d.extraProperties = extraProperties + + return nil +} + +func (d *DeleteResponse) String() string { + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DescribeResponse struct { + Namespaces map[string]*NamespaceSummary `json:"namespaces,omitempty" url:"namespaces,omitempty"` + Dimension *int `json:"dimension,omitempty" url:"dimension,omitempty"` + Fullness *float64 `json:"fullness,omitempty" url:"fullness,omitempty"` + TotalCount *int `json:"totalCount,omitempty" url:"totalCount,omitempty"` + + extraProperties map[string]interface{} +} + +func (d *DescribeResponse) GetNamespaces() map[string]*NamespaceSummary { + if d == nil { + return nil + } + return d.Namespaces +} + +func (d *DescribeResponse) GetDimension() *int { + if d == nil { + return nil + } + return d.Dimension +} + +func (d *DescribeResponse) GetFullness() *float64 { + if d == nil { + return nil + } + return d.Fullness +} + +func (d *DescribeResponse) GetTotalCount() *int { + if d == nil { + return nil + } + return d.TotalCount +} + +func (d *DescribeResponse) GetExtraProperties() map[string]interface{} { + return d.extraProperties +} + +func (d *DescribeResponse) UnmarshalJSON(data []byte) error { + type unmarshaler DescribeResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DescribeResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *d) + if err != nil { + return err + } + d.extraProperties = extraProperties + + return nil +} + +func (d *DescribeResponse) String() string { + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type FetchResponse struct { + Columns map[string]*Column `json:"columns,omitempty" url:"columns,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` + + extraProperties map[string]interface{} +} + +func (f *FetchResponse) GetColumns() map[string]*Column { + if f == nil { + return nil + } + return f.Columns +} + +func (f *FetchResponse) GetNamespace() *string { + if f == nil { + return nil + } + return f.Namespace +} + +func (f *FetchResponse) GetUsage() *Usage { + if f == nil { + return nil + } + return f.Usage +} + +func (f *FetchResponse) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *FetchResponse) UnmarshalJSON(data []byte) error { + type unmarshaler FetchResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = FetchResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + return nil +} + +func (f *FetchResponse) String() string { + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + +type IndexedData struct { + Indices []int `json:"indices,omitempty" url:"indices,omitempty"` + Values []float64 `json:"values,omitempty" url:"values,omitempty"` + + extraProperties map[string]interface{} +} + +func (i *IndexedData) GetIndices() []int { + if i == nil { + return nil + } + return i.Indices +} + +func (i *IndexedData) GetValues() []float64 { + if i == nil { + return nil + } + return i.Values +} + +func (i *IndexedData) GetExtraProperties() map[string]interface{} { + return i.extraProperties +} + +func (i *IndexedData) UnmarshalJSON(data []byte) error { + type unmarshaler IndexedData + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *i = IndexedData(value) + + extraProperties, err := core.ExtractExtraProperties(data, *i) + if err != nil { + return err + } + i.extraProperties = extraProperties + + return nil +} + +func (i *IndexedData) String() string { + if value, err := core.StringifyJSON(i); err == nil { + return value + } + return fmt.Sprintf("%#v", i) +} + +type ListElement struct { + Id *string `json:"id,omitempty" url:"id,omitempty"` + + extraProperties map[string]interface{} +} + +func (l *ListElement) GetId() *string { + if l == nil { + return nil + } + return l.Id +} + +func (l *ListElement) GetExtraProperties() map[string]interface{} { + return l.extraProperties +} + +func (l *ListElement) UnmarshalJSON(data []byte) error { + type unmarshaler ListElement + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *l = ListElement(value) + + extraProperties, err := core.ExtractExtraProperties(data, *l) + if err != nil { + return err + } + l.extraProperties = extraProperties + + return nil +} + +func (l *ListElement) String() string { + if value, err := core.StringifyJSON(l); err == nil { + return value + } + return fmt.Sprintf("%#v", l) +} + +type ListResponse struct { + Columns []*ListElement `json:"columns,omitempty" url:"columns,omitempty"` + Pagination *Pagination `json:"pagination,omitempty" url:"pagination,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` + + extraProperties map[string]interface{} +} + +func (l *ListResponse) GetColumns() []*ListElement { + if l == nil { + return nil + } + return l.Columns +} + +func (l *ListResponse) GetPagination() *Pagination { + if l == nil { + return nil + } + return l.Pagination +} + +func (l *ListResponse) GetNamespace() *string { + if l == nil { + return nil + } + return l.Namespace +} + +func (l *ListResponse) GetUsage() *Usage { + if l == nil { + return nil + } + return l.Usage +} + +func (l *ListResponse) GetExtraProperties() map[string]interface{} { + return l.extraProperties +} + +func (l *ListResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ListResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *l = ListResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *l) + if err != nil { + return err + } + l.extraProperties = extraProperties + + return nil +} + +func (l *ListResponse) String() string { + if value, err := core.StringifyJSON(l); err == nil { + return value + } + return fmt.Sprintf("%#v", l) +} + +type Metadata struct { + StringMetadataValueMap map[string]*MetadataValue + StringUnknownMap map[string]interface{} + + typ string +} + +func NewMetadataFromStringMetadataValueMap(value map[string]*MetadataValue) *Metadata { + return &Metadata{typ: "StringMetadataValueMap", StringMetadataValueMap: value} +} + +func NewMetadataFromStringUnknownMap(value map[string]interface{}) *Metadata { + return &Metadata{typ: "StringUnknownMap", StringUnknownMap: value} +} + +func (m *Metadata) GetStringMetadataValueMap() map[string]*MetadataValue { + if m == nil { + return nil + } + return m.StringMetadataValueMap +} + +func (m *Metadata) GetStringUnknownMap() map[string]interface{} { + if m == nil { + return nil + } + return m.StringUnknownMap +} + +func (m *Metadata) UnmarshalJSON(data []byte) error { + var valueStringMetadataValueMap map[string]*MetadataValue + if err := json.Unmarshal(data, &valueStringMetadataValueMap); err == nil { + m.typ = "StringMetadataValueMap" + m.StringMetadataValueMap = valueStringMetadataValueMap + return nil + } + var valueStringUnknownMap map[string]interface{} + if err := json.Unmarshal(data, &valueStringUnknownMap); err == nil { + m.typ = "StringUnknownMap" + m.StringUnknownMap = valueStringUnknownMap + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, m) +} + +func (m Metadata) MarshalJSON() ([]byte, error) { + if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { + return json.Marshal(m.StringMetadataValueMap) + } + if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { + return json.Marshal(m.StringUnknownMap) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataVisitor interface { + VisitStringMetadataValueMap(map[string]*MetadataValue) error + VisitStringUnknownMap(map[string]interface{}) error +} + +func (m *Metadata) Accept(visitor MetadataVisitor) error { + if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { + return visitor.VisitStringMetadataValueMap(m.StringMetadataValueMap) + } + if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { + return visitor.VisitStringUnknownMap(m.StringUnknownMap) + } + return fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataValue struct { + Double float64 + String string + Boolean bool + + typ string +} + +func NewMetadataValueFromDouble(value float64) *MetadataValue { + return &MetadataValue{typ: "Double", Double: value} +} + +func NewMetadataValueFromString(value string) *MetadataValue { + return &MetadataValue{typ: "String", String: value} +} + +func NewMetadataValueFromBoolean(value bool) *MetadataValue { + return &MetadataValue{typ: "Boolean", Boolean: value} +} + +func (m *MetadataValue) GetDouble() float64 { + if m == nil { + return 0 + } + return m.Double +} + +func (m *MetadataValue) GetString() string { + if m == nil { + return "" + } + return m.String +} + +func (m *MetadataValue) GetBoolean() bool { + if m == nil { + return false + } + return m.Boolean +} + +func (m *MetadataValue) UnmarshalJSON(data []byte) error { + var valueDouble float64 + if err := json.Unmarshal(data, &valueDouble); err == nil { + m.typ = "Double" + m.Double = valueDouble + return nil + } + var valueString string + if err := json.Unmarshal(data, &valueString); err == nil { + m.typ = "String" + m.String = valueString + return nil + } + var valueBoolean bool + if err := json.Unmarshal(data, &valueBoolean); err == nil { + m.typ = "Boolean" + m.Boolean = valueBoolean + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, m) +} + +func (m MetadataValue) MarshalJSON() ([]byte, error) { + if m.typ == "Double" || m.Double != 0 { + return json.Marshal(m.Double) + } + if m.typ == "String" || m.String != "" { + return json.Marshal(m.String) + } + if m.typ == "Boolean" || m.Boolean != false { + return json.Marshal(m.Boolean) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataValueVisitor interface { + VisitDouble(float64) error + VisitString(string) error + VisitBoolean(bool) error +} + +func (m *MetadataValue) Accept(visitor MetadataValueVisitor) error { + if m.typ == "Double" || m.Double != 0 { + return visitor.VisitDouble(m.Double) + } + if m.typ == "String" || m.String != "" { + return visitor.VisitString(m.String) + } + if m.typ == "Boolean" || m.Boolean != false { + return visitor.VisitBoolean(m.Boolean) + } + return fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type NamespaceSummary struct { + Count *int `json:"count,omitempty" url:"count,omitempty"` + + extraProperties map[string]interface{} +} + +func (n *NamespaceSummary) GetCount() *int { + if n == nil { + return nil + } + return n.Count +} + +func (n *NamespaceSummary) GetExtraProperties() map[string]interface{} { + return n.extraProperties +} + +func (n *NamespaceSummary) UnmarshalJSON(data []byte) error { + type unmarshaler NamespaceSummary + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NamespaceSummary(value) + + extraProperties, err := core.ExtractExtraProperties(data, *n) + if err != nil { + return err + } + n.extraProperties = extraProperties + + return nil +} + +func (n *NamespaceSummary) String() string { + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + +type Pagination struct { + Next *string `json:"next,omitempty" url:"next,omitempty"` + + extraProperties map[string]interface{} +} + +func (p *Pagination) GetNext() *string { + if p == nil { + return nil + } + return p.Next +} + +func (p *Pagination) GetExtraProperties() map[string]interface{} { + return p.extraProperties +} + +func (p *Pagination) UnmarshalJSON(data []byte) error { + type unmarshaler Pagination + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = Pagination(value) + + extraProperties, err := core.ExtractExtraProperties(data, *p) + if err != nil { + return err + } + p.extraProperties = extraProperties + + return nil +} + +func (p *Pagination) String() string { + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type QueryColumn struct { + Values []float64 `json:"values,omitempty" url:"values,omitempty"` + TopK *int `json:"topK,omitempty" url:"topK,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + Filter *Metadata `json:"filter,omitempty" url:"filter,omitempty"` + IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` + + extraProperties map[string]interface{} +} + +func (q *QueryColumn) GetValues() []float64 { + if q == nil { + return nil + } + return q.Values +} + +func (q *QueryColumn) GetTopK() *int { + if q == nil { + return nil + } + return q.TopK +} + +func (q *QueryColumn) GetNamespace() *string { + if q == nil { + return nil + } + return q.Namespace +} + +func (q *QueryColumn) GetFilter() *Metadata { + if q == nil { + return nil + } + return q.Filter +} + +func (q *QueryColumn) GetIndexedData() *IndexedData { + if q == nil { + return nil + } + return q.IndexedData +} + +func (q *QueryColumn) GetExtraProperties() map[string]interface{} { + return q.extraProperties +} + +func (q *QueryColumn) UnmarshalJSON(data []byte) error { + type unmarshaler QueryColumn + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *q = QueryColumn(value) + + extraProperties, err := core.ExtractExtraProperties(data, *q) + if err != nil { + return err + } + q.extraProperties = extraProperties + + return nil +} + +func (q *QueryColumn) String() string { + if value, err := core.StringifyJSON(q); err == nil { + return value + } + return fmt.Sprintf("%#v", q) +} + +type QueryResponse struct { + Results []*QueryResult `json:"results,omitempty" url:"results,omitempty"` + Matches []*ScoredColumn `json:"matches,omitempty" url:"matches,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` + + extraProperties map[string]interface{} +} + +func (q *QueryResponse) GetResults() []*QueryResult { + if q == nil { + return nil + } + return q.Results +} + +func (q *QueryResponse) GetMatches() []*ScoredColumn { + if q == nil { + return nil + } + return q.Matches +} + +func (q *QueryResponse) GetNamespace() *string { + if q == nil { + return nil + } + return q.Namespace +} + +func (q *QueryResponse) GetUsage() *Usage { + if q == nil { + return nil + } + return q.Usage +} + +func (q *QueryResponse) GetExtraProperties() map[string]interface{} { + return q.extraProperties +} + +func (q *QueryResponse) UnmarshalJSON(data []byte) error { + type unmarshaler QueryResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *q = QueryResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *q) + if err != nil { + return err + } + q.extraProperties = extraProperties + + return nil +} + +func (q *QueryResponse) String() string { + if value, err := core.StringifyJSON(q); err == nil { + return value + } + return fmt.Sprintf("%#v", q) +} + +type QueryResult struct { + Matches []*ScoredColumn `json:"matches,omitempty" url:"matches,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + + extraProperties map[string]interface{} +} + +func (q *QueryResult) GetMatches() []*ScoredColumn { + if q == nil { + return nil + } + return q.Matches +} + +func (q *QueryResult) GetNamespace() *string { + if q == nil { + return nil + } + return q.Namespace +} + +func (q *QueryResult) GetExtraProperties() map[string]interface{} { + return q.extraProperties +} + +func (q *QueryResult) UnmarshalJSON(data []byte) error { + type unmarshaler QueryResult + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *q = QueryResult(value) + + extraProperties, err := core.ExtractExtraProperties(data, *q) + if err != nil { + return err + } + q.extraProperties = extraProperties + + return nil +} + +func (q *QueryResult) String() string { + if value, err := core.StringifyJSON(q); err == nil { + return value + } + return fmt.Sprintf("%#v", q) +} + +type ScoredColumn struct { + Id string `json:"id" url:"id"` + Score *float64 `json:"score,omitempty" url:"score,omitempty"` + Values []float64 `json:"values,omitempty" url:"values,omitempty"` + Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` + IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` + + extraProperties map[string]interface{} +} + +func (s *ScoredColumn) GetId() string { + if s == nil { + return "" + } + return s.Id +} + +func (s *ScoredColumn) GetScore() *float64 { + if s == nil { + return nil + } + return s.Score +} + +func (s *ScoredColumn) GetValues() []float64 { + if s == nil { + return nil + } + return s.Values +} + +func (s *ScoredColumn) GetMetadata() *Metadata { + if s == nil { + return nil + } + return s.Metadata +} + +func (s *ScoredColumn) GetIndexedData() *IndexedData { + if s == nil { + return nil + } + return s.IndexedData +} + +func (s *ScoredColumn) GetExtraProperties() map[string]interface{} { + return s.extraProperties +} + +func (s *ScoredColumn) UnmarshalJSON(data []byte) error { + type unmarshaler ScoredColumn + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = ScoredColumn(value) + + extraProperties, err := core.ExtractExtraProperties(data, *s) + if err != nil { + return err + } + s.extraProperties = extraProperties + + return nil +} + +func (s *ScoredColumn) String() string { + if value, err := core.StringifyJSON(s); err == nil { + return value + } + return fmt.Sprintf("%#v", s) +} + +type UpdateResponse struct { + extraProperties map[string]interface{} +} + +func (u *UpdateResponse) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UpdateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UpdateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UpdateResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UpdateResponse) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UploadResponse struct { + Count *int `json:"count,omitempty" url:"count,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *UploadResponse) GetCount() *int { + if u == nil { + return nil + } + return u.Count +} + +func (u *UploadResponse) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UploadResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UploadResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UploadResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UploadResponse) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type Usage struct { + Units *int `json:"units,omitempty" url:"units,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *Usage) GetUnits() *int { + if u == nil { + return nil + } + return u.Units +} + +func (u *Usage) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *Usage) UnmarshalJSON(data []byte) error { + type unmarshaler Usage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = Usage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *Usage) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + type UpdateRequest struct { Id string `json:"id" url:"-"` Values []float64 `json:"values,omitempty" url:"-"` diff --git a/seed/go-fiber/grpc-proto-exhaustive/types.go b/seed/go-fiber/grpc-proto-exhaustive/types.go deleted file mode 100644 index 734c14d770d..00000000000 --- a/seed/go-fiber/grpc-proto-exhaustive/types.go +++ /dev/null @@ -1,1004 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/grpc-proto-exhaustive/fern/core" -) - -type Column struct { - Id string `json:"id" url:"id"` - Values []float64 `json:"values,omitempty" url:"values,omitempty"` - Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` - IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` - - extraProperties map[string]interface{} -} - -func (c *Column) GetId() string { - if c == nil { - return "" - } - return c.Id -} - -func (c *Column) GetValues() []float64 { - if c == nil { - return nil - } - return c.Values -} - -func (c *Column) GetMetadata() *Metadata { - if c == nil { - return nil - } - return c.Metadata -} - -func (c *Column) GetIndexedData() *IndexedData { - if c == nil { - return nil - } - return c.IndexedData -} - -func (c *Column) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *Column) UnmarshalJSON(data []byte) error { - type unmarshaler Column - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = Column(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - return nil -} - -func (c *Column) String() string { - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type DeleteResponse struct { - extraProperties map[string]interface{} -} - -func (d *DeleteResponse) GetExtraProperties() map[string]interface{} { - return d.extraProperties -} - -func (d *DeleteResponse) UnmarshalJSON(data []byte) error { - type unmarshaler DeleteResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *d = DeleteResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *d) - if err != nil { - return err - } - d.extraProperties = extraProperties - - return nil -} - -func (d *DeleteResponse) String() string { - if value, err := core.StringifyJSON(d); err == nil { - return value - } - return fmt.Sprintf("%#v", d) -} - -type DescribeResponse struct { - Namespaces map[string]*NamespaceSummary `json:"namespaces,omitempty" url:"namespaces,omitempty"` - Dimension *int `json:"dimension,omitempty" url:"dimension,omitempty"` - Fullness *float64 `json:"fullness,omitempty" url:"fullness,omitempty"` - TotalCount *int `json:"totalCount,omitempty" url:"totalCount,omitempty"` - - extraProperties map[string]interface{} -} - -func (d *DescribeResponse) GetNamespaces() map[string]*NamespaceSummary { - if d == nil { - return nil - } - return d.Namespaces -} - -func (d *DescribeResponse) GetDimension() *int { - if d == nil { - return nil - } - return d.Dimension -} - -func (d *DescribeResponse) GetFullness() *float64 { - if d == nil { - return nil - } - return d.Fullness -} - -func (d *DescribeResponse) GetTotalCount() *int { - if d == nil { - return nil - } - return d.TotalCount -} - -func (d *DescribeResponse) GetExtraProperties() map[string]interface{} { - return d.extraProperties -} - -func (d *DescribeResponse) UnmarshalJSON(data []byte) error { - type unmarshaler DescribeResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *d = DescribeResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *d) - if err != nil { - return err - } - d.extraProperties = extraProperties - - return nil -} - -func (d *DescribeResponse) String() string { - if value, err := core.StringifyJSON(d); err == nil { - return value - } - return fmt.Sprintf("%#v", d) -} - -type FetchResponse struct { - Columns map[string]*Column `json:"columns,omitempty" url:"columns,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` - - extraProperties map[string]interface{} -} - -func (f *FetchResponse) GetColumns() map[string]*Column { - if f == nil { - return nil - } - return f.Columns -} - -func (f *FetchResponse) GetNamespace() *string { - if f == nil { - return nil - } - return f.Namespace -} - -func (f *FetchResponse) GetUsage() *Usage { - if f == nil { - return nil - } - return f.Usage -} - -func (f *FetchResponse) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *FetchResponse) UnmarshalJSON(data []byte) error { - type unmarshaler FetchResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = FetchResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - return nil -} - -func (f *FetchResponse) String() string { - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} - -type IndexedData struct { - Indices []int `json:"indices,omitempty" url:"indices,omitempty"` - Values []float64 `json:"values,omitempty" url:"values,omitempty"` - - extraProperties map[string]interface{} -} - -func (i *IndexedData) GetIndices() []int { - if i == nil { - return nil - } - return i.Indices -} - -func (i *IndexedData) GetValues() []float64 { - if i == nil { - return nil - } - return i.Values -} - -func (i *IndexedData) GetExtraProperties() map[string]interface{} { - return i.extraProperties -} - -func (i *IndexedData) UnmarshalJSON(data []byte) error { - type unmarshaler IndexedData - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *i = IndexedData(value) - - extraProperties, err := core.ExtractExtraProperties(data, *i) - if err != nil { - return err - } - i.extraProperties = extraProperties - - return nil -} - -func (i *IndexedData) String() string { - if value, err := core.StringifyJSON(i); err == nil { - return value - } - return fmt.Sprintf("%#v", i) -} - -type ListElement struct { - Id *string `json:"id,omitempty" url:"id,omitempty"` - - extraProperties map[string]interface{} -} - -func (l *ListElement) GetId() *string { - if l == nil { - return nil - } - return l.Id -} - -func (l *ListElement) GetExtraProperties() map[string]interface{} { - return l.extraProperties -} - -func (l *ListElement) UnmarshalJSON(data []byte) error { - type unmarshaler ListElement - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *l = ListElement(value) - - extraProperties, err := core.ExtractExtraProperties(data, *l) - if err != nil { - return err - } - l.extraProperties = extraProperties - - return nil -} - -func (l *ListElement) String() string { - if value, err := core.StringifyJSON(l); err == nil { - return value - } - return fmt.Sprintf("%#v", l) -} - -type ListResponse struct { - Columns []*ListElement `json:"columns,omitempty" url:"columns,omitempty"` - Pagination *Pagination `json:"pagination,omitempty" url:"pagination,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` - - extraProperties map[string]interface{} -} - -func (l *ListResponse) GetColumns() []*ListElement { - if l == nil { - return nil - } - return l.Columns -} - -func (l *ListResponse) GetPagination() *Pagination { - if l == nil { - return nil - } - return l.Pagination -} - -func (l *ListResponse) GetNamespace() *string { - if l == nil { - return nil - } - return l.Namespace -} - -func (l *ListResponse) GetUsage() *Usage { - if l == nil { - return nil - } - return l.Usage -} - -func (l *ListResponse) GetExtraProperties() map[string]interface{} { - return l.extraProperties -} - -func (l *ListResponse) UnmarshalJSON(data []byte) error { - type unmarshaler ListResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *l = ListResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *l) - if err != nil { - return err - } - l.extraProperties = extraProperties - - return nil -} - -func (l *ListResponse) String() string { - if value, err := core.StringifyJSON(l); err == nil { - return value - } - return fmt.Sprintf("%#v", l) -} - -type Metadata struct { - StringMetadataValueMap map[string]*MetadataValue - StringUnknownMap map[string]interface{} - - typ string -} - -func NewMetadataFromStringMetadataValueMap(value map[string]*MetadataValue) *Metadata { - return &Metadata{typ: "StringMetadataValueMap", StringMetadataValueMap: value} -} - -func NewMetadataFromStringUnknownMap(value map[string]interface{}) *Metadata { - return &Metadata{typ: "StringUnknownMap", StringUnknownMap: value} -} - -func (m *Metadata) GetStringMetadataValueMap() map[string]*MetadataValue { - if m == nil { - return nil - } - return m.StringMetadataValueMap -} - -func (m *Metadata) GetStringUnknownMap() map[string]interface{} { - if m == nil { - return nil - } - return m.StringUnknownMap -} - -func (m *Metadata) UnmarshalJSON(data []byte) error { - var valueStringMetadataValueMap map[string]*MetadataValue - if err := json.Unmarshal(data, &valueStringMetadataValueMap); err == nil { - m.typ = "StringMetadataValueMap" - m.StringMetadataValueMap = valueStringMetadataValueMap - return nil - } - var valueStringUnknownMap map[string]interface{} - if err := json.Unmarshal(data, &valueStringUnknownMap); err == nil { - m.typ = "StringUnknownMap" - m.StringUnknownMap = valueStringUnknownMap - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, m) -} - -func (m Metadata) MarshalJSON() ([]byte, error) { - if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { - return json.Marshal(m.StringMetadataValueMap) - } - if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { - return json.Marshal(m.StringUnknownMap) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataVisitor interface { - VisitStringMetadataValueMap(map[string]*MetadataValue) error - VisitStringUnknownMap(map[string]interface{}) error -} - -func (m *Metadata) Accept(visitor MetadataVisitor) error { - if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { - return visitor.VisitStringMetadataValueMap(m.StringMetadataValueMap) - } - if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { - return visitor.VisitStringUnknownMap(m.StringUnknownMap) - } - return fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataValue struct { - Double float64 - String string - Boolean bool - - typ string -} - -func NewMetadataValueFromDouble(value float64) *MetadataValue { - return &MetadataValue{typ: "Double", Double: value} -} - -func NewMetadataValueFromString(value string) *MetadataValue { - return &MetadataValue{typ: "String", String: value} -} - -func NewMetadataValueFromBoolean(value bool) *MetadataValue { - return &MetadataValue{typ: "Boolean", Boolean: value} -} - -func (m *MetadataValue) GetDouble() float64 { - if m == nil { - return 0 - } - return m.Double -} - -func (m *MetadataValue) GetString() string { - if m == nil { - return "" - } - return m.String -} - -func (m *MetadataValue) GetBoolean() bool { - if m == nil { - return false - } - return m.Boolean -} - -func (m *MetadataValue) UnmarshalJSON(data []byte) error { - var valueDouble float64 - if err := json.Unmarshal(data, &valueDouble); err == nil { - m.typ = "Double" - m.Double = valueDouble - return nil - } - var valueString string - if err := json.Unmarshal(data, &valueString); err == nil { - m.typ = "String" - m.String = valueString - return nil - } - var valueBoolean bool - if err := json.Unmarshal(data, &valueBoolean); err == nil { - m.typ = "Boolean" - m.Boolean = valueBoolean - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, m) -} - -func (m MetadataValue) MarshalJSON() ([]byte, error) { - if m.typ == "Double" || m.Double != 0 { - return json.Marshal(m.Double) - } - if m.typ == "String" || m.String != "" { - return json.Marshal(m.String) - } - if m.typ == "Boolean" || m.Boolean != false { - return json.Marshal(m.Boolean) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataValueVisitor interface { - VisitDouble(float64) error - VisitString(string) error - VisitBoolean(bool) error -} - -func (m *MetadataValue) Accept(visitor MetadataValueVisitor) error { - if m.typ == "Double" || m.Double != 0 { - return visitor.VisitDouble(m.Double) - } - if m.typ == "String" || m.String != "" { - return visitor.VisitString(m.String) - } - if m.typ == "Boolean" || m.Boolean != false { - return visitor.VisitBoolean(m.Boolean) - } - return fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type NamespaceSummary struct { - Count *int `json:"count,omitempty" url:"count,omitempty"` - - extraProperties map[string]interface{} -} - -func (n *NamespaceSummary) GetCount() *int { - if n == nil { - return nil - } - return n.Count -} - -func (n *NamespaceSummary) GetExtraProperties() map[string]interface{} { - return n.extraProperties -} - -func (n *NamespaceSummary) UnmarshalJSON(data []byte) error { - type unmarshaler NamespaceSummary - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *n = NamespaceSummary(value) - - extraProperties, err := core.ExtractExtraProperties(data, *n) - if err != nil { - return err - } - n.extraProperties = extraProperties - - return nil -} - -func (n *NamespaceSummary) String() string { - if value, err := core.StringifyJSON(n); err == nil { - return value - } - return fmt.Sprintf("%#v", n) -} - -type Pagination struct { - Next *string `json:"next,omitempty" url:"next,omitempty"` - - extraProperties map[string]interface{} -} - -func (p *Pagination) GetNext() *string { - if p == nil { - return nil - } - return p.Next -} - -func (p *Pagination) GetExtraProperties() map[string]interface{} { - return p.extraProperties -} - -func (p *Pagination) UnmarshalJSON(data []byte) error { - type unmarshaler Pagination - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *p = Pagination(value) - - extraProperties, err := core.ExtractExtraProperties(data, *p) - if err != nil { - return err - } - p.extraProperties = extraProperties - - return nil -} - -func (p *Pagination) String() string { - if value, err := core.StringifyJSON(p); err == nil { - return value - } - return fmt.Sprintf("%#v", p) -} - -type QueryColumn struct { - Values []float64 `json:"values,omitempty" url:"values,omitempty"` - TopK *int `json:"topK,omitempty" url:"topK,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - Filter *Metadata `json:"filter,omitempty" url:"filter,omitempty"` - IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` - - extraProperties map[string]interface{} -} - -func (q *QueryColumn) GetValues() []float64 { - if q == nil { - return nil - } - return q.Values -} - -func (q *QueryColumn) GetTopK() *int { - if q == nil { - return nil - } - return q.TopK -} - -func (q *QueryColumn) GetNamespace() *string { - if q == nil { - return nil - } - return q.Namespace -} - -func (q *QueryColumn) GetFilter() *Metadata { - if q == nil { - return nil - } - return q.Filter -} - -func (q *QueryColumn) GetIndexedData() *IndexedData { - if q == nil { - return nil - } - return q.IndexedData -} - -func (q *QueryColumn) GetExtraProperties() map[string]interface{} { - return q.extraProperties -} - -func (q *QueryColumn) UnmarshalJSON(data []byte) error { - type unmarshaler QueryColumn - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *q = QueryColumn(value) - - extraProperties, err := core.ExtractExtraProperties(data, *q) - if err != nil { - return err - } - q.extraProperties = extraProperties - - return nil -} - -func (q *QueryColumn) String() string { - if value, err := core.StringifyJSON(q); err == nil { - return value - } - return fmt.Sprintf("%#v", q) -} - -type QueryResponse struct { - Results []*QueryResult `json:"results,omitempty" url:"results,omitempty"` - Matches []*ScoredColumn `json:"matches,omitempty" url:"matches,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` - - extraProperties map[string]interface{} -} - -func (q *QueryResponse) GetResults() []*QueryResult { - if q == nil { - return nil - } - return q.Results -} - -func (q *QueryResponse) GetMatches() []*ScoredColumn { - if q == nil { - return nil - } - return q.Matches -} - -func (q *QueryResponse) GetNamespace() *string { - if q == nil { - return nil - } - return q.Namespace -} - -func (q *QueryResponse) GetUsage() *Usage { - if q == nil { - return nil - } - return q.Usage -} - -func (q *QueryResponse) GetExtraProperties() map[string]interface{} { - return q.extraProperties -} - -func (q *QueryResponse) UnmarshalJSON(data []byte) error { - type unmarshaler QueryResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *q = QueryResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *q) - if err != nil { - return err - } - q.extraProperties = extraProperties - - return nil -} - -func (q *QueryResponse) String() string { - if value, err := core.StringifyJSON(q); err == nil { - return value - } - return fmt.Sprintf("%#v", q) -} - -type QueryResult struct { - Matches []*ScoredColumn `json:"matches,omitempty" url:"matches,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - - extraProperties map[string]interface{} -} - -func (q *QueryResult) GetMatches() []*ScoredColumn { - if q == nil { - return nil - } - return q.Matches -} - -func (q *QueryResult) GetNamespace() *string { - if q == nil { - return nil - } - return q.Namespace -} - -func (q *QueryResult) GetExtraProperties() map[string]interface{} { - return q.extraProperties -} - -func (q *QueryResult) UnmarshalJSON(data []byte) error { - type unmarshaler QueryResult - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *q = QueryResult(value) - - extraProperties, err := core.ExtractExtraProperties(data, *q) - if err != nil { - return err - } - q.extraProperties = extraProperties - - return nil -} - -func (q *QueryResult) String() string { - if value, err := core.StringifyJSON(q); err == nil { - return value - } - return fmt.Sprintf("%#v", q) -} - -type ScoredColumn struct { - Id string `json:"id" url:"id"` - Score *float64 `json:"score,omitempty" url:"score,omitempty"` - Values []float64 `json:"values,omitempty" url:"values,omitempty"` - Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` - IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` - - extraProperties map[string]interface{} -} - -func (s *ScoredColumn) GetId() string { - if s == nil { - return "" - } - return s.Id -} - -func (s *ScoredColumn) GetScore() *float64 { - if s == nil { - return nil - } - return s.Score -} - -func (s *ScoredColumn) GetValues() []float64 { - if s == nil { - return nil - } - return s.Values -} - -func (s *ScoredColumn) GetMetadata() *Metadata { - if s == nil { - return nil - } - return s.Metadata -} - -func (s *ScoredColumn) GetIndexedData() *IndexedData { - if s == nil { - return nil - } - return s.IndexedData -} - -func (s *ScoredColumn) GetExtraProperties() map[string]interface{} { - return s.extraProperties -} - -func (s *ScoredColumn) UnmarshalJSON(data []byte) error { - type unmarshaler ScoredColumn - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = ScoredColumn(value) - - extraProperties, err := core.ExtractExtraProperties(data, *s) - if err != nil { - return err - } - s.extraProperties = extraProperties - - return nil -} - -func (s *ScoredColumn) String() string { - if value, err := core.StringifyJSON(s); err == nil { - return value - } - return fmt.Sprintf("%#v", s) -} - -type UpdateResponse struct { - extraProperties map[string]interface{} -} - -func (u *UpdateResponse) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UpdateResponse) UnmarshalJSON(data []byte) error { - type unmarshaler UpdateResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UpdateResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UpdateResponse) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UploadResponse struct { - Count *int `json:"count,omitempty" url:"count,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *UploadResponse) GetCount() *int { - if u == nil { - return nil - } - return u.Count -} - -func (u *UploadResponse) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UploadResponse) UnmarshalJSON(data []byte) error { - type unmarshaler UploadResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UploadResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UploadResponse) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type Usage struct { - Units *int `json:"units,omitempty" url:"units,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *Usage) GetUnits() *int { - if u == nil { - return nil - } - return u.Units -} - -func (u *Usage) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *Usage) UnmarshalJSON(data []byte) error { - type unmarshaler Usage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = Usage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *Usage) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/seed/go-fiber/grpc-proto/types.go b/seed/go-fiber/grpc-proto/types.go deleted file mode 100644 index 76dca4cb5d4..00000000000 --- a/seed/go-fiber/grpc-proto/types.go +++ /dev/null @@ -1,288 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/grpc-proto/fern/core" -) - -type CreateResponse struct { - User *UserModel `json:"user,omitempty" url:"user,omitempty"` - - extraProperties map[string]interface{} -} - -func (c *CreateResponse) GetUser() *UserModel { - if c == nil { - return nil - } - return c.User -} - -func (c *CreateResponse) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *CreateResponse) UnmarshalJSON(data []byte) error { - type unmarshaler CreateResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = CreateResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - return nil -} - -func (c *CreateResponse) String() string { - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type Metadata struct { - StringMetadataValueMap map[string]*MetadataValue - StringUnknownMap map[string]interface{} - - typ string -} - -func NewMetadataFromStringMetadataValueMap(value map[string]*MetadataValue) *Metadata { - return &Metadata{typ: "StringMetadataValueMap", StringMetadataValueMap: value} -} - -func NewMetadataFromStringUnknownMap(value map[string]interface{}) *Metadata { - return &Metadata{typ: "StringUnknownMap", StringUnknownMap: value} -} - -func (m *Metadata) GetStringMetadataValueMap() map[string]*MetadataValue { - if m == nil { - return nil - } - return m.StringMetadataValueMap -} - -func (m *Metadata) GetStringUnknownMap() map[string]interface{} { - if m == nil { - return nil - } - return m.StringUnknownMap -} - -func (m *Metadata) UnmarshalJSON(data []byte) error { - var valueStringMetadataValueMap map[string]*MetadataValue - if err := json.Unmarshal(data, &valueStringMetadataValueMap); err == nil { - m.typ = "StringMetadataValueMap" - m.StringMetadataValueMap = valueStringMetadataValueMap - return nil - } - var valueStringUnknownMap map[string]interface{} - if err := json.Unmarshal(data, &valueStringUnknownMap); err == nil { - m.typ = "StringUnknownMap" - m.StringUnknownMap = valueStringUnknownMap - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, m) -} - -func (m Metadata) MarshalJSON() ([]byte, error) { - if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { - return json.Marshal(m.StringMetadataValueMap) - } - if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { - return json.Marshal(m.StringUnknownMap) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataVisitor interface { - VisitStringMetadataValueMap(map[string]*MetadataValue) error - VisitStringUnknownMap(map[string]interface{}) error -} - -func (m *Metadata) Accept(visitor MetadataVisitor) error { - if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { - return visitor.VisitStringMetadataValueMap(m.StringMetadataValueMap) - } - if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { - return visitor.VisitStringUnknownMap(m.StringUnknownMap) - } - return fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataValue struct { - Double float64 - String string - Boolean bool - - typ string -} - -func NewMetadataValueFromDouble(value float64) *MetadataValue { - return &MetadataValue{typ: "Double", Double: value} -} - -func NewMetadataValueFromString(value string) *MetadataValue { - return &MetadataValue{typ: "String", String: value} -} - -func NewMetadataValueFromBoolean(value bool) *MetadataValue { - return &MetadataValue{typ: "Boolean", Boolean: value} -} - -func (m *MetadataValue) GetDouble() float64 { - if m == nil { - return 0 - } - return m.Double -} - -func (m *MetadataValue) GetString() string { - if m == nil { - return "" - } - return m.String -} - -func (m *MetadataValue) GetBoolean() bool { - if m == nil { - return false - } - return m.Boolean -} - -func (m *MetadataValue) UnmarshalJSON(data []byte) error { - var valueDouble float64 - if err := json.Unmarshal(data, &valueDouble); err == nil { - m.typ = "Double" - m.Double = valueDouble - return nil - } - var valueString string - if err := json.Unmarshal(data, &valueString); err == nil { - m.typ = "String" - m.String = valueString - return nil - } - var valueBoolean bool - if err := json.Unmarshal(data, &valueBoolean); err == nil { - m.typ = "Boolean" - m.Boolean = valueBoolean - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, m) -} - -func (m MetadataValue) MarshalJSON() ([]byte, error) { - if m.typ == "Double" || m.Double != 0 { - return json.Marshal(m.Double) - } - if m.typ == "String" || m.String != "" { - return json.Marshal(m.String) - } - if m.typ == "Boolean" || m.Boolean != false { - return json.Marshal(m.Boolean) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataValueVisitor interface { - VisitDouble(float64) error - VisitString(string) error - VisitBoolean(bool) error -} - -func (m *MetadataValue) Accept(visitor MetadataValueVisitor) error { - if m.typ == "Double" || m.Double != 0 { - return visitor.VisitDouble(m.Double) - } - if m.typ == "String" || m.String != "" { - return visitor.VisitString(m.String) - } - if m.typ == "Boolean" || m.Boolean != false { - return visitor.VisitBoolean(m.Boolean) - } - return fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type UserModel struct { - Username *string `json:"username,omitempty" url:"username,omitempty"` - Email *string `json:"email,omitempty" url:"email,omitempty"` - Age *int `json:"age,omitempty" url:"age,omitempty"` - Weight *float64 `json:"weight,omitempty" url:"weight,omitempty"` - Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *UserModel) GetUsername() *string { - if u == nil { - return nil - } - return u.Username -} - -func (u *UserModel) GetEmail() *string { - if u == nil { - return nil - } - return u.Email -} - -func (u *UserModel) GetAge() *int { - if u == nil { - return nil - } - return u.Age -} - -func (u *UserModel) GetWeight() *float64 { - if u == nil { - return nil - } - return u.Weight -} - -func (u *UserModel) GetMetadata() *Metadata { - if u == nil { - return nil - } - return u.Metadata -} - -func (u *UserModel) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserModel) UnmarshalJSON(data []byte) error { - type unmarshaler UserModel - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserModel(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UserModel) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/seed/go-fiber/grpc-proto/userservice.go b/seed/go-fiber/grpc-proto/userservice.go index 54b4428f9a3..b5edcc6cdb1 100644 --- a/seed/go-fiber/grpc-proto/userservice.go +++ b/seed/go-fiber/grpc-proto/userservice.go @@ -2,6 +2,12 @@ package api +import ( + json "encoding/json" + fmt "fmt" + core "github.com/grpc-proto/fern/core" +) + type CreateRequest struct { Username *string `json:"username,omitempty" url:"-"` Email *string `json:"email,omitempty" url:"-"` @@ -9,3 +15,282 @@ type CreateRequest struct { Weight *float64 `json:"weight,omitempty" url:"-"` Metadata *Metadata `json:"metadata,omitempty" url:"-"` } + +type CreateResponse struct { + User *UserModel `json:"user,omitempty" url:"user,omitempty"` + + extraProperties map[string]interface{} +} + +func (c *CreateResponse) GetUser() *UserModel { + if c == nil { + return nil + } + return c.User +} + +func (c *CreateResponse) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *CreateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler CreateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = CreateResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + return nil +} + +func (c *CreateResponse) String() string { + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type Metadata struct { + StringMetadataValueMap map[string]*MetadataValue + StringUnknownMap map[string]interface{} + + typ string +} + +func NewMetadataFromStringMetadataValueMap(value map[string]*MetadataValue) *Metadata { + return &Metadata{typ: "StringMetadataValueMap", StringMetadataValueMap: value} +} + +func NewMetadataFromStringUnknownMap(value map[string]interface{}) *Metadata { + return &Metadata{typ: "StringUnknownMap", StringUnknownMap: value} +} + +func (m *Metadata) GetStringMetadataValueMap() map[string]*MetadataValue { + if m == nil { + return nil + } + return m.StringMetadataValueMap +} + +func (m *Metadata) GetStringUnknownMap() map[string]interface{} { + if m == nil { + return nil + } + return m.StringUnknownMap +} + +func (m *Metadata) UnmarshalJSON(data []byte) error { + var valueStringMetadataValueMap map[string]*MetadataValue + if err := json.Unmarshal(data, &valueStringMetadataValueMap); err == nil { + m.typ = "StringMetadataValueMap" + m.StringMetadataValueMap = valueStringMetadataValueMap + return nil + } + var valueStringUnknownMap map[string]interface{} + if err := json.Unmarshal(data, &valueStringUnknownMap); err == nil { + m.typ = "StringUnknownMap" + m.StringUnknownMap = valueStringUnknownMap + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, m) +} + +func (m Metadata) MarshalJSON() ([]byte, error) { + if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { + return json.Marshal(m.StringMetadataValueMap) + } + if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { + return json.Marshal(m.StringUnknownMap) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataVisitor interface { + VisitStringMetadataValueMap(map[string]*MetadataValue) error + VisitStringUnknownMap(map[string]interface{}) error +} + +func (m *Metadata) Accept(visitor MetadataVisitor) error { + if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { + return visitor.VisitStringMetadataValueMap(m.StringMetadataValueMap) + } + if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { + return visitor.VisitStringUnknownMap(m.StringUnknownMap) + } + return fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataValue struct { + Double float64 + String string + Boolean bool + + typ string +} + +func NewMetadataValueFromDouble(value float64) *MetadataValue { + return &MetadataValue{typ: "Double", Double: value} +} + +func NewMetadataValueFromString(value string) *MetadataValue { + return &MetadataValue{typ: "String", String: value} +} + +func NewMetadataValueFromBoolean(value bool) *MetadataValue { + return &MetadataValue{typ: "Boolean", Boolean: value} +} + +func (m *MetadataValue) GetDouble() float64 { + if m == nil { + return 0 + } + return m.Double +} + +func (m *MetadataValue) GetString() string { + if m == nil { + return "" + } + return m.String +} + +func (m *MetadataValue) GetBoolean() bool { + if m == nil { + return false + } + return m.Boolean +} + +func (m *MetadataValue) UnmarshalJSON(data []byte) error { + var valueDouble float64 + if err := json.Unmarshal(data, &valueDouble); err == nil { + m.typ = "Double" + m.Double = valueDouble + return nil + } + var valueString string + if err := json.Unmarshal(data, &valueString); err == nil { + m.typ = "String" + m.String = valueString + return nil + } + var valueBoolean bool + if err := json.Unmarshal(data, &valueBoolean); err == nil { + m.typ = "Boolean" + m.Boolean = valueBoolean + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, m) +} + +func (m MetadataValue) MarshalJSON() ([]byte, error) { + if m.typ == "Double" || m.Double != 0 { + return json.Marshal(m.Double) + } + if m.typ == "String" || m.String != "" { + return json.Marshal(m.String) + } + if m.typ == "Boolean" || m.Boolean != false { + return json.Marshal(m.Boolean) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataValueVisitor interface { + VisitDouble(float64) error + VisitString(string) error + VisitBoolean(bool) error +} + +func (m *MetadataValue) Accept(visitor MetadataValueVisitor) error { + if m.typ == "Double" || m.Double != 0 { + return visitor.VisitDouble(m.Double) + } + if m.typ == "String" || m.String != "" { + return visitor.VisitString(m.String) + } + if m.typ == "Boolean" || m.Boolean != false { + return visitor.VisitBoolean(m.Boolean) + } + return fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type UserModel struct { + Username *string `json:"username,omitempty" url:"username,omitempty"` + Email *string `json:"email,omitempty" url:"email,omitempty"` + Age *int `json:"age,omitempty" url:"age,omitempty"` + Weight *float64 `json:"weight,omitempty" url:"weight,omitempty"` + Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *UserModel) GetUsername() *string { + if u == nil { + return nil + } + return u.Username +} + +func (u *UserModel) GetEmail() *string { + if u == nil { + return nil + } + return u.Email +} + +func (u *UserModel) GetAge() *int { + if u == nil { + return nil + } + return u.Age +} + +func (u *UserModel) GetWeight() *float64 { + if u == nil { + return nil + } + return u.Weight +} + +func (u *UserModel) GetMetadata() *Metadata { + if u == nil { + return nil + } + return u.Metadata +} + +func (u *UserModel) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserModel) UnmarshalJSON(data []byte) error { + type unmarshaler UserModel + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserModel(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UserModel) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} diff --git a/seed/go-fiber/license/.github/workflows/ci.yml b/seed/go-fiber/license/.github/workflows/ci.yml new file mode 100644 index 00000000000..d4c0a5dcd95 --- /dev/null +++ b/seed/go-fiber/license/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: ci + +on: [push] + +jobs: + compile: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up go + uses: actions/setup-go@v4 + + - name: Compile + run: go build ./... + test: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up go + uses: actions/setup-go@v4 + + - name: Test + run: go test ./... diff --git a/seed/go-fiber/license/.mock/definition/__package__.yml b/seed/go-fiber/license/.mock/definition/__package__.yml new file mode 100644 index 00000000000..b1e4d4a878f --- /dev/null +++ b/seed/go-fiber/license/.mock/definition/__package__.yml @@ -0,0 +1,13 @@ +types: + Type: + docs: A simple type with just a name. + properties: + name: string + +service: + auth: false + base-path: / + endpoints: + get: + path: "/" + method: GET diff --git a/seed/go-fiber/license/.mock/definition/api.yml b/seed/go-fiber/license/.mock/definition/api.yml new file mode 100644 index 00000000000..5523ff1f181 --- /dev/null +++ b/seed/go-fiber/license/.mock/definition/api.yml @@ -0,0 +1 @@ +name: license diff --git a/seed/go-fiber/license/.mock/fern.config.json b/seed/go-fiber/license/.mock/fern.config.json new file mode 100644 index 00000000000..4c8e54ac313 --- /dev/null +++ b/seed/go-fiber/license/.mock/fern.config.json @@ -0,0 +1 @@ +{"organization": "fern-test", "version": "*"} \ No newline at end of file diff --git a/seed/go-fiber/license/.mock/generators.yml b/seed/go-fiber/license/.mock/generators.yml new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/seed/go-fiber/license/.mock/generators.yml @@ -0,0 +1 @@ +{} diff --git a/seed/go-fiber/license/core/extra_properties.go b/seed/go-fiber/license/core/extra_properties.go new file mode 100644 index 00000000000..a6af3e12410 --- /dev/null +++ b/seed/go-fiber/license/core/extra_properties.go @@ -0,0 +1,141 @@ +package core + +import ( + "bytes" + "encoding/json" + "fmt" + "reflect" + "strings" +) + +// MarshalJSONWithExtraProperty marshals the given value to JSON, including the extra property. +func MarshalJSONWithExtraProperty(marshaler interface{}, key string, value interface{}) ([]byte, error) { + return MarshalJSONWithExtraProperties(marshaler, map[string]interface{}{key: value}) +} + +// MarshalJSONWithExtraProperties marshals the given value to JSON, including any extra properties. +func MarshalJSONWithExtraProperties(marshaler interface{}, extraProperties map[string]interface{}) ([]byte, error) { + bytes, err := json.Marshal(marshaler) + if err != nil { + return nil, err + } + if len(extraProperties) == 0 { + return bytes, nil + } + keys, err := getKeys(marshaler) + if err != nil { + return nil, err + } + for _, key := range keys { + if _, ok := extraProperties[key]; ok { + return nil, fmt.Errorf("cannot add extra property %q because it is already defined on the type", key) + } + } + extraBytes, err := json.Marshal(extraProperties) + if err != nil { + return nil, err + } + if isEmptyJSON(bytes) { + if isEmptyJSON(extraBytes) { + return bytes, nil + } + return extraBytes, nil + } + result := bytes[:len(bytes)-1] + result = append(result, ',') + result = append(result, extraBytes[1:len(extraBytes)-1]...) + result = append(result, '}') + return result, nil +} + +// ExtractExtraProperties extracts any extra properties from the given value. +func ExtractExtraProperties(bytes []byte, value interface{}, exclude ...string) (map[string]interface{}, error) { + val := reflect.ValueOf(value) + for val.Kind() == reflect.Ptr { + if val.IsNil() { + return nil, fmt.Errorf("value must be non-nil to extract extra properties") + } + val = val.Elem() + } + if err := json.Unmarshal(bytes, &value); err != nil { + return nil, err + } + var extraProperties map[string]interface{} + if err := json.Unmarshal(bytes, &extraProperties); err != nil { + return nil, err + } + for i := 0; i < val.Type().NumField(); i++ { + key := jsonKey(val.Type().Field(i)) + if key == "" || key == "-" { + continue + } + delete(extraProperties, key) + } + for _, key := range exclude { + delete(extraProperties, key) + } + if len(extraProperties) == 0 { + return nil, nil + } + return extraProperties, nil +} + +// getKeys returns the keys associated with the given value. The value must be a +// a struct or a map with string keys. +func getKeys(value interface{}) ([]string, error) { + val := reflect.ValueOf(value) + if val.Kind() == reflect.Ptr { + val = val.Elem() + } + if !val.IsValid() { + return nil, nil + } + switch val.Kind() { + case reflect.Struct: + return getKeysForStructType(val.Type()), nil + case reflect.Map: + var keys []string + if val.Type().Key().Kind() != reflect.String { + return nil, fmt.Errorf("cannot extract keys from %T; only structs and maps with string keys are supported", value) + } + for _, key := range val.MapKeys() { + keys = append(keys, key.String()) + } + return keys, nil + default: + return nil, fmt.Errorf("cannot extract keys from %T; only structs and maps with string keys are supported", value) + } +} + +// getKeysForStructType returns all the keys associated with the given struct type, +// visiting embedded fields recursively. +func getKeysForStructType(structType reflect.Type) []string { + if structType.Kind() == reflect.Pointer { + structType = structType.Elem() + } + if structType.Kind() != reflect.Struct { + return nil + } + var keys []string + for i := 0; i < structType.NumField(); i++ { + field := structType.Field(i) + if field.Anonymous { + keys = append(keys, getKeysForStructType(field.Type)...) + continue + } + keys = append(keys, jsonKey(field)) + } + return keys +} + +// jsonKey returns the JSON key from the struct tag of the given field, +// excluding the omitempty flag (if any). +func jsonKey(field reflect.StructField) string { + return strings.TrimSuffix(field.Tag.Get("json"), ",omitempty") +} + +// isEmptyJSON returns true if the given data is empty, the empty JSON object, or +// an explicit null. +func isEmptyJSON(data []byte) bool { + return len(data) <= 2 || bytes.Equal(data, []byte("null")) +} diff --git a/seed/go-fiber/license/core/extra_properties_test.go b/seed/go-fiber/license/core/extra_properties_test.go new file mode 100644 index 00000000000..dc66fccd7f1 --- /dev/null +++ b/seed/go-fiber/license/core/extra_properties_test.go @@ -0,0 +1,228 @@ +package core + +import ( + "encoding/json" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +type testMarshaler struct { + Name string `json:"name"` + BirthDate time.Time `json:"birthDate"` + CreatedAt time.Time `json:"created_at"` +} + +func (t *testMarshaler) MarshalJSON() ([]byte, error) { + type embed testMarshaler + var marshaler = struct { + embed + BirthDate string `json:"birthDate"` + CreatedAt string `json:"created_at"` + }{ + embed: embed(*t), + BirthDate: t.BirthDate.Format("2006-01-02"), + CreatedAt: t.CreatedAt.Format(time.RFC3339), + } + return MarshalJSONWithExtraProperty(marshaler, "type", "test") +} + +func TestMarshalJSONWithExtraProperties(t *testing.T) { + tests := []struct { + desc string + giveMarshaler interface{} + giveExtraProperties map[string]interface{} + wantBytes []byte + wantError string + }{ + { + desc: "invalid type", + giveMarshaler: []string{"invalid"}, + giveExtraProperties: map[string]interface{}{"key": "overwrite"}, + wantError: `cannot extract keys from []string; only structs and maps with string keys are supported`, + }, + { + desc: "invalid key type", + giveMarshaler: map[int]interface{}{42: "value"}, + giveExtraProperties: map[string]interface{}{"key": "overwrite"}, + wantError: `cannot extract keys from map[int]interface {}; only structs and maps with string keys are supported`, + }, + { + desc: "invalid map overwrite", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{"key": "overwrite"}, + wantError: `cannot add extra property "key" because it is already defined on the type`, + }, + { + desc: "invalid struct overwrite", + giveMarshaler: new(testMarshaler), + giveExtraProperties: map[string]interface{}{"birthDate": "2000-01-01"}, + wantError: `cannot add extra property "birthDate" because it is already defined on the type`, + }, + { + desc: "invalid struct overwrite embedded type", + giveMarshaler: new(testMarshaler), + giveExtraProperties: map[string]interface{}{"name": "bob"}, + wantError: `cannot add extra property "name" because it is already defined on the type`, + }, + { + desc: "nil", + giveMarshaler: nil, + giveExtraProperties: nil, + wantBytes: []byte(`null`), + }, + { + desc: "empty", + giveMarshaler: map[string]interface{}{}, + giveExtraProperties: map[string]interface{}{}, + wantBytes: []byte(`{}`), + }, + { + desc: "no extra properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{}, + wantBytes: []byte(`{"key":"value"}`), + }, + { + desc: "only extra properties", + giveMarshaler: map[string]interface{}{}, + giveExtraProperties: map[string]interface{}{"key": "value"}, + wantBytes: []byte(`{"key":"value"}`), + }, + { + desc: "single extra property", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{"extra": "property"}, + wantBytes: []byte(`{"key":"value","extra":"property"}`), + }, + { + desc: "multiple extra properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{"one": 1, "two": 2}, + wantBytes: []byte(`{"key":"value","one":1,"two":2}`), + }, + { + desc: "nested properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{ + "user": map[string]interface{}{ + "age": 42, + "name": "alice", + }, + }, + wantBytes: []byte(`{"key":"value","user":{"age":42,"name":"alice"}}`), + }, + { + desc: "multiple nested properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{ + "metadata": map[string]interface{}{ + "ip": "127.0.0.1", + }, + "user": map[string]interface{}{ + "age": 42, + "name": "alice", + }, + }, + wantBytes: []byte(`{"key":"value","metadata":{"ip":"127.0.0.1"},"user":{"age":42,"name":"alice"}}`), + }, + { + desc: "custom marshaler", + giveMarshaler: &testMarshaler{ + Name: "alice", + BirthDate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), + CreatedAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC), + }, + giveExtraProperties: map[string]interface{}{ + "extra": "property", + }, + wantBytes: []byte(`{"name":"alice","birthDate":"2000-01-01","created_at":"2024-01-01T00:00:00Z","type":"test","extra":"property"}`), + }, + } + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + bytes, err := MarshalJSONWithExtraProperties(tt.giveMarshaler, tt.giveExtraProperties) + if tt.wantError != "" { + require.EqualError(t, err, tt.wantError) + assert.Nil(t, tt.wantBytes) + return + } + require.NoError(t, err) + assert.Equal(t, tt.wantBytes, bytes) + + value := make(map[string]interface{}) + require.NoError(t, json.Unmarshal(bytes, &value)) + }) + } +} + +func TestExtractExtraProperties(t *testing.T) { + t.Run("none", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := &user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice"}`), value) + require.NoError(t, err) + assert.Nil(t, extraProperties) + }) + + t.Run("non-nil pointer", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := &user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + require.NoError(t, err) + assert.Equal(t, map[string]interface{}{"age": float64(42)}, extraProperties) + }) + + t.Run("nil pointer", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + var value *user + _, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + assert.EqualError(t, err, "value must be non-nil to extract extra properties") + }) + + t.Run("non-zero value", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + require.NoError(t, err) + assert.Equal(t, map[string]interface{}{"age": float64(42)}, extraProperties) + }) + + t.Run("zero value", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + var value user + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + require.NoError(t, err) + assert.Equal(t, map[string]interface{}{"age": float64(42)}, extraProperties) + }) + + t.Run("exclude", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := &user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value, "age") + require.NoError(t, err) + assert.Nil(t, extraProperties) + }) +} diff --git a/seed/go-fiber/license/core/stringer.go b/seed/go-fiber/license/core/stringer.go new file mode 100644 index 00000000000..000cf448641 --- /dev/null +++ b/seed/go-fiber/license/core/stringer.go @@ -0,0 +1,13 @@ +package core + +import "encoding/json" + +// StringifyJSON returns a pretty JSON string representation of +// the given value. +func StringifyJSON(value interface{}) (string, error) { + bytes, err := json.MarshalIndent(value, "", " ") + if err != nil { + return "", err + } + return string(bytes), nil +} diff --git a/seed/go-fiber/license/core/time.go b/seed/go-fiber/license/core/time.go new file mode 100644 index 00000000000..d009ab30c90 --- /dev/null +++ b/seed/go-fiber/license/core/time.go @@ -0,0 +1,137 @@ +package core + +import ( + "encoding/json" + "time" +) + +const dateFormat = "2006-01-02" + +// DateTime wraps time.Time and adapts its JSON representation +// to conform to a RFC3339 date (e.g. 2006-01-02). +// +// Ref: https://ijmacd.github.io/rfc3339-iso8601 +type Date struct { + t *time.Time +} + +// NewDate returns a new *Date. If the given time.Time +// is nil, nil will be returned. +func NewDate(t time.Time) *Date { + return &Date{t: &t} +} + +// NewOptionalDate returns a new *Date. If the given time.Time +// is nil, nil will be returned. +func NewOptionalDate(t *time.Time) *Date { + if t == nil { + return nil + } + return &Date{t: t} +} + +// Time returns the Date's underlying time, if any. If the +// date is nil, the zero value is returned. +func (d *Date) Time() time.Time { + if d == nil || d.t == nil { + return time.Time{} + } + return *d.t +} + +// TimePtr returns a pointer to the Date's underlying time.Time, if any. +func (d *Date) TimePtr() *time.Time { + if d == nil || d.t == nil { + return nil + } + if d.t.IsZero() { + return nil + } + return d.t +} + +func (d *Date) MarshalJSON() ([]byte, error) { + if d == nil || d.t == nil { + return nil, nil + } + return json.Marshal(d.t.Format(dateFormat)) +} + +func (d *Date) UnmarshalJSON(data []byte) error { + var raw string + if err := json.Unmarshal(data, &raw); err != nil { + return err + } + + parsedTime, err := time.Parse(dateFormat, raw) + if err != nil { + return err + } + + *d = Date{t: &parsedTime} + return nil +} + +// DateTime wraps time.Time and adapts its JSON representation +// to conform to a RFC3339 date-time (e.g. 2017-07-21T17:32:28Z). +// +// Ref: https://ijmacd.github.io/rfc3339-iso8601 +type DateTime struct { + t *time.Time +} + +// NewDateTime returns a new *DateTime. +func NewDateTime(t time.Time) *DateTime { + return &DateTime{t: &t} +} + +// NewOptionalDateTime returns a new *DateTime. If the given time.Time +// is nil, nil will be returned. +func NewOptionalDateTime(t *time.Time) *DateTime { + if t == nil { + return nil + } + return &DateTime{t: t} +} + +// Time returns the DateTime's underlying time, if any. If the +// date-time is nil, the zero value is returned. +func (d *DateTime) Time() time.Time { + if d == nil || d.t == nil { + return time.Time{} + } + return *d.t +} + +// TimePtr returns a pointer to the DateTime's underlying time.Time, if any. +func (d *DateTime) TimePtr() *time.Time { + if d == nil || d.t == nil { + return nil + } + if d.t.IsZero() { + return nil + } + return d.t +} + +func (d *DateTime) MarshalJSON() ([]byte, error) { + if d == nil || d.t == nil { + return nil, nil + } + return json.Marshal(d.t.Format(time.RFC3339)) +} + +func (d *DateTime) UnmarshalJSON(data []byte) error { + var raw string + if err := json.Unmarshal(data, &raw); err != nil { + return err + } + + parsedTime, err := time.Parse(time.RFC3339, raw) + if err != nil { + return err + } + + *d = DateTime{t: &parsedTime} + return nil +} diff --git a/seed/go-fiber/license/go.mod b/seed/go-fiber/license/go.mod new file mode 100644 index 00000000000..1dec86e3fdc --- /dev/null +++ b/seed/go-fiber/license/go.mod @@ -0,0 +1,8 @@ +module github.com/license/fern + +go 1.13 + +require ( + github.com/stretchr/testify v1.7.0 + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/seed/go-fiber/license/go.sum b/seed/go-fiber/license/go.sum new file mode 100644 index 00000000000..fc3dd9e67e8 --- /dev/null +++ b/seed/go-fiber/license/go.sum @@ -0,0 +1,12 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/seed/go-fiber/license/snippet-templates.json b/seed/go-fiber/license/snippet-templates.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/seed/go-fiber/license/snippet.json b/seed/go-fiber/license/snippet.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/seed/go-fiber/license/types.go b/seed/go-fiber/license/types.go new file mode 100644 index 00000000000..db51d068e02 --- /dev/null +++ b/seed/go-fiber/license/types.go @@ -0,0 +1,51 @@ +// This file was auto-generated by Fern from our API Definition. + +package license + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/license/fern/core" +) + +// A simple type with just a name. +type Type struct { + Name string `json:"name" url:"name"` + + extraProperties map[string]interface{} +} + +func (t *Type) GetName() string { + if t == nil { + return "" + } + return t.Name +} + +func (t *Type) GetExtraProperties() map[string]interface{} { + return t.extraProperties +} + +func (t *Type) UnmarshalJSON(data []byte) error { + type unmarshaler Type + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = Type(value) + + extraProperties, err := core.ExtractExtraProperties(data, *t) + if err != nil { + return err + } + t.extraProperties = extraProperties + + return nil +} + +func (t *Type) String() string { + if value, err := core.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} diff --git a/seed/go-fiber/literal/inlined.go b/seed/go-fiber/literal/inlined.go index 63ff17c9bce..3197b36aed7 100644 --- a/seed/go-fiber/literal/inlined.go +++ b/seed/go-fiber/literal/inlined.go @@ -53,6 +53,65 @@ func (s *SendLiteralsInlinedRequest) MarshalJSON() ([]byte, error) { return json.Marshal(marshaler) } +type ANestedLiteral struct { + myLiteral string + + extraProperties map[string]interface{} +} + +func (a *ANestedLiteral) MyLiteral() string { + return a.myLiteral +} + +func (a *ANestedLiteral) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *ANestedLiteral) UnmarshalJSON(data []byte) error { + type embed ANestedLiteral + var unmarshaler = struct { + embed + MyLiteral string `json:"myLiteral"` + }{ + embed: embed(*a), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *a = ANestedLiteral(unmarshaler.embed) + if unmarshaler.MyLiteral != "How super cool" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", a, "How super cool", unmarshaler.MyLiteral) + } + a.myLiteral = unmarshaler.MyLiteral + + extraProperties, err := core.ExtractExtraProperties(data, *a, "myLiteral") + if err != nil { + return err + } + a.extraProperties = extraProperties + + return nil +} + +func (a *ANestedLiteral) MarshalJSON() ([]byte, error) { + type embed ANestedLiteral + var marshaler = struct { + embed + MyLiteral string `json:"myLiteral"` + }{ + embed: embed(*a), + MyLiteral: "How super cool", + } + return json.Marshal(marshaler) +} + +func (a *ANestedLiteral) String() string { + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} + type ATopLevelLiteral struct { NestedLiteral *ANestedLiteral `json:"nestedLiteral,omitempty" url:"nestedLiteral,omitempty"` diff --git a/seed/go-fiber/literal/reference.go b/seed/go-fiber/literal/reference.go index d2e1e8d7f1c..922662d00bb 100644 --- a/seed/go-fiber/literal/reference.go +++ b/seed/go-fiber/literal/reference.go @@ -8,6 +8,126 @@ import ( core "github.com/literal/fern/core" ) +type ContainerObject struct { + NestedObjects []*NestedObjectWithLiterals `json:"nestedObjects,omitempty" url:"nestedObjects,omitempty"` + + extraProperties map[string]interface{} +} + +func (c *ContainerObject) GetNestedObjects() []*NestedObjectWithLiterals { + if c == nil { + return nil + } + return c.NestedObjects +} + +func (c *ContainerObject) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *ContainerObject) UnmarshalJSON(data []byte) error { + type unmarshaler ContainerObject + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ContainerObject(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + return nil +} + +func (c *ContainerObject) String() string { + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type NestedObjectWithLiterals struct { + StrProp string `json:"strProp" url:"strProp"` + literal1 string + literal2 string + + extraProperties map[string]interface{} +} + +func (n *NestedObjectWithLiterals) GetStrProp() string { + if n == nil { + return "" + } + return n.StrProp +} + +func (n *NestedObjectWithLiterals) Literal1() string { + return n.literal1 +} + +func (n *NestedObjectWithLiterals) Literal2() string { + return n.literal2 +} + +func (n *NestedObjectWithLiterals) GetExtraProperties() map[string]interface{} { + return n.extraProperties +} + +func (n *NestedObjectWithLiterals) UnmarshalJSON(data []byte) error { + type embed NestedObjectWithLiterals + var unmarshaler = struct { + embed + Literal1 string `json:"literal1"` + Literal2 string `json:"literal2"` + }{ + embed: embed(*n), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *n = NestedObjectWithLiterals(unmarshaler.embed) + if unmarshaler.Literal1 != "literal1" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", n, "literal1", unmarshaler.Literal1) + } + n.literal1 = unmarshaler.Literal1 + if unmarshaler.Literal2 != "literal2" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", n, "literal2", unmarshaler.Literal2) + } + n.literal2 = unmarshaler.Literal2 + + extraProperties, err := core.ExtractExtraProperties(data, *n, "literal1", "literal2") + if err != nil { + return err + } + n.extraProperties = extraProperties + + return nil +} + +func (n *NestedObjectWithLiterals) MarshalJSON() ([]byte, error) { + type embed NestedObjectWithLiterals + var marshaler = struct { + embed + Literal1 string `json:"literal1"` + Literal2 string `json:"literal2"` + }{ + embed: embed(*n), + Literal1: "literal1", + Literal2: "literal2", + } + return json.Marshal(marshaler) +} + +func (n *NestedObjectWithLiterals) String() string { + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + type SendRequest struct { Query string `json:"query" url:"query"` Context SomeLiteral `json:"context,omitempty" url:"context,omitempty"` @@ -96,3 +216,5 @@ func (s *SendRequest) String() string { } return fmt.Sprintf("%#v", s) } + +type SomeLiteral = string diff --git a/seed/go-fiber/literal/types.go b/seed/go-fiber/literal/types.go index 8f8283bc2cf..71967d5a74e 100644 --- a/seed/go-fiber/literal/types.go +++ b/seed/go-fiber/literal/types.go @@ -82,184 +82,3 @@ func (s *SendResponse) String() string { } return fmt.Sprintf("%#v", s) } - -type ANestedLiteral struct { - myLiteral string - - extraProperties map[string]interface{} -} - -func (a *ANestedLiteral) MyLiteral() string { - return a.myLiteral -} - -func (a *ANestedLiteral) GetExtraProperties() map[string]interface{} { - return a.extraProperties -} - -func (a *ANestedLiteral) UnmarshalJSON(data []byte) error { - type embed ANestedLiteral - var unmarshaler = struct { - embed - MyLiteral string `json:"myLiteral"` - }{ - embed: embed(*a), - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - *a = ANestedLiteral(unmarshaler.embed) - if unmarshaler.MyLiteral != "How super cool" { - return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", a, "How super cool", unmarshaler.MyLiteral) - } - a.myLiteral = unmarshaler.MyLiteral - - extraProperties, err := core.ExtractExtraProperties(data, *a, "myLiteral") - if err != nil { - return err - } - a.extraProperties = extraProperties - - return nil -} - -func (a *ANestedLiteral) MarshalJSON() ([]byte, error) { - type embed ANestedLiteral - var marshaler = struct { - embed - MyLiteral string `json:"myLiteral"` - }{ - embed: embed(*a), - MyLiteral: "How super cool", - } - return json.Marshal(marshaler) -} - -func (a *ANestedLiteral) String() string { - if value, err := core.StringifyJSON(a); err == nil { - return value - } - return fmt.Sprintf("%#v", a) -} - -type ContainerObject struct { - NestedObjects []*NestedObjectWithLiterals `json:"nestedObjects,omitempty" url:"nestedObjects,omitempty"` - - extraProperties map[string]interface{} -} - -func (c *ContainerObject) GetNestedObjects() []*NestedObjectWithLiterals { - if c == nil { - return nil - } - return c.NestedObjects -} - -func (c *ContainerObject) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *ContainerObject) UnmarshalJSON(data []byte) error { - type unmarshaler ContainerObject - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = ContainerObject(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - return nil -} - -func (c *ContainerObject) String() string { - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type NestedObjectWithLiterals struct { - StrProp string `json:"strProp" url:"strProp"` - literal1 string - literal2 string - - extraProperties map[string]interface{} -} - -func (n *NestedObjectWithLiterals) GetStrProp() string { - if n == nil { - return "" - } - return n.StrProp -} - -func (n *NestedObjectWithLiterals) Literal1() string { - return n.literal1 -} - -func (n *NestedObjectWithLiterals) Literal2() string { - return n.literal2 -} - -func (n *NestedObjectWithLiterals) GetExtraProperties() map[string]interface{} { - return n.extraProperties -} - -func (n *NestedObjectWithLiterals) UnmarshalJSON(data []byte) error { - type embed NestedObjectWithLiterals - var unmarshaler = struct { - embed - Literal1 string `json:"literal1"` - Literal2 string `json:"literal2"` - }{ - embed: embed(*n), - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - *n = NestedObjectWithLiterals(unmarshaler.embed) - if unmarshaler.Literal1 != "literal1" { - return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", n, "literal1", unmarshaler.Literal1) - } - n.literal1 = unmarshaler.Literal1 - if unmarshaler.Literal2 != "literal2" { - return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", n, "literal2", unmarshaler.Literal2) - } - n.literal2 = unmarshaler.Literal2 - - extraProperties, err := core.ExtractExtraProperties(data, *n, "literal1", "literal2") - if err != nil { - return err - } - n.extraProperties = extraProperties - - return nil -} - -func (n *NestedObjectWithLiterals) MarshalJSON() ([]byte, error) { - type embed NestedObjectWithLiterals - var marshaler = struct { - embed - Literal1 string `json:"literal1"` - Literal2 string `json:"literal2"` - }{ - embed: embed(*n), - Literal1: "literal1", - Literal2: "literal2", - } - return json.Marshal(marshaler) -} - -func (n *NestedObjectWithLiterals) String() string { - if value, err := core.StringifyJSON(n); err == nil { - return value - } - return fmt.Sprintf("%#v", n) -} - -type SomeLiteral = string diff --git a/seed/go-fiber/mixed-case/service.go b/seed/go-fiber/mixed-case/service.go index 43d9aec6a7b..3388859ff4b 100644 --- a/seed/go-fiber/mixed-case/service.go +++ b/seed/go-fiber/mixed-case/service.go @@ -14,6 +14,96 @@ type ListResourcesRequest struct { BeforeDate time.Time `query:"beforeDate"` } +type NestedUser struct { + Name string `json:"Name" url:"Name"` + NestedUser *User `json:"NestedUser,omitempty" url:"NestedUser,omitempty"` + + extraProperties map[string]interface{} +} + +func (n *NestedUser) GetName() string { + if n == nil { + return "" + } + return n.Name +} + +func (n *NestedUser) GetNestedUser() *User { + if n == nil { + return nil + } + return n.NestedUser +} + +func (n *NestedUser) GetExtraProperties() map[string]interface{} { + return n.extraProperties +} + +func (n *NestedUser) UnmarshalJSON(data []byte) error { + type unmarshaler NestedUser + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NestedUser(value) + + extraProperties, err := core.ExtractExtraProperties(data, *n) + if err != nil { + return err + } + n.extraProperties = extraProperties + + return nil +} + +func (n *NestedUser) String() string { + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + +type Organization struct { + Name string `json:"name" url:"name"` + + extraProperties map[string]interface{} +} + +func (o *Organization) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *Organization) GetExtraProperties() map[string]interface{} { + return o.extraProperties +} + +func (o *Organization) UnmarshalJSON(data []byte) error { + type unmarshaler Organization + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *o = Organization(value) + + extraProperties, err := core.ExtractExtraProperties(data, *o) + if err != nil { + return err + } + o.extraProperties = extraProperties + + return nil +} + +func (o *Organization) String() string { + if value, err := core.StringifyJSON(o); err == nil { + return value + } + return fmt.Sprintf("%#v", o) +} + type Resource struct { ResourceType string Status ResourceStatus @@ -113,3 +203,82 @@ func (r *Resource) Accept(visitor ResourceVisitor) error { return visitor.VisitOrganization(r.Organization) } } + +type ResourceStatus string + +const ( + ResourceStatusActive ResourceStatus = "ACTIVE" + ResourceStatusInactive ResourceStatus = "INACTIVE" +) + +func NewResourceStatusFromString(s string) (ResourceStatus, error) { + switch s { + case "ACTIVE": + return ResourceStatusActive, nil + case "INACTIVE": + return ResourceStatusInactive, nil + } + var t ResourceStatus + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (r ResourceStatus) Ptr() *ResourceStatus { + return &r +} + +type User struct { + UserName string `json:"userName" url:"userName"` + MetadataTags []string `json:"metadata_tags,omitempty" url:"metadata_tags,omitempty"` + ExtraProperties map[string]string `json:"EXTRA_PROPERTIES,omitempty" url:"EXTRA_PROPERTIES,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *User) GetUserName() string { + if u == nil { + return "" + } + return u.UserName +} + +func (u *User) GetMetadataTags() []string { + if u == nil { + return nil + } + return u.MetadataTags +} + +func (u *User) GetExtraProperties() map[string]string { + if u == nil { + return nil + } + return u.ExtraProperties +} + +func (u *User) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *User) UnmarshalJSON(data []byte) error { + type unmarshaler User + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = User(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *User) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} diff --git a/seed/go-fiber/mixed-case/types.go b/seed/go-fiber/mixed-case/types.go deleted file mode 100644 index fa7b3d1de2c..00000000000 --- a/seed/go-fiber/mixed-case/types.go +++ /dev/null @@ -1,178 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package mixedcase - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/mixed-case/fern/core" -) - -type NestedUser struct { - Name string `json:"Name" url:"Name"` - NestedUser *User `json:"NestedUser,omitempty" url:"NestedUser,omitempty"` - - extraProperties map[string]interface{} -} - -func (n *NestedUser) GetName() string { - if n == nil { - return "" - } - return n.Name -} - -func (n *NestedUser) GetNestedUser() *User { - if n == nil { - return nil - } - return n.NestedUser -} - -func (n *NestedUser) GetExtraProperties() map[string]interface{} { - return n.extraProperties -} - -func (n *NestedUser) UnmarshalJSON(data []byte) error { - type unmarshaler NestedUser - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *n = NestedUser(value) - - extraProperties, err := core.ExtractExtraProperties(data, *n) - if err != nil { - return err - } - n.extraProperties = extraProperties - - return nil -} - -func (n *NestedUser) String() string { - if value, err := core.StringifyJSON(n); err == nil { - return value - } - return fmt.Sprintf("%#v", n) -} - -type Organization struct { - Name string `json:"name" url:"name"` - - extraProperties map[string]interface{} -} - -func (o *Organization) GetName() string { - if o == nil { - return "" - } - return o.Name -} - -func (o *Organization) GetExtraProperties() map[string]interface{} { - return o.extraProperties -} - -func (o *Organization) UnmarshalJSON(data []byte) error { - type unmarshaler Organization - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *o = Organization(value) - - extraProperties, err := core.ExtractExtraProperties(data, *o) - if err != nil { - return err - } - o.extraProperties = extraProperties - - return nil -} - -func (o *Organization) String() string { - if value, err := core.StringifyJSON(o); err == nil { - return value - } - return fmt.Sprintf("%#v", o) -} - -type ResourceStatus string - -const ( - ResourceStatusActive ResourceStatus = "ACTIVE" - ResourceStatusInactive ResourceStatus = "INACTIVE" -) - -func NewResourceStatusFromString(s string) (ResourceStatus, error) { - switch s { - case "ACTIVE": - return ResourceStatusActive, nil - case "INACTIVE": - return ResourceStatusInactive, nil - } - var t ResourceStatus - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (r ResourceStatus) Ptr() *ResourceStatus { - return &r -} - -type User struct { - UserName string `json:"userName" url:"userName"` - MetadataTags []string `json:"metadata_tags,omitempty" url:"metadata_tags,omitempty"` - ExtraProperties map[string]string `json:"EXTRA_PROPERTIES,omitempty" url:"EXTRA_PROPERTIES,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *User) GetUserName() string { - if u == nil { - return "" - } - return u.UserName -} - -func (u *User) GetMetadataTags() []string { - if u == nil { - return nil - } - return u.MetadataTags -} - -func (u *User) GetExtraProperties() map[string]string { - if u == nil { - return nil - } - return u.ExtraProperties -} - -func (u *User) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *User) UnmarshalJSON(data []byte) error { - type unmarshaler User - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = User(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *User) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/seed/go-fiber/oauth-client-credentials-nested-root/auth/auth.go b/seed/go-fiber/oauth-client-credentials-nested-root/auth/auth.go deleted file mode 100644 index 9019a11c485..00000000000 --- a/seed/go-fiber/oauth-client-credentials-nested-root/auth/auth.go +++ /dev/null @@ -1,67 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package auth - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/oauth-client-credentials-nested-root/fern/core" -) - -// An OAuth token response. -type TokenResponse struct { - AccessToken string `json:"access_token" url:"access_token"` - ExpiresIn int `json:"expires_in" url:"expires_in"` - RefreshToken *string `json:"refresh_token,omitempty" url:"refresh_token,omitempty"` - - extraProperties map[string]interface{} -} - -func (t *TokenResponse) GetAccessToken() string { - if t == nil { - return "" - } - return t.AccessToken -} - -func (t *TokenResponse) GetExpiresIn() int { - if t == nil { - return 0 - } - return t.ExpiresIn -} - -func (t *TokenResponse) GetRefreshToken() *string { - if t == nil { - return nil - } - return t.RefreshToken -} - -func (t *TokenResponse) GetExtraProperties() map[string]interface{} { - return t.extraProperties -} - -func (t *TokenResponse) UnmarshalJSON(data []byte) error { - type unmarshaler TokenResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *t = TokenResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *t) - if err != nil { - return err - } - t.extraProperties = extraProperties - - return nil -} - -func (t *TokenResponse) String() string { - if value, err := core.StringifyJSON(t); err == nil { - return value - } - return fmt.Sprintf("%#v", t) -} diff --git a/seed/go-fiber/oauth-client-credentials-nested-root/auth/types.go b/seed/go-fiber/oauth-client-credentials-nested-root/auth/types.go index c05ee1427c8..de631f3651b 100644 --- a/seed/go-fiber/oauth-client-credentials-nested-root/auth/types.go +++ b/seed/go-fiber/oauth-client-credentials-nested-root/auth/types.go @@ -4,6 +4,8 @@ package auth import ( json "encoding/json" + fmt "fmt" + core "github.com/oauth-client-credentials-nested-root/fern/core" ) type GetTokenRequest struct { @@ -47,3 +49,61 @@ func (g *GetTokenRequest) MarshalJSON() ([]byte, error) { } return json.Marshal(marshaler) } + +// An OAuth token response. +type TokenResponse struct { + AccessToken string `json:"access_token" url:"access_token"` + ExpiresIn int `json:"expires_in" url:"expires_in"` + RefreshToken *string `json:"refresh_token,omitempty" url:"refresh_token,omitempty"` + + extraProperties map[string]interface{} +} + +func (t *TokenResponse) GetAccessToken() string { + if t == nil { + return "" + } + return t.AccessToken +} + +func (t *TokenResponse) GetExpiresIn() int { + if t == nil { + return 0 + } + return t.ExpiresIn +} + +func (t *TokenResponse) GetRefreshToken() *string { + if t == nil { + return nil + } + return t.RefreshToken +} + +func (t *TokenResponse) GetExtraProperties() map[string]interface{} { + return t.extraProperties +} + +func (t *TokenResponse) UnmarshalJSON(data []byte) error { + type unmarshaler TokenResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = TokenResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *t) + if err != nil { + return err + } + t.extraProperties = extraProperties + + return nil +} + +func (t *TokenResponse) String() string { + if value, err := core.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} diff --git a/seed/go-fiber/objects-with-imports/commons/types.go b/seed/go-fiber/objects-with-imports/commons/metadata.go similarity index 100% rename from seed/go-fiber/objects-with-imports/commons/types.go rename to seed/go-fiber/objects-with-imports/commons/metadata.go diff --git a/seed/go-fiber/objects-with-imports/file.go b/seed/go-fiber/objects-with-imports/file.go new file mode 100644 index 00000000000..fd807feaf59 --- /dev/null +++ b/seed/go-fiber/objects-with-imports/file.go @@ -0,0 +1,90 @@ +// This file was auto-generated by Fern from our API Definition. + +package objectswithimports + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/objects-with-imports/fern/core" +) + +type File struct { + Name string `json:"name" url:"name"` + Contents string `json:"contents" url:"contents"` + Info FileInfo `json:"info" url:"info"` + + extraProperties map[string]interface{} +} + +func (f *File) GetName() string { + if f == nil { + return "" + } + return f.Name +} + +func (f *File) GetContents() string { + if f == nil { + return "" + } + return f.Contents +} + +func (f *File) GetInfo() FileInfo { + if f == nil { + return "" + } + return f.Info +} + +func (f *File) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *File) UnmarshalJSON(data []byte) error { + type unmarshaler File + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = File(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + return nil +} + +func (f *File) String() string { + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + +type FileInfo string + +const ( + // A regular file (e.g. foo.txt). + FileInfoRegular FileInfo = "REGULAR" + // A directory (e.g. foo/). + FileInfoDirectory FileInfo = "DIRECTORY" +) + +func NewFileInfoFromString(s string) (FileInfo, error) { + switch s { + case "REGULAR": + return FileInfoRegular, nil + case "DIRECTORY": + return FileInfoDirectory, nil + } + var t FileInfo + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (f FileInfo) Ptr() *FileInfo { + return &f +} diff --git a/seed/go-fiber/objects-with-imports/file/types.go b/seed/go-fiber/objects-with-imports/file/directory.go similarity index 100% rename from seed/go-fiber/objects-with-imports/file/types.go rename to seed/go-fiber/objects-with-imports/file/directory.go diff --git a/seed/go-fiber/objects-with-imports/types.go b/seed/go-fiber/objects-with-imports/types.go index dce16f47f3e..01d4469fa38 100644 --- a/seed/go-fiber/objects-with-imports/types.go +++ b/seed/go-fiber/objects-with-imports/types.go @@ -106,84 +106,3 @@ func (t *Tree) String() string { } return fmt.Sprintf("%#v", t) } - -type File struct { - Name string `json:"name" url:"name"` - Contents string `json:"contents" url:"contents"` - Info FileInfo `json:"info" url:"info"` - - extraProperties map[string]interface{} -} - -func (f *File) GetName() string { - if f == nil { - return "" - } - return f.Name -} - -func (f *File) GetContents() string { - if f == nil { - return "" - } - return f.Contents -} - -func (f *File) GetInfo() FileInfo { - if f == nil { - return "" - } - return f.Info -} - -func (f *File) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *File) UnmarshalJSON(data []byte) error { - type unmarshaler File - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = File(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - return nil -} - -func (f *File) String() string { - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} - -type FileInfo string - -const ( - // A regular file (e.g. foo.txt). - FileInfoRegular FileInfo = "REGULAR" - // A directory (e.g. foo/). - FileInfoDirectory FileInfo = "DIRECTORY" -) - -func NewFileInfoFromString(s string) (FileInfo, error) { - switch s { - case "REGULAR": - return FileInfoRegular, nil - case "DIRECTORY": - return FileInfoDirectory, nil - } - var t FileInfo - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (f FileInfo) Ptr() *FileInfo { - return &f -} diff --git a/seed/go-fiber/pagination/types.go b/seed/go-fiber/pagination/types.go deleted file mode 100644 index e66d8e13096..00000000000 --- a/seed/go-fiber/pagination/types.go +++ /dev/null @@ -1,403 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package pagination - -import ( - json "encoding/json" - fmt "fmt" - uuid "github.com/google/uuid" - core "github.com/pagination/fern/core" -) - -type UsernamePage struct { - After *string `json:"after,omitempty" url:"after,omitempty"` - Data []string `json:"data,omitempty" url:"data,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *UsernamePage) GetAfter() *string { - if u == nil { - return nil - } - return u.After -} - -func (u *UsernamePage) GetData() []string { - if u == nil { - return nil - } - return u.Data -} - -func (u *UsernamePage) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UsernamePage) UnmarshalJSON(data []byte) error { - type unmarshaler UsernamePage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UsernamePage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UsernamePage) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type NextPage struct { - Page int `json:"page" url:"page"` - StartingAfter string `json:"starting_after" url:"starting_after"` - - extraProperties map[string]interface{} -} - -func (n *NextPage) GetPage() int { - if n == nil { - return 0 - } - return n.Page -} - -func (n *NextPage) GetStartingAfter() string { - if n == nil { - return "" - } - return n.StartingAfter -} - -func (n *NextPage) GetExtraProperties() map[string]interface{} { - return n.extraProperties -} - -func (n *NextPage) UnmarshalJSON(data []byte) error { - type unmarshaler NextPage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *n = NextPage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *n) - if err != nil { - return err - } - n.extraProperties = extraProperties - - return nil -} - -func (n *NextPage) String() string { - if value, err := core.StringifyJSON(n); err == nil { - return value - } - return fmt.Sprintf("%#v", n) -} - -type Page struct { - // The current page - Page int `json:"page" url:"page"` - Next *NextPage `json:"next,omitempty" url:"next,omitempty"` - PerPage int `json:"per_page" url:"per_page"` - TotalPage int `json:"total_page" url:"total_page"` - - extraProperties map[string]interface{} -} - -func (p *Page) GetPage() int { - if p == nil { - return 0 - } - return p.Page -} - -func (p *Page) GetNext() *NextPage { - if p == nil { - return nil - } - return p.Next -} - -func (p *Page) GetPerPage() int { - if p == nil { - return 0 - } - return p.PerPage -} - -func (p *Page) GetTotalPage() int { - if p == nil { - return 0 - } - return p.TotalPage -} - -func (p *Page) GetExtraProperties() map[string]interface{} { - return p.extraProperties -} - -func (p *Page) UnmarshalJSON(data []byte) error { - type unmarshaler Page - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *p = Page(value) - - extraProperties, err := core.ExtractExtraProperties(data, *p) - if err != nil { - return err - } - p.extraProperties = extraProperties - - return nil -} - -func (p *Page) String() string { - if value, err := core.StringifyJSON(p); err == nil { - return value - } - return fmt.Sprintf("%#v", p) -} - -type User struct { - Name string `json:"name" url:"name"` - Id int `json:"id" url:"id"` - - extraProperties map[string]interface{} -} - -func (u *User) GetName() string { - if u == nil { - return "" - } - return u.Name -} - -func (u *User) GetId() int { - if u == nil { - return 0 - } - return u.Id -} - -func (u *User) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *User) UnmarshalJSON(data []byte) error { - type unmarshaler User - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = User(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *User) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserListContainer struct { - Users []*User `json:"users,omitempty" url:"users,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *UserListContainer) GetUsers() []*User { - if u == nil { - return nil - } - return u.Users -} - -func (u *UserListContainer) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserListContainer) UnmarshalJSON(data []byte) error { - type unmarshaler UserListContainer - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserListContainer(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UserListContainer) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserOptionalListContainer struct { - Users []*User `json:"users,omitempty" url:"users,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *UserOptionalListContainer) GetUsers() []*User { - if u == nil { - return nil - } - return u.Users -} - -func (u *UserOptionalListContainer) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserOptionalListContainer) UnmarshalJSON(data []byte) error { - type unmarshaler UserOptionalListContainer - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserOptionalListContainer(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UserOptionalListContainer) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserOptionalListPage struct { - Data *UserOptionalListContainer `json:"data,omitempty" url:"data,omitempty"` - Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *UserOptionalListPage) GetData() *UserOptionalListContainer { - if u == nil { - return nil - } - return u.Data -} - -func (u *UserOptionalListPage) GetNext() *uuid.UUID { - if u == nil { - return nil - } - return u.Next -} - -func (u *UserOptionalListPage) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserOptionalListPage) UnmarshalJSON(data []byte) error { - type unmarshaler UserOptionalListPage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserOptionalListPage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UserOptionalListPage) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserPage struct { - Data *UserListContainer `json:"data,omitempty" url:"data,omitempty"` - Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *UserPage) GetData() *UserListContainer { - if u == nil { - return nil - } - return u.Data -} - -func (u *UserPage) GetNext() *uuid.UUID { - if u == nil { - return nil - } - return u.Next -} - -func (u *UserPage) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserPage) UnmarshalJSON(data []byte) error { - type unmarshaler UserPage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserPage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UserPage) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/seed/go-fiber/pagination/users.go b/seed/go-fiber/pagination/users.go index 85b1273c081..d63c454d726 100644 --- a/seed/go-fiber/pagination/users.go +++ b/seed/go-fiber/pagination/users.go @@ -122,6 +122,55 @@ func (u *UsernameCursor) String() string { return fmt.Sprintf("%#v", u) } +type UsernamePage struct { + After *string `json:"after,omitempty" url:"after,omitempty"` + Data []string `json:"data,omitempty" url:"data,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *UsernamePage) GetAfter() *string { + if u == nil { + return nil + } + return u.After +} + +func (u *UsernamePage) GetData() []string { + if u == nil { + return nil + } + return u.Data +} + +func (u *UsernamePage) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UsernamePage) UnmarshalJSON(data []byte) error { + type unmarshaler UsernamePage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UsernamePage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UsernamePage) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + type ListUsersExtendedOptionalListResponse struct { Data *UserOptionalListContainer `json:"data,omitempty" url:"data,omitempty"` Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` @@ -304,6 +353,55 @@ func (l *ListUsersPaginationResponse) String() string { return fmt.Sprintf("%#v", l) } +type NextPage struct { + Page int `json:"page" url:"page"` + StartingAfter string `json:"starting_after" url:"starting_after"` + + extraProperties map[string]interface{} +} + +func (n *NextPage) GetPage() int { + if n == nil { + return 0 + } + return n.Page +} + +func (n *NextPage) GetStartingAfter() string { + if n == nil { + return "" + } + return n.StartingAfter +} + +func (n *NextPage) GetExtraProperties() map[string]interface{} { + return n.extraProperties +} + +func (n *NextPage) UnmarshalJSON(data []byte) error { + type unmarshaler NextPage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NextPage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *n) + if err != nil { + return err + } + n.extraProperties = extraProperties + + return nil +} + +func (n *NextPage) String() string { + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + type Order string const ( @@ -326,6 +424,301 @@ func (o Order) Ptr() *Order { return &o } +type Page struct { + // The current page + Page int `json:"page" url:"page"` + Next *NextPage `json:"next,omitempty" url:"next,omitempty"` + PerPage int `json:"per_page" url:"per_page"` + TotalPage int `json:"total_page" url:"total_page"` + + extraProperties map[string]interface{} +} + +func (p *Page) GetPage() int { + if p == nil { + return 0 + } + return p.Page +} + +func (p *Page) GetNext() *NextPage { + if p == nil { + return nil + } + return p.Next +} + +func (p *Page) GetPerPage() int { + if p == nil { + return 0 + } + return p.PerPage +} + +func (p *Page) GetTotalPage() int { + if p == nil { + return 0 + } + return p.TotalPage +} + +func (p *Page) GetExtraProperties() map[string]interface{} { + return p.extraProperties +} + +func (p *Page) UnmarshalJSON(data []byte) error { + type unmarshaler Page + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = Page(value) + + extraProperties, err := core.ExtractExtraProperties(data, *p) + if err != nil { + return err + } + p.extraProperties = extraProperties + + return nil +} + +func (p *Page) String() string { + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type User struct { + Name string `json:"name" url:"name"` + Id int `json:"id" url:"id"` + + extraProperties map[string]interface{} +} + +func (u *User) GetName() string { + if u == nil { + return "" + } + return u.Name +} + +func (u *User) GetId() int { + if u == nil { + return 0 + } + return u.Id +} + +func (u *User) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *User) UnmarshalJSON(data []byte) error { + type unmarshaler User + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = User(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *User) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UserListContainer struct { + Users []*User `json:"users,omitempty" url:"users,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *UserListContainer) GetUsers() []*User { + if u == nil { + return nil + } + return u.Users +} + +func (u *UserListContainer) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserListContainer) UnmarshalJSON(data []byte) error { + type unmarshaler UserListContainer + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserListContainer(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UserListContainer) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UserOptionalListContainer struct { + Users []*User `json:"users,omitempty" url:"users,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *UserOptionalListContainer) GetUsers() []*User { + if u == nil { + return nil + } + return u.Users +} + +func (u *UserOptionalListContainer) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserOptionalListContainer) UnmarshalJSON(data []byte) error { + type unmarshaler UserOptionalListContainer + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserOptionalListContainer(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UserOptionalListContainer) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UserOptionalListPage struct { + Data *UserOptionalListContainer `json:"data,omitempty" url:"data,omitempty"` + Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *UserOptionalListPage) GetData() *UserOptionalListContainer { + if u == nil { + return nil + } + return u.Data +} + +func (u *UserOptionalListPage) GetNext() *uuid.UUID { + if u == nil { + return nil + } + return u.Next +} + +func (u *UserOptionalListPage) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserOptionalListPage) UnmarshalJSON(data []byte) error { + type unmarshaler UserOptionalListPage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserOptionalListPage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UserOptionalListPage) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UserPage struct { + Data *UserListContainer `json:"data,omitempty" url:"data,omitempty"` + Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *UserPage) GetData() *UserListContainer { + if u == nil { + return nil + } + return u.Data +} + +func (u *UserPage) GetNext() *uuid.UUID { + if u == nil { + return nil + } + return u.Next +} + +func (u *UserPage) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserPage) UnmarshalJSON(data []byte) error { + type unmarshaler UserPage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserPage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UserPage) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + type UsernameContainer struct { Results []string `json:"results,omitempty" url:"results,omitempty"` diff --git a/seed/go-fiber/response-property/service.go b/seed/go-fiber/response-property/service.go index 5be7b7f72ec..3f20678abd8 100644 --- a/seed/go-fiber/response-property/service.go +++ b/seed/go-fiber/response-property/service.go @@ -51,6 +51,96 @@ func (s *StringResponse) String() string { return fmt.Sprintf("%#v", s) } +type WithMetadata struct { + Metadata map[string]string `json:"metadata,omitempty" url:"metadata,omitempty"` + + extraProperties map[string]interface{} +} + +func (w *WithMetadata) GetMetadata() map[string]string { + if w == nil { + return nil + } + return w.Metadata +} + +func (w *WithMetadata) GetExtraProperties() map[string]interface{} { + return w.extraProperties +} + +func (w *WithMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler WithMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *w = WithMetadata(value) + + extraProperties, err := core.ExtractExtraProperties(data, *w) + if err != nil { + return err + } + w.extraProperties = extraProperties + + return nil +} + +func (w *WithMetadata) String() string { + if value, err := core.StringifyJSON(w); err == nil { + return value + } + return fmt.Sprintf("%#v", w) +} + +type Movie struct { + Id string `json:"id" url:"id"` + Name string `json:"name" url:"name"` + + extraProperties map[string]interface{} +} + +func (m *Movie) GetId() string { + if m == nil { + return "" + } + return m.Id +} + +func (m *Movie) GetName() string { + if m == nil { + return "" + } + return m.Name +} + +func (m *Movie) GetExtraProperties() map[string]interface{} { + return m.extraProperties +} + +func (m *Movie) UnmarshalJSON(data []byte) error { + type unmarshaler Movie + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *m = Movie(value) + + extraProperties, err := core.ExtractExtraProperties(data, *m) + if err != nil { + return err + } + m.extraProperties = extraProperties + + return nil +} + +func (m *Movie) String() string { + if value, err := core.StringifyJSON(m); err == nil { + return value + } + return fmt.Sprintf("%#v", m) +} + type OptionalWithDocs = *WithDocs type Response struct { @@ -109,3 +199,44 @@ func (r *Response) String() string { } return fmt.Sprintf("%#v", r) } + +type WithDocs struct { + Docs string `json:"docs" url:"docs"` + + extraProperties map[string]interface{} +} + +func (w *WithDocs) GetDocs() string { + if w == nil { + return "" + } + return w.Docs +} + +func (w *WithDocs) GetExtraProperties() map[string]interface{} { + return w.extraProperties +} + +func (w *WithDocs) UnmarshalJSON(data []byte) error { + type unmarshaler WithDocs + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *w = WithDocs(value) + + extraProperties, err := core.ExtractExtraProperties(data, *w) + if err != nil { + return err + } + w.extraProperties = extraProperties + + return nil +} + +func (w *WithDocs) String() string { + if value, err := core.StringifyJSON(w); err == nil { + return value + } + return fmt.Sprintf("%#v", w) +} diff --git a/seed/go-fiber/response-property/types.go b/seed/go-fiber/response-property/types.go deleted file mode 100644 index 968222f01e6..00000000000 --- a/seed/go-fiber/response-property/types.go +++ /dev/null @@ -1,140 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package responseproperty - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/response-property/fern/core" -) - -type WithMetadata struct { - Metadata map[string]string `json:"metadata,omitempty" url:"metadata,omitempty"` - - extraProperties map[string]interface{} -} - -func (w *WithMetadata) GetMetadata() map[string]string { - if w == nil { - return nil - } - return w.Metadata -} - -func (w *WithMetadata) GetExtraProperties() map[string]interface{} { - return w.extraProperties -} - -func (w *WithMetadata) UnmarshalJSON(data []byte) error { - type unmarshaler WithMetadata - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *w = WithMetadata(value) - - extraProperties, err := core.ExtractExtraProperties(data, *w) - if err != nil { - return err - } - w.extraProperties = extraProperties - - return nil -} - -func (w *WithMetadata) String() string { - if value, err := core.StringifyJSON(w); err == nil { - return value - } - return fmt.Sprintf("%#v", w) -} - -type Movie struct { - Id string `json:"id" url:"id"` - Name string `json:"name" url:"name"` - - extraProperties map[string]interface{} -} - -func (m *Movie) GetId() string { - if m == nil { - return "" - } - return m.Id -} - -func (m *Movie) GetName() string { - if m == nil { - return "" - } - return m.Name -} - -func (m *Movie) GetExtraProperties() map[string]interface{} { - return m.extraProperties -} - -func (m *Movie) UnmarshalJSON(data []byte) error { - type unmarshaler Movie - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *m = Movie(value) - - extraProperties, err := core.ExtractExtraProperties(data, *m) - if err != nil { - return err - } - m.extraProperties = extraProperties - - return nil -} - -func (m *Movie) String() string { - if value, err := core.StringifyJSON(m); err == nil { - return value - } - return fmt.Sprintf("%#v", m) -} - -type WithDocs struct { - Docs string `json:"docs" url:"docs"` - - extraProperties map[string]interface{} -} - -func (w *WithDocs) GetDocs() string { - if w == nil { - return "" - } - return w.Docs -} - -func (w *WithDocs) GetExtraProperties() map[string]interface{} { - return w.extraProperties -} - -func (w *WithDocs) UnmarshalJSON(data []byte) error { - type unmarshaler WithDocs - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *w = WithDocs(value) - - extraProperties, err := core.ExtractExtraProperties(data, *w) - if err != nil { - return err - } - w.extraProperties = extraProperties - - return nil -} - -func (w *WithDocs) String() string { - if value, err := core.StringifyJSON(w); err == nil { - return value - } - return fmt.Sprintf("%#v", w) -} diff --git a/seed/go-fiber/undiscriminated-unions/types.go b/seed/go-fiber/undiscriminated-unions/types.go deleted file mode 100644 index d8e6c927076..00000000000 --- a/seed/go-fiber/undiscriminated-unions/types.go +++ /dev/null @@ -1,142 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package undiscriminatedunions - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/undiscriminated-unions/fern/core" -) - -type Key struct { - KeyType KeyType - defaultStringLiteral string - - typ string -} - -func NewKeyFromKeyType(value KeyType) *Key { - return &Key{typ: "KeyType", KeyType: value} -} - -func NewKeyWithDefaultStringLiteral() *Key { - return &Key{typ: "defaultStringLiteral", defaultStringLiteral: "default"} -} - -func (k *Key) GetKeyType() KeyType { - if k == nil { - return "" - } - return k.KeyType -} - -func (k *Key) DefaultStringLiteral() string { - return k.defaultStringLiteral -} - -func (k *Key) UnmarshalJSON(data []byte) error { - var valueKeyType KeyType - if err := json.Unmarshal(data, &valueKeyType); err == nil { - k.typ = "KeyType" - k.KeyType = valueKeyType - return nil - } - var valueDefaultStringLiteral string - if err := json.Unmarshal(data, &valueDefaultStringLiteral); err == nil { - k.typ = "defaultStringLiteral" - k.defaultStringLiteral = valueDefaultStringLiteral - if k.defaultStringLiteral != "default" { - return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", k, "default", valueDefaultStringLiteral) - } - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, k) -} - -func (k Key) MarshalJSON() ([]byte, error) { - if k.typ == "KeyType" || k.KeyType != "" { - return json.Marshal(k.KeyType) - } - if k.typ == "defaultStringLiteral" || k.defaultStringLiteral != "" { - return json.Marshal("default") - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", k) -} - -type KeyVisitor interface { - VisitKeyType(KeyType) error - VisitDefaultStringLiteral(string) error -} - -func (k *Key) Accept(visitor KeyVisitor) error { - if k.typ == "KeyType" || k.KeyType != "" { - return visitor.VisitKeyType(k.KeyType) - } - if k.typ == "defaultStringLiteral" || k.defaultStringLiteral != "" { - return visitor.VisitDefaultStringLiteral(k.defaultStringLiteral) - } - return fmt.Errorf("type %T does not include a non-empty union type", k) -} - -type KeyType string - -const ( - KeyTypeName KeyType = "name" - KeyTypeValue KeyType = "value" -) - -func NewKeyTypeFromString(s string) (KeyType, error) { - switch s { - case "name": - return KeyTypeName, nil - case "value": - return KeyTypeValue, nil - } - var t KeyType - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (k KeyType) Ptr() *KeyType { - return &k -} - -type TypeWithOptionalUnion struct { - MyUnion *MyUnion `json:"myUnion,omitempty" url:"myUnion,omitempty"` - - extraProperties map[string]interface{} -} - -func (t *TypeWithOptionalUnion) GetMyUnion() *MyUnion { - if t == nil { - return nil - } - return t.MyUnion -} - -func (t *TypeWithOptionalUnion) GetExtraProperties() map[string]interface{} { - return t.extraProperties -} - -func (t *TypeWithOptionalUnion) UnmarshalJSON(data []byte) error { - type unmarshaler TypeWithOptionalUnion - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *t = TypeWithOptionalUnion(value) - - extraProperties, err := core.ExtractExtraProperties(data, *t) - if err != nil { - return err - } - t.extraProperties = extraProperties - - return nil -} - -func (t *TypeWithOptionalUnion) String() string { - if value, err := core.StringifyJSON(t); err == nil { - return value - } - return fmt.Sprintf("%#v", t) -} diff --git a/seed/go-fiber/undiscriminated-unions/union.go b/seed/go-fiber/undiscriminated-unions/union.go index 5ac50a67ffc..e2959bdd52e 100644 --- a/seed/go-fiber/undiscriminated-unions/union.go +++ b/seed/go-fiber/undiscriminated-unions/union.go @@ -5,8 +5,101 @@ package undiscriminatedunions import ( json "encoding/json" fmt "fmt" + core "github.com/undiscriminated-unions/fern/core" ) +type Key struct { + KeyType KeyType + defaultStringLiteral string + + typ string +} + +func NewKeyFromKeyType(value KeyType) *Key { + return &Key{typ: "KeyType", KeyType: value} +} + +func NewKeyWithDefaultStringLiteral() *Key { + return &Key{typ: "defaultStringLiteral", defaultStringLiteral: "default"} +} + +func (k *Key) GetKeyType() KeyType { + if k == nil { + return "" + } + return k.KeyType +} + +func (k *Key) DefaultStringLiteral() string { + return k.defaultStringLiteral +} + +func (k *Key) UnmarshalJSON(data []byte) error { + var valueKeyType KeyType + if err := json.Unmarshal(data, &valueKeyType); err == nil { + k.typ = "KeyType" + k.KeyType = valueKeyType + return nil + } + var valueDefaultStringLiteral string + if err := json.Unmarshal(data, &valueDefaultStringLiteral); err == nil { + k.typ = "defaultStringLiteral" + k.defaultStringLiteral = valueDefaultStringLiteral + if k.defaultStringLiteral != "default" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", k, "default", valueDefaultStringLiteral) + } + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, k) +} + +func (k Key) MarshalJSON() ([]byte, error) { + if k.typ == "KeyType" || k.KeyType != "" { + return json.Marshal(k.KeyType) + } + if k.typ == "defaultStringLiteral" || k.defaultStringLiteral != "" { + return json.Marshal("default") + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", k) +} + +type KeyVisitor interface { + VisitKeyType(KeyType) error + VisitDefaultStringLiteral(string) error +} + +func (k *Key) Accept(visitor KeyVisitor) error { + if k.typ == "KeyType" || k.KeyType != "" { + return visitor.VisitKeyType(k.KeyType) + } + if k.typ == "defaultStringLiteral" || k.defaultStringLiteral != "" { + return visitor.VisitDefaultStringLiteral(k.defaultStringLiteral) + } + return fmt.Errorf("type %T does not include a non-empty union type", k) +} + +type KeyType string + +const ( + KeyTypeName KeyType = "name" + KeyTypeValue KeyType = "value" +) + +func NewKeyTypeFromString(s string) (KeyType, error) { + switch s { + case "name": + return KeyTypeName, nil + case "value": + return KeyTypeValue, nil + } + var t KeyType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (k KeyType) Ptr() *KeyType { + return &k +} + // Undiscriminated unions can act as a map key // as long as all of their values are valid keys // (i.e. do they have a valid string representation). @@ -182,3 +275,44 @@ func (m *MyUnion) Accept(visitor MyUnionVisitor) error { } return fmt.Errorf("type %T does not include a non-empty union type", m) } + +type TypeWithOptionalUnion struct { + MyUnion *MyUnion `json:"myUnion,omitempty" url:"myUnion,omitempty"` + + extraProperties map[string]interface{} +} + +func (t *TypeWithOptionalUnion) GetMyUnion() *MyUnion { + if t == nil { + return nil + } + return t.MyUnion +} + +func (t *TypeWithOptionalUnion) GetExtraProperties() map[string]interface{} { + return t.extraProperties +} + +func (t *TypeWithOptionalUnion) UnmarshalJSON(data []byte) error { + type unmarshaler TypeWithOptionalUnion + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = TypeWithOptionalUnion(value) + + extraProperties, err := core.ExtractExtraProperties(data, *t) + if err != nil { + return err + } + t.extraProperties = extraProperties + + return nil +} + +func (t *TypeWithOptionalUnion) String() string { + if value, err := core.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} diff --git a/seed/go-fiber/unions/types.go b/seed/go-fiber/unions/types.go index f403ffec7d8..1979023e38a 100644 --- a/seed/go-fiber/unions/types.go +++ b/seed/go-fiber/unions/types.go @@ -1158,126 +1158,3 @@ func (u *UnionWithoutKey) Accept(visitor UnionWithoutKeyVisitor) error { return visitor.VisitBar(u.Bar) } } - -type Circle struct { - Radius float64 `json:"radius" url:"radius"` - - extraProperties map[string]interface{} -} - -func (c *Circle) GetRadius() float64 { - if c == nil { - return 0 - } - return c.Radius -} - -func (c *Circle) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *Circle) UnmarshalJSON(data []byte) error { - type unmarshaler Circle - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = Circle(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - return nil -} - -func (c *Circle) String() string { - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type GetShapeRequest struct { - Id string `json:"id" url:"id"` - - extraProperties map[string]interface{} -} - -func (g *GetShapeRequest) GetId() string { - if g == nil { - return "" - } - return g.Id -} - -func (g *GetShapeRequest) GetExtraProperties() map[string]interface{} { - return g.extraProperties -} - -func (g *GetShapeRequest) UnmarshalJSON(data []byte) error { - type unmarshaler GetShapeRequest - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *g = GetShapeRequest(value) - - extraProperties, err := core.ExtractExtraProperties(data, *g) - if err != nil { - return err - } - g.extraProperties = extraProperties - - return nil -} - -func (g *GetShapeRequest) String() string { - if value, err := core.StringifyJSON(g); err == nil { - return value - } - return fmt.Sprintf("%#v", g) -} - -type Square struct { - Length float64 `json:"length" url:"length"` - - extraProperties map[string]interface{} -} - -func (s *Square) GetLength() float64 { - if s == nil { - return 0 - } - return s.Length -} - -func (s *Square) GetExtraProperties() map[string]interface{} { - return s.extraProperties -} - -func (s *Square) UnmarshalJSON(data []byte) error { - type unmarshaler Square - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = Square(value) - - extraProperties, err := core.ExtractExtraProperties(data, *s) - if err != nil { - return err - } - s.extraProperties = extraProperties - - return nil -} - -func (s *Square) String() string { - if value, err := core.StringifyJSON(s); err == nil { - return value - } - return fmt.Sprintf("%#v", s) -} diff --git a/seed/go-fiber/unions/union.go b/seed/go-fiber/unions/union.go index 7381d0b122e..070bb9be671 100644 --- a/seed/go-fiber/unions/union.go +++ b/seed/go-fiber/unions/union.go @@ -8,6 +8,88 @@ import ( core "github.com/unions/fern/core" ) +type Circle struct { + Radius float64 `json:"radius" url:"radius"` + + extraProperties map[string]interface{} +} + +func (c *Circle) GetRadius() float64 { + if c == nil { + return 0 + } + return c.Radius +} + +func (c *Circle) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *Circle) UnmarshalJSON(data []byte) error { + type unmarshaler Circle + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = Circle(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + return nil +} + +func (c *Circle) String() string { + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type GetShapeRequest struct { + Id string `json:"id" url:"id"` + + extraProperties map[string]interface{} +} + +func (g *GetShapeRequest) GetId() string { + if g == nil { + return "" + } + return g.Id +} + +func (g *GetShapeRequest) GetExtraProperties() map[string]interface{} { + return g.extraProperties +} + +func (g *GetShapeRequest) UnmarshalJSON(data []byte) error { + type unmarshaler GetShapeRequest + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *g = GetShapeRequest(value) + + extraProperties, err := core.ExtractExtraProperties(data, *g) + if err != nil { + return err + } + g.extraProperties = extraProperties + + return nil +} + +func (g *GetShapeRequest) String() string { + if value, err := core.StringifyJSON(g); err == nil { + return value + } + return fmt.Sprintf("%#v", g) +} + type Shape struct { Type string Id string @@ -107,3 +189,44 @@ func (s *Shape) Accept(visitor ShapeVisitor) error { return visitor.VisitSquare(s.Square) } } + +type Square struct { + Length float64 `json:"length" url:"length"` + + extraProperties map[string]interface{} +} + +func (s *Square) GetLength() float64 { + if s == nil { + return 0 + } + return s.Length +} + +func (s *Square) GetExtraProperties() map[string]interface{} { + return s.extraProperties +} + +func (s *Square) UnmarshalJSON(data []byte) error { + type unmarshaler Square + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = Square(value) + + extraProperties, err := core.ExtractExtraProperties(data, *s) + if err != nil { + return err + } + s.extraProperties = extraProperties + + return nil +} + +func (s *Square) String() string { + if value, err := core.StringifyJSON(s); err == nil { + return value + } + return fmt.Sprintf("%#v", s) +} diff --git a/seed/go-fiber/unknown/types.go b/seed/go-fiber/unknown/types.go deleted file mode 100644 index 500e23e0ba2..00000000000 --- a/seed/go-fiber/unknown/types.go +++ /dev/null @@ -1,5 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package unknownasany - -type MyAlias = interface{} diff --git a/seed/go-fiber/unknown/unknown.go b/seed/go-fiber/unknown/unknown.go index 9e057d019f3..00436b19b6d 100644 --- a/seed/go-fiber/unknown/unknown.go +++ b/seed/go-fiber/unknown/unknown.go @@ -8,6 +8,8 @@ import ( core "github.com/unknown/fern/core" ) +type MyAlias = interface{} + type MyObject struct { Unknown interface{} `json:"unknown,omitempty" url:"unknown,omitempty"` diff --git a/seed/go-sdk/examples/always-send-required-properties/file/types.go b/seed/go-model/audiences/commons.go similarity index 62% rename from seed/go-sdk/examples/always-send-required-properties/file/types.go rename to seed/go-model/audiences/commons.go index edc509f893e..b214fff131d 100644 --- a/seed/go-sdk/examples/always-send-required-properties/file/types.go +++ b/seed/go-model/audiences/commons.go @@ -1,5 +1,5 @@ // This file was auto-generated by Fern from our API Definition. -package file +package audiences -type Filename = string +type Imported = string diff --git a/seed/go-model/audiences/folderb/types.go b/seed/go-model/audiences/folderb/common.go similarity index 100% rename from seed/go-model/audiences/folderb/types.go rename to seed/go-model/audiences/folderb/common.go diff --git a/seed/go-model/audiences/folderc/types.go b/seed/go-model/audiences/folderc/common.go similarity index 100% rename from seed/go-model/audiences/folderc/types.go rename to seed/go-model/audiences/folderc/common.go diff --git a/seed/go-model/audiences/foo.go b/seed/go-model/audiences/foo.go index 0760155fa73..5e6bd7732d3 100644 --- a/seed/go-model/audiences/foo.go +++ b/seed/go-model/audiences/foo.go @@ -8,6 +8,55 @@ import ( core "github.com/audiences/fern/core" ) +type FilteredType struct { + PublicProperty *string `json:"public_property,omitempty" url:"public_property,omitempty"` + PrivateProperty int `json:"private_property" url:"private_property"` + + extraProperties map[string]interface{} +} + +func (f *FilteredType) GetPublicProperty() *string { + if f == nil { + return nil + } + return f.PublicProperty +} + +func (f *FilteredType) GetPrivateProperty() int { + if f == nil { + return 0 + } + return f.PrivateProperty +} + +func (f *FilteredType) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *FilteredType) UnmarshalJSON(data []byte) error { + type unmarshaler FilteredType + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = FilteredType(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + return nil +} + +func (f *FilteredType) String() string { + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + type ImportingType struct { Imported Imported `json:"imported" url:"imported"` diff --git a/seed/go-model/audiences/types.go b/seed/go-model/audiences/types.go deleted file mode 100644 index 706ef88eb6c..00000000000 --- a/seed/go-model/audiences/types.go +++ /dev/null @@ -1,60 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package audiences - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/audiences/fern/core" -) - -type Imported = string - -type FilteredType struct { - PublicProperty *string `json:"public_property,omitempty" url:"public_property,omitempty"` - PrivateProperty int `json:"private_property" url:"private_property"` - - extraProperties map[string]interface{} -} - -func (f *FilteredType) GetPublicProperty() *string { - if f == nil { - return nil - } - return f.PublicProperty -} - -func (f *FilteredType) GetPrivateProperty() int { - if f == nil { - return 0 - } - return f.PrivateProperty -} - -func (f *FilteredType) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *FilteredType) UnmarshalJSON(data []byte) error { - type unmarshaler FilteredType - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = FilteredType(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - return nil -} - -func (f *FilteredType) String() string { - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} diff --git a/seed/go-model/circular-references-advanced/a.go b/seed/go-model/circular-references-advanced/a.go new file mode 100644 index 00000000000..90d8f431f71 --- /dev/null +++ b/seed/go-model/circular-references-advanced/a.go @@ -0,0 +1,50 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/circular-references-advanced/fern/core" +) + +type A struct { + S string `json:"s" url:"s"` + + extraProperties map[string]interface{} +} + +func (a *A) GetS() string { + if a == nil { + return "" + } + return a.S +} + +func (a *A) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *A) UnmarshalJSON(data []byte) error { + type unmarshaler A + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *a = A(value) + + extraProperties, err := core.ExtractExtraProperties(data, *a) + if err != nil { + return err + } + a.extraProperties = extraProperties + + return nil +} + +func (a *A) String() string { + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} diff --git a/seed/go-model/circular-references-advanced/ast.go b/seed/go-model/circular-references-advanced/ast.go new file mode 100644 index 00000000000..b053cf04ef7 --- /dev/null +++ b/seed/go-model/circular-references-advanced/ast.go @@ -0,0 +1,354 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/circular-references-advanced/fern/core" +) + +type ContainerValue struct { + Type string + List []*FieldValue + Optional *FieldValue +} + +func NewContainerValueFromList(value []*FieldValue) *ContainerValue { + return &ContainerValue{Type: "list", List: value} +} + +func NewContainerValueFromOptional(value *FieldValue) *ContainerValue { + return &ContainerValue{Type: "optional", Optional: value} +} + +func (c *ContainerValue) GetType() string { + if c == nil { + return "" + } + return c.Type +} + +func (c *ContainerValue) GetList() []*FieldValue { + if c == nil { + return nil + } + return c.List +} + +func (c *ContainerValue) GetOptional() *FieldValue { + if c == nil { + return nil + } + return c.Optional +} + +func (c *ContainerValue) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + c.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", c) + } + switch unmarshaler.Type { + case "list": + var valueUnmarshaler struct { + List []*FieldValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + c.List = valueUnmarshaler.List + case "optional": + var valueUnmarshaler struct { + Optional *FieldValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + c.Optional = valueUnmarshaler.Optional + } + return nil +} + +func (c ContainerValue) MarshalJSON() ([]byte, error) { + switch c.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", c.Type, c) + case "list": + var marshaler = struct { + Type string `json:"type"` + List []*FieldValue `json:"value,omitempty"` + }{ + Type: "list", + List: c.List, + } + return json.Marshal(marshaler) + case "optional": + var marshaler = struct { + Type string `json:"type"` + Optional *FieldValue `json:"value,omitempty"` + }{ + Type: "optional", + Optional: c.Optional, + } + return json.Marshal(marshaler) + } +} + +type ContainerValueVisitor interface { + VisitList([]*FieldValue) error + VisitOptional(*FieldValue) error +} + +func (c *ContainerValue) Accept(visitor ContainerValueVisitor) error { + switch c.Type { + default: + return fmt.Errorf("invalid type %s in %T", c.Type, c) + case "list": + return visitor.VisitList(c.List) + case "optional": + return visitor.VisitOptional(c.Optional) + } +} + +type FieldName = string + +type FieldValue struct { + Type string + PrimitiveValue PrimitiveValue + ObjectValue *ObjectValue + ContainerValue *ContainerValue +} + +func NewFieldValueFromPrimitiveValue(value PrimitiveValue) *FieldValue { + return &FieldValue{Type: "primitive_value", PrimitiveValue: value} +} + +func NewFieldValueFromObjectValue(value *ObjectValue) *FieldValue { + return &FieldValue{Type: "object_value", ObjectValue: value} +} + +func NewFieldValueFromContainerValue(value *ContainerValue) *FieldValue { + return &FieldValue{Type: "container_value", ContainerValue: value} +} + +func (f *FieldValue) GetType() string { + if f == nil { + return "" + } + return f.Type +} + +func (f *FieldValue) GetPrimitiveValue() PrimitiveValue { + if f == nil { + return "" + } + return f.PrimitiveValue +} + +func (f *FieldValue) GetObjectValue() *ObjectValue { + if f == nil { + return nil + } + return f.ObjectValue +} + +func (f *FieldValue) GetContainerValue() *ContainerValue { + if f == nil { + return nil + } + return f.ContainerValue +} + +func (f *FieldValue) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + f.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", f) + } + switch unmarshaler.Type { + case "primitive_value": + var valueUnmarshaler struct { + PrimitiveValue PrimitiveValue `json:"value"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + f.PrimitiveValue = valueUnmarshaler.PrimitiveValue + case "object_value": + value := new(ObjectValue) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + f.ObjectValue = value + case "container_value": + var valueUnmarshaler struct { + ContainerValue *ContainerValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + f.ContainerValue = valueUnmarshaler.ContainerValue + } + return nil +} + +func (f FieldValue) MarshalJSON() ([]byte, error) { + switch f.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", f.Type, f) + case "primitive_value": + var marshaler = struct { + Type string `json:"type"` + PrimitiveValue PrimitiveValue `json:"value"` + }{ + Type: "primitive_value", + PrimitiveValue: f.PrimitiveValue, + } + return json.Marshal(marshaler) + case "object_value": + return core.MarshalJSONWithExtraProperty(f.ObjectValue, "type", "object_value") + case "container_value": + var marshaler = struct { + Type string `json:"type"` + ContainerValue *ContainerValue `json:"value,omitempty"` + }{ + Type: "container_value", + ContainerValue: f.ContainerValue, + } + return json.Marshal(marshaler) + } +} + +type FieldValueVisitor interface { + VisitPrimitiveValue(PrimitiveValue) error + VisitObjectValue(*ObjectValue) error + VisitContainerValue(*ContainerValue) error +} + +func (f *FieldValue) Accept(visitor FieldValueVisitor) error { + switch f.Type { + default: + return fmt.Errorf("invalid type %s in %T", f.Type, f) + case "primitive_value": + return visitor.VisitPrimitiveValue(f.PrimitiveValue) + case "object_value": + return visitor.VisitObjectValue(f.ObjectValue) + case "container_value": + return visitor.VisitContainerValue(f.ContainerValue) + } +} + +// This type allows us to test a circular reference with a union type (see FieldValue). +type ObjectFieldValue struct { + Name FieldName `json:"name" url:"name"` + Value *FieldValue `json:"value,omitempty" url:"value,omitempty"` + + extraProperties map[string]interface{} +} + +func (o *ObjectFieldValue) GetName() FieldName { + if o == nil { + return "" + } + return o.Name +} + +func (o *ObjectFieldValue) GetValue() *FieldValue { + if o == nil { + return nil + } + return o.Value +} + +func (o *ObjectFieldValue) GetExtraProperties() map[string]interface{} { + return o.extraProperties +} + +func (o *ObjectFieldValue) UnmarshalJSON(data []byte) error { + type unmarshaler ObjectFieldValue + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *o = ObjectFieldValue(value) + + extraProperties, err := core.ExtractExtraProperties(data, *o) + if err != nil { + return err + } + o.extraProperties = extraProperties + + return nil +} + +func (o *ObjectFieldValue) String() string { + if value, err := core.StringifyJSON(o); err == nil { + return value + } + return fmt.Sprintf("%#v", o) +} + +type ObjectValue struct { + extraProperties map[string]interface{} +} + +func (o *ObjectValue) GetExtraProperties() map[string]interface{} { + return o.extraProperties +} + +func (o *ObjectValue) UnmarshalJSON(data []byte) error { + type unmarshaler ObjectValue + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *o = ObjectValue(value) + + extraProperties, err := core.ExtractExtraProperties(data, *o) + if err != nil { + return err + } + o.extraProperties = extraProperties + + return nil +} + +func (o *ObjectValue) String() string { + if value, err := core.StringifyJSON(o); err == nil { + return value + } + return fmt.Sprintf("%#v", o) +} + +type PrimitiveValue string + +const ( + PrimitiveValueString PrimitiveValue = "STRING" + PrimitiveValueNumber PrimitiveValue = "NUMBER" +) + +func NewPrimitiveValueFromString(s string) (PrimitiveValue, error) { + switch s { + case "STRING": + return PrimitiveValueString, nil + case "NUMBER": + return PrimitiveValueNumber, nil + } + var t PrimitiveValue + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (p PrimitiveValue) Ptr() *PrimitiveValue { + return &p +} diff --git a/seed/go-model/circular-references-advanced/types.go b/seed/go-model/circular-references-advanced/types.go index f1b9abb4f31..7eb351b730c 100644 --- a/seed/go-model/circular-references-advanced/types.go +++ b/seed/go-model/circular-references-advanced/types.go @@ -89,389 +89,3 @@ func (r *RootType) String() string { } return fmt.Sprintf("%#v", r) } - -type A struct { - S string `json:"s" url:"s"` - - extraProperties map[string]interface{} -} - -func (a *A) GetS() string { - if a == nil { - return "" - } - return a.S -} - -func (a *A) GetExtraProperties() map[string]interface{} { - return a.extraProperties -} - -func (a *A) UnmarshalJSON(data []byte) error { - type unmarshaler A - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *a = A(value) - - extraProperties, err := core.ExtractExtraProperties(data, *a) - if err != nil { - return err - } - a.extraProperties = extraProperties - - return nil -} - -func (a *A) String() string { - if value, err := core.StringifyJSON(a); err == nil { - return value - } - return fmt.Sprintf("%#v", a) -} - -type ContainerValue struct { - Type string - List []*FieldValue - Optional *FieldValue -} - -func NewContainerValueFromList(value []*FieldValue) *ContainerValue { - return &ContainerValue{Type: "list", List: value} -} - -func NewContainerValueFromOptional(value *FieldValue) *ContainerValue { - return &ContainerValue{Type: "optional", Optional: value} -} - -func (c *ContainerValue) GetType() string { - if c == nil { - return "" - } - return c.Type -} - -func (c *ContainerValue) GetList() []*FieldValue { - if c == nil { - return nil - } - return c.List -} - -func (c *ContainerValue) GetOptional() *FieldValue { - if c == nil { - return nil - } - return c.Optional -} - -func (c *ContainerValue) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - c.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", c) - } - switch unmarshaler.Type { - case "list": - var valueUnmarshaler struct { - List []*FieldValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - c.List = valueUnmarshaler.List - case "optional": - var valueUnmarshaler struct { - Optional *FieldValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - c.Optional = valueUnmarshaler.Optional - } - return nil -} - -func (c ContainerValue) MarshalJSON() ([]byte, error) { - switch c.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", c.Type, c) - case "list": - var marshaler = struct { - Type string `json:"type"` - List []*FieldValue `json:"value,omitempty"` - }{ - Type: "list", - List: c.List, - } - return json.Marshal(marshaler) - case "optional": - var marshaler = struct { - Type string `json:"type"` - Optional *FieldValue `json:"value,omitempty"` - }{ - Type: "optional", - Optional: c.Optional, - } - return json.Marshal(marshaler) - } -} - -type ContainerValueVisitor interface { - VisitList([]*FieldValue) error - VisitOptional(*FieldValue) error -} - -func (c *ContainerValue) Accept(visitor ContainerValueVisitor) error { - switch c.Type { - default: - return fmt.Errorf("invalid type %s in %T", c.Type, c) - case "list": - return visitor.VisitList(c.List) - case "optional": - return visitor.VisitOptional(c.Optional) - } -} - -type FieldName = string - -type FieldValue struct { - Type string - PrimitiveValue PrimitiveValue - ObjectValue *ObjectValue - ContainerValue *ContainerValue -} - -func NewFieldValueFromPrimitiveValue(value PrimitiveValue) *FieldValue { - return &FieldValue{Type: "primitive_value", PrimitiveValue: value} -} - -func NewFieldValueFromObjectValue(value *ObjectValue) *FieldValue { - return &FieldValue{Type: "object_value", ObjectValue: value} -} - -func NewFieldValueFromContainerValue(value *ContainerValue) *FieldValue { - return &FieldValue{Type: "container_value", ContainerValue: value} -} - -func (f *FieldValue) GetType() string { - if f == nil { - return "" - } - return f.Type -} - -func (f *FieldValue) GetPrimitiveValue() PrimitiveValue { - if f == nil { - return "" - } - return f.PrimitiveValue -} - -func (f *FieldValue) GetObjectValue() *ObjectValue { - if f == nil { - return nil - } - return f.ObjectValue -} - -func (f *FieldValue) GetContainerValue() *ContainerValue { - if f == nil { - return nil - } - return f.ContainerValue -} - -func (f *FieldValue) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - f.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", f) - } - switch unmarshaler.Type { - case "primitive_value": - var valueUnmarshaler struct { - PrimitiveValue PrimitiveValue `json:"value"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - f.PrimitiveValue = valueUnmarshaler.PrimitiveValue - case "object_value": - value := new(ObjectValue) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - f.ObjectValue = value - case "container_value": - var valueUnmarshaler struct { - ContainerValue *ContainerValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - f.ContainerValue = valueUnmarshaler.ContainerValue - } - return nil -} - -func (f FieldValue) MarshalJSON() ([]byte, error) { - switch f.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", f.Type, f) - case "primitive_value": - var marshaler = struct { - Type string `json:"type"` - PrimitiveValue PrimitiveValue `json:"value"` - }{ - Type: "primitive_value", - PrimitiveValue: f.PrimitiveValue, - } - return json.Marshal(marshaler) - case "object_value": - return core.MarshalJSONWithExtraProperty(f.ObjectValue, "type", "object_value") - case "container_value": - var marshaler = struct { - Type string `json:"type"` - ContainerValue *ContainerValue `json:"value,omitempty"` - }{ - Type: "container_value", - ContainerValue: f.ContainerValue, - } - return json.Marshal(marshaler) - } -} - -type FieldValueVisitor interface { - VisitPrimitiveValue(PrimitiveValue) error - VisitObjectValue(*ObjectValue) error - VisitContainerValue(*ContainerValue) error -} - -func (f *FieldValue) Accept(visitor FieldValueVisitor) error { - switch f.Type { - default: - return fmt.Errorf("invalid type %s in %T", f.Type, f) - case "primitive_value": - return visitor.VisitPrimitiveValue(f.PrimitiveValue) - case "object_value": - return visitor.VisitObjectValue(f.ObjectValue) - case "container_value": - return visitor.VisitContainerValue(f.ContainerValue) - } -} - -// This type allows us to test a circular reference with a union type (see FieldValue). -type ObjectFieldValue struct { - Name FieldName `json:"name" url:"name"` - Value *FieldValue `json:"value,omitempty" url:"value,omitempty"` - - extraProperties map[string]interface{} -} - -func (o *ObjectFieldValue) GetName() FieldName { - if o == nil { - return "" - } - return o.Name -} - -func (o *ObjectFieldValue) GetValue() *FieldValue { - if o == nil { - return nil - } - return o.Value -} - -func (o *ObjectFieldValue) GetExtraProperties() map[string]interface{} { - return o.extraProperties -} - -func (o *ObjectFieldValue) UnmarshalJSON(data []byte) error { - type unmarshaler ObjectFieldValue - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *o = ObjectFieldValue(value) - - extraProperties, err := core.ExtractExtraProperties(data, *o) - if err != nil { - return err - } - o.extraProperties = extraProperties - - return nil -} - -func (o *ObjectFieldValue) String() string { - if value, err := core.StringifyJSON(o); err == nil { - return value - } - return fmt.Sprintf("%#v", o) -} - -type ObjectValue struct { - extraProperties map[string]interface{} -} - -func (o *ObjectValue) GetExtraProperties() map[string]interface{} { - return o.extraProperties -} - -func (o *ObjectValue) UnmarshalJSON(data []byte) error { - type unmarshaler ObjectValue - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *o = ObjectValue(value) - - extraProperties, err := core.ExtractExtraProperties(data, *o) - if err != nil { - return err - } - o.extraProperties = extraProperties - - return nil -} - -func (o *ObjectValue) String() string { - if value, err := core.StringifyJSON(o); err == nil { - return value - } - return fmt.Sprintf("%#v", o) -} - -type PrimitiveValue string - -const ( - PrimitiveValueString PrimitiveValue = "STRING" - PrimitiveValueNumber PrimitiveValue = "NUMBER" -) - -func NewPrimitiveValueFromString(s string) (PrimitiveValue, error) { - switch s { - case "STRING": - return PrimitiveValueString, nil - case "NUMBER": - return PrimitiveValueNumber, nil - } - var t PrimitiveValue - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (p PrimitiveValue) Ptr() *PrimitiveValue { - return &p -} diff --git a/seed/go-model/circular-references/a.go b/seed/go-model/circular-references/a.go new file mode 100644 index 00000000000..f8e88eda5fe --- /dev/null +++ b/seed/go-model/circular-references/a.go @@ -0,0 +1,50 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/circular-references/fern/core" +) + +type A struct { + S string `json:"s" url:"s"` + + extraProperties map[string]interface{} +} + +func (a *A) GetS() string { + if a == nil { + return "" + } + return a.S +} + +func (a *A) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *A) UnmarshalJSON(data []byte) error { + type unmarshaler A + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *a = A(value) + + extraProperties, err := core.ExtractExtraProperties(data, *a) + if err != nil { + return err + } + a.extraProperties = extraProperties + + return nil +} + +func (a *A) String() string { + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} diff --git a/seed/go-model/circular-references/ast.go b/seed/go-model/circular-references/ast.go new file mode 100644 index 00000000000..c1d10703c8e --- /dev/null +++ b/seed/go-model/circular-references/ast.go @@ -0,0 +1,447 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/circular-references/fern/core" +) + +type ContainerValue struct { + Type string + List []*FieldValue + Optional *FieldValue +} + +func NewContainerValueFromList(value []*FieldValue) *ContainerValue { + return &ContainerValue{Type: "list", List: value} +} + +func NewContainerValueFromOptional(value *FieldValue) *ContainerValue { + return &ContainerValue{Type: "optional", Optional: value} +} + +func (c *ContainerValue) GetType() string { + if c == nil { + return "" + } + return c.Type +} + +func (c *ContainerValue) GetList() []*FieldValue { + if c == nil { + return nil + } + return c.List +} + +func (c *ContainerValue) GetOptional() *FieldValue { + if c == nil { + return nil + } + return c.Optional +} + +func (c *ContainerValue) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + c.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", c) + } + switch unmarshaler.Type { + case "list": + var valueUnmarshaler struct { + List []*FieldValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + c.List = valueUnmarshaler.List + case "optional": + var valueUnmarshaler struct { + Optional *FieldValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + c.Optional = valueUnmarshaler.Optional + } + return nil +} + +func (c ContainerValue) MarshalJSON() ([]byte, error) { + switch c.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", c.Type, c) + case "list": + var marshaler = struct { + Type string `json:"type"` + List []*FieldValue `json:"value,omitempty"` + }{ + Type: "list", + List: c.List, + } + return json.Marshal(marshaler) + case "optional": + var marshaler = struct { + Type string `json:"type"` + Optional *FieldValue `json:"value,omitempty"` + }{ + Type: "optional", + Optional: c.Optional, + } + return json.Marshal(marshaler) + } +} + +type ContainerValueVisitor interface { + VisitList([]*FieldValue) error + VisitOptional(*FieldValue) error +} + +func (c *ContainerValue) Accept(visitor ContainerValueVisitor) error { + switch c.Type { + default: + return fmt.Errorf("invalid type %s in %T", c.Type, c) + case "list": + return visitor.VisitList(c.List) + case "optional": + return visitor.VisitOptional(c.Optional) + } +} + +type FieldValue struct { + Type string + PrimitiveValue PrimitiveValue + ObjectValue *ObjectValue + ContainerValue *ContainerValue +} + +func NewFieldValueFromPrimitiveValue(value PrimitiveValue) *FieldValue { + return &FieldValue{Type: "primitive_value", PrimitiveValue: value} +} + +func NewFieldValueFromObjectValue(value *ObjectValue) *FieldValue { + return &FieldValue{Type: "object_value", ObjectValue: value} +} + +func NewFieldValueFromContainerValue(value *ContainerValue) *FieldValue { + return &FieldValue{Type: "container_value", ContainerValue: value} +} + +func (f *FieldValue) GetType() string { + if f == nil { + return "" + } + return f.Type +} + +func (f *FieldValue) GetPrimitiveValue() PrimitiveValue { + if f == nil { + return "" + } + return f.PrimitiveValue +} + +func (f *FieldValue) GetObjectValue() *ObjectValue { + if f == nil { + return nil + } + return f.ObjectValue +} + +func (f *FieldValue) GetContainerValue() *ContainerValue { + if f == nil { + return nil + } + return f.ContainerValue +} + +func (f *FieldValue) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + f.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", f) + } + switch unmarshaler.Type { + case "primitive_value": + var valueUnmarshaler struct { + PrimitiveValue PrimitiveValue `json:"value"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + f.PrimitiveValue = valueUnmarshaler.PrimitiveValue + case "object_value": + value := new(ObjectValue) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + f.ObjectValue = value + case "container_value": + var valueUnmarshaler struct { + ContainerValue *ContainerValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + f.ContainerValue = valueUnmarshaler.ContainerValue + } + return nil +} + +func (f FieldValue) MarshalJSON() ([]byte, error) { + switch f.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", f.Type, f) + case "primitive_value": + var marshaler = struct { + Type string `json:"type"` + PrimitiveValue PrimitiveValue `json:"value"` + }{ + Type: "primitive_value", + PrimitiveValue: f.PrimitiveValue, + } + return json.Marshal(marshaler) + case "object_value": + return core.MarshalJSONWithExtraProperty(f.ObjectValue, "type", "object_value") + case "container_value": + var marshaler = struct { + Type string `json:"type"` + ContainerValue *ContainerValue `json:"value,omitempty"` + }{ + Type: "container_value", + ContainerValue: f.ContainerValue, + } + return json.Marshal(marshaler) + } +} + +type FieldValueVisitor interface { + VisitPrimitiveValue(PrimitiveValue) error + VisitObjectValue(*ObjectValue) error + VisitContainerValue(*ContainerValue) error +} + +func (f *FieldValue) Accept(visitor FieldValueVisitor) error { + switch f.Type { + default: + return fmt.Errorf("invalid type %s in %T", f.Type, f) + case "primitive_value": + return visitor.VisitPrimitiveValue(f.PrimitiveValue) + case "object_value": + return visitor.VisitObjectValue(f.ObjectValue) + case "container_value": + return visitor.VisitContainerValue(f.ContainerValue) + } +} + +type JsonLike struct { + JsonLikeList []*JsonLike + StringJsonLikeMap map[string]*JsonLike + String string + Integer int + Boolean bool + + typ string +} + +func NewJsonLikeFromJsonLikeList(value []*JsonLike) *JsonLike { + return &JsonLike{typ: "JsonLikeList", JsonLikeList: value} +} + +func NewJsonLikeFromStringJsonLikeMap(value map[string]*JsonLike) *JsonLike { + return &JsonLike{typ: "StringJsonLikeMap", StringJsonLikeMap: value} +} + +func NewJsonLikeFromString(value string) *JsonLike { + return &JsonLike{typ: "String", String: value} +} + +func NewJsonLikeFromInteger(value int) *JsonLike { + return &JsonLike{typ: "Integer", Integer: value} +} + +func NewJsonLikeFromBoolean(value bool) *JsonLike { + return &JsonLike{typ: "Boolean", Boolean: value} +} + +func (j *JsonLike) GetJsonLikeList() []*JsonLike { + if j == nil { + return nil + } + return j.JsonLikeList +} + +func (j *JsonLike) GetStringJsonLikeMap() map[string]*JsonLike { + if j == nil { + return nil + } + return j.StringJsonLikeMap +} + +func (j *JsonLike) GetString() string { + if j == nil { + return "" + } + return j.String +} + +func (j *JsonLike) GetInteger() int { + if j == nil { + return 0 + } + return j.Integer +} + +func (j *JsonLike) GetBoolean() bool { + if j == nil { + return false + } + return j.Boolean +} + +func (j *JsonLike) UnmarshalJSON(data []byte) error { + var valueJsonLikeList []*JsonLike + if err := json.Unmarshal(data, &valueJsonLikeList); err == nil { + j.typ = "JsonLikeList" + j.JsonLikeList = valueJsonLikeList + return nil + } + var valueStringJsonLikeMap map[string]*JsonLike + if err := json.Unmarshal(data, &valueStringJsonLikeMap); err == nil { + j.typ = "StringJsonLikeMap" + j.StringJsonLikeMap = valueStringJsonLikeMap + return nil + } + var valueString string + if err := json.Unmarshal(data, &valueString); err == nil { + j.typ = "String" + j.String = valueString + return nil + } + var valueInteger int + if err := json.Unmarshal(data, &valueInteger); err == nil { + j.typ = "Integer" + j.Integer = valueInteger + return nil + } + var valueBoolean bool + if err := json.Unmarshal(data, &valueBoolean); err == nil { + j.typ = "Boolean" + j.Boolean = valueBoolean + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, j) +} + +func (j JsonLike) MarshalJSON() ([]byte, error) { + if j.typ == "JsonLikeList" || j.JsonLikeList != nil { + return json.Marshal(j.JsonLikeList) + } + if j.typ == "StringJsonLikeMap" || j.StringJsonLikeMap != nil { + return json.Marshal(j.StringJsonLikeMap) + } + if j.typ == "String" || j.String != "" { + return json.Marshal(j.String) + } + if j.typ == "Integer" || j.Integer != 0 { + return json.Marshal(j.Integer) + } + if j.typ == "Boolean" || j.Boolean != false { + return json.Marshal(j.Boolean) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", j) +} + +type JsonLikeVisitor interface { + VisitJsonLikeList([]*JsonLike) error + VisitStringJsonLikeMap(map[string]*JsonLike) error + VisitString(string) error + VisitInteger(int) error + VisitBoolean(bool) error +} + +func (j *JsonLike) Accept(visitor JsonLikeVisitor) error { + if j.typ == "JsonLikeList" || j.JsonLikeList != nil { + return visitor.VisitJsonLikeList(j.JsonLikeList) + } + if j.typ == "StringJsonLikeMap" || j.StringJsonLikeMap != nil { + return visitor.VisitStringJsonLikeMap(j.StringJsonLikeMap) + } + if j.typ == "String" || j.String != "" { + return visitor.VisitString(j.String) + } + if j.typ == "Integer" || j.Integer != 0 { + return visitor.VisitInteger(j.Integer) + } + if j.typ == "Boolean" || j.Boolean != false { + return visitor.VisitBoolean(j.Boolean) + } + return fmt.Errorf("type %T does not include a non-empty union type", j) +} + +type ObjectValue struct { + extraProperties map[string]interface{} +} + +func (o *ObjectValue) GetExtraProperties() map[string]interface{} { + return o.extraProperties +} + +func (o *ObjectValue) UnmarshalJSON(data []byte) error { + type unmarshaler ObjectValue + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *o = ObjectValue(value) + + extraProperties, err := core.ExtractExtraProperties(data, *o) + if err != nil { + return err + } + o.extraProperties = extraProperties + + return nil +} + +func (o *ObjectValue) String() string { + if value, err := core.StringifyJSON(o); err == nil { + return value + } + return fmt.Sprintf("%#v", o) +} + +type PrimitiveValue string + +const ( + PrimitiveValueString PrimitiveValue = "STRING" + PrimitiveValueNumber PrimitiveValue = "NUMBER" +) + +func NewPrimitiveValueFromString(s string) (PrimitiveValue, error) { + switch s { + case "STRING": + return PrimitiveValueString, nil + case "NUMBER": + return PrimitiveValueNumber, nil + } + var t PrimitiveValue + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (p PrimitiveValue) Ptr() *PrimitiveValue { + return &p +} diff --git a/seed/go-model/circular-references/types.go b/seed/go-model/circular-references/types.go index 9f877505669..7e33a17438c 100644 --- a/seed/go-model/circular-references/types.go +++ b/seed/go-model/circular-references/types.go @@ -89,482 +89,3 @@ func (r *RootType) String() string { } return fmt.Sprintf("%#v", r) } - -type A struct { - S string `json:"s" url:"s"` - - extraProperties map[string]interface{} -} - -func (a *A) GetS() string { - if a == nil { - return "" - } - return a.S -} - -func (a *A) GetExtraProperties() map[string]interface{} { - return a.extraProperties -} - -func (a *A) UnmarshalJSON(data []byte) error { - type unmarshaler A - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *a = A(value) - - extraProperties, err := core.ExtractExtraProperties(data, *a) - if err != nil { - return err - } - a.extraProperties = extraProperties - - return nil -} - -func (a *A) String() string { - if value, err := core.StringifyJSON(a); err == nil { - return value - } - return fmt.Sprintf("%#v", a) -} - -type ContainerValue struct { - Type string - List []*FieldValue - Optional *FieldValue -} - -func NewContainerValueFromList(value []*FieldValue) *ContainerValue { - return &ContainerValue{Type: "list", List: value} -} - -func NewContainerValueFromOptional(value *FieldValue) *ContainerValue { - return &ContainerValue{Type: "optional", Optional: value} -} - -func (c *ContainerValue) GetType() string { - if c == nil { - return "" - } - return c.Type -} - -func (c *ContainerValue) GetList() []*FieldValue { - if c == nil { - return nil - } - return c.List -} - -func (c *ContainerValue) GetOptional() *FieldValue { - if c == nil { - return nil - } - return c.Optional -} - -func (c *ContainerValue) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - c.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", c) - } - switch unmarshaler.Type { - case "list": - var valueUnmarshaler struct { - List []*FieldValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - c.List = valueUnmarshaler.List - case "optional": - var valueUnmarshaler struct { - Optional *FieldValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - c.Optional = valueUnmarshaler.Optional - } - return nil -} - -func (c ContainerValue) MarshalJSON() ([]byte, error) { - switch c.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", c.Type, c) - case "list": - var marshaler = struct { - Type string `json:"type"` - List []*FieldValue `json:"value,omitempty"` - }{ - Type: "list", - List: c.List, - } - return json.Marshal(marshaler) - case "optional": - var marshaler = struct { - Type string `json:"type"` - Optional *FieldValue `json:"value,omitempty"` - }{ - Type: "optional", - Optional: c.Optional, - } - return json.Marshal(marshaler) - } -} - -type ContainerValueVisitor interface { - VisitList([]*FieldValue) error - VisitOptional(*FieldValue) error -} - -func (c *ContainerValue) Accept(visitor ContainerValueVisitor) error { - switch c.Type { - default: - return fmt.Errorf("invalid type %s in %T", c.Type, c) - case "list": - return visitor.VisitList(c.List) - case "optional": - return visitor.VisitOptional(c.Optional) - } -} - -type FieldValue struct { - Type string - PrimitiveValue PrimitiveValue - ObjectValue *ObjectValue - ContainerValue *ContainerValue -} - -func NewFieldValueFromPrimitiveValue(value PrimitiveValue) *FieldValue { - return &FieldValue{Type: "primitive_value", PrimitiveValue: value} -} - -func NewFieldValueFromObjectValue(value *ObjectValue) *FieldValue { - return &FieldValue{Type: "object_value", ObjectValue: value} -} - -func NewFieldValueFromContainerValue(value *ContainerValue) *FieldValue { - return &FieldValue{Type: "container_value", ContainerValue: value} -} - -func (f *FieldValue) GetType() string { - if f == nil { - return "" - } - return f.Type -} - -func (f *FieldValue) GetPrimitiveValue() PrimitiveValue { - if f == nil { - return "" - } - return f.PrimitiveValue -} - -func (f *FieldValue) GetObjectValue() *ObjectValue { - if f == nil { - return nil - } - return f.ObjectValue -} - -func (f *FieldValue) GetContainerValue() *ContainerValue { - if f == nil { - return nil - } - return f.ContainerValue -} - -func (f *FieldValue) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - f.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", f) - } - switch unmarshaler.Type { - case "primitive_value": - var valueUnmarshaler struct { - PrimitiveValue PrimitiveValue `json:"value"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - f.PrimitiveValue = valueUnmarshaler.PrimitiveValue - case "object_value": - value := new(ObjectValue) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - f.ObjectValue = value - case "container_value": - var valueUnmarshaler struct { - ContainerValue *ContainerValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - f.ContainerValue = valueUnmarshaler.ContainerValue - } - return nil -} - -func (f FieldValue) MarshalJSON() ([]byte, error) { - switch f.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", f.Type, f) - case "primitive_value": - var marshaler = struct { - Type string `json:"type"` - PrimitiveValue PrimitiveValue `json:"value"` - }{ - Type: "primitive_value", - PrimitiveValue: f.PrimitiveValue, - } - return json.Marshal(marshaler) - case "object_value": - return core.MarshalJSONWithExtraProperty(f.ObjectValue, "type", "object_value") - case "container_value": - var marshaler = struct { - Type string `json:"type"` - ContainerValue *ContainerValue `json:"value,omitempty"` - }{ - Type: "container_value", - ContainerValue: f.ContainerValue, - } - return json.Marshal(marshaler) - } -} - -type FieldValueVisitor interface { - VisitPrimitiveValue(PrimitiveValue) error - VisitObjectValue(*ObjectValue) error - VisitContainerValue(*ContainerValue) error -} - -func (f *FieldValue) Accept(visitor FieldValueVisitor) error { - switch f.Type { - default: - return fmt.Errorf("invalid type %s in %T", f.Type, f) - case "primitive_value": - return visitor.VisitPrimitiveValue(f.PrimitiveValue) - case "object_value": - return visitor.VisitObjectValue(f.ObjectValue) - case "container_value": - return visitor.VisitContainerValue(f.ContainerValue) - } -} - -type JsonLike struct { - JsonLikeList []*JsonLike - StringJsonLikeMap map[string]*JsonLike - String string - Integer int - Boolean bool - - typ string -} - -func NewJsonLikeFromJsonLikeList(value []*JsonLike) *JsonLike { - return &JsonLike{typ: "JsonLikeList", JsonLikeList: value} -} - -func NewJsonLikeFromStringJsonLikeMap(value map[string]*JsonLike) *JsonLike { - return &JsonLike{typ: "StringJsonLikeMap", StringJsonLikeMap: value} -} - -func NewJsonLikeFromString(value string) *JsonLike { - return &JsonLike{typ: "String", String: value} -} - -func NewJsonLikeFromInteger(value int) *JsonLike { - return &JsonLike{typ: "Integer", Integer: value} -} - -func NewJsonLikeFromBoolean(value bool) *JsonLike { - return &JsonLike{typ: "Boolean", Boolean: value} -} - -func (j *JsonLike) GetJsonLikeList() []*JsonLike { - if j == nil { - return nil - } - return j.JsonLikeList -} - -func (j *JsonLike) GetStringJsonLikeMap() map[string]*JsonLike { - if j == nil { - return nil - } - return j.StringJsonLikeMap -} - -func (j *JsonLike) GetString() string { - if j == nil { - return "" - } - return j.String -} - -func (j *JsonLike) GetInteger() int { - if j == nil { - return 0 - } - return j.Integer -} - -func (j *JsonLike) GetBoolean() bool { - if j == nil { - return false - } - return j.Boolean -} - -func (j *JsonLike) UnmarshalJSON(data []byte) error { - var valueJsonLikeList []*JsonLike - if err := json.Unmarshal(data, &valueJsonLikeList); err == nil { - j.typ = "JsonLikeList" - j.JsonLikeList = valueJsonLikeList - return nil - } - var valueStringJsonLikeMap map[string]*JsonLike - if err := json.Unmarshal(data, &valueStringJsonLikeMap); err == nil { - j.typ = "StringJsonLikeMap" - j.StringJsonLikeMap = valueStringJsonLikeMap - return nil - } - var valueString string - if err := json.Unmarshal(data, &valueString); err == nil { - j.typ = "String" - j.String = valueString - return nil - } - var valueInteger int - if err := json.Unmarshal(data, &valueInteger); err == nil { - j.typ = "Integer" - j.Integer = valueInteger - return nil - } - var valueBoolean bool - if err := json.Unmarshal(data, &valueBoolean); err == nil { - j.typ = "Boolean" - j.Boolean = valueBoolean - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, j) -} - -func (j JsonLike) MarshalJSON() ([]byte, error) { - if j.typ == "JsonLikeList" || j.JsonLikeList != nil { - return json.Marshal(j.JsonLikeList) - } - if j.typ == "StringJsonLikeMap" || j.StringJsonLikeMap != nil { - return json.Marshal(j.StringJsonLikeMap) - } - if j.typ == "String" || j.String != "" { - return json.Marshal(j.String) - } - if j.typ == "Integer" || j.Integer != 0 { - return json.Marshal(j.Integer) - } - if j.typ == "Boolean" || j.Boolean != false { - return json.Marshal(j.Boolean) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", j) -} - -type JsonLikeVisitor interface { - VisitJsonLikeList([]*JsonLike) error - VisitStringJsonLikeMap(map[string]*JsonLike) error - VisitString(string) error - VisitInteger(int) error - VisitBoolean(bool) error -} - -func (j *JsonLike) Accept(visitor JsonLikeVisitor) error { - if j.typ == "JsonLikeList" || j.JsonLikeList != nil { - return visitor.VisitJsonLikeList(j.JsonLikeList) - } - if j.typ == "StringJsonLikeMap" || j.StringJsonLikeMap != nil { - return visitor.VisitStringJsonLikeMap(j.StringJsonLikeMap) - } - if j.typ == "String" || j.String != "" { - return visitor.VisitString(j.String) - } - if j.typ == "Integer" || j.Integer != 0 { - return visitor.VisitInteger(j.Integer) - } - if j.typ == "Boolean" || j.Boolean != false { - return visitor.VisitBoolean(j.Boolean) - } - return fmt.Errorf("type %T does not include a non-empty union type", j) -} - -type ObjectValue struct { - extraProperties map[string]interface{} -} - -func (o *ObjectValue) GetExtraProperties() map[string]interface{} { - return o.extraProperties -} - -func (o *ObjectValue) UnmarshalJSON(data []byte) error { - type unmarshaler ObjectValue - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *o = ObjectValue(value) - - extraProperties, err := core.ExtractExtraProperties(data, *o) - if err != nil { - return err - } - o.extraProperties = extraProperties - - return nil -} - -func (o *ObjectValue) String() string { - if value, err := core.StringifyJSON(o); err == nil { - return value - } - return fmt.Sprintf("%#v", o) -} - -type PrimitiveValue string - -const ( - PrimitiveValueString PrimitiveValue = "STRING" - PrimitiveValueNumber PrimitiveValue = "NUMBER" -) - -func NewPrimitiveValueFromString(s string) (PrimitiveValue, error) { - switch s { - case "STRING": - return PrimitiveValueString, nil - case "NUMBER": - return PrimitiveValueNumber, nil - } - var t PrimitiveValue - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (p PrimitiveValue) Ptr() *PrimitiveValue { - return &p -} diff --git a/seed/go-model/cross-package-type-names/types.go b/seed/go-model/cross-package-type-names/commons.go similarity index 100% rename from seed/go-model/cross-package-type-names/types.go rename to seed/go-model/cross-package-type-names/commons.go diff --git a/seed/go-model/cross-package-type-names/folderb/types.go b/seed/go-model/cross-package-type-names/folderb/common.go similarity index 100% rename from seed/go-model/cross-package-type-names/folderb/types.go rename to seed/go-model/cross-package-type-names/folderb/common.go diff --git a/seed/go-model/cross-package-type-names/folderc/types.go b/seed/go-model/cross-package-type-names/folderc/common.go similarity index 100% rename from seed/go-model/cross-package-type-names/folderc/types.go rename to seed/go-model/cross-package-type-names/folderc/common.go diff --git a/seed/go-model/examples/file/service.go b/seed/go-model/examples/file/service.go index ea34b32bdeb..edc509f893e 100644 --- a/seed/go-model/examples/file/service.go +++ b/seed/go-model/examples/file/service.go @@ -1,3 +1,5 @@ // This file was auto-generated by Fern from our API Definition. package file + +type Filename = string diff --git a/seed/go-model/exhaustive/.mock/definition/endpoints/content-type.yml b/seed/go-model/exhaustive/.mock/definition/endpoints/content-type.yml new file mode 100644 index 00000000000..7c54e39fa5a --- /dev/null +++ b/seed/go-model/exhaustive/.mock/definition/endpoints/content-type.yml @@ -0,0 +1,19 @@ +imports: + objects: ../types/object.yml + +service: + auth: true + base-path: /foo + endpoints: + postJsonPatchContentType: + path: /bar + method: POST + request: + body: objects.ObjectWithOptionalField + content-type: application/json-patch+json + postJsonPatchContentWithCharsetType: + path: /baz + method: POST + request: + body: objects.ObjectWithOptionalField + content-type: application/json-patch+json; charset=utf-8 diff --git a/seed/go-model/exhaustive/types.go b/seed/go-model/exhaustive/general_errors.go similarity index 100% rename from seed/go-model/exhaustive/types.go rename to seed/go-model/exhaustive/general_errors.go diff --git a/seed/go-model/exhaustive/types/enum.go b/seed/go-model/exhaustive/types/enum.go new file mode 100644 index 00000000000..d6da74c7932 --- /dev/null +++ b/seed/go-model/exhaustive/types/enum.go @@ -0,0 +1,35 @@ +// This file was auto-generated by Fern from our API Definition. + +package types + +import ( + fmt "fmt" +) + +type WeatherReport string + +const ( + WeatherReportSunny WeatherReport = "SUNNY" + WeatherReportCloudy WeatherReport = "CLOUDY" + WeatherReportRaining WeatherReport = "RAINING" + WeatherReportSnowing WeatherReport = "SNOWING" +) + +func NewWeatherReportFromString(s string) (WeatherReport, error) { + switch s { + case "SUNNY": + return WeatherReportSunny, nil + case "CLOUDY": + return WeatherReportCloudy, nil + case "RAINING": + return WeatherReportRaining, nil + case "SNOWING": + return WeatherReportSnowing, nil + } + var t WeatherReport + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (w WeatherReport) Ptr() *WeatherReport { + return &w +} diff --git a/seed/go-model/exhaustive/types/types.go b/seed/go-model/exhaustive/types/object.go similarity index 68% rename from seed/go-model/exhaustive/types/types.go rename to seed/go-model/exhaustive/types/object.go index 618e04b2c04..bdf2d03b93b 100644 --- a/seed/go-model/exhaustive/types/types.go +++ b/seed/go-model/exhaustive/types/object.go @@ -10,34 +10,6 @@ import ( time "time" ) -type WeatherReport string - -const ( - WeatherReportSunny WeatherReport = "SUNNY" - WeatherReportCloudy WeatherReport = "CLOUDY" - WeatherReportRaining WeatherReport = "RAINING" - WeatherReportSnowing WeatherReport = "SNOWING" -) - -func NewWeatherReportFromString(s string) (WeatherReport, error) { - switch s { - case "SUNNY": - return WeatherReportSunny, nil - case "CLOUDY": - return WeatherReportCloudy, nil - case "RAINING": - return WeatherReportRaining, nil - case "SNOWING": - return WeatherReportSnowing, nil - } - var t WeatherReport - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (w WeatherReport) Ptr() *WeatherReport { - return &w -} - type DoubleOptional struct { OptionalAlias *OptionalAlias `json:"optionalAlias,omitempty" url:"optionalAlias,omitempty"` @@ -420,191 +392,3 @@ func (o *ObjectWithRequiredField) String() string { } type OptionalAlias = *string - -type Animal struct { - Animal string - Dog *Dog - Cat *Cat -} - -func NewAnimalFromDog(value *Dog) *Animal { - return &Animal{Animal: "dog", Dog: value} -} - -func NewAnimalFromCat(value *Cat) *Animal { - return &Animal{Animal: "cat", Cat: value} -} - -func (a *Animal) GetAnimal() string { - if a == nil { - return "" - } - return a.Animal -} - -func (a *Animal) GetDog() *Dog { - if a == nil { - return nil - } - return a.Dog -} - -func (a *Animal) GetCat() *Cat { - if a == nil { - return nil - } - return a.Cat -} - -func (a *Animal) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Animal string `json:"animal"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - a.Animal = unmarshaler.Animal - if unmarshaler.Animal == "" { - return fmt.Errorf("%T did not include discriminant animal", a) - } - switch unmarshaler.Animal { - case "dog": - value := new(Dog) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - a.Dog = value - case "cat": - value := new(Cat) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - a.Cat = value - } - return nil -} - -func (a Animal) MarshalJSON() ([]byte, error) { - switch a.Animal { - default: - return nil, fmt.Errorf("invalid type %s in %T", a.Animal, a) - case "dog": - return core.MarshalJSONWithExtraProperty(a.Dog, "animal", "dog") - case "cat": - return core.MarshalJSONWithExtraProperty(a.Cat, "animal", "cat") - } -} - -type AnimalVisitor interface { - VisitDog(*Dog) error - VisitCat(*Cat) error -} - -func (a *Animal) Accept(visitor AnimalVisitor) error { - switch a.Animal { - default: - return fmt.Errorf("invalid type %s in %T", a.Animal, a) - case "dog": - return visitor.VisitDog(a.Dog) - case "cat": - return visitor.VisitCat(a.Cat) - } -} - -type Cat struct { - Name string `json:"name" url:"name"` - LikesToMeow bool `json:"likesToMeow" url:"likesToMeow"` - - extraProperties map[string]interface{} -} - -func (c *Cat) GetName() string { - if c == nil { - return "" - } - return c.Name -} - -func (c *Cat) GetLikesToMeow() bool { - if c == nil { - return false - } - return c.LikesToMeow -} - -func (c *Cat) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *Cat) UnmarshalJSON(data []byte) error { - type unmarshaler Cat - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = Cat(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - return nil -} - -func (c *Cat) String() string { - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type Dog struct { - Name string `json:"name" url:"name"` - LikesToWoof bool `json:"likesToWoof" url:"likesToWoof"` - - extraProperties map[string]interface{} -} - -func (d *Dog) GetName() string { - if d == nil { - return "" - } - return d.Name -} - -func (d *Dog) GetLikesToWoof() bool { - if d == nil { - return false - } - return d.LikesToWoof -} - -func (d *Dog) GetExtraProperties() map[string]interface{} { - return d.extraProperties -} - -func (d *Dog) UnmarshalJSON(data []byte) error { - type unmarshaler Dog - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *d = Dog(value) - - extraProperties, err := core.ExtractExtraProperties(data, *d) - if err != nil { - return err - } - d.extraProperties = extraProperties - - return nil -} - -func (d *Dog) String() string { - if value, err := core.StringifyJSON(d); err == nil { - return value - } - return fmt.Sprintf("%#v", d) -} diff --git a/seed/go-model/exhaustive/types/union.go b/seed/go-model/exhaustive/types/union.go new file mode 100644 index 00000000000..8ca6406b032 --- /dev/null +++ b/seed/go-model/exhaustive/types/union.go @@ -0,0 +1,197 @@ +// This file was auto-generated by Fern from our API Definition. + +package types + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/exhaustive/fern/core" +) + +type Animal struct { + Animal string + Dog *Dog + Cat *Cat +} + +func NewAnimalFromDog(value *Dog) *Animal { + return &Animal{Animal: "dog", Dog: value} +} + +func NewAnimalFromCat(value *Cat) *Animal { + return &Animal{Animal: "cat", Cat: value} +} + +func (a *Animal) GetAnimal() string { + if a == nil { + return "" + } + return a.Animal +} + +func (a *Animal) GetDog() *Dog { + if a == nil { + return nil + } + return a.Dog +} + +func (a *Animal) GetCat() *Cat { + if a == nil { + return nil + } + return a.Cat +} + +func (a *Animal) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Animal string `json:"animal"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + a.Animal = unmarshaler.Animal + if unmarshaler.Animal == "" { + return fmt.Errorf("%T did not include discriminant animal", a) + } + switch unmarshaler.Animal { + case "dog": + value := new(Dog) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + a.Dog = value + case "cat": + value := new(Cat) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + a.Cat = value + } + return nil +} + +func (a Animal) MarshalJSON() ([]byte, error) { + switch a.Animal { + default: + return nil, fmt.Errorf("invalid type %s in %T", a.Animal, a) + case "dog": + return core.MarshalJSONWithExtraProperty(a.Dog, "animal", "dog") + case "cat": + return core.MarshalJSONWithExtraProperty(a.Cat, "animal", "cat") + } +} + +type AnimalVisitor interface { + VisitDog(*Dog) error + VisitCat(*Cat) error +} + +func (a *Animal) Accept(visitor AnimalVisitor) error { + switch a.Animal { + default: + return fmt.Errorf("invalid type %s in %T", a.Animal, a) + case "dog": + return visitor.VisitDog(a.Dog) + case "cat": + return visitor.VisitCat(a.Cat) + } +} + +type Cat struct { + Name string `json:"name" url:"name"` + LikesToMeow bool `json:"likesToMeow" url:"likesToMeow"` + + extraProperties map[string]interface{} +} + +func (c *Cat) GetName() string { + if c == nil { + return "" + } + return c.Name +} + +func (c *Cat) GetLikesToMeow() bool { + if c == nil { + return false + } + return c.LikesToMeow +} + +func (c *Cat) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *Cat) UnmarshalJSON(data []byte) error { + type unmarshaler Cat + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = Cat(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + return nil +} + +func (c *Cat) String() string { + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type Dog struct { + Name string `json:"name" url:"name"` + LikesToWoof bool `json:"likesToWoof" url:"likesToWoof"` + + extraProperties map[string]interface{} +} + +func (d *Dog) GetName() string { + if d == nil { + return "" + } + return d.Name +} + +func (d *Dog) GetLikesToWoof() bool { + if d == nil { + return false + } + return d.LikesToWoof +} + +func (d *Dog) GetExtraProperties() map[string]interface{} { + return d.extraProperties +} + +func (d *Dog) UnmarshalJSON(data []byte) error { + type unmarshaler Dog + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = Dog(value) + + extraProperties, err := core.ExtractExtraProperties(data, *d) + if err != nil { + return err + } + d.extraProperties = extraProperties + + return nil +} + +func (d *Dog) String() string { + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} diff --git a/seed/go-model/grpc-proto-exhaustive/dataservice.go b/seed/go-model/grpc-proto-exhaustive/dataservice.go index 884eed6ba61..734c14d770d 100644 --- a/seed/go-model/grpc-proto-exhaustive/dataservice.go +++ b/seed/go-model/grpc-proto-exhaustive/dataservice.go @@ -1,3 +1,1004 @@ // This file was auto-generated by Fern from our API Definition. package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/grpc-proto-exhaustive/fern/core" +) + +type Column struct { + Id string `json:"id" url:"id"` + Values []float64 `json:"values,omitempty" url:"values,omitempty"` + Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` + IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` + + extraProperties map[string]interface{} +} + +func (c *Column) GetId() string { + if c == nil { + return "" + } + return c.Id +} + +func (c *Column) GetValues() []float64 { + if c == nil { + return nil + } + return c.Values +} + +func (c *Column) GetMetadata() *Metadata { + if c == nil { + return nil + } + return c.Metadata +} + +func (c *Column) GetIndexedData() *IndexedData { + if c == nil { + return nil + } + return c.IndexedData +} + +func (c *Column) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *Column) UnmarshalJSON(data []byte) error { + type unmarshaler Column + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = Column(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + return nil +} + +func (c *Column) String() string { + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type DeleteResponse struct { + extraProperties map[string]interface{} +} + +func (d *DeleteResponse) GetExtraProperties() map[string]interface{} { + return d.extraProperties +} + +func (d *DeleteResponse) UnmarshalJSON(data []byte) error { + type unmarshaler DeleteResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DeleteResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *d) + if err != nil { + return err + } + d.extraProperties = extraProperties + + return nil +} + +func (d *DeleteResponse) String() string { + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DescribeResponse struct { + Namespaces map[string]*NamespaceSummary `json:"namespaces,omitempty" url:"namespaces,omitempty"` + Dimension *int `json:"dimension,omitempty" url:"dimension,omitempty"` + Fullness *float64 `json:"fullness,omitempty" url:"fullness,omitempty"` + TotalCount *int `json:"totalCount,omitempty" url:"totalCount,omitempty"` + + extraProperties map[string]interface{} +} + +func (d *DescribeResponse) GetNamespaces() map[string]*NamespaceSummary { + if d == nil { + return nil + } + return d.Namespaces +} + +func (d *DescribeResponse) GetDimension() *int { + if d == nil { + return nil + } + return d.Dimension +} + +func (d *DescribeResponse) GetFullness() *float64 { + if d == nil { + return nil + } + return d.Fullness +} + +func (d *DescribeResponse) GetTotalCount() *int { + if d == nil { + return nil + } + return d.TotalCount +} + +func (d *DescribeResponse) GetExtraProperties() map[string]interface{} { + return d.extraProperties +} + +func (d *DescribeResponse) UnmarshalJSON(data []byte) error { + type unmarshaler DescribeResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DescribeResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *d) + if err != nil { + return err + } + d.extraProperties = extraProperties + + return nil +} + +func (d *DescribeResponse) String() string { + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type FetchResponse struct { + Columns map[string]*Column `json:"columns,omitempty" url:"columns,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` + + extraProperties map[string]interface{} +} + +func (f *FetchResponse) GetColumns() map[string]*Column { + if f == nil { + return nil + } + return f.Columns +} + +func (f *FetchResponse) GetNamespace() *string { + if f == nil { + return nil + } + return f.Namespace +} + +func (f *FetchResponse) GetUsage() *Usage { + if f == nil { + return nil + } + return f.Usage +} + +func (f *FetchResponse) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *FetchResponse) UnmarshalJSON(data []byte) error { + type unmarshaler FetchResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = FetchResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + return nil +} + +func (f *FetchResponse) String() string { + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + +type IndexedData struct { + Indices []int `json:"indices,omitempty" url:"indices,omitempty"` + Values []float64 `json:"values,omitempty" url:"values,omitempty"` + + extraProperties map[string]interface{} +} + +func (i *IndexedData) GetIndices() []int { + if i == nil { + return nil + } + return i.Indices +} + +func (i *IndexedData) GetValues() []float64 { + if i == nil { + return nil + } + return i.Values +} + +func (i *IndexedData) GetExtraProperties() map[string]interface{} { + return i.extraProperties +} + +func (i *IndexedData) UnmarshalJSON(data []byte) error { + type unmarshaler IndexedData + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *i = IndexedData(value) + + extraProperties, err := core.ExtractExtraProperties(data, *i) + if err != nil { + return err + } + i.extraProperties = extraProperties + + return nil +} + +func (i *IndexedData) String() string { + if value, err := core.StringifyJSON(i); err == nil { + return value + } + return fmt.Sprintf("%#v", i) +} + +type ListElement struct { + Id *string `json:"id,omitempty" url:"id,omitempty"` + + extraProperties map[string]interface{} +} + +func (l *ListElement) GetId() *string { + if l == nil { + return nil + } + return l.Id +} + +func (l *ListElement) GetExtraProperties() map[string]interface{} { + return l.extraProperties +} + +func (l *ListElement) UnmarshalJSON(data []byte) error { + type unmarshaler ListElement + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *l = ListElement(value) + + extraProperties, err := core.ExtractExtraProperties(data, *l) + if err != nil { + return err + } + l.extraProperties = extraProperties + + return nil +} + +func (l *ListElement) String() string { + if value, err := core.StringifyJSON(l); err == nil { + return value + } + return fmt.Sprintf("%#v", l) +} + +type ListResponse struct { + Columns []*ListElement `json:"columns,omitempty" url:"columns,omitempty"` + Pagination *Pagination `json:"pagination,omitempty" url:"pagination,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` + + extraProperties map[string]interface{} +} + +func (l *ListResponse) GetColumns() []*ListElement { + if l == nil { + return nil + } + return l.Columns +} + +func (l *ListResponse) GetPagination() *Pagination { + if l == nil { + return nil + } + return l.Pagination +} + +func (l *ListResponse) GetNamespace() *string { + if l == nil { + return nil + } + return l.Namespace +} + +func (l *ListResponse) GetUsage() *Usage { + if l == nil { + return nil + } + return l.Usage +} + +func (l *ListResponse) GetExtraProperties() map[string]interface{} { + return l.extraProperties +} + +func (l *ListResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ListResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *l = ListResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *l) + if err != nil { + return err + } + l.extraProperties = extraProperties + + return nil +} + +func (l *ListResponse) String() string { + if value, err := core.StringifyJSON(l); err == nil { + return value + } + return fmt.Sprintf("%#v", l) +} + +type Metadata struct { + StringMetadataValueMap map[string]*MetadataValue + StringUnknownMap map[string]interface{} + + typ string +} + +func NewMetadataFromStringMetadataValueMap(value map[string]*MetadataValue) *Metadata { + return &Metadata{typ: "StringMetadataValueMap", StringMetadataValueMap: value} +} + +func NewMetadataFromStringUnknownMap(value map[string]interface{}) *Metadata { + return &Metadata{typ: "StringUnknownMap", StringUnknownMap: value} +} + +func (m *Metadata) GetStringMetadataValueMap() map[string]*MetadataValue { + if m == nil { + return nil + } + return m.StringMetadataValueMap +} + +func (m *Metadata) GetStringUnknownMap() map[string]interface{} { + if m == nil { + return nil + } + return m.StringUnknownMap +} + +func (m *Metadata) UnmarshalJSON(data []byte) error { + var valueStringMetadataValueMap map[string]*MetadataValue + if err := json.Unmarshal(data, &valueStringMetadataValueMap); err == nil { + m.typ = "StringMetadataValueMap" + m.StringMetadataValueMap = valueStringMetadataValueMap + return nil + } + var valueStringUnknownMap map[string]interface{} + if err := json.Unmarshal(data, &valueStringUnknownMap); err == nil { + m.typ = "StringUnknownMap" + m.StringUnknownMap = valueStringUnknownMap + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, m) +} + +func (m Metadata) MarshalJSON() ([]byte, error) { + if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { + return json.Marshal(m.StringMetadataValueMap) + } + if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { + return json.Marshal(m.StringUnknownMap) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataVisitor interface { + VisitStringMetadataValueMap(map[string]*MetadataValue) error + VisitStringUnknownMap(map[string]interface{}) error +} + +func (m *Metadata) Accept(visitor MetadataVisitor) error { + if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { + return visitor.VisitStringMetadataValueMap(m.StringMetadataValueMap) + } + if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { + return visitor.VisitStringUnknownMap(m.StringUnknownMap) + } + return fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataValue struct { + Double float64 + String string + Boolean bool + + typ string +} + +func NewMetadataValueFromDouble(value float64) *MetadataValue { + return &MetadataValue{typ: "Double", Double: value} +} + +func NewMetadataValueFromString(value string) *MetadataValue { + return &MetadataValue{typ: "String", String: value} +} + +func NewMetadataValueFromBoolean(value bool) *MetadataValue { + return &MetadataValue{typ: "Boolean", Boolean: value} +} + +func (m *MetadataValue) GetDouble() float64 { + if m == nil { + return 0 + } + return m.Double +} + +func (m *MetadataValue) GetString() string { + if m == nil { + return "" + } + return m.String +} + +func (m *MetadataValue) GetBoolean() bool { + if m == nil { + return false + } + return m.Boolean +} + +func (m *MetadataValue) UnmarshalJSON(data []byte) error { + var valueDouble float64 + if err := json.Unmarshal(data, &valueDouble); err == nil { + m.typ = "Double" + m.Double = valueDouble + return nil + } + var valueString string + if err := json.Unmarshal(data, &valueString); err == nil { + m.typ = "String" + m.String = valueString + return nil + } + var valueBoolean bool + if err := json.Unmarshal(data, &valueBoolean); err == nil { + m.typ = "Boolean" + m.Boolean = valueBoolean + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, m) +} + +func (m MetadataValue) MarshalJSON() ([]byte, error) { + if m.typ == "Double" || m.Double != 0 { + return json.Marshal(m.Double) + } + if m.typ == "String" || m.String != "" { + return json.Marshal(m.String) + } + if m.typ == "Boolean" || m.Boolean != false { + return json.Marshal(m.Boolean) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataValueVisitor interface { + VisitDouble(float64) error + VisitString(string) error + VisitBoolean(bool) error +} + +func (m *MetadataValue) Accept(visitor MetadataValueVisitor) error { + if m.typ == "Double" || m.Double != 0 { + return visitor.VisitDouble(m.Double) + } + if m.typ == "String" || m.String != "" { + return visitor.VisitString(m.String) + } + if m.typ == "Boolean" || m.Boolean != false { + return visitor.VisitBoolean(m.Boolean) + } + return fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type NamespaceSummary struct { + Count *int `json:"count,omitempty" url:"count,omitempty"` + + extraProperties map[string]interface{} +} + +func (n *NamespaceSummary) GetCount() *int { + if n == nil { + return nil + } + return n.Count +} + +func (n *NamespaceSummary) GetExtraProperties() map[string]interface{} { + return n.extraProperties +} + +func (n *NamespaceSummary) UnmarshalJSON(data []byte) error { + type unmarshaler NamespaceSummary + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NamespaceSummary(value) + + extraProperties, err := core.ExtractExtraProperties(data, *n) + if err != nil { + return err + } + n.extraProperties = extraProperties + + return nil +} + +func (n *NamespaceSummary) String() string { + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + +type Pagination struct { + Next *string `json:"next,omitempty" url:"next,omitempty"` + + extraProperties map[string]interface{} +} + +func (p *Pagination) GetNext() *string { + if p == nil { + return nil + } + return p.Next +} + +func (p *Pagination) GetExtraProperties() map[string]interface{} { + return p.extraProperties +} + +func (p *Pagination) UnmarshalJSON(data []byte) error { + type unmarshaler Pagination + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = Pagination(value) + + extraProperties, err := core.ExtractExtraProperties(data, *p) + if err != nil { + return err + } + p.extraProperties = extraProperties + + return nil +} + +func (p *Pagination) String() string { + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type QueryColumn struct { + Values []float64 `json:"values,omitempty" url:"values,omitempty"` + TopK *int `json:"topK,omitempty" url:"topK,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + Filter *Metadata `json:"filter,omitempty" url:"filter,omitempty"` + IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` + + extraProperties map[string]interface{} +} + +func (q *QueryColumn) GetValues() []float64 { + if q == nil { + return nil + } + return q.Values +} + +func (q *QueryColumn) GetTopK() *int { + if q == nil { + return nil + } + return q.TopK +} + +func (q *QueryColumn) GetNamespace() *string { + if q == nil { + return nil + } + return q.Namespace +} + +func (q *QueryColumn) GetFilter() *Metadata { + if q == nil { + return nil + } + return q.Filter +} + +func (q *QueryColumn) GetIndexedData() *IndexedData { + if q == nil { + return nil + } + return q.IndexedData +} + +func (q *QueryColumn) GetExtraProperties() map[string]interface{} { + return q.extraProperties +} + +func (q *QueryColumn) UnmarshalJSON(data []byte) error { + type unmarshaler QueryColumn + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *q = QueryColumn(value) + + extraProperties, err := core.ExtractExtraProperties(data, *q) + if err != nil { + return err + } + q.extraProperties = extraProperties + + return nil +} + +func (q *QueryColumn) String() string { + if value, err := core.StringifyJSON(q); err == nil { + return value + } + return fmt.Sprintf("%#v", q) +} + +type QueryResponse struct { + Results []*QueryResult `json:"results,omitempty" url:"results,omitempty"` + Matches []*ScoredColumn `json:"matches,omitempty" url:"matches,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` + + extraProperties map[string]interface{} +} + +func (q *QueryResponse) GetResults() []*QueryResult { + if q == nil { + return nil + } + return q.Results +} + +func (q *QueryResponse) GetMatches() []*ScoredColumn { + if q == nil { + return nil + } + return q.Matches +} + +func (q *QueryResponse) GetNamespace() *string { + if q == nil { + return nil + } + return q.Namespace +} + +func (q *QueryResponse) GetUsage() *Usage { + if q == nil { + return nil + } + return q.Usage +} + +func (q *QueryResponse) GetExtraProperties() map[string]interface{} { + return q.extraProperties +} + +func (q *QueryResponse) UnmarshalJSON(data []byte) error { + type unmarshaler QueryResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *q = QueryResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *q) + if err != nil { + return err + } + q.extraProperties = extraProperties + + return nil +} + +func (q *QueryResponse) String() string { + if value, err := core.StringifyJSON(q); err == nil { + return value + } + return fmt.Sprintf("%#v", q) +} + +type QueryResult struct { + Matches []*ScoredColumn `json:"matches,omitempty" url:"matches,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + + extraProperties map[string]interface{} +} + +func (q *QueryResult) GetMatches() []*ScoredColumn { + if q == nil { + return nil + } + return q.Matches +} + +func (q *QueryResult) GetNamespace() *string { + if q == nil { + return nil + } + return q.Namespace +} + +func (q *QueryResult) GetExtraProperties() map[string]interface{} { + return q.extraProperties +} + +func (q *QueryResult) UnmarshalJSON(data []byte) error { + type unmarshaler QueryResult + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *q = QueryResult(value) + + extraProperties, err := core.ExtractExtraProperties(data, *q) + if err != nil { + return err + } + q.extraProperties = extraProperties + + return nil +} + +func (q *QueryResult) String() string { + if value, err := core.StringifyJSON(q); err == nil { + return value + } + return fmt.Sprintf("%#v", q) +} + +type ScoredColumn struct { + Id string `json:"id" url:"id"` + Score *float64 `json:"score,omitempty" url:"score,omitempty"` + Values []float64 `json:"values,omitempty" url:"values,omitempty"` + Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` + IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` + + extraProperties map[string]interface{} +} + +func (s *ScoredColumn) GetId() string { + if s == nil { + return "" + } + return s.Id +} + +func (s *ScoredColumn) GetScore() *float64 { + if s == nil { + return nil + } + return s.Score +} + +func (s *ScoredColumn) GetValues() []float64 { + if s == nil { + return nil + } + return s.Values +} + +func (s *ScoredColumn) GetMetadata() *Metadata { + if s == nil { + return nil + } + return s.Metadata +} + +func (s *ScoredColumn) GetIndexedData() *IndexedData { + if s == nil { + return nil + } + return s.IndexedData +} + +func (s *ScoredColumn) GetExtraProperties() map[string]interface{} { + return s.extraProperties +} + +func (s *ScoredColumn) UnmarshalJSON(data []byte) error { + type unmarshaler ScoredColumn + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = ScoredColumn(value) + + extraProperties, err := core.ExtractExtraProperties(data, *s) + if err != nil { + return err + } + s.extraProperties = extraProperties + + return nil +} + +func (s *ScoredColumn) String() string { + if value, err := core.StringifyJSON(s); err == nil { + return value + } + return fmt.Sprintf("%#v", s) +} + +type UpdateResponse struct { + extraProperties map[string]interface{} +} + +func (u *UpdateResponse) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UpdateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UpdateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UpdateResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UpdateResponse) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UploadResponse struct { + Count *int `json:"count,omitempty" url:"count,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *UploadResponse) GetCount() *int { + if u == nil { + return nil + } + return u.Count +} + +func (u *UploadResponse) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UploadResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UploadResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UploadResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UploadResponse) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type Usage struct { + Units *int `json:"units,omitempty" url:"units,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *Usage) GetUnits() *int { + if u == nil { + return nil + } + return u.Units +} + +func (u *Usage) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *Usage) UnmarshalJSON(data []byte) error { + type unmarshaler Usage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = Usage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *Usage) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} diff --git a/seed/go-model/grpc-proto-exhaustive/types.go b/seed/go-model/grpc-proto-exhaustive/types.go deleted file mode 100644 index 734c14d770d..00000000000 --- a/seed/go-model/grpc-proto-exhaustive/types.go +++ /dev/null @@ -1,1004 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/grpc-proto-exhaustive/fern/core" -) - -type Column struct { - Id string `json:"id" url:"id"` - Values []float64 `json:"values,omitempty" url:"values,omitempty"` - Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` - IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` - - extraProperties map[string]interface{} -} - -func (c *Column) GetId() string { - if c == nil { - return "" - } - return c.Id -} - -func (c *Column) GetValues() []float64 { - if c == nil { - return nil - } - return c.Values -} - -func (c *Column) GetMetadata() *Metadata { - if c == nil { - return nil - } - return c.Metadata -} - -func (c *Column) GetIndexedData() *IndexedData { - if c == nil { - return nil - } - return c.IndexedData -} - -func (c *Column) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *Column) UnmarshalJSON(data []byte) error { - type unmarshaler Column - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = Column(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - return nil -} - -func (c *Column) String() string { - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type DeleteResponse struct { - extraProperties map[string]interface{} -} - -func (d *DeleteResponse) GetExtraProperties() map[string]interface{} { - return d.extraProperties -} - -func (d *DeleteResponse) UnmarshalJSON(data []byte) error { - type unmarshaler DeleteResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *d = DeleteResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *d) - if err != nil { - return err - } - d.extraProperties = extraProperties - - return nil -} - -func (d *DeleteResponse) String() string { - if value, err := core.StringifyJSON(d); err == nil { - return value - } - return fmt.Sprintf("%#v", d) -} - -type DescribeResponse struct { - Namespaces map[string]*NamespaceSummary `json:"namespaces,omitempty" url:"namespaces,omitempty"` - Dimension *int `json:"dimension,omitempty" url:"dimension,omitempty"` - Fullness *float64 `json:"fullness,omitempty" url:"fullness,omitempty"` - TotalCount *int `json:"totalCount,omitempty" url:"totalCount,omitempty"` - - extraProperties map[string]interface{} -} - -func (d *DescribeResponse) GetNamespaces() map[string]*NamespaceSummary { - if d == nil { - return nil - } - return d.Namespaces -} - -func (d *DescribeResponse) GetDimension() *int { - if d == nil { - return nil - } - return d.Dimension -} - -func (d *DescribeResponse) GetFullness() *float64 { - if d == nil { - return nil - } - return d.Fullness -} - -func (d *DescribeResponse) GetTotalCount() *int { - if d == nil { - return nil - } - return d.TotalCount -} - -func (d *DescribeResponse) GetExtraProperties() map[string]interface{} { - return d.extraProperties -} - -func (d *DescribeResponse) UnmarshalJSON(data []byte) error { - type unmarshaler DescribeResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *d = DescribeResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *d) - if err != nil { - return err - } - d.extraProperties = extraProperties - - return nil -} - -func (d *DescribeResponse) String() string { - if value, err := core.StringifyJSON(d); err == nil { - return value - } - return fmt.Sprintf("%#v", d) -} - -type FetchResponse struct { - Columns map[string]*Column `json:"columns,omitempty" url:"columns,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` - - extraProperties map[string]interface{} -} - -func (f *FetchResponse) GetColumns() map[string]*Column { - if f == nil { - return nil - } - return f.Columns -} - -func (f *FetchResponse) GetNamespace() *string { - if f == nil { - return nil - } - return f.Namespace -} - -func (f *FetchResponse) GetUsage() *Usage { - if f == nil { - return nil - } - return f.Usage -} - -func (f *FetchResponse) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *FetchResponse) UnmarshalJSON(data []byte) error { - type unmarshaler FetchResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = FetchResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - return nil -} - -func (f *FetchResponse) String() string { - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} - -type IndexedData struct { - Indices []int `json:"indices,omitempty" url:"indices,omitempty"` - Values []float64 `json:"values,omitempty" url:"values,omitempty"` - - extraProperties map[string]interface{} -} - -func (i *IndexedData) GetIndices() []int { - if i == nil { - return nil - } - return i.Indices -} - -func (i *IndexedData) GetValues() []float64 { - if i == nil { - return nil - } - return i.Values -} - -func (i *IndexedData) GetExtraProperties() map[string]interface{} { - return i.extraProperties -} - -func (i *IndexedData) UnmarshalJSON(data []byte) error { - type unmarshaler IndexedData - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *i = IndexedData(value) - - extraProperties, err := core.ExtractExtraProperties(data, *i) - if err != nil { - return err - } - i.extraProperties = extraProperties - - return nil -} - -func (i *IndexedData) String() string { - if value, err := core.StringifyJSON(i); err == nil { - return value - } - return fmt.Sprintf("%#v", i) -} - -type ListElement struct { - Id *string `json:"id,omitempty" url:"id,omitempty"` - - extraProperties map[string]interface{} -} - -func (l *ListElement) GetId() *string { - if l == nil { - return nil - } - return l.Id -} - -func (l *ListElement) GetExtraProperties() map[string]interface{} { - return l.extraProperties -} - -func (l *ListElement) UnmarshalJSON(data []byte) error { - type unmarshaler ListElement - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *l = ListElement(value) - - extraProperties, err := core.ExtractExtraProperties(data, *l) - if err != nil { - return err - } - l.extraProperties = extraProperties - - return nil -} - -func (l *ListElement) String() string { - if value, err := core.StringifyJSON(l); err == nil { - return value - } - return fmt.Sprintf("%#v", l) -} - -type ListResponse struct { - Columns []*ListElement `json:"columns,omitempty" url:"columns,omitempty"` - Pagination *Pagination `json:"pagination,omitempty" url:"pagination,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` - - extraProperties map[string]interface{} -} - -func (l *ListResponse) GetColumns() []*ListElement { - if l == nil { - return nil - } - return l.Columns -} - -func (l *ListResponse) GetPagination() *Pagination { - if l == nil { - return nil - } - return l.Pagination -} - -func (l *ListResponse) GetNamespace() *string { - if l == nil { - return nil - } - return l.Namespace -} - -func (l *ListResponse) GetUsage() *Usage { - if l == nil { - return nil - } - return l.Usage -} - -func (l *ListResponse) GetExtraProperties() map[string]interface{} { - return l.extraProperties -} - -func (l *ListResponse) UnmarshalJSON(data []byte) error { - type unmarshaler ListResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *l = ListResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *l) - if err != nil { - return err - } - l.extraProperties = extraProperties - - return nil -} - -func (l *ListResponse) String() string { - if value, err := core.StringifyJSON(l); err == nil { - return value - } - return fmt.Sprintf("%#v", l) -} - -type Metadata struct { - StringMetadataValueMap map[string]*MetadataValue - StringUnknownMap map[string]interface{} - - typ string -} - -func NewMetadataFromStringMetadataValueMap(value map[string]*MetadataValue) *Metadata { - return &Metadata{typ: "StringMetadataValueMap", StringMetadataValueMap: value} -} - -func NewMetadataFromStringUnknownMap(value map[string]interface{}) *Metadata { - return &Metadata{typ: "StringUnknownMap", StringUnknownMap: value} -} - -func (m *Metadata) GetStringMetadataValueMap() map[string]*MetadataValue { - if m == nil { - return nil - } - return m.StringMetadataValueMap -} - -func (m *Metadata) GetStringUnknownMap() map[string]interface{} { - if m == nil { - return nil - } - return m.StringUnknownMap -} - -func (m *Metadata) UnmarshalJSON(data []byte) error { - var valueStringMetadataValueMap map[string]*MetadataValue - if err := json.Unmarshal(data, &valueStringMetadataValueMap); err == nil { - m.typ = "StringMetadataValueMap" - m.StringMetadataValueMap = valueStringMetadataValueMap - return nil - } - var valueStringUnknownMap map[string]interface{} - if err := json.Unmarshal(data, &valueStringUnknownMap); err == nil { - m.typ = "StringUnknownMap" - m.StringUnknownMap = valueStringUnknownMap - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, m) -} - -func (m Metadata) MarshalJSON() ([]byte, error) { - if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { - return json.Marshal(m.StringMetadataValueMap) - } - if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { - return json.Marshal(m.StringUnknownMap) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataVisitor interface { - VisitStringMetadataValueMap(map[string]*MetadataValue) error - VisitStringUnknownMap(map[string]interface{}) error -} - -func (m *Metadata) Accept(visitor MetadataVisitor) error { - if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { - return visitor.VisitStringMetadataValueMap(m.StringMetadataValueMap) - } - if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { - return visitor.VisitStringUnknownMap(m.StringUnknownMap) - } - return fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataValue struct { - Double float64 - String string - Boolean bool - - typ string -} - -func NewMetadataValueFromDouble(value float64) *MetadataValue { - return &MetadataValue{typ: "Double", Double: value} -} - -func NewMetadataValueFromString(value string) *MetadataValue { - return &MetadataValue{typ: "String", String: value} -} - -func NewMetadataValueFromBoolean(value bool) *MetadataValue { - return &MetadataValue{typ: "Boolean", Boolean: value} -} - -func (m *MetadataValue) GetDouble() float64 { - if m == nil { - return 0 - } - return m.Double -} - -func (m *MetadataValue) GetString() string { - if m == nil { - return "" - } - return m.String -} - -func (m *MetadataValue) GetBoolean() bool { - if m == nil { - return false - } - return m.Boolean -} - -func (m *MetadataValue) UnmarshalJSON(data []byte) error { - var valueDouble float64 - if err := json.Unmarshal(data, &valueDouble); err == nil { - m.typ = "Double" - m.Double = valueDouble - return nil - } - var valueString string - if err := json.Unmarshal(data, &valueString); err == nil { - m.typ = "String" - m.String = valueString - return nil - } - var valueBoolean bool - if err := json.Unmarshal(data, &valueBoolean); err == nil { - m.typ = "Boolean" - m.Boolean = valueBoolean - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, m) -} - -func (m MetadataValue) MarshalJSON() ([]byte, error) { - if m.typ == "Double" || m.Double != 0 { - return json.Marshal(m.Double) - } - if m.typ == "String" || m.String != "" { - return json.Marshal(m.String) - } - if m.typ == "Boolean" || m.Boolean != false { - return json.Marshal(m.Boolean) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataValueVisitor interface { - VisitDouble(float64) error - VisitString(string) error - VisitBoolean(bool) error -} - -func (m *MetadataValue) Accept(visitor MetadataValueVisitor) error { - if m.typ == "Double" || m.Double != 0 { - return visitor.VisitDouble(m.Double) - } - if m.typ == "String" || m.String != "" { - return visitor.VisitString(m.String) - } - if m.typ == "Boolean" || m.Boolean != false { - return visitor.VisitBoolean(m.Boolean) - } - return fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type NamespaceSummary struct { - Count *int `json:"count,omitempty" url:"count,omitempty"` - - extraProperties map[string]interface{} -} - -func (n *NamespaceSummary) GetCount() *int { - if n == nil { - return nil - } - return n.Count -} - -func (n *NamespaceSummary) GetExtraProperties() map[string]interface{} { - return n.extraProperties -} - -func (n *NamespaceSummary) UnmarshalJSON(data []byte) error { - type unmarshaler NamespaceSummary - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *n = NamespaceSummary(value) - - extraProperties, err := core.ExtractExtraProperties(data, *n) - if err != nil { - return err - } - n.extraProperties = extraProperties - - return nil -} - -func (n *NamespaceSummary) String() string { - if value, err := core.StringifyJSON(n); err == nil { - return value - } - return fmt.Sprintf("%#v", n) -} - -type Pagination struct { - Next *string `json:"next,omitempty" url:"next,omitempty"` - - extraProperties map[string]interface{} -} - -func (p *Pagination) GetNext() *string { - if p == nil { - return nil - } - return p.Next -} - -func (p *Pagination) GetExtraProperties() map[string]interface{} { - return p.extraProperties -} - -func (p *Pagination) UnmarshalJSON(data []byte) error { - type unmarshaler Pagination - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *p = Pagination(value) - - extraProperties, err := core.ExtractExtraProperties(data, *p) - if err != nil { - return err - } - p.extraProperties = extraProperties - - return nil -} - -func (p *Pagination) String() string { - if value, err := core.StringifyJSON(p); err == nil { - return value - } - return fmt.Sprintf("%#v", p) -} - -type QueryColumn struct { - Values []float64 `json:"values,omitempty" url:"values,omitempty"` - TopK *int `json:"topK,omitempty" url:"topK,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - Filter *Metadata `json:"filter,omitempty" url:"filter,omitempty"` - IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` - - extraProperties map[string]interface{} -} - -func (q *QueryColumn) GetValues() []float64 { - if q == nil { - return nil - } - return q.Values -} - -func (q *QueryColumn) GetTopK() *int { - if q == nil { - return nil - } - return q.TopK -} - -func (q *QueryColumn) GetNamespace() *string { - if q == nil { - return nil - } - return q.Namespace -} - -func (q *QueryColumn) GetFilter() *Metadata { - if q == nil { - return nil - } - return q.Filter -} - -func (q *QueryColumn) GetIndexedData() *IndexedData { - if q == nil { - return nil - } - return q.IndexedData -} - -func (q *QueryColumn) GetExtraProperties() map[string]interface{} { - return q.extraProperties -} - -func (q *QueryColumn) UnmarshalJSON(data []byte) error { - type unmarshaler QueryColumn - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *q = QueryColumn(value) - - extraProperties, err := core.ExtractExtraProperties(data, *q) - if err != nil { - return err - } - q.extraProperties = extraProperties - - return nil -} - -func (q *QueryColumn) String() string { - if value, err := core.StringifyJSON(q); err == nil { - return value - } - return fmt.Sprintf("%#v", q) -} - -type QueryResponse struct { - Results []*QueryResult `json:"results,omitempty" url:"results,omitempty"` - Matches []*ScoredColumn `json:"matches,omitempty" url:"matches,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` - - extraProperties map[string]interface{} -} - -func (q *QueryResponse) GetResults() []*QueryResult { - if q == nil { - return nil - } - return q.Results -} - -func (q *QueryResponse) GetMatches() []*ScoredColumn { - if q == nil { - return nil - } - return q.Matches -} - -func (q *QueryResponse) GetNamespace() *string { - if q == nil { - return nil - } - return q.Namespace -} - -func (q *QueryResponse) GetUsage() *Usage { - if q == nil { - return nil - } - return q.Usage -} - -func (q *QueryResponse) GetExtraProperties() map[string]interface{} { - return q.extraProperties -} - -func (q *QueryResponse) UnmarshalJSON(data []byte) error { - type unmarshaler QueryResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *q = QueryResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *q) - if err != nil { - return err - } - q.extraProperties = extraProperties - - return nil -} - -func (q *QueryResponse) String() string { - if value, err := core.StringifyJSON(q); err == nil { - return value - } - return fmt.Sprintf("%#v", q) -} - -type QueryResult struct { - Matches []*ScoredColumn `json:"matches,omitempty" url:"matches,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - - extraProperties map[string]interface{} -} - -func (q *QueryResult) GetMatches() []*ScoredColumn { - if q == nil { - return nil - } - return q.Matches -} - -func (q *QueryResult) GetNamespace() *string { - if q == nil { - return nil - } - return q.Namespace -} - -func (q *QueryResult) GetExtraProperties() map[string]interface{} { - return q.extraProperties -} - -func (q *QueryResult) UnmarshalJSON(data []byte) error { - type unmarshaler QueryResult - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *q = QueryResult(value) - - extraProperties, err := core.ExtractExtraProperties(data, *q) - if err != nil { - return err - } - q.extraProperties = extraProperties - - return nil -} - -func (q *QueryResult) String() string { - if value, err := core.StringifyJSON(q); err == nil { - return value - } - return fmt.Sprintf("%#v", q) -} - -type ScoredColumn struct { - Id string `json:"id" url:"id"` - Score *float64 `json:"score,omitempty" url:"score,omitempty"` - Values []float64 `json:"values,omitempty" url:"values,omitempty"` - Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` - IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` - - extraProperties map[string]interface{} -} - -func (s *ScoredColumn) GetId() string { - if s == nil { - return "" - } - return s.Id -} - -func (s *ScoredColumn) GetScore() *float64 { - if s == nil { - return nil - } - return s.Score -} - -func (s *ScoredColumn) GetValues() []float64 { - if s == nil { - return nil - } - return s.Values -} - -func (s *ScoredColumn) GetMetadata() *Metadata { - if s == nil { - return nil - } - return s.Metadata -} - -func (s *ScoredColumn) GetIndexedData() *IndexedData { - if s == nil { - return nil - } - return s.IndexedData -} - -func (s *ScoredColumn) GetExtraProperties() map[string]interface{} { - return s.extraProperties -} - -func (s *ScoredColumn) UnmarshalJSON(data []byte) error { - type unmarshaler ScoredColumn - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = ScoredColumn(value) - - extraProperties, err := core.ExtractExtraProperties(data, *s) - if err != nil { - return err - } - s.extraProperties = extraProperties - - return nil -} - -func (s *ScoredColumn) String() string { - if value, err := core.StringifyJSON(s); err == nil { - return value - } - return fmt.Sprintf("%#v", s) -} - -type UpdateResponse struct { - extraProperties map[string]interface{} -} - -func (u *UpdateResponse) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UpdateResponse) UnmarshalJSON(data []byte) error { - type unmarshaler UpdateResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UpdateResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UpdateResponse) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UploadResponse struct { - Count *int `json:"count,omitempty" url:"count,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *UploadResponse) GetCount() *int { - if u == nil { - return nil - } - return u.Count -} - -func (u *UploadResponse) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UploadResponse) UnmarshalJSON(data []byte) error { - type unmarshaler UploadResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UploadResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UploadResponse) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type Usage struct { - Units *int `json:"units,omitempty" url:"units,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *Usage) GetUnits() *int { - if u == nil { - return nil - } - return u.Units -} - -func (u *Usage) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *Usage) UnmarshalJSON(data []byte) error { - type unmarshaler Usage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = Usage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *Usage) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/seed/go-model/grpc-proto/types.go b/seed/go-model/grpc-proto/types.go deleted file mode 100644 index 76dca4cb5d4..00000000000 --- a/seed/go-model/grpc-proto/types.go +++ /dev/null @@ -1,288 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/grpc-proto/fern/core" -) - -type CreateResponse struct { - User *UserModel `json:"user,omitempty" url:"user,omitempty"` - - extraProperties map[string]interface{} -} - -func (c *CreateResponse) GetUser() *UserModel { - if c == nil { - return nil - } - return c.User -} - -func (c *CreateResponse) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *CreateResponse) UnmarshalJSON(data []byte) error { - type unmarshaler CreateResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = CreateResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - return nil -} - -func (c *CreateResponse) String() string { - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type Metadata struct { - StringMetadataValueMap map[string]*MetadataValue - StringUnknownMap map[string]interface{} - - typ string -} - -func NewMetadataFromStringMetadataValueMap(value map[string]*MetadataValue) *Metadata { - return &Metadata{typ: "StringMetadataValueMap", StringMetadataValueMap: value} -} - -func NewMetadataFromStringUnknownMap(value map[string]interface{}) *Metadata { - return &Metadata{typ: "StringUnknownMap", StringUnknownMap: value} -} - -func (m *Metadata) GetStringMetadataValueMap() map[string]*MetadataValue { - if m == nil { - return nil - } - return m.StringMetadataValueMap -} - -func (m *Metadata) GetStringUnknownMap() map[string]interface{} { - if m == nil { - return nil - } - return m.StringUnknownMap -} - -func (m *Metadata) UnmarshalJSON(data []byte) error { - var valueStringMetadataValueMap map[string]*MetadataValue - if err := json.Unmarshal(data, &valueStringMetadataValueMap); err == nil { - m.typ = "StringMetadataValueMap" - m.StringMetadataValueMap = valueStringMetadataValueMap - return nil - } - var valueStringUnknownMap map[string]interface{} - if err := json.Unmarshal(data, &valueStringUnknownMap); err == nil { - m.typ = "StringUnknownMap" - m.StringUnknownMap = valueStringUnknownMap - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, m) -} - -func (m Metadata) MarshalJSON() ([]byte, error) { - if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { - return json.Marshal(m.StringMetadataValueMap) - } - if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { - return json.Marshal(m.StringUnknownMap) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataVisitor interface { - VisitStringMetadataValueMap(map[string]*MetadataValue) error - VisitStringUnknownMap(map[string]interface{}) error -} - -func (m *Metadata) Accept(visitor MetadataVisitor) error { - if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { - return visitor.VisitStringMetadataValueMap(m.StringMetadataValueMap) - } - if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { - return visitor.VisitStringUnknownMap(m.StringUnknownMap) - } - return fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataValue struct { - Double float64 - String string - Boolean bool - - typ string -} - -func NewMetadataValueFromDouble(value float64) *MetadataValue { - return &MetadataValue{typ: "Double", Double: value} -} - -func NewMetadataValueFromString(value string) *MetadataValue { - return &MetadataValue{typ: "String", String: value} -} - -func NewMetadataValueFromBoolean(value bool) *MetadataValue { - return &MetadataValue{typ: "Boolean", Boolean: value} -} - -func (m *MetadataValue) GetDouble() float64 { - if m == nil { - return 0 - } - return m.Double -} - -func (m *MetadataValue) GetString() string { - if m == nil { - return "" - } - return m.String -} - -func (m *MetadataValue) GetBoolean() bool { - if m == nil { - return false - } - return m.Boolean -} - -func (m *MetadataValue) UnmarshalJSON(data []byte) error { - var valueDouble float64 - if err := json.Unmarshal(data, &valueDouble); err == nil { - m.typ = "Double" - m.Double = valueDouble - return nil - } - var valueString string - if err := json.Unmarshal(data, &valueString); err == nil { - m.typ = "String" - m.String = valueString - return nil - } - var valueBoolean bool - if err := json.Unmarshal(data, &valueBoolean); err == nil { - m.typ = "Boolean" - m.Boolean = valueBoolean - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, m) -} - -func (m MetadataValue) MarshalJSON() ([]byte, error) { - if m.typ == "Double" || m.Double != 0 { - return json.Marshal(m.Double) - } - if m.typ == "String" || m.String != "" { - return json.Marshal(m.String) - } - if m.typ == "Boolean" || m.Boolean != false { - return json.Marshal(m.Boolean) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataValueVisitor interface { - VisitDouble(float64) error - VisitString(string) error - VisitBoolean(bool) error -} - -func (m *MetadataValue) Accept(visitor MetadataValueVisitor) error { - if m.typ == "Double" || m.Double != 0 { - return visitor.VisitDouble(m.Double) - } - if m.typ == "String" || m.String != "" { - return visitor.VisitString(m.String) - } - if m.typ == "Boolean" || m.Boolean != false { - return visitor.VisitBoolean(m.Boolean) - } - return fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type UserModel struct { - Username *string `json:"username,omitempty" url:"username,omitempty"` - Email *string `json:"email,omitempty" url:"email,omitempty"` - Age *int `json:"age,omitempty" url:"age,omitempty"` - Weight *float64 `json:"weight,omitempty" url:"weight,omitempty"` - Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *UserModel) GetUsername() *string { - if u == nil { - return nil - } - return u.Username -} - -func (u *UserModel) GetEmail() *string { - if u == nil { - return nil - } - return u.Email -} - -func (u *UserModel) GetAge() *int { - if u == nil { - return nil - } - return u.Age -} - -func (u *UserModel) GetWeight() *float64 { - if u == nil { - return nil - } - return u.Weight -} - -func (u *UserModel) GetMetadata() *Metadata { - if u == nil { - return nil - } - return u.Metadata -} - -func (u *UserModel) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserModel) UnmarshalJSON(data []byte) error { - type unmarshaler UserModel - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserModel(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UserModel) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/seed/go-model/grpc-proto/userservice.go b/seed/go-model/grpc-proto/userservice.go index 884eed6ba61..76dca4cb5d4 100644 --- a/seed/go-model/grpc-proto/userservice.go +++ b/seed/go-model/grpc-proto/userservice.go @@ -1,3 +1,288 @@ // This file was auto-generated by Fern from our API Definition. package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/grpc-proto/fern/core" +) + +type CreateResponse struct { + User *UserModel `json:"user,omitempty" url:"user,omitempty"` + + extraProperties map[string]interface{} +} + +func (c *CreateResponse) GetUser() *UserModel { + if c == nil { + return nil + } + return c.User +} + +func (c *CreateResponse) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *CreateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler CreateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = CreateResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + return nil +} + +func (c *CreateResponse) String() string { + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type Metadata struct { + StringMetadataValueMap map[string]*MetadataValue + StringUnknownMap map[string]interface{} + + typ string +} + +func NewMetadataFromStringMetadataValueMap(value map[string]*MetadataValue) *Metadata { + return &Metadata{typ: "StringMetadataValueMap", StringMetadataValueMap: value} +} + +func NewMetadataFromStringUnknownMap(value map[string]interface{}) *Metadata { + return &Metadata{typ: "StringUnknownMap", StringUnknownMap: value} +} + +func (m *Metadata) GetStringMetadataValueMap() map[string]*MetadataValue { + if m == nil { + return nil + } + return m.StringMetadataValueMap +} + +func (m *Metadata) GetStringUnknownMap() map[string]interface{} { + if m == nil { + return nil + } + return m.StringUnknownMap +} + +func (m *Metadata) UnmarshalJSON(data []byte) error { + var valueStringMetadataValueMap map[string]*MetadataValue + if err := json.Unmarshal(data, &valueStringMetadataValueMap); err == nil { + m.typ = "StringMetadataValueMap" + m.StringMetadataValueMap = valueStringMetadataValueMap + return nil + } + var valueStringUnknownMap map[string]interface{} + if err := json.Unmarshal(data, &valueStringUnknownMap); err == nil { + m.typ = "StringUnknownMap" + m.StringUnknownMap = valueStringUnknownMap + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, m) +} + +func (m Metadata) MarshalJSON() ([]byte, error) { + if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { + return json.Marshal(m.StringMetadataValueMap) + } + if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { + return json.Marshal(m.StringUnknownMap) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataVisitor interface { + VisitStringMetadataValueMap(map[string]*MetadataValue) error + VisitStringUnknownMap(map[string]interface{}) error +} + +func (m *Metadata) Accept(visitor MetadataVisitor) error { + if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { + return visitor.VisitStringMetadataValueMap(m.StringMetadataValueMap) + } + if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { + return visitor.VisitStringUnknownMap(m.StringUnknownMap) + } + return fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataValue struct { + Double float64 + String string + Boolean bool + + typ string +} + +func NewMetadataValueFromDouble(value float64) *MetadataValue { + return &MetadataValue{typ: "Double", Double: value} +} + +func NewMetadataValueFromString(value string) *MetadataValue { + return &MetadataValue{typ: "String", String: value} +} + +func NewMetadataValueFromBoolean(value bool) *MetadataValue { + return &MetadataValue{typ: "Boolean", Boolean: value} +} + +func (m *MetadataValue) GetDouble() float64 { + if m == nil { + return 0 + } + return m.Double +} + +func (m *MetadataValue) GetString() string { + if m == nil { + return "" + } + return m.String +} + +func (m *MetadataValue) GetBoolean() bool { + if m == nil { + return false + } + return m.Boolean +} + +func (m *MetadataValue) UnmarshalJSON(data []byte) error { + var valueDouble float64 + if err := json.Unmarshal(data, &valueDouble); err == nil { + m.typ = "Double" + m.Double = valueDouble + return nil + } + var valueString string + if err := json.Unmarshal(data, &valueString); err == nil { + m.typ = "String" + m.String = valueString + return nil + } + var valueBoolean bool + if err := json.Unmarshal(data, &valueBoolean); err == nil { + m.typ = "Boolean" + m.Boolean = valueBoolean + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, m) +} + +func (m MetadataValue) MarshalJSON() ([]byte, error) { + if m.typ == "Double" || m.Double != 0 { + return json.Marshal(m.Double) + } + if m.typ == "String" || m.String != "" { + return json.Marshal(m.String) + } + if m.typ == "Boolean" || m.Boolean != false { + return json.Marshal(m.Boolean) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataValueVisitor interface { + VisitDouble(float64) error + VisitString(string) error + VisitBoolean(bool) error +} + +func (m *MetadataValue) Accept(visitor MetadataValueVisitor) error { + if m.typ == "Double" || m.Double != 0 { + return visitor.VisitDouble(m.Double) + } + if m.typ == "String" || m.String != "" { + return visitor.VisitString(m.String) + } + if m.typ == "Boolean" || m.Boolean != false { + return visitor.VisitBoolean(m.Boolean) + } + return fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type UserModel struct { + Username *string `json:"username,omitempty" url:"username,omitempty"` + Email *string `json:"email,omitempty" url:"email,omitempty"` + Age *int `json:"age,omitempty" url:"age,omitempty"` + Weight *float64 `json:"weight,omitempty" url:"weight,omitempty"` + Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *UserModel) GetUsername() *string { + if u == nil { + return nil + } + return u.Username +} + +func (u *UserModel) GetEmail() *string { + if u == nil { + return nil + } + return u.Email +} + +func (u *UserModel) GetAge() *int { + if u == nil { + return nil + } + return u.Age +} + +func (u *UserModel) GetWeight() *float64 { + if u == nil { + return nil + } + return u.Weight +} + +func (u *UserModel) GetMetadata() *Metadata { + if u == nil { + return nil + } + return u.Metadata +} + +func (u *UserModel) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserModel) UnmarshalJSON(data []byte) error { + type unmarshaler UserModel + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserModel(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UserModel) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} diff --git a/seed/go-model/license/.github/workflows/ci.yml b/seed/go-model/license/.github/workflows/ci.yml new file mode 100644 index 00000000000..d4c0a5dcd95 --- /dev/null +++ b/seed/go-model/license/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: ci + +on: [push] + +jobs: + compile: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up go + uses: actions/setup-go@v4 + + - name: Compile + run: go build ./... + test: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up go + uses: actions/setup-go@v4 + + - name: Test + run: go test ./... diff --git a/seed/go-model/license/.mock/definition/__package__.yml b/seed/go-model/license/.mock/definition/__package__.yml new file mode 100644 index 00000000000..b1e4d4a878f --- /dev/null +++ b/seed/go-model/license/.mock/definition/__package__.yml @@ -0,0 +1,13 @@ +types: + Type: + docs: A simple type with just a name. + properties: + name: string + +service: + auth: false + base-path: / + endpoints: + get: + path: "/" + method: GET diff --git a/seed/go-model/license/.mock/definition/api.yml b/seed/go-model/license/.mock/definition/api.yml new file mode 100644 index 00000000000..5523ff1f181 --- /dev/null +++ b/seed/go-model/license/.mock/definition/api.yml @@ -0,0 +1 @@ +name: license diff --git a/seed/go-model/license/.mock/fern.config.json b/seed/go-model/license/.mock/fern.config.json new file mode 100644 index 00000000000..4c8e54ac313 --- /dev/null +++ b/seed/go-model/license/.mock/fern.config.json @@ -0,0 +1 @@ +{"organization": "fern-test", "version": "*"} \ No newline at end of file diff --git a/seed/go-model/license/.mock/generators.yml b/seed/go-model/license/.mock/generators.yml new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/seed/go-model/license/.mock/generators.yml @@ -0,0 +1 @@ +{} diff --git a/seed/go-model/license/core/extra_properties.go b/seed/go-model/license/core/extra_properties.go new file mode 100644 index 00000000000..a6af3e12410 --- /dev/null +++ b/seed/go-model/license/core/extra_properties.go @@ -0,0 +1,141 @@ +package core + +import ( + "bytes" + "encoding/json" + "fmt" + "reflect" + "strings" +) + +// MarshalJSONWithExtraProperty marshals the given value to JSON, including the extra property. +func MarshalJSONWithExtraProperty(marshaler interface{}, key string, value interface{}) ([]byte, error) { + return MarshalJSONWithExtraProperties(marshaler, map[string]interface{}{key: value}) +} + +// MarshalJSONWithExtraProperties marshals the given value to JSON, including any extra properties. +func MarshalJSONWithExtraProperties(marshaler interface{}, extraProperties map[string]interface{}) ([]byte, error) { + bytes, err := json.Marshal(marshaler) + if err != nil { + return nil, err + } + if len(extraProperties) == 0 { + return bytes, nil + } + keys, err := getKeys(marshaler) + if err != nil { + return nil, err + } + for _, key := range keys { + if _, ok := extraProperties[key]; ok { + return nil, fmt.Errorf("cannot add extra property %q because it is already defined on the type", key) + } + } + extraBytes, err := json.Marshal(extraProperties) + if err != nil { + return nil, err + } + if isEmptyJSON(bytes) { + if isEmptyJSON(extraBytes) { + return bytes, nil + } + return extraBytes, nil + } + result := bytes[:len(bytes)-1] + result = append(result, ',') + result = append(result, extraBytes[1:len(extraBytes)-1]...) + result = append(result, '}') + return result, nil +} + +// ExtractExtraProperties extracts any extra properties from the given value. +func ExtractExtraProperties(bytes []byte, value interface{}, exclude ...string) (map[string]interface{}, error) { + val := reflect.ValueOf(value) + for val.Kind() == reflect.Ptr { + if val.IsNil() { + return nil, fmt.Errorf("value must be non-nil to extract extra properties") + } + val = val.Elem() + } + if err := json.Unmarshal(bytes, &value); err != nil { + return nil, err + } + var extraProperties map[string]interface{} + if err := json.Unmarshal(bytes, &extraProperties); err != nil { + return nil, err + } + for i := 0; i < val.Type().NumField(); i++ { + key := jsonKey(val.Type().Field(i)) + if key == "" || key == "-" { + continue + } + delete(extraProperties, key) + } + for _, key := range exclude { + delete(extraProperties, key) + } + if len(extraProperties) == 0 { + return nil, nil + } + return extraProperties, nil +} + +// getKeys returns the keys associated with the given value. The value must be a +// a struct or a map with string keys. +func getKeys(value interface{}) ([]string, error) { + val := reflect.ValueOf(value) + if val.Kind() == reflect.Ptr { + val = val.Elem() + } + if !val.IsValid() { + return nil, nil + } + switch val.Kind() { + case reflect.Struct: + return getKeysForStructType(val.Type()), nil + case reflect.Map: + var keys []string + if val.Type().Key().Kind() != reflect.String { + return nil, fmt.Errorf("cannot extract keys from %T; only structs and maps with string keys are supported", value) + } + for _, key := range val.MapKeys() { + keys = append(keys, key.String()) + } + return keys, nil + default: + return nil, fmt.Errorf("cannot extract keys from %T; only structs and maps with string keys are supported", value) + } +} + +// getKeysForStructType returns all the keys associated with the given struct type, +// visiting embedded fields recursively. +func getKeysForStructType(structType reflect.Type) []string { + if structType.Kind() == reflect.Pointer { + structType = structType.Elem() + } + if structType.Kind() != reflect.Struct { + return nil + } + var keys []string + for i := 0; i < structType.NumField(); i++ { + field := structType.Field(i) + if field.Anonymous { + keys = append(keys, getKeysForStructType(field.Type)...) + continue + } + keys = append(keys, jsonKey(field)) + } + return keys +} + +// jsonKey returns the JSON key from the struct tag of the given field, +// excluding the omitempty flag (if any). +func jsonKey(field reflect.StructField) string { + return strings.TrimSuffix(field.Tag.Get("json"), ",omitempty") +} + +// isEmptyJSON returns true if the given data is empty, the empty JSON object, or +// an explicit null. +func isEmptyJSON(data []byte) bool { + return len(data) <= 2 || bytes.Equal(data, []byte("null")) +} diff --git a/seed/go-model/license/core/extra_properties_test.go b/seed/go-model/license/core/extra_properties_test.go new file mode 100644 index 00000000000..dc66fccd7f1 --- /dev/null +++ b/seed/go-model/license/core/extra_properties_test.go @@ -0,0 +1,228 @@ +package core + +import ( + "encoding/json" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +type testMarshaler struct { + Name string `json:"name"` + BirthDate time.Time `json:"birthDate"` + CreatedAt time.Time `json:"created_at"` +} + +func (t *testMarshaler) MarshalJSON() ([]byte, error) { + type embed testMarshaler + var marshaler = struct { + embed + BirthDate string `json:"birthDate"` + CreatedAt string `json:"created_at"` + }{ + embed: embed(*t), + BirthDate: t.BirthDate.Format("2006-01-02"), + CreatedAt: t.CreatedAt.Format(time.RFC3339), + } + return MarshalJSONWithExtraProperty(marshaler, "type", "test") +} + +func TestMarshalJSONWithExtraProperties(t *testing.T) { + tests := []struct { + desc string + giveMarshaler interface{} + giveExtraProperties map[string]interface{} + wantBytes []byte + wantError string + }{ + { + desc: "invalid type", + giveMarshaler: []string{"invalid"}, + giveExtraProperties: map[string]interface{}{"key": "overwrite"}, + wantError: `cannot extract keys from []string; only structs and maps with string keys are supported`, + }, + { + desc: "invalid key type", + giveMarshaler: map[int]interface{}{42: "value"}, + giveExtraProperties: map[string]interface{}{"key": "overwrite"}, + wantError: `cannot extract keys from map[int]interface {}; only structs and maps with string keys are supported`, + }, + { + desc: "invalid map overwrite", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{"key": "overwrite"}, + wantError: `cannot add extra property "key" because it is already defined on the type`, + }, + { + desc: "invalid struct overwrite", + giveMarshaler: new(testMarshaler), + giveExtraProperties: map[string]interface{}{"birthDate": "2000-01-01"}, + wantError: `cannot add extra property "birthDate" because it is already defined on the type`, + }, + { + desc: "invalid struct overwrite embedded type", + giveMarshaler: new(testMarshaler), + giveExtraProperties: map[string]interface{}{"name": "bob"}, + wantError: `cannot add extra property "name" because it is already defined on the type`, + }, + { + desc: "nil", + giveMarshaler: nil, + giveExtraProperties: nil, + wantBytes: []byte(`null`), + }, + { + desc: "empty", + giveMarshaler: map[string]interface{}{}, + giveExtraProperties: map[string]interface{}{}, + wantBytes: []byte(`{}`), + }, + { + desc: "no extra properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{}, + wantBytes: []byte(`{"key":"value"}`), + }, + { + desc: "only extra properties", + giveMarshaler: map[string]interface{}{}, + giveExtraProperties: map[string]interface{}{"key": "value"}, + wantBytes: []byte(`{"key":"value"}`), + }, + { + desc: "single extra property", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{"extra": "property"}, + wantBytes: []byte(`{"key":"value","extra":"property"}`), + }, + { + desc: "multiple extra properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{"one": 1, "two": 2}, + wantBytes: []byte(`{"key":"value","one":1,"two":2}`), + }, + { + desc: "nested properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{ + "user": map[string]interface{}{ + "age": 42, + "name": "alice", + }, + }, + wantBytes: []byte(`{"key":"value","user":{"age":42,"name":"alice"}}`), + }, + { + desc: "multiple nested properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{ + "metadata": map[string]interface{}{ + "ip": "127.0.0.1", + }, + "user": map[string]interface{}{ + "age": 42, + "name": "alice", + }, + }, + wantBytes: []byte(`{"key":"value","metadata":{"ip":"127.0.0.1"},"user":{"age":42,"name":"alice"}}`), + }, + { + desc: "custom marshaler", + giveMarshaler: &testMarshaler{ + Name: "alice", + BirthDate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), + CreatedAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC), + }, + giveExtraProperties: map[string]interface{}{ + "extra": "property", + }, + wantBytes: []byte(`{"name":"alice","birthDate":"2000-01-01","created_at":"2024-01-01T00:00:00Z","type":"test","extra":"property"}`), + }, + } + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + bytes, err := MarshalJSONWithExtraProperties(tt.giveMarshaler, tt.giveExtraProperties) + if tt.wantError != "" { + require.EqualError(t, err, tt.wantError) + assert.Nil(t, tt.wantBytes) + return + } + require.NoError(t, err) + assert.Equal(t, tt.wantBytes, bytes) + + value := make(map[string]interface{}) + require.NoError(t, json.Unmarshal(bytes, &value)) + }) + } +} + +func TestExtractExtraProperties(t *testing.T) { + t.Run("none", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := &user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice"}`), value) + require.NoError(t, err) + assert.Nil(t, extraProperties) + }) + + t.Run("non-nil pointer", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := &user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + require.NoError(t, err) + assert.Equal(t, map[string]interface{}{"age": float64(42)}, extraProperties) + }) + + t.Run("nil pointer", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + var value *user + _, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + assert.EqualError(t, err, "value must be non-nil to extract extra properties") + }) + + t.Run("non-zero value", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + require.NoError(t, err) + assert.Equal(t, map[string]interface{}{"age": float64(42)}, extraProperties) + }) + + t.Run("zero value", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + var value user + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + require.NoError(t, err) + assert.Equal(t, map[string]interface{}{"age": float64(42)}, extraProperties) + }) + + t.Run("exclude", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := &user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value, "age") + require.NoError(t, err) + assert.Nil(t, extraProperties) + }) +} diff --git a/seed/go-model/license/core/stringer.go b/seed/go-model/license/core/stringer.go new file mode 100644 index 00000000000..000cf448641 --- /dev/null +++ b/seed/go-model/license/core/stringer.go @@ -0,0 +1,13 @@ +package core + +import "encoding/json" + +// StringifyJSON returns a pretty JSON string representation of +// the given value. +func StringifyJSON(value interface{}) (string, error) { + bytes, err := json.MarshalIndent(value, "", " ") + if err != nil { + return "", err + } + return string(bytes), nil +} diff --git a/seed/go-model/license/core/time.go b/seed/go-model/license/core/time.go new file mode 100644 index 00000000000..d009ab30c90 --- /dev/null +++ b/seed/go-model/license/core/time.go @@ -0,0 +1,137 @@ +package core + +import ( + "encoding/json" + "time" +) + +const dateFormat = "2006-01-02" + +// DateTime wraps time.Time and adapts its JSON representation +// to conform to a RFC3339 date (e.g. 2006-01-02). +// +// Ref: https://ijmacd.github.io/rfc3339-iso8601 +type Date struct { + t *time.Time +} + +// NewDate returns a new *Date. If the given time.Time +// is nil, nil will be returned. +func NewDate(t time.Time) *Date { + return &Date{t: &t} +} + +// NewOptionalDate returns a new *Date. If the given time.Time +// is nil, nil will be returned. +func NewOptionalDate(t *time.Time) *Date { + if t == nil { + return nil + } + return &Date{t: t} +} + +// Time returns the Date's underlying time, if any. If the +// date is nil, the zero value is returned. +func (d *Date) Time() time.Time { + if d == nil || d.t == nil { + return time.Time{} + } + return *d.t +} + +// TimePtr returns a pointer to the Date's underlying time.Time, if any. +func (d *Date) TimePtr() *time.Time { + if d == nil || d.t == nil { + return nil + } + if d.t.IsZero() { + return nil + } + return d.t +} + +func (d *Date) MarshalJSON() ([]byte, error) { + if d == nil || d.t == nil { + return nil, nil + } + return json.Marshal(d.t.Format(dateFormat)) +} + +func (d *Date) UnmarshalJSON(data []byte) error { + var raw string + if err := json.Unmarshal(data, &raw); err != nil { + return err + } + + parsedTime, err := time.Parse(dateFormat, raw) + if err != nil { + return err + } + + *d = Date{t: &parsedTime} + return nil +} + +// DateTime wraps time.Time and adapts its JSON representation +// to conform to a RFC3339 date-time (e.g. 2017-07-21T17:32:28Z). +// +// Ref: https://ijmacd.github.io/rfc3339-iso8601 +type DateTime struct { + t *time.Time +} + +// NewDateTime returns a new *DateTime. +func NewDateTime(t time.Time) *DateTime { + return &DateTime{t: &t} +} + +// NewOptionalDateTime returns a new *DateTime. If the given time.Time +// is nil, nil will be returned. +func NewOptionalDateTime(t *time.Time) *DateTime { + if t == nil { + return nil + } + return &DateTime{t: t} +} + +// Time returns the DateTime's underlying time, if any. If the +// date-time is nil, the zero value is returned. +func (d *DateTime) Time() time.Time { + if d == nil || d.t == nil { + return time.Time{} + } + return *d.t +} + +// TimePtr returns a pointer to the DateTime's underlying time.Time, if any. +func (d *DateTime) TimePtr() *time.Time { + if d == nil || d.t == nil { + return nil + } + if d.t.IsZero() { + return nil + } + return d.t +} + +func (d *DateTime) MarshalJSON() ([]byte, error) { + if d == nil || d.t == nil { + return nil, nil + } + return json.Marshal(d.t.Format(time.RFC3339)) +} + +func (d *DateTime) UnmarshalJSON(data []byte) error { + var raw string + if err := json.Unmarshal(data, &raw); err != nil { + return err + } + + parsedTime, err := time.Parse(time.RFC3339, raw) + if err != nil { + return err + } + + *d = DateTime{t: &parsedTime} + return nil +} diff --git a/seed/go-model/license/go.mod b/seed/go-model/license/go.mod new file mode 100644 index 00000000000..1dec86e3fdc --- /dev/null +++ b/seed/go-model/license/go.mod @@ -0,0 +1,8 @@ +module github.com/license/fern + +go 1.13 + +require ( + github.com/stretchr/testify v1.7.0 + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/seed/go-model/license/go.sum b/seed/go-model/license/go.sum new file mode 100644 index 00000000000..fc3dd9e67e8 --- /dev/null +++ b/seed/go-model/license/go.sum @@ -0,0 +1,12 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/seed/go-model/license/snippet-templates.json b/seed/go-model/license/snippet-templates.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/seed/go-model/license/snippet.json b/seed/go-model/license/snippet.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/seed/go-model/license/types.go b/seed/go-model/license/types.go new file mode 100644 index 00000000000..db51d068e02 --- /dev/null +++ b/seed/go-model/license/types.go @@ -0,0 +1,51 @@ +// This file was auto-generated by Fern from our API Definition. + +package license + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/license/fern/core" +) + +// A simple type with just a name. +type Type struct { + Name string `json:"name" url:"name"` + + extraProperties map[string]interface{} +} + +func (t *Type) GetName() string { + if t == nil { + return "" + } + return t.Name +} + +func (t *Type) GetExtraProperties() map[string]interface{} { + return t.extraProperties +} + +func (t *Type) UnmarshalJSON(data []byte) error { + type unmarshaler Type + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = Type(value) + + extraProperties, err := core.ExtractExtraProperties(data, *t) + if err != nil { + return err + } + t.extraProperties = extraProperties + + return nil +} + +func (t *Type) String() string { + if value, err := core.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} diff --git a/seed/go-model/literal/inlined.go b/seed/go-model/literal/inlined.go index 95a066ba453..e2f695c4e22 100644 --- a/seed/go-model/literal/inlined.go +++ b/seed/go-model/literal/inlined.go @@ -8,6 +8,65 @@ import ( core "github.com/literal/fern/core" ) +type ANestedLiteral struct { + myLiteral string + + extraProperties map[string]interface{} +} + +func (a *ANestedLiteral) MyLiteral() string { + return a.myLiteral +} + +func (a *ANestedLiteral) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *ANestedLiteral) UnmarshalJSON(data []byte) error { + type embed ANestedLiteral + var unmarshaler = struct { + embed + MyLiteral string `json:"myLiteral"` + }{ + embed: embed(*a), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *a = ANestedLiteral(unmarshaler.embed) + if unmarshaler.MyLiteral != "How super cool" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", a, "How super cool", unmarshaler.MyLiteral) + } + a.myLiteral = unmarshaler.MyLiteral + + extraProperties, err := core.ExtractExtraProperties(data, *a, "myLiteral") + if err != nil { + return err + } + a.extraProperties = extraProperties + + return nil +} + +func (a *ANestedLiteral) MarshalJSON() ([]byte, error) { + type embed ANestedLiteral + var marshaler = struct { + embed + MyLiteral string `json:"myLiteral"` + }{ + embed: embed(*a), + MyLiteral: "How super cool", + } + return json.Marshal(marshaler) +} + +func (a *ANestedLiteral) String() string { + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} + type ATopLevelLiteral struct { NestedLiteral *ANestedLiteral `json:"nestedLiteral,omitempty" url:"nestedLiteral,omitempty"` diff --git a/seed/go-model/literal/reference.go b/seed/go-model/literal/reference.go index d2e1e8d7f1c..922662d00bb 100644 --- a/seed/go-model/literal/reference.go +++ b/seed/go-model/literal/reference.go @@ -8,6 +8,126 @@ import ( core "github.com/literal/fern/core" ) +type ContainerObject struct { + NestedObjects []*NestedObjectWithLiterals `json:"nestedObjects,omitempty" url:"nestedObjects,omitempty"` + + extraProperties map[string]interface{} +} + +func (c *ContainerObject) GetNestedObjects() []*NestedObjectWithLiterals { + if c == nil { + return nil + } + return c.NestedObjects +} + +func (c *ContainerObject) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *ContainerObject) UnmarshalJSON(data []byte) error { + type unmarshaler ContainerObject + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ContainerObject(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + return nil +} + +func (c *ContainerObject) String() string { + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type NestedObjectWithLiterals struct { + StrProp string `json:"strProp" url:"strProp"` + literal1 string + literal2 string + + extraProperties map[string]interface{} +} + +func (n *NestedObjectWithLiterals) GetStrProp() string { + if n == nil { + return "" + } + return n.StrProp +} + +func (n *NestedObjectWithLiterals) Literal1() string { + return n.literal1 +} + +func (n *NestedObjectWithLiterals) Literal2() string { + return n.literal2 +} + +func (n *NestedObjectWithLiterals) GetExtraProperties() map[string]interface{} { + return n.extraProperties +} + +func (n *NestedObjectWithLiterals) UnmarshalJSON(data []byte) error { + type embed NestedObjectWithLiterals + var unmarshaler = struct { + embed + Literal1 string `json:"literal1"` + Literal2 string `json:"literal2"` + }{ + embed: embed(*n), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *n = NestedObjectWithLiterals(unmarshaler.embed) + if unmarshaler.Literal1 != "literal1" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", n, "literal1", unmarshaler.Literal1) + } + n.literal1 = unmarshaler.Literal1 + if unmarshaler.Literal2 != "literal2" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", n, "literal2", unmarshaler.Literal2) + } + n.literal2 = unmarshaler.Literal2 + + extraProperties, err := core.ExtractExtraProperties(data, *n, "literal1", "literal2") + if err != nil { + return err + } + n.extraProperties = extraProperties + + return nil +} + +func (n *NestedObjectWithLiterals) MarshalJSON() ([]byte, error) { + type embed NestedObjectWithLiterals + var marshaler = struct { + embed + Literal1 string `json:"literal1"` + Literal2 string `json:"literal2"` + }{ + embed: embed(*n), + Literal1: "literal1", + Literal2: "literal2", + } + return json.Marshal(marshaler) +} + +func (n *NestedObjectWithLiterals) String() string { + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + type SendRequest struct { Query string `json:"query" url:"query"` Context SomeLiteral `json:"context,omitempty" url:"context,omitempty"` @@ -96,3 +216,5 @@ func (s *SendRequest) String() string { } return fmt.Sprintf("%#v", s) } + +type SomeLiteral = string diff --git a/seed/go-model/literal/types.go b/seed/go-model/literal/types.go index 8f8283bc2cf..71967d5a74e 100644 --- a/seed/go-model/literal/types.go +++ b/seed/go-model/literal/types.go @@ -82,184 +82,3 @@ func (s *SendResponse) String() string { } return fmt.Sprintf("%#v", s) } - -type ANestedLiteral struct { - myLiteral string - - extraProperties map[string]interface{} -} - -func (a *ANestedLiteral) MyLiteral() string { - return a.myLiteral -} - -func (a *ANestedLiteral) GetExtraProperties() map[string]interface{} { - return a.extraProperties -} - -func (a *ANestedLiteral) UnmarshalJSON(data []byte) error { - type embed ANestedLiteral - var unmarshaler = struct { - embed - MyLiteral string `json:"myLiteral"` - }{ - embed: embed(*a), - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - *a = ANestedLiteral(unmarshaler.embed) - if unmarshaler.MyLiteral != "How super cool" { - return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", a, "How super cool", unmarshaler.MyLiteral) - } - a.myLiteral = unmarshaler.MyLiteral - - extraProperties, err := core.ExtractExtraProperties(data, *a, "myLiteral") - if err != nil { - return err - } - a.extraProperties = extraProperties - - return nil -} - -func (a *ANestedLiteral) MarshalJSON() ([]byte, error) { - type embed ANestedLiteral - var marshaler = struct { - embed - MyLiteral string `json:"myLiteral"` - }{ - embed: embed(*a), - MyLiteral: "How super cool", - } - return json.Marshal(marshaler) -} - -func (a *ANestedLiteral) String() string { - if value, err := core.StringifyJSON(a); err == nil { - return value - } - return fmt.Sprintf("%#v", a) -} - -type ContainerObject struct { - NestedObjects []*NestedObjectWithLiterals `json:"nestedObjects,omitempty" url:"nestedObjects,omitempty"` - - extraProperties map[string]interface{} -} - -func (c *ContainerObject) GetNestedObjects() []*NestedObjectWithLiterals { - if c == nil { - return nil - } - return c.NestedObjects -} - -func (c *ContainerObject) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *ContainerObject) UnmarshalJSON(data []byte) error { - type unmarshaler ContainerObject - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = ContainerObject(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - return nil -} - -func (c *ContainerObject) String() string { - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type NestedObjectWithLiterals struct { - StrProp string `json:"strProp" url:"strProp"` - literal1 string - literal2 string - - extraProperties map[string]interface{} -} - -func (n *NestedObjectWithLiterals) GetStrProp() string { - if n == nil { - return "" - } - return n.StrProp -} - -func (n *NestedObjectWithLiterals) Literal1() string { - return n.literal1 -} - -func (n *NestedObjectWithLiterals) Literal2() string { - return n.literal2 -} - -func (n *NestedObjectWithLiterals) GetExtraProperties() map[string]interface{} { - return n.extraProperties -} - -func (n *NestedObjectWithLiterals) UnmarshalJSON(data []byte) error { - type embed NestedObjectWithLiterals - var unmarshaler = struct { - embed - Literal1 string `json:"literal1"` - Literal2 string `json:"literal2"` - }{ - embed: embed(*n), - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - *n = NestedObjectWithLiterals(unmarshaler.embed) - if unmarshaler.Literal1 != "literal1" { - return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", n, "literal1", unmarshaler.Literal1) - } - n.literal1 = unmarshaler.Literal1 - if unmarshaler.Literal2 != "literal2" { - return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", n, "literal2", unmarshaler.Literal2) - } - n.literal2 = unmarshaler.Literal2 - - extraProperties, err := core.ExtractExtraProperties(data, *n, "literal1", "literal2") - if err != nil { - return err - } - n.extraProperties = extraProperties - - return nil -} - -func (n *NestedObjectWithLiterals) MarshalJSON() ([]byte, error) { - type embed NestedObjectWithLiterals - var marshaler = struct { - embed - Literal1 string `json:"literal1"` - Literal2 string `json:"literal2"` - }{ - embed: embed(*n), - Literal1: "literal1", - Literal2: "literal2", - } - return json.Marshal(marshaler) -} - -func (n *NestedObjectWithLiterals) String() string { - if value, err := core.StringifyJSON(n); err == nil { - return value - } - return fmt.Sprintf("%#v", n) -} - -type SomeLiteral = string diff --git a/seed/go-model/mixed-case/service.go b/seed/go-model/mixed-case/service.go index 59a01c476af..3520df262ec 100644 --- a/seed/go-model/mixed-case/service.go +++ b/seed/go-model/mixed-case/service.go @@ -8,6 +8,96 @@ import ( core "github.com/mixed-case/fern/core" ) +type NestedUser struct { + Name string `json:"Name" url:"Name"` + NestedUser *User `json:"NestedUser,omitempty" url:"NestedUser,omitempty"` + + extraProperties map[string]interface{} +} + +func (n *NestedUser) GetName() string { + if n == nil { + return "" + } + return n.Name +} + +func (n *NestedUser) GetNestedUser() *User { + if n == nil { + return nil + } + return n.NestedUser +} + +func (n *NestedUser) GetExtraProperties() map[string]interface{} { + return n.extraProperties +} + +func (n *NestedUser) UnmarshalJSON(data []byte) error { + type unmarshaler NestedUser + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NestedUser(value) + + extraProperties, err := core.ExtractExtraProperties(data, *n) + if err != nil { + return err + } + n.extraProperties = extraProperties + + return nil +} + +func (n *NestedUser) String() string { + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + +type Organization struct { + Name string `json:"name" url:"name"` + + extraProperties map[string]interface{} +} + +func (o *Organization) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *Organization) GetExtraProperties() map[string]interface{} { + return o.extraProperties +} + +func (o *Organization) UnmarshalJSON(data []byte) error { + type unmarshaler Organization + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *o = Organization(value) + + extraProperties, err := core.ExtractExtraProperties(data, *o) + if err != nil { + return err + } + o.extraProperties = extraProperties + + return nil +} + +func (o *Organization) String() string { + if value, err := core.StringifyJSON(o); err == nil { + return value + } + return fmt.Sprintf("%#v", o) +} + type Resource struct { ResourceType string Status ResourceStatus @@ -107,3 +197,82 @@ func (r *Resource) Accept(visitor ResourceVisitor) error { return visitor.VisitOrganization(r.Organization) } } + +type ResourceStatus string + +const ( + ResourceStatusActive ResourceStatus = "ACTIVE" + ResourceStatusInactive ResourceStatus = "INACTIVE" +) + +func NewResourceStatusFromString(s string) (ResourceStatus, error) { + switch s { + case "ACTIVE": + return ResourceStatusActive, nil + case "INACTIVE": + return ResourceStatusInactive, nil + } + var t ResourceStatus + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (r ResourceStatus) Ptr() *ResourceStatus { + return &r +} + +type User struct { + UserName string `json:"userName" url:"userName"` + MetadataTags []string `json:"metadata_tags,omitempty" url:"metadata_tags,omitempty"` + ExtraProperties map[string]string `json:"EXTRA_PROPERTIES,omitempty" url:"EXTRA_PROPERTIES,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *User) GetUserName() string { + if u == nil { + return "" + } + return u.UserName +} + +func (u *User) GetMetadataTags() []string { + if u == nil { + return nil + } + return u.MetadataTags +} + +func (u *User) GetExtraProperties() map[string]string { + if u == nil { + return nil + } + return u.ExtraProperties +} + +func (u *User) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *User) UnmarshalJSON(data []byte) error { + type unmarshaler User + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = User(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *User) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} diff --git a/seed/go-model/mixed-case/types.go b/seed/go-model/mixed-case/types.go deleted file mode 100644 index fa7b3d1de2c..00000000000 --- a/seed/go-model/mixed-case/types.go +++ /dev/null @@ -1,178 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package mixedcase - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/mixed-case/fern/core" -) - -type NestedUser struct { - Name string `json:"Name" url:"Name"` - NestedUser *User `json:"NestedUser,omitempty" url:"NestedUser,omitempty"` - - extraProperties map[string]interface{} -} - -func (n *NestedUser) GetName() string { - if n == nil { - return "" - } - return n.Name -} - -func (n *NestedUser) GetNestedUser() *User { - if n == nil { - return nil - } - return n.NestedUser -} - -func (n *NestedUser) GetExtraProperties() map[string]interface{} { - return n.extraProperties -} - -func (n *NestedUser) UnmarshalJSON(data []byte) error { - type unmarshaler NestedUser - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *n = NestedUser(value) - - extraProperties, err := core.ExtractExtraProperties(data, *n) - if err != nil { - return err - } - n.extraProperties = extraProperties - - return nil -} - -func (n *NestedUser) String() string { - if value, err := core.StringifyJSON(n); err == nil { - return value - } - return fmt.Sprintf("%#v", n) -} - -type Organization struct { - Name string `json:"name" url:"name"` - - extraProperties map[string]interface{} -} - -func (o *Organization) GetName() string { - if o == nil { - return "" - } - return o.Name -} - -func (o *Organization) GetExtraProperties() map[string]interface{} { - return o.extraProperties -} - -func (o *Organization) UnmarshalJSON(data []byte) error { - type unmarshaler Organization - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *o = Organization(value) - - extraProperties, err := core.ExtractExtraProperties(data, *o) - if err != nil { - return err - } - o.extraProperties = extraProperties - - return nil -} - -func (o *Organization) String() string { - if value, err := core.StringifyJSON(o); err == nil { - return value - } - return fmt.Sprintf("%#v", o) -} - -type ResourceStatus string - -const ( - ResourceStatusActive ResourceStatus = "ACTIVE" - ResourceStatusInactive ResourceStatus = "INACTIVE" -) - -func NewResourceStatusFromString(s string) (ResourceStatus, error) { - switch s { - case "ACTIVE": - return ResourceStatusActive, nil - case "INACTIVE": - return ResourceStatusInactive, nil - } - var t ResourceStatus - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (r ResourceStatus) Ptr() *ResourceStatus { - return &r -} - -type User struct { - UserName string `json:"userName" url:"userName"` - MetadataTags []string `json:"metadata_tags,omitempty" url:"metadata_tags,omitempty"` - ExtraProperties map[string]string `json:"EXTRA_PROPERTIES,omitempty" url:"EXTRA_PROPERTIES,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *User) GetUserName() string { - if u == nil { - return "" - } - return u.UserName -} - -func (u *User) GetMetadataTags() []string { - if u == nil { - return nil - } - return u.MetadataTags -} - -func (u *User) GetExtraProperties() map[string]string { - if u == nil { - return nil - } - return u.ExtraProperties -} - -func (u *User) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *User) UnmarshalJSON(data []byte) error { - type unmarshaler User - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = User(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *User) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/seed/go-model/oauth-client-credentials-nested-root/auth/auth.go b/seed/go-model/oauth-client-credentials-nested-root/auth/auth.go deleted file mode 100644 index 9019a11c485..00000000000 --- a/seed/go-model/oauth-client-credentials-nested-root/auth/auth.go +++ /dev/null @@ -1,67 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package auth - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/oauth-client-credentials-nested-root/fern/core" -) - -// An OAuth token response. -type TokenResponse struct { - AccessToken string `json:"access_token" url:"access_token"` - ExpiresIn int `json:"expires_in" url:"expires_in"` - RefreshToken *string `json:"refresh_token,omitempty" url:"refresh_token,omitempty"` - - extraProperties map[string]interface{} -} - -func (t *TokenResponse) GetAccessToken() string { - if t == nil { - return "" - } - return t.AccessToken -} - -func (t *TokenResponse) GetExpiresIn() int { - if t == nil { - return 0 - } - return t.ExpiresIn -} - -func (t *TokenResponse) GetRefreshToken() *string { - if t == nil { - return nil - } - return t.RefreshToken -} - -func (t *TokenResponse) GetExtraProperties() map[string]interface{} { - return t.extraProperties -} - -func (t *TokenResponse) UnmarshalJSON(data []byte) error { - type unmarshaler TokenResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *t = TokenResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *t) - if err != nil { - return err - } - t.extraProperties = extraProperties - - return nil -} - -func (t *TokenResponse) String() string { - if value, err := core.StringifyJSON(t); err == nil { - return value - } - return fmt.Sprintf("%#v", t) -} diff --git a/seed/go-model/oauth-client-credentials-nested-root/auth/types.go b/seed/go-model/oauth-client-credentials-nested-root/auth/types.go index b392c0415a5..9019a11c485 100644 --- a/seed/go-model/oauth-client-credentials-nested-root/auth/types.go +++ b/seed/go-model/oauth-client-credentials-nested-root/auth/types.go @@ -1,3 +1,67 @@ // This file was auto-generated by Fern from our API Definition. package auth + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/oauth-client-credentials-nested-root/fern/core" +) + +// An OAuth token response. +type TokenResponse struct { + AccessToken string `json:"access_token" url:"access_token"` + ExpiresIn int `json:"expires_in" url:"expires_in"` + RefreshToken *string `json:"refresh_token,omitempty" url:"refresh_token,omitempty"` + + extraProperties map[string]interface{} +} + +func (t *TokenResponse) GetAccessToken() string { + if t == nil { + return "" + } + return t.AccessToken +} + +func (t *TokenResponse) GetExpiresIn() int { + if t == nil { + return 0 + } + return t.ExpiresIn +} + +func (t *TokenResponse) GetRefreshToken() *string { + if t == nil { + return nil + } + return t.RefreshToken +} + +func (t *TokenResponse) GetExtraProperties() map[string]interface{} { + return t.extraProperties +} + +func (t *TokenResponse) UnmarshalJSON(data []byte) error { + type unmarshaler TokenResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = TokenResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *t) + if err != nil { + return err + } + t.extraProperties = extraProperties + + return nil +} + +func (t *TokenResponse) String() string { + if value, err := core.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} diff --git a/seed/go-model/objects-with-imports/commons/types.go b/seed/go-model/objects-with-imports/commons/metadata.go similarity index 100% rename from seed/go-model/objects-with-imports/commons/types.go rename to seed/go-model/objects-with-imports/commons/metadata.go diff --git a/seed/go-model/objects-with-imports/file.go b/seed/go-model/objects-with-imports/file.go new file mode 100644 index 00000000000..fd807feaf59 --- /dev/null +++ b/seed/go-model/objects-with-imports/file.go @@ -0,0 +1,90 @@ +// This file was auto-generated by Fern from our API Definition. + +package objectswithimports + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/objects-with-imports/fern/core" +) + +type File struct { + Name string `json:"name" url:"name"` + Contents string `json:"contents" url:"contents"` + Info FileInfo `json:"info" url:"info"` + + extraProperties map[string]interface{} +} + +func (f *File) GetName() string { + if f == nil { + return "" + } + return f.Name +} + +func (f *File) GetContents() string { + if f == nil { + return "" + } + return f.Contents +} + +func (f *File) GetInfo() FileInfo { + if f == nil { + return "" + } + return f.Info +} + +func (f *File) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *File) UnmarshalJSON(data []byte) error { + type unmarshaler File + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = File(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + return nil +} + +func (f *File) String() string { + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + +type FileInfo string + +const ( + // A regular file (e.g. foo.txt). + FileInfoRegular FileInfo = "REGULAR" + // A directory (e.g. foo/). + FileInfoDirectory FileInfo = "DIRECTORY" +) + +func NewFileInfoFromString(s string) (FileInfo, error) { + switch s { + case "REGULAR": + return FileInfoRegular, nil + case "DIRECTORY": + return FileInfoDirectory, nil + } + var t FileInfo + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (f FileInfo) Ptr() *FileInfo { + return &f +} diff --git a/seed/go-model/objects-with-imports/file/types.go b/seed/go-model/objects-with-imports/file/directory.go similarity index 100% rename from seed/go-model/objects-with-imports/file/types.go rename to seed/go-model/objects-with-imports/file/directory.go diff --git a/seed/go-model/objects-with-imports/types.go b/seed/go-model/objects-with-imports/types.go index dce16f47f3e..01d4469fa38 100644 --- a/seed/go-model/objects-with-imports/types.go +++ b/seed/go-model/objects-with-imports/types.go @@ -106,84 +106,3 @@ func (t *Tree) String() string { } return fmt.Sprintf("%#v", t) } - -type File struct { - Name string `json:"name" url:"name"` - Contents string `json:"contents" url:"contents"` - Info FileInfo `json:"info" url:"info"` - - extraProperties map[string]interface{} -} - -func (f *File) GetName() string { - if f == nil { - return "" - } - return f.Name -} - -func (f *File) GetContents() string { - if f == nil { - return "" - } - return f.Contents -} - -func (f *File) GetInfo() FileInfo { - if f == nil { - return "" - } - return f.Info -} - -func (f *File) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *File) UnmarshalJSON(data []byte) error { - type unmarshaler File - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = File(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - return nil -} - -func (f *File) String() string { - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} - -type FileInfo string - -const ( - // A regular file (e.g. foo.txt). - FileInfoRegular FileInfo = "REGULAR" - // A directory (e.g. foo/). - FileInfoDirectory FileInfo = "DIRECTORY" -) - -func NewFileInfoFromString(s string) (FileInfo, error) { - switch s { - case "REGULAR": - return FileInfoRegular, nil - case "DIRECTORY": - return FileInfoDirectory, nil - } - var t FileInfo - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (f FileInfo) Ptr() *FileInfo { - return &f -} diff --git a/seed/go-model/pagination/types.go b/seed/go-model/pagination/types.go deleted file mode 100644 index e66d8e13096..00000000000 --- a/seed/go-model/pagination/types.go +++ /dev/null @@ -1,403 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package pagination - -import ( - json "encoding/json" - fmt "fmt" - uuid "github.com/google/uuid" - core "github.com/pagination/fern/core" -) - -type UsernamePage struct { - After *string `json:"after,omitempty" url:"after,omitempty"` - Data []string `json:"data,omitempty" url:"data,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *UsernamePage) GetAfter() *string { - if u == nil { - return nil - } - return u.After -} - -func (u *UsernamePage) GetData() []string { - if u == nil { - return nil - } - return u.Data -} - -func (u *UsernamePage) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UsernamePage) UnmarshalJSON(data []byte) error { - type unmarshaler UsernamePage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UsernamePage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UsernamePage) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type NextPage struct { - Page int `json:"page" url:"page"` - StartingAfter string `json:"starting_after" url:"starting_after"` - - extraProperties map[string]interface{} -} - -func (n *NextPage) GetPage() int { - if n == nil { - return 0 - } - return n.Page -} - -func (n *NextPage) GetStartingAfter() string { - if n == nil { - return "" - } - return n.StartingAfter -} - -func (n *NextPage) GetExtraProperties() map[string]interface{} { - return n.extraProperties -} - -func (n *NextPage) UnmarshalJSON(data []byte) error { - type unmarshaler NextPage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *n = NextPage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *n) - if err != nil { - return err - } - n.extraProperties = extraProperties - - return nil -} - -func (n *NextPage) String() string { - if value, err := core.StringifyJSON(n); err == nil { - return value - } - return fmt.Sprintf("%#v", n) -} - -type Page struct { - // The current page - Page int `json:"page" url:"page"` - Next *NextPage `json:"next,omitempty" url:"next,omitempty"` - PerPage int `json:"per_page" url:"per_page"` - TotalPage int `json:"total_page" url:"total_page"` - - extraProperties map[string]interface{} -} - -func (p *Page) GetPage() int { - if p == nil { - return 0 - } - return p.Page -} - -func (p *Page) GetNext() *NextPage { - if p == nil { - return nil - } - return p.Next -} - -func (p *Page) GetPerPage() int { - if p == nil { - return 0 - } - return p.PerPage -} - -func (p *Page) GetTotalPage() int { - if p == nil { - return 0 - } - return p.TotalPage -} - -func (p *Page) GetExtraProperties() map[string]interface{} { - return p.extraProperties -} - -func (p *Page) UnmarshalJSON(data []byte) error { - type unmarshaler Page - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *p = Page(value) - - extraProperties, err := core.ExtractExtraProperties(data, *p) - if err != nil { - return err - } - p.extraProperties = extraProperties - - return nil -} - -func (p *Page) String() string { - if value, err := core.StringifyJSON(p); err == nil { - return value - } - return fmt.Sprintf("%#v", p) -} - -type User struct { - Name string `json:"name" url:"name"` - Id int `json:"id" url:"id"` - - extraProperties map[string]interface{} -} - -func (u *User) GetName() string { - if u == nil { - return "" - } - return u.Name -} - -func (u *User) GetId() int { - if u == nil { - return 0 - } - return u.Id -} - -func (u *User) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *User) UnmarshalJSON(data []byte) error { - type unmarshaler User - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = User(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *User) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserListContainer struct { - Users []*User `json:"users,omitempty" url:"users,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *UserListContainer) GetUsers() []*User { - if u == nil { - return nil - } - return u.Users -} - -func (u *UserListContainer) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserListContainer) UnmarshalJSON(data []byte) error { - type unmarshaler UserListContainer - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserListContainer(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UserListContainer) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserOptionalListContainer struct { - Users []*User `json:"users,omitempty" url:"users,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *UserOptionalListContainer) GetUsers() []*User { - if u == nil { - return nil - } - return u.Users -} - -func (u *UserOptionalListContainer) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserOptionalListContainer) UnmarshalJSON(data []byte) error { - type unmarshaler UserOptionalListContainer - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserOptionalListContainer(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UserOptionalListContainer) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserOptionalListPage struct { - Data *UserOptionalListContainer `json:"data,omitempty" url:"data,omitempty"` - Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *UserOptionalListPage) GetData() *UserOptionalListContainer { - if u == nil { - return nil - } - return u.Data -} - -func (u *UserOptionalListPage) GetNext() *uuid.UUID { - if u == nil { - return nil - } - return u.Next -} - -func (u *UserOptionalListPage) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserOptionalListPage) UnmarshalJSON(data []byte) error { - type unmarshaler UserOptionalListPage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserOptionalListPage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UserOptionalListPage) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserPage struct { - Data *UserListContainer `json:"data,omitempty" url:"data,omitempty"` - Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` - - extraProperties map[string]interface{} -} - -func (u *UserPage) GetData() *UserListContainer { - if u == nil { - return nil - } - return u.Data -} - -func (u *UserPage) GetNext() *uuid.UUID { - if u == nil { - return nil - } - return u.Next -} - -func (u *UserPage) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserPage) UnmarshalJSON(data []byte) error { - type unmarshaler UserPage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserPage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - return nil -} - -func (u *UserPage) String() string { - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/seed/go-model/pagination/users.go b/seed/go-model/pagination/users.go index b2fc0fdb9f6..08ede821ace 100644 --- a/seed/go-model/pagination/users.go +++ b/seed/go-model/pagination/users.go @@ -50,6 +50,55 @@ func (u *UsernameCursor) String() string { return fmt.Sprintf("%#v", u) } +type UsernamePage struct { + After *string `json:"after,omitempty" url:"after,omitempty"` + Data []string `json:"data,omitempty" url:"data,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *UsernamePage) GetAfter() *string { + if u == nil { + return nil + } + return u.After +} + +func (u *UsernamePage) GetData() []string { + if u == nil { + return nil + } + return u.Data +} + +func (u *UsernamePage) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UsernamePage) UnmarshalJSON(data []byte) error { + type unmarshaler UsernamePage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UsernamePage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UsernamePage) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + type ListUsersExtendedOptionalListResponse struct { Data *UserOptionalListContainer `json:"data,omitempty" url:"data,omitempty"` Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` @@ -232,6 +281,55 @@ func (l *ListUsersPaginationResponse) String() string { return fmt.Sprintf("%#v", l) } +type NextPage struct { + Page int `json:"page" url:"page"` + StartingAfter string `json:"starting_after" url:"starting_after"` + + extraProperties map[string]interface{} +} + +func (n *NextPage) GetPage() int { + if n == nil { + return 0 + } + return n.Page +} + +func (n *NextPage) GetStartingAfter() string { + if n == nil { + return "" + } + return n.StartingAfter +} + +func (n *NextPage) GetExtraProperties() map[string]interface{} { + return n.extraProperties +} + +func (n *NextPage) UnmarshalJSON(data []byte) error { + type unmarshaler NextPage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NextPage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *n) + if err != nil { + return err + } + n.extraProperties = extraProperties + + return nil +} + +func (n *NextPage) String() string { + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + type Order string const ( @@ -254,6 +352,301 @@ func (o Order) Ptr() *Order { return &o } +type Page struct { + // The current page + Page int `json:"page" url:"page"` + Next *NextPage `json:"next,omitempty" url:"next,omitempty"` + PerPage int `json:"per_page" url:"per_page"` + TotalPage int `json:"total_page" url:"total_page"` + + extraProperties map[string]interface{} +} + +func (p *Page) GetPage() int { + if p == nil { + return 0 + } + return p.Page +} + +func (p *Page) GetNext() *NextPage { + if p == nil { + return nil + } + return p.Next +} + +func (p *Page) GetPerPage() int { + if p == nil { + return 0 + } + return p.PerPage +} + +func (p *Page) GetTotalPage() int { + if p == nil { + return 0 + } + return p.TotalPage +} + +func (p *Page) GetExtraProperties() map[string]interface{} { + return p.extraProperties +} + +func (p *Page) UnmarshalJSON(data []byte) error { + type unmarshaler Page + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = Page(value) + + extraProperties, err := core.ExtractExtraProperties(data, *p) + if err != nil { + return err + } + p.extraProperties = extraProperties + + return nil +} + +func (p *Page) String() string { + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type User struct { + Name string `json:"name" url:"name"` + Id int `json:"id" url:"id"` + + extraProperties map[string]interface{} +} + +func (u *User) GetName() string { + if u == nil { + return "" + } + return u.Name +} + +func (u *User) GetId() int { + if u == nil { + return 0 + } + return u.Id +} + +func (u *User) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *User) UnmarshalJSON(data []byte) error { + type unmarshaler User + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = User(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *User) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UserListContainer struct { + Users []*User `json:"users,omitempty" url:"users,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *UserListContainer) GetUsers() []*User { + if u == nil { + return nil + } + return u.Users +} + +func (u *UserListContainer) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserListContainer) UnmarshalJSON(data []byte) error { + type unmarshaler UserListContainer + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserListContainer(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UserListContainer) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UserOptionalListContainer struct { + Users []*User `json:"users,omitempty" url:"users,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *UserOptionalListContainer) GetUsers() []*User { + if u == nil { + return nil + } + return u.Users +} + +func (u *UserOptionalListContainer) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserOptionalListContainer) UnmarshalJSON(data []byte) error { + type unmarshaler UserOptionalListContainer + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserOptionalListContainer(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UserOptionalListContainer) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UserOptionalListPage struct { + Data *UserOptionalListContainer `json:"data,omitempty" url:"data,omitempty"` + Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *UserOptionalListPage) GetData() *UserOptionalListContainer { + if u == nil { + return nil + } + return u.Data +} + +func (u *UserOptionalListPage) GetNext() *uuid.UUID { + if u == nil { + return nil + } + return u.Next +} + +func (u *UserOptionalListPage) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserOptionalListPage) UnmarshalJSON(data []byte) error { + type unmarshaler UserOptionalListPage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserOptionalListPage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UserOptionalListPage) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UserPage struct { + Data *UserListContainer `json:"data,omitempty" url:"data,omitempty"` + Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` + + extraProperties map[string]interface{} +} + +func (u *UserPage) GetData() *UserListContainer { + if u == nil { + return nil + } + return u.Data +} + +func (u *UserPage) GetNext() *uuid.UUID { + if u == nil { + return nil + } + return u.Next +} + +func (u *UserPage) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserPage) UnmarshalJSON(data []byte) error { + type unmarshaler UserPage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserPage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + return nil +} + +func (u *UserPage) String() string { + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + type UsernameContainer struct { Results []string `json:"results,omitempty" url:"results,omitempty"` diff --git a/seed/go-model/response-property/service.go b/seed/go-model/response-property/service.go index 5be7b7f72ec..3f20678abd8 100644 --- a/seed/go-model/response-property/service.go +++ b/seed/go-model/response-property/service.go @@ -51,6 +51,96 @@ func (s *StringResponse) String() string { return fmt.Sprintf("%#v", s) } +type WithMetadata struct { + Metadata map[string]string `json:"metadata,omitempty" url:"metadata,omitempty"` + + extraProperties map[string]interface{} +} + +func (w *WithMetadata) GetMetadata() map[string]string { + if w == nil { + return nil + } + return w.Metadata +} + +func (w *WithMetadata) GetExtraProperties() map[string]interface{} { + return w.extraProperties +} + +func (w *WithMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler WithMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *w = WithMetadata(value) + + extraProperties, err := core.ExtractExtraProperties(data, *w) + if err != nil { + return err + } + w.extraProperties = extraProperties + + return nil +} + +func (w *WithMetadata) String() string { + if value, err := core.StringifyJSON(w); err == nil { + return value + } + return fmt.Sprintf("%#v", w) +} + +type Movie struct { + Id string `json:"id" url:"id"` + Name string `json:"name" url:"name"` + + extraProperties map[string]interface{} +} + +func (m *Movie) GetId() string { + if m == nil { + return "" + } + return m.Id +} + +func (m *Movie) GetName() string { + if m == nil { + return "" + } + return m.Name +} + +func (m *Movie) GetExtraProperties() map[string]interface{} { + return m.extraProperties +} + +func (m *Movie) UnmarshalJSON(data []byte) error { + type unmarshaler Movie + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *m = Movie(value) + + extraProperties, err := core.ExtractExtraProperties(data, *m) + if err != nil { + return err + } + m.extraProperties = extraProperties + + return nil +} + +func (m *Movie) String() string { + if value, err := core.StringifyJSON(m); err == nil { + return value + } + return fmt.Sprintf("%#v", m) +} + type OptionalWithDocs = *WithDocs type Response struct { @@ -109,3 +199,44 @@ func (r *Response) String() string { } return fmt.Sprintf("%#v", r) } + +type WithDocs struct { + Docs string `json:"docs" url:"docs"` + + extraProperties map[string]interface{} +} + +func (w *WithDocs) GetDocs() string { + if w == nil { + return "" + } + return w.Docs +} + +func (w *WithDocs) GetExtraProperties() map[string]interface{} { + return w.extraProperties +} + +func (w *WithDocs) UnmarshalJSON(data []byte) error { + type unmarshaler WithDocs + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *w = WithDocs(value) + + extraProperties, err := core.ExtractExtraProperties(data, *w) + if err != nil { + return err + } + w.extraProperties = extraProperties + + return nil +} + +func (w *WithDocs) String() string { + if value, err := core.StringifyJSON(w); err == nil { + return value + } + return fmt.Sprintf("%#v", w) +} diff --git a/seed/go-model/response-property/types.go b/seed/go-model/response-property/types.go deleted file mode 100644 index 968222f01e6..00000000000 --- a/seed/go-model/response-property/types.go +++ /dev/null @@ -1,140 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package responseproperty - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/response-property/fern/core" -) - -type WithMetadata struct { - Metadata map[string]string `json:"metadata,omitempty" url:"metadata,omitempty"` - - extraProperties map[string]interface{} -} - -func (w *WithMetadata) GetMetadata() map[string]string { - if w == nil { - return nil - } - return w.Metadata -} - -func (w *WithMetadata) GetExtraProperties() map[string]interface{} { - return w.extraProperties -} - -func (w *WithMetadata) UnmarshalJSON(data []byte) error { - type unmarshaler WithMetadata - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *w = WithMetadata(value) - - extraProperties, err := core.ExtractExtraProperties(data, *w) - if err != nil { - return err - } - w.extraProperties = extraProperties - - return nil -} - -func (w *WithMetadata) String() string { - if value, err := core.StringifyJSON(w); err == nil { - return value - } - return fmt.Sprintf("%#v", w) -} - -type Movie struct { - Id string `json:"id" url:"id"` - Name string `json:"name" url:"name"` - - extraProperties map[string]interface{} -} - -func (m *Movie) GetId() string { - if m == nil { - return "" - } - return m.Id -} - -func (m *Movie) GetName() string { - if m == nil { - return "" - } - return m.Name -} - -func (m *Movie) GetExtraProperties() map[string]interface{} { - return m.extraProperties -} - -func (m *Movie) UnmarshalJSON(data []byte) error { - type unmarshaler Movie - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *m = Movie(value) - - extraProperties, err := core.ExtractExtraProperties(data, *m) - if err != nil { - return err - } - m.extraProperties = extraProperties - - return nil -} - -func (m *Movie) String() string { - if value, err := core.StringifyJSON(m); err == nil { - return value - } - return fmt.Sprintf("%#v", m) -} - -type WithDocs struct { - Docs string `json:"docs" url:"docs"` - - extraProperties map[string]interface{} -} - -func (w *WithDocs) GetDocs() string { - if w == nil { - return "" - } - return w.Docs -} - -func (w *WithDocs) GetExtraProperties() map[string]interface{} { - return w.extraProperties -} - -func (w *WithDocs) UnmarshalJSON(data []byte) error { - type unmarshaler WithDocs - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *w = WithDocs(value) - - extraProperties, err := core.ExtractExtraProperties(data, *w) - if err != nil { - return err - } - w.extraProperties = extraProperties - - return nil -} - -func (w *WithDocs) String() string { - if value, err := core.StringifyJSON(w); err == nil { - return value - } - return fmt.Sprintf("%#v", w) -} diff --git a/seed/go-model/undiscriminated-unions/types.go b/seed/go-model/undiscriminated-unions/types.go deleted file mode 100644 index d8e6c927076..00000000000 --- a/seed/go-model/undiscriminated-unions/types.go +++ /dev/null @@ -1,142 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package undiscriminatedunions - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/undiscriminated-unions/fern/core" -) - -type Key struct { - KeyType KeyType - defaultStringLiteral string - - typ string -} - -func NewKeyFromKeyType(value KeyType) *Key { - return &Key{typ: "KeyType", KeyType: value} -} - -func NewKeyWithDefaultStringLiteral() *Key { - return &Key{typ: "defaultStringLiteral", defaultStringLiteral: "default"} -} - -func (k *Key) GetKeyType() KeyType { - if k == nil { - return "" - } - return k.KeyType -} - -func (k *Key) DefaultStringLiteral() string { - return k.defaultStringLiteral -} - -func (k *Key) UnmarshalJSON(data []byte) error { - var valueKeyType KeyType - if err := json.Unmarshal(data, &valueKeyType); err == nil { - k.typ = "KeyType" - k.KeyType = valueKeyType - return nil - } - var valueDefaultStringLiteral string - if err := json.Unmarshal(data, &valueDefaultStringLiteral); err == nil { - k.typ = "defaultStringLiteral" - k.defaultStringLiteral = valueDefaultStringLiteral - if k.defaultStringLiteral != "default" { - return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", k, "default", valueDefaultStringLiteral) - } - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, k) -} - -func (k Key) MarshalJSON() ([]byte, error) { - if k.typ == "KeyType" || k.KeyType != "" { - return json.Marshal(k.KeyType) - } - if k.typ == "defaultStringLiteral" || k.defaultStringLiteral != "" { - return json.Marshal("default") - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", k) -} - -type KeyVisitor interface { - VisitKeyType(KeyType) error - VisitDefaultStringLiteral(string) error -} - -func (k *Key) Accept(visitor KeyVisitor) error { - if k.typ == "KeyType" || k.KeyType != "" { - return visitor.VisitKeyType(k.KeyType) - } - if k.typ == "defaultStringLiteral" || k.defaultStringLiteral != "" { - return visitor.VisitDefaultStringLiteral(k.defaultStringLiteral) - } - return fmt.Errorf("type %T does not include a non-empty union type", k) -} - -type KeyType string - -const ( - KeyTypeName KeyType = "name" - KeyTypeValue KeyType = "value" -) - -func NewKeyTypeFromString(s string) (KeyType, error) { - switch s { - case "name": - return KeyTypeName, nil - case "value": - return KeyTypeValue, nil - } - var t KeyType - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (k KeyType) Ptr() *KeyType { - return &k -} - -type TypeWithOptionalUnion struct { - MyUnion *MyUnion `json:"myUnion,omitempty" url:"myUnion,omitempty"` - - extraProperties map[string]interface{} -} - -func (t *TypeWithOptionalUnion) GetMyUnion() *MyUnion { - if t == nil { - return nil - } - return t.MyUnion -} - -func (t *TypeWithOptionalUnion) GetExtraProperties() map[string]interface{} { - return t.extraProperties -} - -func (t *TypeWithOptionalUnion) UnmarshalJSON(data []byte) error { - type unmarshaler TypeWithOptionalUnion - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *t = TypeWithOptionalUnion(value) - - extraProperties, err := core.ExtractExtraProperties(data, *t) - if err != nil { - return err - } - t.extraProperties = extraProperties - - return nil -} - -func (t *TypeWithOptionalUnion) String() string { - if value, err := core.StringifyJSON(t); err == nil { - return value - } - return fmt.Sprintf("%#v", t) -} diff --git a/seed/go-model/undiscriminated-unions/union.go b/seed/go-model/undiscriminated-unions/union.go index 5ac50a67ffc..e2959bdd52e 100644 --- a/seed/go-model/undiscriminated-unions/union.go +++ b/seed/go-model/undiscriminated-unions/union.go @@ -5,8 +5,101 @@ package undiscriminatedunions import ( json "encoding/json" fmt "fmt" + core "github.com/undiscriminated-unions/fern/core" ) +type Key struct { + KeyType KeyType + defaultStringLiteral string + + typ string +} + +func NewKeyFromKeyType(value KeyType) *Key { + return &Key{typ: "KeyType", KeyType: value} +} + +func NewKeyWithDefaultStringLiteral() *Key { + return &Key{typ: "defaultStringLiteral", defaultStringLiteral: "default"} +} + +func (k *Key) GetKeyType() KeyType { + if k == nil { + return "" + } + return k.KeyType +} + +func (k *Key) DefaultStringLiteral() string { + return k.defaultStringLiteral +} + +func (k *Key) UnmarshalJSON(data []byte) error { + var valueKeyType KeyType + if err := json.Unmarshal(data, &valueKeyType); err == nil { + k.typ = "KeyType" + k.KeyType = valueKeyType + return nil + } + var valueDefaultStringLiteral string + if err := json.Unmarshal(data, &valueDefaultStringLiteral); err == nil { + k.typ = "defaultStringLiteral" + k.defaultStringLiteral = valueDefaultStringLiteral + if k.defaultStringLiteral != "default" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", k, "default", valueDefaultStringLiteral) + } + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, k) +} + +func (k Key) MarshalJSON() ([]byte, error) { + if k.typ == "KeyType" || k.KeyType != "" { + return json.Marshal(k.KeyType) + } + if k.typ == "defaultStringLiteral" || k.defaultStringLiteral != "" { + return json.Marshal("default") + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", k) +} + +type KeyVisitor interface { + VisitKeyType(KeyType) error + VisitDefaultStringLiteral(string) error +} + +func (k *Key) Accept(visitor KeyVisitor) error { + if k.typ == "KeyType" || k.KeyType != "" { + return visitor.VisitKeyType(k.KeyType) + } + if k.typ == "defaultStringLiteral" || k.defaultStringLiteral != "" { + return visitor.VisitDefaultStringLiteral(k.defaultStringLiteral) + } + return fmt.Errorf("type %T does not include a non-empty union type", k) +} + +type KeyType string + +const ( + KeyTypeName KeyType = "name" + KeyTypeValue KeyType = "value" +) + +func NewKeyTypeFromString(s string) (KeyType, error) { + switch s { + case "name": + return KeyTypeName, nil + case "value": + return KeyTypeValue, nil + } + var t KeyType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (k KeyType) Ptr() *KeyType { + return &k +} + // Undiscriminated unions can act as a map key // as long as all of their values are valid keys // (i.e. do they have a valid string representation). @@ -182,3 +275,44 @@ func (m *MyUnion) Accept(visitor MyUnionVisitor) error { } return fmt.Errorf("type %T does not include a non-empty union type", m) } + +type TypeWithOptionalUnion struct { + MyUnion *MyUnion `json:"myUnion,omitempty" url:"myUnion,omitempty"` + + extraProperties map[string]interface{} +} + +func (t *TypeWithOptionalUnion) GetMyUnion() *MyUnion { + if t == nil { + return nil + } + return t.MyUnion +} + +func (t *TypeWithOptionalUnion) GetExtraProperties() map[string]interface{} { + return t.extraProperties +} + +func (t *TypeWithOptionalUnion) UnmarshalJSON(data []byte) error { + type unmarshaler TypeWithOptionalUnion + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = TypeWithOptionalUnion(value) + + extraProperties, err := core.ExtractExtraProperties(data, *t) + if err != nil { + return err + } + t.extraProperties = extraProperties + + return nil +} + +func (t *TypeWithOptionalUnion) String() string { + if value, err := core.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} diff --git a/seed/go-model/unions/types.go b/seed/go-model/unions/types.go index f403ffec7d8..1979023e38a 100644 --- a/seed/go-model/unions/types.go +++ b/seed/go-model/unions/types.go @@ -1158,126 +1158,3 @@ func (u *UnionWithoutKey) Accept(visitor UnionWithoutKeyVisitor) error { return visitor.VisitBar(u.Bar) } } - -type Circle struct { - Radius float64 `json:"radius" url:"radius"` - - extraProperties map[string]interface{} -} - -func (c *Circle) GetRadius() float64 { - if c == nil { - return 0 - } - return c.Radius -} - -func (c *Circle) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *Circle) UnmarshalJSON(data []byte) error { - type unmarshaler Circle - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = Circle(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - return nil -} - -func (c *Circle) String() string { - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type GetShapeRequest struct { - Id string `json:"id" url:"id"` - - extraProperties map[string]interface{} -} - -func (g *GetShapeRequest) GetId() string { - if g == nil { - return "" - } - return g.Id -} - -func (g *GetShapeRequest) GetExtraProperties() map[string]interface{} { - return g.extraProperties -} - -func (g *GetShapeRequest) UnmarshalJSON(data []byte) error { - type unmarshaler GetShapeRequest - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *g = GetShapeRequest(value) - - extraProperties, err := core.ExtractExtraProperties(data, *g) - if err != nil { - return err - } - g.extraProperties = extraProperties - - return nil -} - -func (g *GetShapeRequest) String() string { - if value, err := core.StringifyJSON(g); err == nil { - return value - } - return fmt.Sprintf("%#v", g) -} - -type Square struct { - Length float64 `json:"length" url:"length"` - - extraProperties map[string]interface{} -} - -func (s *Square) GetLength() float64 { - if s == nil { - return 0 - } - return s.Length -} - -func (s *Square) GetExtraProperties() map[string]interface{} { - return s.extraProperties -} - -func (s *Square) UnmarshalJSON(data []byte) error { - type unmarshaler Square - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = Square(value) - - extraProperties, err := core.ExtractExtraProperties(data, *s) - if err != nil { - return err - } - s.extraProperties = extraProperties - - return nil -} - -func (s *Square) String() string { - if value, err := core.StringifyJSON(s); err == nil { - return value - } - return fmt.Sprintf("%#v", s) -} diff --git a/seed/go-model/unions/union.go b/seed/go-model/unions/union.go index 7381d0b122e..070bb9be671 100644 --- a/seed/go-model/unions/union.go +++ b/seed/go-model/unions/union.go @@ -8,6 +8,88 @@ import ( core "github.com/unions/fern/core" ) +type Circle struct { + Radius float64 `json:"radius" url:"radius"` + + extraProperties map[string]interface{} +} + +func (c *Circle) GetRadius() float64 { + if c == nil { + return 0 + } + return c.Radius +} + +func (c *Circle) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *Circle) UnmarshalJSON(data []byte) error { + type unmarshaler Circle + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = Circle(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + return nil +} + +func (c *Circle) String() string { + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type GetShapeRequest struct { + Id string `json:"id" url:"id"` + + extraProperties map[string]interface{} +} + +func (g *GetShapeRequest) GetId() string { + if g == nil { + return "" + } + return g.Id +} + +func (g *GetShapeRequest) GetExtraProperties() map[string]interface{} { + return g.extraProperties +} + +func (g *GetShapeRequest) UnmarshalJSON(data []byte) error { + type unmarshaler GetShapeRequest + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *g = GetShapeRequest(value) + + extraProperties, err := core.ExtractExtraProperties(data, *g) + if err != nil { + return err + } + g.extraProperties = extraProperties + + return nil +} + +func (g *GetShapeRequest) String() string { + if value, err := core.StringifyJSON(g); err == nil { + return value + } + return fmt.Sprintf("%#v", g) +} + type Shape struct { Type string Id string @@ -107,3 +189,44 @@ func (s *Shape) Accept(visitor ShapeVisitor) error { return visitor.VisitSquare(s.Square) } } + +type Square struct { + Length float64 `json:"length" url:"length"` + + extraProperties map[string]interface{} +} + +func (s *Square) GetLength() float64 { + if s == nil { + return 0 + } + return s.Length +} + +func (s *Square) GetExtraProperties() map[string]interface{} { + return s.extraProperties +} + +func (s *Square) UnmarshalJSON(data []byte) error { + type unmarshaler Square + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = Square(value) + + extraProperties, err := core.ExtractExtraProperties(data, *s) + if err != nil { + return err + } + s.extraProperties = extraProperties + + return nil +} + +func (s *Square) String() string { + if value, err := core.StringifyJSON(s); err == nil { + return value + } + return fmt.Sprintf("%#v", s) +} diff --git a/seed/go-model/unknown/types.go b/seed/go-model/unknown/types.go deleted file mode 100644 index 500e23e0ba2..00000000000 --- a/seed/go-model/unknown/types.go +++ /dev/null @@ -1,5 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package unknownasany - -type MyAlias = interface{} diff --git a/seed/go-model/unknown/unknown.go b/seed/go-model/unknown/unknown.go index 9e057d019f3..00436b19b6d 100644 --- a/seed/go-model/unknown/unknown.go +++ b/seed/go-model/unknown/unknown.go @@ -8,6 +8,8 @@ import ( core "github.com/unknown/fern/core" ) +type MyAlias = interface{} + type MyObject struct { Unknown interface{} `json:"unknown,omitempty" url:"unknown,omitempty"` diff --git a/seed/go-model/examples/file/types.go b/seed/go-sdk/audiences/commons.go similarity index 62% rename from seed/go-model/examples/file/types.go rename to seed/go-sdk/audiences/commons.go index edc509f893e..b214fff131d 100644 --- a/seed/go-model/examples/file/types.go +++ b/seed/go-sdk/audiences/commons.go @@ -1,5 +1,5 @@ // This file was auto-generated by Fern from our API Definition. -package file +package audiences -type Filename = string +type Imported = string diff --git a/seed/go-sdk/audiences/folderb/types.go b/seed/go-sdk/audiences/folderb/common.go similarity index 100% rename from seed/go-sdk/audiences/folderb/types.go rename to seed/go-sdk/audiences/folderb/common.go diff --git a/seed/go-sdk/audiences/folderc/types.go b/seed/go-sdk/audiences/folderc/common.go similarity index 100% rename from seed/go-sdk/audiences/folderc/types.go rename to seed/go-sdk/audiences/folderc/common.go diff --git a/seed/go-sdk/audiences/foo.go b/seed/go-sdk/audiences/foo.go index 17f39d2d232..c1b85296beb 100644 --- a/seed/go-sdk/audiences/foo.go +++ b/seed/go-sdk/audiences/foo.go @@ -14,6 +14,62 @@ type FindRequest struct { PrivateProperty *int `json:"privateProperty,omitempty" url:"-"` } +type FilteredType struct { + PublicProperty *string `json:"public_property,omitempty" url:"public_property,omitempty"` + PrivateProperty int `json:"private_property" url:"private_property"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (f *FilteredType) GetPublicProperty() *string { + if f == nil { + return nil + } + return f.PublicProperty +} + +func (f *FilteredType) GetPrivateProperty() int { + if f == nil { + return 0 + } + return f.PrivateProperty +} + +func (f *FilteredType) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *FilteredType) UnmarshalJSON(data []byte) error { + type unmarshaler FilteredType + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = FilteredType(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + f._rawJSON = json.RawMessage(data) + return nil +} + +func (f *FilteredType) String() string { + if len(f._rawJSON) > 0 { + if value, err := core.StringifyJSON(f._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + type ImportingType struct { Imported Imported `json:"imported" url:"imported"` diff --git a/seed/go-sdk/audiences/types.go b/seed/go-sdk/audiences/types.go deleted file mode 100644 index ee35d1e921f..00000000000 --- a/seed/go-sdk/audiences/types.go +++ /dev/null @@ -1,67 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package audiences - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/audiences/fern/core" -) - -type Imported = string - -type FilteredType struct { - PublicProperty *string `json:"public_property,omitempty" url:"public_property,omitempty"` - PrivateProperty int `json:"private_property" url:"private_property"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (f *FilteredType) GetPublicProperty() *string { - if f == nil { - return nil - } - return f.PublicProperty -} - -func (f *FilteredType) GetPrivateProperty() int { - if f == nil { - return 0 - } - return f.PrivateProperty -} - -func (f *FilteredType) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *FilteredType) UnmarshalJSON(data []byte) error { - type unmarshaler FilteredType - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = FilteredType(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - f._rawJSON = json.RawMessage(data) - return nil -} - -func (f *FilteredType) String() string { - if len(f._rawJSON) > 0 { - if value, err := core.StringifyJSON(f._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} diff --git a/seed/go-sdk/circular-references-advanced/a.go b/seed/go-sdk/circular-references-advanced/a.go new file mode 100644 index 00000000000..0e9b0e2a9b5 --- /dev/null +++ b/seed/go-sdk/circular-references-advanced/a.go @@ -0,0 +1,57 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/circular-references-advanced/fern/core" +) + +type A struct { + S string `json:"s" url:"s"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (a *A) GetS() string { + if a == nil { + return "" + } + return a.S +} + +func (a *A) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *A) UnmarshalJSON(data []byte) error { + type unmarshaler A + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *a = A(value) + + extraProperties, err := core.ExtractExtraProperties(data, *a) + if err != nil { + return err + } + a.extraProperties = extraProperties + + a._rawJSON = json.RawMessage(data) + return nil +} + +func (a *A) String() string { + if len(a._rawJSON) > 0 { + if value, err := core.StringifyJSON(a._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} diff --git a/seed/go-sdk/circular-references-advanced/ast.go b/seed/go-sdk/circular-references-advanced/ast.go new file mode 100644 index 00000000000..5716d0731eb --- /dev/null +++ b/seed/go-sdk/circular-references-advanced/ast.go @@ -0,0 +1,368 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/circular-references-advanced/fern/core" +) + +type ContainerValue struct { + Type string + List []*FieldValue + Optional *FieldValue +} + +func NewContainerValueFromList(value []*FieldValue) *ContainerValue { + return &ContainerValue{Type: "list", List: value} +} + +func NewContainerValueFromOptional(value *FieldValue) *ContainerValue { + return &ContainerValue{Type: "optional", Optional: value} +} + +func (c *ContainerValue) GetType() string { + if c == nil { + return "" + } + return c.Type +} + +func (c *ContainerValue) GetList() []*FieldValue { + if c == nil { + return nil + } + return c.List +} + +func (c *ContainerValue) GetOptional() *FieldValue { + if c == nil { + return nil + } + return c.Optional +} + +func (c *ContainerValue) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + c.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", c) + } + switch unmarshaler.Type { + case "list": + var valueUnmarshaler struct { + List []*FieldValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + c.List = valueUnmarshaler.List + case "optional": + var valueUnmarshaler struct { + Optional *FieldValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + c.Optional = valueUnmarshaler.Optional + } + return nil +} + +func (c ContainerValue) MarshalJSON() ([]byte, error) { + switch c.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", c.Type, c) + case "list": + var marshaler = struct { + Type string `json:"type"` + List []*FieldValue `json:"value,omitempty"` + }{ + Type: "list", + List: c.List, + } + return json.Marshal(marshaler) + case "optional": + var marshaler = struct { + Type string `json:"type"` + Optional *FieldValue `json:"value,omitempty"` + }{ + Type: "optional", + Optional: c.Optional, + } + return json.Marshal(marshaler) + } +} + +type ContainerValueVisitor interface { + VisitList([]*FieldValue) error + VisitOptional(*FieldValue) error +} + +func (c *ContainerValue) Accept(visitor ContainerValueVisitor) error { + switch c.Type { + default: + return fmt.Errorf("invalid type %s in %T", c.Type, c) + case "list": + return visitor.VisitList(c.List) + case "optional": + return visitor.VisitOptional(c.Optional) + } +} + +type FieldName = string + +type FieldValue struct { + Type string + PrimitiveValue PrimitiveValue + ObjectValue *ObjectValue + ContainerValue *ContainerValue +} + +func NewFieldValueFromPrimitiveValue(value PrimitiveValue) *FieldValue { + return &FieldValue{Type: "primitive_value", PrimitiveValue: value} +} + +func NewFieldValueFromObjectValue(value *ObjectValue) *FieldValue { + return &FieldValue{Type: "object_value", ObjectValue: value} +} + +func NewFieldValueFromContainerValue(value *ContainerValue) *FieldValue { + return &FieldValue{Type: "container_value", ContainerValue: value} +} + +func (f *FieldValue) GetType() string { + if f == nil { + return "" + } + return f.Type +} + +func (f *FieldValue) GetPrimitiveValue() PrimitiveValue { + if f == nil { + return "" + } + return f.PrimitiveValue +} + +func (f *FieldValue) GetObjectValue() *ObjectValue { + if f == nil { + return nil + } + return f.ObjectValue +} + +func (f *FieldValue) GetContainerValue() *ContainerValue { + if f == nil { + return nil + } + return f.ContainerValue +} + +func (f *FieldValue) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + f.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", f) + } + switch unmarshaler.Type { + case "primitive_value": + var valueUnmarshaler struct { + PrimitiveValue PrimitiveValue `json:"value"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + f.PrimitiveValue = valueUnmarshaler.PrimitiveValue + case "object_value": + value := new(ObjectValue) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + f.ObjectValue = value + case "container_value": + var valueUnmarshaler struct { + ContainerValue *ContainerValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + f.ContainerValue = valueUnmarshaler.ContainerValue + } + return nil +} + +func (f FieldValue) MarshalJSON() ([]byte, error) { + switch f.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", f.Type, f) + case "primitive_value": + var marshaler = struct { + Type string `json:"type"` + PrimitiveValue PrimitiveValue `json:"value"` + }{ + Type: "primitive_value", + PrimitiveValue: f.PrimitiveValue, + } + return json.Marshal(marshaler) + case "object_value": + return core.MarshalJSONWithExtraProperty(f.ObjectValue, "type", "object_value") + case "container_value": + var marshaler = struct { + Type string `json:"type"` + ContainerValue *ContainerValue `json:"value,omitempty"` + }{ + Type: "container_value", + ContainerValue: f.ContainerValue, + } + return json.Marshal(marshaler) + } +} + +type FieldValueVisitor interface { + VisitPrimitiveValue(PrimitiveValue) error + VisitObjectValue(*ObjectValue) error + VisitContainerValue(*ContainerValue) error +} + +func (f *FieldValue) Accept(visitor FieldValueVisitor) error { + switch f.Type { + default: + return fmt.Errorf("invalid type %s in %T", f.Type, f) + case "primitive_value": + return visitor.VisitPrimitiveValue(f.PrimitiveValue) + case "object_value": + return visitor.VisitObjectValue(f.ObjectValue) + case "container_value": + return visitor.VisitContainerValue(f.ContainerValue) + } +} + +// This type allows us to test a circular reference with a union type (see FieldValue). +type ObjectFieldValue struct { + Name FieldName `json:"name" url:"name"` + Value *FieldValue `json:"value,omitempty" url:"value,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (o *ObjectFieldValue) GetName() FieldName { + if o == nil { + return "" + } + return o.Name +} + +func (o *ObjectFieldValue) GetValue() *FieldValue { + if o == nil { + return nil + } + return o.Value +} + +func (o *ObjectFieldValue) GetExtraProperties() map[string]interface{} { + return o.extraProperties +} + +func (o *ObjectFieldValue) UnmarshalJSON(data []byte) error { + type unmarshaler ObjectFieldValue + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *o = ObjectFieldValue(value) + + extraProperties, err := core.ExtractExtraProperties(data, *o) + if err != nil { + return err + } + o.extraProperties = extraProperties + + o._rawJSON = json.RawMessage(data) + return nil +} + +func (o *ObjectFieldValue) String() string { + if len(o._rawJSON) > 0 { + if value, err := core.StringifyJSON(o._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(o); err == nil { + return value + } + return fmt.Sprintf("%#v", o) +} + +type ObjectValue struct { + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (o *ObjectValue) GetExtraProperties() map[string]interface{} { + return o.extraProperties +} + +func (o *ObjectValue) UnmarshalJSON(data []byte) error { + type unmarshaler ObjectValue + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *o = ObjectValue(value) + + extraProperties, err := core.ExtractExtraProperties(data, *o) + if err != nil { + return err + } + o.extraProperties = extraProperties + + o._rawJSON = json.RawMessage(data) + return nil +} + +func (o *ObjectValue) String() string { + if len(o._rawJSON) > 0 { + if value, err := core.StringifyJSON(o._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(o); err == nil { + return value + } + return fmt.Sprintf("%#v", o) +} + +type PrimitiveValue string + +const ( + PrimitiveValueString PrimitiveValue = "STRING" + PrimitiveValueNumber PrimitiveValue = "NUMBER" +) + +func NewPrimitiveValueFromString(s string) (PrimitiveValue, error) { + switch s { + case "STRING": + return PrimitiveValueString, nil + case "NUMBER": + return PrimitiveValueNumber, nil + } + var t PrimitiveValue + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (p PrimitiveValue) Ptr() *PrimitiveValue { + return &p +} diff --git a/seed/go-sdk/circular-references-advanced/types.go b/seed/go-sdk/circular-references-advanced/types.go index 1cbe55da78b..5d1211d995f 100644 --- a/seed/go-sdk/circular-references-advanced/types.go +++ b/seed/go-sdk/circular-references-advanced/types.go @@ -103,410 +103,3 @@ func (r *RootType) String() string { } return fmt.Sprintf("%#v", r) } - -type A struct { - S string `json:"s" url:"s"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (a *A) GetS() string { - if a == nil { - return "" - } - return a.S -} - -func (a *A) GetExtraProperties() map[string]interface{} { - return a.extraProperties -} - -func (a *A) UnmarshalJSON(data []byte) error { - type unmarshaler A - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *a = A(value) - - extraProperties, err := core.ExtractExtraProperties(data, *a) - if err != nil { - return err - } - a.extraProperties = extraProperties - - a._rawJSON = json.RawMessage(data) - return nil -} - -func (a *A) String() string { - if len(a._rawJSON) > 0 { - if value, err := core.StringifyJSON(a._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(a); err == nil { - return value - } - return fmt.Sprintf("%#v", a) -} - -type ContainerValue struct { - Type string - List []*FieldValue - Optional *FieldValue -} - -func NewContainerValueFromList(value []*FieldValue) *ContainerValue { - return &ContainerValue{Type: "list", List: value} -} - -func NewContainerValueFromOptional(value *FieldValue) *ContainerValue { - return &ContainerValue{Type: "optional", Optional: value} -} - -func (c *ContainerValue) GetType() string { - if c == nil { - return "" - } - return c.Type -} - -func (c *ContainerValue) GetList() []*FieldValue { - if c == nil { - return nil - } - return c.List -} - -func (c *ContainerValue) GetOptional() *FieldValue { - if c == nil { - return nil - } - return c.Optional -} - -func (c *ContainerValue) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - c.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", c) - } - switch unmarshaler.Type { - case "list": - var valueUnmarshaler struct { - List []*FieldValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - c.List = valueUnmarshaler.List - case "optional": - var valueUnmarshaler struct { - Optional *FieldValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - c.Optional = valueUnmarshaler.Optional - } - return nil -} - -func (c ContainerValue) MarshalJSON() ([]byte, error) { - switch c.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", c.Type, c) - case "list": - var marshaler = struct { - Type string `json:"type"` - List []*FieldValue `json:"value,omitempty"` - }{ - Type: "list", - List: c.List, - } - return json.Marshal(marshaler) - case "optional": - var marshaler = struct { - Type string `json:"type"` - Optional *FieldValue `json:"value,omitempty"` - }{ - Type: "optional", - Optional: c.Optional, - } - return json.Marshal(marshaler) - } -} - -type ContainerValueVisitor interface { - VisitList([]*FieldValue) error - VisitOptional(*FieldValue) error -} - -func (c *ContainerValue) Accept(visitor ContainerValueVisitor) error { - switch c.Type { - default: - return fmt.Errorf("invalid type %s in %T", c.Type, c) - case "list": - return visitor.VisitList(c.List) - case "optional": - return visitor.VisitOptional(c.Optional) - } -} - -type FieldName = string - -type FieldValue struct { - Type string - PrimitiveValue PrimitiveValue - ObjectValue *ObjectValue - ContainerValue *ContainerValue -} - -func NewFieldValueFromPrimitiveValue(value PrimitiveValue) *FieldValue { - return &FieldValue{Type: "primitive_value", PrimitiveValue: value} -} - -func NewFieldValueFromObjectValue(value *ObjectValue) *FieldValue { - return &FieldValue{Type: "object_value", ObjectValue: value} -} - -func NewFieldValueFromContainerValue(value *ContainerValue) *FieldValue { - return &FieldValue{Type: "container_value", ContainerValue: value} -} - -func (f *FieldValue) GetType() string { - if f == nil { - return "" - } - return f.Type -} - -func (f *FieldValue) GetPrimitiveValue() PrimitiveValue { - if f == nil { - return "" - } - return f.PrimitiveValue -} - -func (f *FieldValue) GetObjectValue() *ObjectValue { - if f == nil { - return nil - } - return f.ObjectValue -} - -func (f *FieldValue) GetContainerValue() *ContainerValue { - if f == nil { - return nil - } - return f.ContainerValue -} - -func (f *FieldValue) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - f.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", f) - } - switch unmarshaler.Type { - case "primitive_value": - var valueUnmarshaler struct { - PrimitiveValue PrimitiveValue `json:"value"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - f.PrimitiveValue = valueUnmarshaler.PrimitiveValue - case "object_value": - value := new(ObjectValue) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - f.ObjectValue = value - case "container_value": - var valueUnmarshaler struct { - ContainerValue *ContainerValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - f.ContainerValue = valueUnmarshaler.ContainerValue - } - return nil -} - -func (f FieldValue) MarshalJSON() ([]byte, error) { - switch f.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", f.Type, f) - case "primitive_value": - var marshaler = struct { - Type string `json:"type"` - PrimitiveValue PrimitiveValue `json:"value"` - }{ - Type: "primitive_value", - PrimitiveValue: f.PrimitiveValue, - } - return json.Marshal(marshaler) - case "object_value": - return core.MarshalJSONWithExtraProperty(f.ObjectValue, "type", "object_value") - case "container_value": - var marshaler = struct { - Type string `json:"type"` - ContainerValue *ContainerValue `json:"value,omitempty"` - }{ - Type: "container_value", - ContainerValue: f.ContainerValue, - } - return json.Marshal(marshaler) - } -} - -type FieldValueVisitor interface { - VisitPrimitiveValue(PrimitiveValue) error - VisitObjectValue(*ObjectValue) error - VisitContainerValue(*ContainerValue) error -} - -func (f *FieldValue) Accept(visitor FieldValueVisitor) error { - switch f.Type { - default: - return fmt.Errorf("invalid type %s in %T", f.Type, f) - case "primitive_value": - return visitor.VisitPrimitiveValue(f.PrimitiveValue) - case "object_value": - return visitor.VisitObjectValue(f.ObjectValue) - case "container_value": - return visitor.VisitContainerValue(f.ContainerValue) - } -} - -// This type allows us to test a circular reference with a union type (see FieldValue). -type ObjectFieldValue struct { - Name FieldName `json:"name" url:"name"` - Value *FieldValue `json:"value,omitempty" url:"value,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (o *ObjectFieldValue) GetName() FieldName { - if o == nil { - return "" - } - return o.Name -} - -func (o *ObjectFieldValue) GetValue() *FieldValue { - if o == nil { - return nil - } - return o.Value -} - -func (o *ObjectFieldValue) GetExtraProperties() map[string]interface{} { - return o.extraProperties -} - -func (o *ObjectFieldValue) UnmarshalJSON(data []byte) error { - type unmarshaler ObjectFieldValue - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *o = ObjectFieldValue(value) - - extraProperties, err := core.ExtractExtraProperties(data, *o) - if err != nil { - return err - } - o.extraProperties = extraProperties - - o._rawJSON = json.RawMessage(data) - return nil -} - -func (o *ObjectFieldValue) String() string { - if len(o._rawJSON) > 0 { - if value, err := core.StringifyJSON(o._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(o); err == nil { - return value - } - return fmt.Sprintf("%#v", o) -} - -type ObjectValue struct { - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (o *ObjectValue) GetExtraProperties() map[string]interface{} { - return o.extraProperties -} - -func (o *ObjectValue) UnmarshalJSON(data []byte) error { - type unmarshaler ObjectValue - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *o = ObjectValue(value) - - extraProperties, err := core.ExtractExtraProperties(data, *o) - if err != nil { - return err - } - o.extraProperties = extraProperties - - o._rawJSON = json.RawMessage(data) - return nil -} - -func (o *ObjectValue) String() string { - if len(o._rawJSON) > 0 { - if value, err := core.StringifyJSON(o._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(o); err == nil { - return value - } - return fmt.Sprintf("%#v", o) -} - -type PrimitiveValue string - -const ( - PrimitiveValueString PrimitiveValue = "STRING" - PrimitiveValueNumber PrimitiveValue = "NUMBER" -) - -func NewPrimitiveValueFromString(s string) (PrimitiveValue, error) { - switch s { - case "STRING": - return PrimitiveValueString, nil - case "NUMBER": - return PrimitiveValueNumber, nil - } - var t PrimitiveValue - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (p PrimitiveValue) Ptr() *PrimitiveValue { - return &p -} diff --git a/seed/go-sdk/circular-references/a.go b/seed/go-sdk/circular-references/a.go new file mode 100644 index 00000000000..0000f158a74 --- /dev/null +++ b/seed/go-sdk/circular-references/a.go @@ -0,0 +1,57 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/circular-references/fern/core" +) + +type A struct { + S string `json:"s" url:"s"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (a *A) GetS() string { + if a == nil { + return "" + } + return a.S +} + +func (a *A) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *A) UnmarshalJSON(data []byte) error { + type unmarshaler A + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *a = A(value) + + extraProperties, err := core.ExtractExtraProperties(data, *a) + if err != nil { + return err + } + a.extraProperties = extraProperties + + a._rawJSON = json.RawMessage(data) + return nil +} + +func (a *A) String() string { + if len(a._rawJSON) > 0 { + if value, err := core.StringifyJSON(a._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} diff --git a/seed/go-sdk/circular-references/ast.go b/seed/go-sdk/circular-references/ast.go new file mode 100644 index 00000000000..e6e646811a3 --- /dev/null +++ b/seed/go-sdk/circular-references/ast.go @@ -0,0 +1,454 @@ +// This file was auto-generated by Fern from our API Definition. + +package api + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/circular-references/fern/core" +) + +type ContainerValue struct { + Type string + List []*FieldValue + Optional *FieldValue +} + +func NewContainerValueFromList(value []*FieldValue) *ContainerValue { + return &ContainerValue{Type: "list", List: value} +} + +func NewContainerValueFromOptional(value *FieldValue) *ContainerValue { + return &ContainerValue{Type: "optional", Optional: value} +} + +func (c *ContainerValue) GetType() string { + if c == nil { + return "" + } + return c.Type +} + +func (c *ContainerValue) GetList() []*FieldValue { + if c == nil { + return nil + } + return c.List +} + +func (c *ContainerValue) GetOptional() *FieldValue { + if c == nil { + return nil + } + return c.Optional +} + +func (c *ContainerValue) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + c.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", c) + } + switch unmarshaler.Type { + case "list": + var valueUnmarshaler struct { + List []*FieldValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + c.List = valueUnmarshaler.List + case "optional": + var valueUnmarshaler struct { + Optional *FieldValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + c.Optional = valueUnmarshaler.Optional + } + return nil +} + +func (c ContainerValue) MarshalJSON() ([]byte, error) { + switch c.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", c.Type, c) + case "list": + var marshaler = struct { + Type string `json:"type"` + List []*FieldValue `json:"value,omitempty"` + }{ + Type: "list", + List: c.List, + } + return json.Marshal(marshaler) + case "optional": + var marshaler = struct { + Type string `json:"type"` + Optional *FieldValue `json:"value,omitempty"` + }{ + Type: "optional", + Optional: c.Optional, + } + return json.Marshal(marshaler) + } +} + +type ContainerValueVisitor interface { + VisitList([]*FieldValue) error + VisitOptional(*FieldValue) error +} + +func (c *ContainerValue) Accept(visitor ContainerValueVisitor) error { + switch c.Type { + default: + return fmt.Errorf("invalid type %s in %T", c.Type, c) + case "list": + return visitor.VisitList(c.List) + case "optional": + return visitor.VisitOptional(c.Optional) + } +} + +type FieldValue struct { + Type string + PrimitiveValue PrimitiveValue + ObjectValue *ObjectValue + ContainerValue *ContainerValue +} + +func NewFieldValueFromPrimitiveValue(value PrimitiveValue) *FieldValue { + return &FieldValue{Type: "primitive_value", PrimitiveValue: value} +} + +func NewFieldValueFromObjectValue(value *ObjectValue) *FieldValue { + return &FieldValue{Type: "object_value", ObjectValue: value} +} + +func NewFieldValueFromContainerValue(value *ContainerValue) *FieldValue { + return &FieldValue{Type: "container_value", ContainerValue: value} +} + +func (f *FieldValue) GetType() string { + if f == nil { + return "" + } + return f.Type +} + +func (f *FieldValue) GetPrimitiveValue() PrimitiveValue { + if f == nil { + return "" + } + return f.PrimitiveValue +} + +func (f *FieldValue) GetObjectValue() *ObjectValue { + if f == nil { + return nil + } + return f.ObjectValue +} + +func (f *FieldValue) GetContainerValue() *ContainerValue { + if f == nil { + return nil + } + return f.ContainerValue +} + +func (f *FieldValue) UnmarshalJSON(data []byte) error { + var unmarshaler struct { + Type string `json:"type"` + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + f.Type = unmarshaler.Type + if unmarshaler.Type == "" { + return fmt.Errorf("%T did not include discriminant type", f) + } + switch unmarshaler.Type { + case "primitive_value": + var valueUnmarshaler struct { + PrimitiveValue PrimitiveValue `json:"value"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + f.PrimitiveValue = valueUnmarshaler.PrimitiveValue + case "object_value": + value := new(ObjectValue) + if err := json.Unmarshal(data, &value); err != nil { + return err + } + f.ObjectValue = value + case "container_value": + var valueUnmarshaler struct { + ContainerValue *ContainerValue `json:"value,omitempty"` + } + if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { + return err + } + f.ContainerValue = valueUnmarshaler.ContainerValue + } + return nil +} + +func (f FieldValue) MarshalJSON() ([]byte, error) { + switch f.Type { + default: + return nil, fmt.Errorf("invalid type %s in %T", f.Type, f) + case "primitive_value": + var marshaler = struct { + Type string `json:"type"` + PrimitiveValue PrimitiveValue `json:"value"` + }{ + Type: "primitive_value", + PrimitiveValue: f.PrimitiveValue, + } + return json.Marshal(marshaler) + case "object_value": + return core.MarshalJSONWithExtraProperty(f.ObjectValue, "type", "object_value") + case "container_value": + var marshaler = struct { + Type string `json:"type"` + ContainerValue *ContainerValue `json:"value,omitempty"` + }{ + Type: "container_value", + ContainerValue: f.ContainerValue, + } + return json.Marshal(marshaler) + } +} + +type FieldValueVisitor interface { + VisitPrimitiveValue(PrimitiveValue) error + VisitObjectValue(*ObjectValue) error + VisitContainerValue(*ContainerValue) error +} + +func (f *FieldValue) Accept(visitor FieldValueVisitor) error { + switch f.Type { + default: + return fmt.Errorf("invalid type %s in %T", f.Type, f) + case "primitive_value": + return visitor.VisitPrimitiveValue(f.PrimitiveValue) + case "object_value": + return visitor.VisitObjectValue(f.ObjectValue) + case "container_value": + return visitor.VisitContainerValue(f.ContainerValue) + } +} + +type JsonLike struct { + JsonLikeList []*JsonLike + StringJsonLikeMap map[string]*JsonLike + String string + Integer int + Boolean bool + + typ string +} + +func NewJsonLikeFromJsonLikeList(value []*JsonLike) *JsonLike { + return &JsonLike{typ: "JsonLikeList", JsonLikeList: value} +} + +func NewJsonLikeFromStringJsonLikeMap(value map[string]*JsonLike) *JsonLike { + return &JsonLike{typ: "StringJsonLikeMap", StringJsonLikeMap: value} +} + +func NewJsonLikeFromString(value string) *JsonLike { + return &JsonLike{typ: "String", String: value} +} + +func NewJsonLikeFromInteger(value int) *JsonLike { + return &JsonLike{typ: "Integer", Integer: value} +} + +func NewJsonLikeFromBoolean(value bool) *JsonLike { + return &JsonLike{typ: "Boolean", Boolean: value} +} + +func (j *JsonLike) GetJsonLikeList() []*JsonLike { + if j == nil { + return nil + } + return j.JsonLikeList +} + +func (j *JsonLike) GetStringJsonLikeMap() map[string]*JsonLike { + if j == nil { + return nil + } + return j.StringJsonLikeMap +} + +func (j *JsonLike) GetString() string { + if j == nil { + return "" + } + return j.String +} + +func (j *JsonLike) GetInteger() int { + if j == nil { + return 0 + } + return j.Integer +} + +func (j *JsonLike) GetBoolean() bool { + if j == nil { + return false + } + return j.Boolean +} + +func (j *JsonLike) UnmarshalJSON(data []byte) error { + var valueJsonLikeList []*JsonLike + if err := json.Unmarshal(data, &valueJsonLikeList); err == nil { + j.typ = "JsonLikeList" + j.JsonLikeList = valueJsonLikeList + return nil + } + var valueStringJsonLikeMap map[string]*JsonLike + if err := json.Unmarshal(data, &valueStringJsonLikeMap); err == nil { + j.typ = "StringJsonLikeMap" + j.StringJsonLikeMap = valueStringJsonLikeMap + return nil + } + var valueString string + if err := json.Unmarshal(data, &valueString); err == nil { + j.typ = "String" + j.String = valueString + return nil + } + var valueInteger int + if err := json.Unmarshal(data, &valueInteger); err == nil { + j.typ = "Integer" + j.Integer = valueInteger + return nil + } + var valueBoolean bool + if err := json.Unmarshal(data, &valueBoolean); err == nil { + j.typ = "Boolean" + j.Boolean = valueBoolean + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, j) +} + +func (j JsonLike) MarshalJSON() ([]byte, error) { + if j.typ == "JsonLikeList" || j.JsonLikeList != nil { + return json.Marshal(j.JsonLikeList) + } + if j.typ == "StringJsonLikeMap" || j.StringJsonLikeMap != nil { + return json.Marshal(j.StringJsonLikeMap) + } + if j.typ == "String" || j.String != "" { + return json.Marshal(j.String) + } + if j.typ == "Integer" || j.Integer != 0 { + return json.Marshal(j.Integer) + } + if j.typ == "Boolean" || j.Boolean != false { + return json.Marshal(j.Boolean) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", j) +} + +type JsonLikeVisitor interface { + VisitJsonLikeList([]*JsonLike) error + VisitStringJsonLikeMap(map[string]*JsonLike) error + VisitString(string) error + VisitInteger(int) error + VisitBoolean(bool) error +} + +func (j *JsonLike) Accept(visitor JsonLikeVisitor) error { + if j.typ == "JsonLikeList" || j.JsonLikeList != nil { + return visitor.VisitJsonLikeList(j.JsonLikeList) + } + if j.typ == "StringJsonLikeMap" || j.StringJsonLikeMap != nil { + return visitor.VisitStringJsonLikeMap(j.StringJsonLikeMap) + } + if j.typ == "String" || j.String != "" { + return visitor.VisitString(j.String) + } + if j.typ == "Integer" || j.Integer != 0 { + return visitor.VisitInteger(j.Integer) + } + if j.typ == "Boolean" || j.Boolean != false { + return visitor.VisitBoolean(j.Boolean) + } + return fmt.Errorf("type %T does not include a non-empty union type", j) +} + +type ObjectValue struct { + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (o *ObjectValue) GetExtraProperties() map[string]interface{} { + return o.extraProperties +} + +func (o *ObjectValue) UnmarshalJSON(data []byte) error { + type unmarshaler ObjectValue + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *o = ObjectValue(value) + + extraProperties, err := core.ExtractExtraProperties(data, *o) + if err != nil { + return err + } + o.extraProperties = extraProperties + + o._rawJSON = json.RawMessage(data) + return nil +} + +func (o *ObjectValue) String() string { + if len(o._rawJSON) > 0 { + if value, err := core.StringifyJSON(o._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(o); err == nil { + return value + } + return fmt.Sprintf("%#v", o) +} + +type PrimitiveValue string + +const ( + PrimitiveValueString PrimitiveValue = "STRING" + PrimitiveValueNumber PrimitiveValue = "NUMBER" +) + +func NewPrimitiveValueFromString(s string) (PrimitiveValue, error) { + switch s { + case "STRING": + return PrimitiveValueString, nil + case "NUMBER": + return PrimitiveValueNumber, nil + } + var t PrimitiveValue + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (p PrimitiveValue) Ptr() *PrimitiveValue { + return &p +} diff --git a/seed/go-sdk/circular-references/types.go b/seed/go-sdk/circular-references/types.go index 1c58caedfc1..ef3563dd469 100644 --- a/seed/go-sdk/circular-references/types.go +++ b/seed/go-sdk/circular-references/types.go @@ -103,496 +103,3 @@ func (r *RootType) String() string { } return fmt.Sprintf("%#v", r) } - -type A struct { - S string `json:"s" url:"s"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (a *A) GetS() string { - if a == nil { - return "" - } - return a.S -} - -func (a *A) GetExtraProperties() map[string]interface{} { - return a.extraProperties -} - -func (a *A) UnmarshalJSON(data []byte) error { - type unmarshaler A - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *a = A(value) - - extraProperties, err := core.ExtractExtraProperties(data, *a) - if err != nil { - return err - } - a.extraProperties = extraProperties - - a._rawJSON = json.RawMessage(data) - return nil -} - -func (a *A) String() string { - if len(a._rawJSON) > 0 { - if value, err := core.StringifyJSON(a._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(a); err == nil { - return value - } - return fmt.Sprintf("%#v", a) -} - -type ContainerValue struct { - Type string - List []*FieldValue - Optional *FieldValue -} - -func NewContainerValueFromList(value []*FieldValue) *ContainerValue { - return &ContainerValue{Type: "list", List: value} -} - -func NewContainerValueFromOptional(value *FieldValue) *ContainerValue { - return &ContainerValue{Type: "optional", Optional: value} -} - -func (c *ContainerValue) GetType() string { - if c == nil { - return "" - } - return c.Type -} - -func (c *ContainerValue) GetList() []*FieldValue { - if c == nil { - return nil - } - return c.List -} - -func (c *ContainerValue) GetOptional() *FieldValue { - if c == nil { - return nil - } - return c.Optional -} - -func (c *ContainerValue) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - c.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", c) - } - switch unmarshaler.Type { - case "list": - var valueUnmarshaler struct { - List []*FieldValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - c.List = valueUnmarshaler.List - case "optional": - var valueUnmarshaler struct { - Optional *FieldValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - c.Optional = valueUnmarshaler.Optional - } - return nil -} - -func (c ContainerValue) MarshalJSON() ([]byte, error) { - switch c.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", c.Type, c) - case "list": - var marshaler = struct { - Type string `json:"type"` - List []*FieldValue `json:"value,omitempty"` - }{ - Type: "list", - List: c.List, - } - return json.Marshal(marshaler) - case "optional": - var marshaler = struct { - Type string `json:"type"` - Optional *FieldValue `json:"value,omitempty"` - }{ - Type: "optional", - Optional: c.Optional, - } - return json.Marshal(marshaler) - } -} - -type ContainerValueVisitor interface { - VisitList([]*FieldValue) error - VisitOptional(*FieldValue) error -} - -func (c *ContainerValue) Accept(visitor ContainerValueVisitor) error { - switch c.Type { - default: - return fmt.Errorf("invalid type %s in %T", c.Type, c) - case "list": - return visitor.VisitList(c.List) - case "optional": - return visitor.VisitOptional(c.Optional) - } -} - -type FieldValue struct { - Type string - PrimitiveValue PrimitiveValue - ObjectValue *ObjectValue - ContainerValue *ContainerValue -} - -func NewFieldValueFromPrimitiveValue(value PrimitiveValue) *FieldValue { - return &FieldValue{Type: "primitive_value", PrimitiveValue: value} -} - -func NewFieldValueFromObjectValue(value *ObjectValue) *FieldValue { - return &FieldValue{Type: "object_value", ObjectValue: value} -} - -func NewFieldValueFromContainerValue(value *ContainerValue) *FieldValue { - return &FieldValue{Type: "container_value", ContainerValue: value} -} - -func (f *FieldValue) GetType() string { - if f == nil { - return "" - } - return f.Type -} - -func (f *FieldValue) GetPrimitiveValue() PrimitiveValue { - if f == nil { - return "" - } - return f.PrimitiveValue -} - -func (f *FieldValue) GetObjectValue() *ObjectValue { - if f == nil { - return nil - } - return f.ObjectValue -} - -func (f *FieldValue) GetContainerValue() *ContainerValue { - if f == nil { - return nil - } - return f.ContainerValue -} - -func (f *FieldValue) UnmarshalJSON(data []byte) error { - var unmarshaler struct { - Type string `json:"type"` - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - f.Type = unmarshaler.Type - if unmarshaler.Type == "" { - return fmt.Errorf("%T did not include discriminant type", f) - } - switch unmarshaler.Type { - case "primitive_value": - var valueUnmarshaler struct { - PrimitiveValue PrimitiveValue `json:"value"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - f.PrimitiveValue = valueUnmarshaler.PrimitiveValue - case "object_value": - value := new(ObjectValue) - if err := json.Unmarshal(data, &value); err != nil { - return err - } - f.ObjectValue = value - case "container_value": - var valueUnmarshaler struct { - ContainerValue *ContainerValue `json:"value,omitempty"` - } - if err := json.Unmarshal(data, &valueUnmarshaler); err != nil { - return err - } - f.ContainerValue = valueUnmarshaler.ContainerValue - } - return nil -} - -func (f FieldValue) MarshalJSON() ([]byte, error) { - switch f.Type { - default: - return nil, fmt.Errorf("invalid type %s in %T", f.Type, f) - case "primitive_value": - var marshaler = struct { - Type string `json:"type"` - PrimitiveValue PrimitiveValue `json:"value"` - }{ - Type: "primitive_value", - PrimitiveValue: f.PrimitiveValue, - } - return json.Marshal(marshaler) - case "object_value": - return core.MarshalJSONWithExtraProperty(f.ObjectValue, "type", "object_value") - case "container_value": - var marshaler = struct { - Type string `json:"type"` - ContainerValue *ContainerValue `json:"value,omitempty"` - }{ - Type: "container_value", - ContainerValue: f.ContainerValue, - } - return json.Marshal(marshaler) - } -} - -type FieldValueVisitor interface { - VisitPrimitiveValue(PrimitiveValue) error - VisitObjectValue(*ObjectValue) error - VisitContainerValue(*ContainerValue) error -} - -func (f *FieldValue) Accept(visitor FieldValueVisitor) error { - switch f.Type { - default: - return fmt.Errorf("invalid type %s in %T", f.Type, f) - case "primitive_value": - return visitor.VisitPrimitiveValue(f.PrimitiveValue) - case "object_value": - return visitor.VisitObjectValue(f.ObjectValue) - case "container_value": - return visitor.VisitContainerValue(f.ContainerValue) - } -} - -type JsonLike struct { - JsonLikeList []*JsonLike - StringJsonLikeMap map[string]*JsonLike - String string - Integer int - Boolean bool - - typ string -} - -func NewJsonLikeFromJsonLikeList(value []*JsonLike) *JsonLike { - return &JsonLike{typ: "JsonLikeList", JsonLikeList: value} -} - -func NewJsonLikeFromStringJsonLikeMap(value map[string]*JsonLike) *JsonLike { - return &JsonLike{typ: "StringJsonLikeMap", StringJsonLikeMap: value} -} - -func NewJsonLikeFromString(value string) *JsonLike { - return &JsonLike{typ: "String", String: value} -} - -func NewJsonLikeFromInteger(value int) *JsonLike { - return &JsonLike{typ: "Integer", Integer: value} -} - -func NewJsonLikeFromBoolean(value bool) *JsonLike { - return &JsonLike{typ: "Boolean", Boolean: value} -} - -func (j *JsonLike) GetJsonLikeList() []*JsonLike { - if j == nil { - return nil - } - return j.JsonLikeList -} - -func (j *JsonLike) GetStringJsonLikeMap() map[string]*JsonLike { - if j == nil { - return nil - } - return j.StringJsonLikeMap -} - -func (j *JsonLike) GetString() string { - if j == nil { - return "" - } - return j.String -} - -func (j *JsonLike) GetInteger() int { - if j == nil { - return 0 - } - return j.Integer -} - -func (j *JsonLike) GetBoolean() bool { - if j == nil { - return false - } - return j.Boolean -} - -func (j *JsonLike) UnmarshalJSON(data []byte) error { - var valueJsonLikeList []*JsonLike - if err := json.Unmarshal(data, &valueJsonLikeList); err == nil { - j.typ = "JsonLikeList" - j.JsonLikeList = valueJsonLikeList - return nil - } - var valueStringJsonLikeMap map[string]*JsonLike - if err := json.Unmarshal(data, &valueStringJsonLikeMap); err == nil { - j.typ = "StringJsonLikeMap" - j.StringJsonLikeMap = valueStringJsonLikeMap - return nil - } - var valueString string - if err := json.Unmarshal(data, &valueString); err == nil { - j.typ = "String" - j.String = valueString - return nil - } - var valueInteger int - if err := json.Unmarshal(data, &valueInteger); err == nil { - j.typ = "Integer" - j.Integer = valueInteger - return nil - } - var valueBoolean bool - if err := json.Unmarshal(data, &valueBoolean); err == nil { - j.typ = "Boolean" - j.Boolean = valueBoolean - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, j) -} - -func (j JsonLike) MarshalJSON() ([]byte, error) { - if j.typ == "JsonLikeList" || j.JsonLikeList != nil { - return json.Marshal(j.JsonLikeList) - } - if j.typ == "StringJsonLikeMap" || j.StringJsonLikeMap != nil { - return json.Marshal(j.StringJsonLikeMap) - } - if j.typ == "String" || j.String != "" { - return json.Marshal(j.String) - } - if j.typ == "Integer" || j.Integer != 0 { - return json.Marshal(j.Integer) - } - if j.typ == "Boolean" || j.Boolean != false { - return json.Marshal(j.Boolean) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", j) -} - -type JsonLikeVisitor interface { - VisitJsonLikeList([]*JsonLike) error - VisitStringJsonLikeMap(map[string]*JsonLike) error - VisitString(string) error - VisitInteger(int) error - VisitBoolean(bool) error -} - -func (j *JsonLike) Accept(visitor JsonLikeVisitor) error { - if j.typ == "JsonLikeList" || j.JsonLikeList != nil { - return visitor.VisitJsonLikeList(j.JsonLikeList) - } - if j.typ == "StringJsonLikeMap" || j.StringJsonLikeMap != nil { - return visitor.VisitStringJsonLikeMap(j.StringJsonLikeMap) - } - if j.typ == "String" || j.String != "" { - return visitor.VisitString(j.String) - } - if j.typ == "Integer" || j.Integer != 0 { - return visitor.VisitInteger(j.Integer) - } - if j.typ == "Boolean" || j.Boolean != false { - return visitor.VisitBoolean(j.Boolean) - } - return fmt.Errorf("type %T does not include a non-empty union type", j) -} - -type ObjectValue struct { - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (o *ObjectValue) GetExtraProperties() map[string]interface{} { - return o.extraProperties -} - -func (o *ObjectValue) UnmarshalJSON(data []byte) error { - type unmarshaler ObjectValue - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *o = ObjectValue(value) - - extraProperties, err := core.ExtractExtraProperties(data, *o) - if err != nil { - return err - } - o.extraProperties = extraProperties - - o._rawJSON = json.RawMessage(data) - return nil -} - -func (o *ObjectValue) String() string { - if len(o._rawJSON) > 0 { - if value, err := core.StringifyJSON(o._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(o); err == nil { - return value - } - return fmt.Sprintf("%#v", o) -} - -type PrimitiveValue string - -const ( - PrimitiveValueString PrimitiveValue = "STRING" - PrimitiveValueNumber PrimitiveValue = "NUMBER" -) - -func NewPrimitiveValueFromString(s string) (PrimitiveValue, error) { - switch s { - case "STRING": - return PrimitiveValueString, nil - case "NUMBER": - return PrimitiveValueNumber, nil - } - var t PrimitiveValue - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (p PrimitiveValue) Ptr() *PrimitiveValue { - return &p -} diff --git a/seed/go-sdk/cross-package-type-names/types.go b/seed/go-sdk/cross-package-type-names/commons.go similarity index 100% rename from seed/go-sdk/cross-package-type-names/types.go rename to seed/go-sdk/cross-package-type-names/commons.go diff --git a/seed/go-sdk/cross-package-type-names/folderb/types.go b/seed/go-sdk/cross-package-type-names/folderb/common.go similarity index 100% rename from seed/go-sdk/cross-package-type-names/folderb/types.go rename to seed/go-sdk/cross-package-type-names/folderb/common.go diff --git a/seed/go-sdk/cross-package-type-names/folderc/types.go b/seed/go-sdk/cross-package-type-names/folderc/common.go similarity index 100% rename from seed/go-sdk/cross-package-type-names/folderc/types.go rename to seed/go-sdk/cross-package-type-names/folderc/common.go diff --git a/seed/go-sdk/examples/always-send-required-properties/file/service.go b/seed/go-sdk/examples/always-send-required-properties/file/service.go index 23fdbef7190..421311b1af4 100644 --- a/seed/go-sdk/examples/always-send-required-properties/file/service.go +++ b/seed/go-sdk/examples/always-send-required-properties/file/service.go @@ -5,3 +5,5 @@ package file type GetFileRequest struct { XFileApiVersion string `json:"-" url:"-"` } + +type Filename = string diff --git a/seed/go-sdk/examples/exported-client-name/file/service.go b/seed/go-sdk/examples/exported-client-name/file/service.go index 23fdbef7190..421311b1af4 100644 --- a/seed/go-sdk/examples/exported-client-name/file/service.go +++ b/seed/go-sdk/examples/exported-client-name/file/service.go @@ -5,3 +5,5 @@ package file type GetFileRequest struct { XFileApiVersion string `json:"-" url:"-"` } + +type Filename = string diff --git a/seed/go-sdk/examples/exported-client-name/file/types.go b/seed/go-sdk/examples/exported-client-name/file/types.go deleted file mode 100644 index edc509f893e..00000000000 --- a/seed/go-sdk/examples/exported-client-name/file/types.go +++ /dev/null @@ -1,5 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package file - -type Filename = string diff --git a/seed/go-sdk/examples/no-custom-config/file/service.go b/seed/go-sdk/examples/no-custom-config/file/service.go index 23fdbef7190..421311b1af4 100644 --- a/seed/go-sdk/examples/no-custom-config/file/service.go +++ b/seed/go-sdk/examples/no-custom-config/file/service.go @@ -5,3 +5,5 @@ package file type GetFileRequest struct { XFileApiVersion string `json:"-" url:"-"` } + +type Filename = string diff --git a/seed/go-sdk/examples/no-custom-config/file/types.go b/seed/go-sdk/examples/no-custom-config/file/types.go deleted file mode 100644 index edc509f893e..00000000000 --- a/seed/go-sdk/examples/no-custom-config/file/types.go +++ /dev/null @@ -1,5 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package file - -type Filename = string diff --git a/seed/go-sdk/grpc-proto-exhaustive/dataservice.go b/seed/go-sdk/grpc-proto-exhaustive/dataservice.go index 28fc86668d6..6bfbed803d1 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dataservice.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dataservice.go @@ -2,6 +2,12 @@ package api +import ( + json "encoding/json" + fmt "fmt" + core "github.com/grpc-proto-exhaustive/fern/core" +) + type DeleteRequest struct { Ids []string `json:"ids,omitempty" url:"-"` DeleteAll *bool `json:"deleteAll,omitempty" url:"-"` @@ -37,6 +43,1113 @@ type QueryRequest struct { IndexedData *IndexedData `json:"indexedData,omitempty" url:"-"` } +type Column struct { + Id string `json:"id" url:"id"` + Values []float64 `json:"values,omitempty" url:"values,omitempty"` + Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` + IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (c *Column) GetId() string { + if c == nil { + return "" + } + return c.Id +} + +func (c *Column) GetValues() []float64 { + if c == nil { + return nil + } + return c.Values +} + +func (c *Column) GetMetadata() *Metadata { + if c == nil { + return nil + } + return c.Metadata +} + +func (c *Column) GetIndexedData() *IndexedData { + if c == nil { + return nil + } + return c.IndexedData +} + +func (c *Column) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *Column) UnmarshalJSON(data []byte) error { + type unmarshaler Column + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = Column(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + c._rawJSON = json.RawMessage(data) + return nil +} + +func (c *Column) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type DeleteResponse struct { + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (d *DeleteResponse) GetExtraProperties() map[string]interface{} { + return d.extraProperties +} + +func (d *DeleteResponse) UnmarshalJSON(data []byte) error { + type unmarshaler DeleteResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DeleteResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *d) + if err != nil { + return err + } + d.extraProperties = extraProperties + + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DeleteResponse) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type DescribeResponse struct { + Namespaces map[string]*NamespaceSummary `json:"namespaces,omitempty" url:"namespaces,omitempty"` + Dimension *int `json:"dimension,omitempty" url:"dimension,omitempty"` + Fullness *float64 `json:"fullness,omitempty" url:"fullness,omitempty"` + TotalCount *int `json:"totalCount,omitempty" url:"totalCount,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (d *DescribeResponse) GetNamespaces() map[string]*NamespaceSummary { + if d == nil { + return nil + } + return d.Namespaces +} + +func (d *DescribeResponse) GetDimension() *int { + if d == nil { + return nil + } + return d.Dimension +} + +func (d *DescribeResponse) GetFullness() *float64 { + if d == nil { + return nil + } + return d.Fullness +} + +func (d *DescribeResponse) GetTotalCount() *int { + if d == nil { + return nil + } + return d.TotalCount +} + +func (d *DescribeResponse) GetExtraProperties() map[string]interface{} { + return d.extraProperties +} + +func (d *DescribeResponse) UnmarshalJSON(data []byte) error { + type unmarshaler DescribeResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *d = DescribeResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *d) + if err != nil { + return err + } + d.extraProperties = extraProperties + + d._rawJSON = json.RawMessage(data) + return nil +} + +func (d *DescribeResponse) String() string { + if len(d._rawJSON) > 0 { + if value, err := core.StringifyJSON(d._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(d); err == nil { + return value + } + return fmt.Sprintf("%#v", d) +} + +type FetchResponse struct { + Columns map[string]*Column `json:"columns,omitempty" url:"columns,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (f *FetchResponse) GetColumns() map[string]*Column { + if f == nil { + return nil + } + return f.Columns +} + +func (f *FetchResponse) GetNamespace() *string { + if f == nil { + return nil + } + return f.Namespace +} + +func (f *FetchResponse) GetUsage() *Usage { + if f == nil { + return nil + } + return f.Usage +} + +func (f *FetchResponse) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *FetchResponse) UnmarshalJSON(data []byte) error { + type unmarshaler FetchResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = FetchResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + f._rawJSON = json.RawMessage(data) + return nil +} + +func (f *FetchResponse) String() string { + if len(f._rawJSON) > 0 { + if value, err := core.StringifyJSON(f._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + +type IndexedData struct { + Indices []int `json:"indices,omitempty" url:"indices,omitempty"` + Values []float64 `json:"values,omitempty" url:"values,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (i *IndexedData) GetIndices() []int { + if i == nil { + return nil + } + return i.Indices +} + +func (i *IndexedData) GetValues() []float64 { + if i == nil { + return nil + } + return i.Values +} + +func (i *IndexedData) GetExtraProperties() map[string]interface{} { + return i.extraProperties +} + +func (i *IndexedData) UnmarshalJSON(data []byte) error { + type unmarshaler IndexedData + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *i = IndexedData(value) + + extraProperties, err := core.ExtractExtraProperties(data, *i) + if err != nil { + return err + } + i.extraProperties = extraProperties + + i._rawJSON = json.RawMessage(data) + return nil +} + +func (i *IndexedData) String() string { + if len(i._rawJSON) > 0 { + if value, err := core.StringifyJSON(i._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(i); err == nil { + return value + } + return fmt.Sprintf("%#v", i) +} + +type ListElement struct { + Id *string `json:"id,omitempty" url:"id,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (l *ListElement) GetId() *string { + if l == nil { + return nil + } + return l.Id +} + +func (l *ListElement) GetExtraProperties() map[string]interface{} { + return l.extraProperties +} + +func (l *ListElement) UnmarshalJSON(data []byte) error { + type unmarshaler ListElement + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *l = ListElement(value) + + extraProperties, err := core.ExtractExtraProperties(data, *l) + if err != nil { + return err + } + l.extraProperties = extraProperties + + l._rawJSON = json.RawMessage(data) + return nil +} + +func (l *ListElement) String() string { + if len(l._rawJSON) > 0 { + if value, err := core.StringifyJSON(l._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(l); err == nil { + return value + } + return fmt.Sprintf("%#v", l) +} + +type ListResponse struct { + Columns []*ListElement `json:"columns,omitempty" url:"columns,omitempty"` + Pagination *Pagination `json:"pagination,omitempty" url:"pagination,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (l *ListResponse) GetColumns() []*ListElement { + if l == nil { + return nil + } + return l.Columns +} + +func (l *ListResponse) GetPagination() *Pagination { + if l == nil { + return nil + } + return l.Pagination +} + +func (l *ListResponse) GetNamespace() *string { + if l == nil { + return nil + } + return l.Namespace +} + +func (l *ListResponse) GetUsage() *Usage { + if l == nil { + return nil + } + return l.Usage +} + +func (l *ListResponse) GetExtraProperties() map[string]interface{} { + return l.extraProperties +} + +func (l *ListResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ListResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *l = ListResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *l) + if err != nil { + return err + } + l.extraProperties = extraProperties + + l._rawJSON = json.RawMessage(data) + return nil +} + +func (l *ListResponse) String() string { + if len(l._rawJSON) > 0 { + if value, err := core.StringifyJSON(l._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(l); err == nil { + return value + } + return fmt.Sprintf("%#v", l) +} + +type Metadata struct { + StringMetadataValueMap map[string]*MetadataValue + StringUnknownMap map[string]interface{} + + typ string +} + +func NewMetadataFromStringMetadataValueMap(value map[string]*MetadataValue) *Metadata { + return &Metadata{typ: "StringMetadataValueMap", StringMetadataValueMap: value} +} + +func NewMetadataFromStringUnknownMap(value map[string]interface{}) *Metadata { + return &Metadata{typ: "StringUnknownMap", StringUnknownMap: value} +} + +func (m *Metadata) GetStringMetadataValueMap() map[string]*MetadataValue { + if m == nil { + return nil + } + return m.StringMetadataValueMap +} + +func (m *Metadata) GetStringUnknownMap() map[string]interface{} { + if m == nil { + return nil + } + return m.StringUnknownMap +} + +func (m *Metadata) UnmarshalJSON(data []byte) error { + var valueStringMetadataValueMap map[string]*MetadataValue + if err := json.Unmarshal(data, &valueStringMetadataValueMap); err == nil { + m.typ = "StringMetadataValueMap" + m.StringMetadataValueMap = valueStringMetadataValueMap + return nil + } + var valueStringUnknownMap map[string]interface{} + if err := json.Unmarshal(data, &valueStringUnknownMap); err == nil { + m.typ = "StringUnknownMap" + m.StringUnknownMap = valueStringUnknownMap + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, m) +} + +func (m Metadata) MarshalJSON() ([]byte, error) { + if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { + return json.Marshal(m.StringMetadataValueMap) + } + if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { + return json.Marshal(m.StringUnknownMap) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataVisitor interface { + VisitStringMetadataValueMap(map[string]*MetadataValue) error + VisitStringUnknownMap(map[string]interface{}) error +} + +func (m *Metadata) Accept(visitor MetadataVisitor) error { + if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { + return visitor.VisitStringMetadataValueMap(m.StringMetadataValueMap) + } + if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { + return visitor.VisitStringUnknownMap(m.StringUnknownMap) + } + return fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataValue struct { + Double float64 + String string + Boolean bool + + typ string +} + +func NewMetadataValueFromDouble(value float64) *MetadataValue { + return &MetadataValue{typ: "Double", Double: value} +} + +func NewMetadataValueFromString(value string) *MetadataValue { + return &MetadataValue{typ: "String", String: value} +} + +func NewMetadataValueFromBoolean(value bool) *MetadataValue { + return &MetadataValue{typ: "Boolean", Boolean: value} +} + +func (m *MetadataValue) GetDouble() float64 { + if m == nil { + return 0 + } + return m.Double +} + +func (m *MetadataValue) GetString() string { + if m == nil { + return "" + } + return m.String +} + +func (m *MetadataValue) GetBoolean() bool { + if m == nil { + return false + } + return m.Boolean +} + +func (m *MetadataValue) UnmarshalJSON(data []byte) error { + var valueDouble float64 + if err := json.Unmarshal(data, &valueDouble); err == nil { + m.typ = "Double" + m.Double = valueDouble + return nil + } + var valueString string + if err := json.Unmarshal(data, &valueString); err == nil { + m.typ = "String" + m.String = valueString + return nil + } + var valueBoolean bool + if err := json.Unmarshal(data, &valueBoolean); err == nil { + m.typ = "Boolean" + m.Boolean = valueBoolean + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, m) +} + +func (m MetadataValue) MarshalJSON() ([]byte, error) { + if m.typ == "Double" || m.Double != 0 { + return json.Marshal(m.Double) + } + if m.typ == "String" || m.String != "" { + return json.Marshal(m.String) + } + if m.typ == "Boolean" || m.Boolean != false { + return json.Marshal(m.Boolean) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataValueVisitor interface { + VisitDouble(float64) error + VisitString(string) error + VisitBoolean(bool) error +} + +func (m *MetadataValue) Accept(visitor MetadataValueVisitor) error { + if m.typ == "Double" || m.Double != 0 { + return visitor.VisitDouble(m.Double) + } + if m.typ == "String" || m.String != "" { + return visitor.VisitString(m.String) + } + if m.typ == "Boolean" || m.Boolean != false { + return visitor.VisitBoolean(m.Boolean) + } + return fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type NamespaceSummary struct { + Count *int `json:"count,omitempty" url:"count,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (n *NamespaceSummary) GetCount() *int { + if n == nil { + return nil + } + return n.Count +} + +func (n *NamespaceSummary) GetExtraProperties() map[string]interface{} { + return n.extraProperties +} + +func (n *NamespaceSummary) UnmarshalJSON(data []byte) error { + type unmarshaler NamespaceSummary + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NamespaceSummary(value) + + extraProperties, err := core.ExtractExtraProperties(data, *n) + if err != nil { + return err + } + n.extraProperties = extraProperties + + n._rawJSON = json.RawMessage(data) + return nil +} + +func (n *NamespaceSummary) String() string { + if len(n._rawJSON) > 0 { + if value, err := core.StringifyJSON(n._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + +type Pagination struct { + Next *string `json:"next,omitempty" url:"next,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (p *Pagination) GetNext() *string { + if p == nil { + return nil + } + return p.Next +} + +func (p *Pagination) GetExtraProperties() map[string]interface{} { + return p.extraProperties +} + +func (p *Pagination) UnmarshalJSON(data []byte) error { + type unmarshaler Pagination + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = Pagination(value) + + extraProperties, err := core.ExtractExtraProperties(data, *p) + if err != nil { + return err + } + p.extraProperties = extraProperties + + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *Pagination) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type QueryColumn struct { + Values []float64 `json:"values,omitempty" url:"values,omitempty"` + TopK *int `json:"topK,omitempty" url:"topK,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + Filter *Metadata `json:"filter,omitempty" url:"filter,omitempty"` + IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (q *QueryColumn) GetValues() []float64 { + if q == nil { + return nil + } + return q.Values +} + +func (q *QueryColumn) GetTopK() *int { + if q == nil { + return nil + } + return q.TopK +} + +func (q *QueryColumn) GetNamespace() *string { + if q == nil { + return nil + } + return q.Namespace +} + +func (q *QueryColumn) GetFilter() *Metadata { + if q == nil { + return nil + } + return q.Filter +} + +func (q *QueryColumn) GetIndexedData() *IndexedData { + if q == nil { + return nil + } + return q.IndexedData +} + +func (q *QueryColumn) GetExtraProperties() map[string]interface{} { + return q.extraProperties +} + +func (q *QueryColumn) UnmarshalJSON(data []byte) error { + type unmarshaler QueryColumn + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *q = QueryColumn(value) + + extraProperties, err := core.ExtractExtraProperties(data, *q) + if err != nil { + return err + } + q.extraProperties = extraProperties + + q._rawJSON = json.RawMessage(data) + return nil +} + +func (q *QueryColumn) String() string { + if len(q._rawJSON) > 0 { + if value, err := core.StringifyJSON(q._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(q); err == nil { + return value + } + return fmt.Sprintf("%#v", q) +} + +type QueryResponse struct { + Results []*QueryResult `json:"results,omitempty" url:"results,omitempty"` + Matches []*ScoredColumn `json:"matches,omitempty" url:"matches,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (q *QueryResponse) GetResults() []*QueryResult { + if q == nil { + return nil + } + return q.Results +} + +func (q *QueryResponse) GetMatches() []*ScoredColumn { + if q == nil { + return nil + } + return q.Matches +} + +func (q *QueryResponse) GetNamespace() *string { + if q == nil { + return nil + } + return q.Namespace +} + +func (q *QueryResponse) GetUsage() *Usage { + if q == nil { + return nil + } + return q.Usage +} + +func (q *QueryResponse) GetExtraProperties() map[string]interface{} { + return q.extraProperties +} + +func (q *QueryResponse) UnmarshalJSON(data []byte) error { + type unmarshaler QueryResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *q = QueryResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *q) + if err != nil { + return err + } + q.extraProperties = extraProperties + + q._rawJSON = json.RawMessage(data) + return nil +} + +func (q *QueryResponse) String() string { + if len(q._rawJSON) > 0 { + if value, err := core.StringifyJSON(q._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(q); err == nil { + return value + } + return fmt.Sprintf("%#v", q) +} + +type QueryResult struct { + Matches []*ScoredColumn `json:"matches,omitempty" url:"matches,omitempty"` + Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (q *QueryResult) GetMatches() []*ScoredColumn { + if q == nil { + return nil + } + return q.Matches +} + +func (q *QueryResult) GetNamespace() *string { + if q == nil { + return nil + } + return q.Namespace +} + +func (q *QueryResult) GetExtraProperties() map[string]interface{} { + return q.extraProperties +} + +func (q *QueryResult) UnmarshalJSON(data []byte) error { + type unmarshaler QueryResult + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *q = QueryResult(value) + + extraProperties, err := core.ExtractExtraProperties(data, *q) + if err != nil { + return err + } + q.extraProperties = extraProperties + + q._rawJSON = json.RawMessage(data) + return nil +} + +func (q *QueryResult) String() string { + if len(q._rawJSON) > 0 { + if value, err := core.StringifyJSON(q._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(q); err == nil { + return value + } + return fmt.Sprintf("%#v", q) +} + +type ScoredColumn struct { + Id string `json:"id" url:"id"` + Score *float64 `json:"score,omitempty" url:"score,omitempty"` + Values []float64 `json:"values,omitempty" url:"values,omitempty"` + Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` + IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (s *ScoredColumn) GetId() string { + if s == nil { + return "" + } + return s.Id +} + +func (s *ScoredColumn) GetScore() *float64 { + if s == nil { + return nil + } + return s.Score +} + +func (s *ScoredColumn) GetValues() []float64 { + if s == nil { + return nil + } + return s.Values +} + +func (s *ScoredColumn) GetMetadata() *Metadata { + if s == nil { + return nil + } + return s.Metadata +} + +func (s *ScoredColumn) GetIndexedData() *IndexedData { + if s == nil { + return nil + } + return s.IndexedData +} + +func (s *ScoredColumn) GetExtraProperties() map[string]interface{} { + return s.extraProperties +} + +func (s *ScoredColumn) UnmarshalJSON(data []byte) error { + type unmarshaler ScoredColumn + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = ScoredColumn(value) + + extraProperties, err := core.ExtractExtraProperties(data, *s) + if err != nil { + return err + } + s.extraProperties = extraProperties + + s._rawJSON = json.RawMessage(data) + return nil +} + +func (s *ScoredColumn) String() string { + if len(s._rawJSON) > 0 { + if value, err := core.StringifyJSON(s._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(s); err == nil { + return value + } + return fmt.Sprintf("%#v", s) +} + +type UpdateResponse struct { + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (u *UpdateResponse) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UpdateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UpdateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UpdateResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UpdateResponse) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UploadResponse struct { + Count *int `json:"count,omitempty" url:"count,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (u *UploadResponse) GetCount() *int { + if u == nil { + return nil + } + return u.Count +} + +func (u *UploadResponse) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UploadResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UploadResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UploadResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UploadResponse) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type Usage struct { + Units *int `json:"units,omitempty" url:"units,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (u *Usage) GetUnits() *int { + if u == nil { + return nil + } + return u.Units +} + +func (u *Usage) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *Usage) UnmarshalJSON(data []byte) error { + type unmarshaler Usage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = Usage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *Usage) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + type UpdateRequest struct { Id string `json:"id" url:"-"` Values []float64 `json:"values,omitempty" url:"-"` diff --git a/seed/go-sdk/grpc-proto-exhaustive/types.go b/seed/go-sdk/grpc-proto-exhaustive/types.go deleted file mode 100644 index 84dbdf536d3..00000000000 --- a/seed/go-sdk/grpc-proto-exhaustive/types.go +++ /dev/null @@ -1,1116 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/grpc-proto-exhaustive/fern/core" -) - -type Column struct { - Id string `json:"id" url:"id"` - Values []float64 `json:"values,omitempty" url:"values,omitempty"` - Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` - IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (c *Column) GetId() string { - if c == nil { - return "" - } - return c.Id -} - -func (c *Column) GetValues() []float64 { - if c == nil { - return nil - } - return c.Values -} - -func (c *Column) GetMetadata() *Metadata { - if c == nil { - return nil - } - return c.Metadata -} - -func (c *Column) GetIndexedData() *IndexedData { - if c == nil { - return nil - } - return c.IndexedData -} - -func (c *Column) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *Column) UnmarshalJSON(data []byte) error { - type unmarshaler Column - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = Column(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - c._rawJSON = json.RawMessage(data) - return nil -} - -func (c *Column) String() string { - if len(c._rawJSON) > 0 { - if value, err := core.StringifyJSON(c._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type DeleteResponse struct { - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (d *DeleteResponse) GetExtraProperties() map[string]interface{} { - return d.extraProperties -} - -func (d *DeleteResponse) UnmarshalJSON(data []byte) error { - type unmarshaler DeleteResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *d = DeleteResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *d) - if err != nil { - return err - } - d.extraProperties = extraProperties - - d._rawJSON = json.RawMessage(data) - return nil -} - -func (d *DeleteResponse) String() string { - if len(d._rawJSON) > 0 { - if value, err := core.StringifyJSON(d._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(d); err == nil { - return value - } - return fmt.Sprintf("%#v", d) -} - -type DescribeResponse struct { - Namespaces map[string]*NamespaceSummary `json:"namespaces,omitempty" url:"namespaces,omitempty"` - Dimension *int `json:"dimension,omitempty" url:"dimension,omitempty"` - Fullness *float64 `json:"fullness,omitempty" url:"fullness,omitempty"` - TotalCount *int `json:"totalCount,omitempty" url:"totalCount,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (d *DescribeResponse) GetNamespaces() map[string]*NamespaceSummary { - if d == nil { - return nil - } - return d.Namespaces -} - -func (d *DescribeResponse) GetDimension() *int { - if d == nil { - return nil - } - return d.Dimension -} - -func (d *DescribeResponse) GetFullness() *float64 { - if d == nil { - return nil - } - return d.Fullness -} - -func (d *DescribeResponse) GetTotalCount() *int { - if d == nil { - return nil - } - return d.TotalCount -} - -func (d *DescribeResponse) GetExtraProperties() map[string]interface{} { - return d.extraProperties -} - -func (d *DescribeResponse) UnmarshalJSON(data []byte) error { - type unmarshaler DescribeResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *d = DescribeResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *d) - if err != nil { - return err - } - d.extraProperties = extraProperties - - d._rawJSON = json.RawMessage(data) - return nil -} - -func (d *DescribeResponse) String() string { - if len(d._rawJSON) > 0 { - if value, err := core.StringifyJSON(d._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(d); err == nil { - return value - } - return fmt.Sprintf("%#v", d) -} - -type FetchResponse struct { - Columns map[string]*Column `json:"columns,omitempty" url:"columns,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (f *FetchResponse) GetColumns() map[string]*Column { - if f == nil { - return nil - } - return f.Columns -} - -func (f *FetchResponse) GetNamespace() *string { - if f == nil { - return nil - } - return f.Namespace -} - -func (f *FetchResponse) GetUsage() *Usage { - if f == nil { - return nil - } - return f.Usage -} - -func (f *FetchResponse) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *FetchResponse) UnmarshalJSON(data []byte) error { - type unmarshaler FetchResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = FetchResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - f._rawJSON = json.RawMessage(data) - return nil -} - -func (f *FetchResponse) String() string { - if len(f._rawJSON) > 0 { - if value, err := core.StringifyJSON(f._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} - -type IndexedData struct { - Indices []int `json:"indices,omitempty" url:"indices,omitempty"` - Values []float64 `json:"values,omitempty" url:"values,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (i *IndexedData) GetIndices() []int { - if i == nil { - return nil - } - return i.Indices -} - -func (i *IndexedData) GetValues() []float64 { - if i == nil { - return nil - } - return i.Values -} - -func (i *IndexedData) GetExtraProperties() map[string]interface{} { - return i.extraProperties -} - -func (i *IndexedData) UnmarshalJSON(data []byte) error { - type unmarshaler IndexedData - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *i = IndexedData(value) - - extraProperties, err := core.ExtractExtraProperties(data, *i) - if err != nil { - return err - } - i.extraProperties = extraProperties - - i._rawJSON = json.RawMessage(data) - return nil -} - -func (i *IndexedData) String() string { - if len(i._rawJSON) > 0 { - if value, err := core.StringifyJSON(i._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(i); err == nil { - return value - } - return fmt.Sprintf("%#v", i) -} - -type ListElement struct { - Id *string `json:"id,omitempty" url:"id,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (l *ListElement) GetId() *string { - if l == nil { - return nil - } - return l.Id -} - -func (l *ListElement) GetExtraProperties() map[string]interface{} { - return l.extraProperties -} - -func (l *ListElement) UnmarshalJSON(data []byte) error { - type unmarshaler ListElement - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *l = ListElement(value) - - extraProperties, err := core.ExtractExtraProperties(data, *l) - if err != nil { - return err - } - l.extraProperties = extraProperties - - l._rawJSON = json.RawMessage(data) - return nil -} - -func (l *ListElement) String() string { - if len(l._rawJSON) > 0 { - if value, err := core.StringifyJSON(l._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(l); err == nil { - return value - } - return fmt.Sprintf("%#v", l) -} - -type ListResponse struct { - Columns []*ListElement `json:"columns,omitempty" url:"columns,omitempty"` - Pagination *Pagination `json:"pagination,omitempty" url:"pagination,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (l *ListResponse) GetColumns() []*ListElement { - if l == nil { - return nil - } - return l.Columns -} - -func (l *ListResponse) GetPagination() *Pagination { - if l == nil { - return nil - } - return l.Pagination -} - -func (l *ListResponse) GetNamespace() *string { - if l == nil { - return nil - } - return l.Namespace -} - -func (l *ListResponse) GetUsage() *Usage { - if l == nil { - return nil - } - return l.Usage -} - -func (l *ListResponse) GetExtraProperties() map[string]interface{} { - return l.extraProperties -} - -func (l *ListResponse) UnmarshalJSON(data []byte) error { - type unmarshaler ListResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *l = ListResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *l) - if err != nil { - return err - } - l.extraProperties = extraProperties - - l._rawJSON = json.RawMessage(data) - return nil -} - -func (l *ListResponse) String() string { - if len(l._rawJSON) > 0 { - if value, err := core.StringifyJSON(l._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(l); err == nil { - return value - } - return fmt.Sprintf("%#v", l) -} - -type Metadata struct { - StringMetadataValueMap map[string]*MetadataValue - StringUnknownMap map[string]interface{} - - typ string -} - -func NewMetadataFromStringMetadataValueMap(value map[string]*MetadataValue) *Metadata { - return &Metadata{typ: "StringMetadataValueMap", StringMetadataValueMap: value} -} - -func NewMetadataFromStringUnknownMap(value map[string]interface{}) *Metadata { - return &Metadata{typ: "StringUnknownMap", StringUnknownMap: value} -} - -func (m *Metadata) GetStringMetadataValueMap() map[string]*MetadataValue { - if m == nil { - return nil - } - return m.StringMetadataValueMap -} - -func (m *Metadata) GetStringUnknownMap() map[string]interface{} { - if m == nil { - return nil - } - return m.StringUnknownMap -} - -func (m *Metadata) UnmarshalJSON(data []byte) error { - var valueStringMetadataValueMap map[string]*MetadataValue - if err := json.Unmarshal(data, &valueStringMetadataValueMap); err == nil { - m.typ = "StringMetadataValueMap" - m.StringMetadataValueMap = valueStringMetadataValueMap - return nil - } - var valueStringUnknownMap map[string]interface{} - if err := json.Unmarshal(data, &valueStringUnknownMap); err == nil { - m.typ = "StringUnknownMap" - m.StringUnknownMap = valueStringUnknownMap - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, m) -} - -func (m Metadata) MarshalJSON() ([]byte, error) { - if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { - return json.Marshal(m.StringMetadataValueMap) - } - if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { - return json.Marshal(m.StringUnknownMap) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataVisitor interface { - VisitStringMetadataValueMap(map[string]*MetadataValue) error - VisitStringUnknownMap(map[string]interface{}) error -} - -func (m *Metadata) Accept(visitor MetadataVisitor) error { - if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { - return visitor.VisitStringMetadataValueMap(m.StringMetadataValueMap) - } - if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { - return visitor.VisitStringUnknownMap(m.StringUnknownMap) - } - return fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataValue struct { - Double float64 - String string - Boolean bool - - typ string -} - -func NewMetadataValueFromDouble(value float64) *MetadataValue { - return &MetadataValue{typ: "Double", Double: value} -} - -func NewMetadataValueFromString(value string) *MetadataValue { - return &MetadataValue{typ: "String", String: value} -} - -func NewMetadataValueFromBoolean(value bool) *MetadataValue { - return &MetadataValue{typ: "Boolean", Boolean: value} -} - -func (m *MetadataValue) GetDouble() float64 { - if m == nil { - return 0 - } - return m.Double -} - -func (m *MetadataValue) GetString() string { - if m == nil { - return "" - } - return m.String -} - -func (m *MetadataValue) GetBoolean() bool { - if m == nil { - return false - } - return m.Boolean -} - -func (m *MetadataValue) UnmarshalJSON(data []byte) error { - var valueDouble float64 - if err := json.Unmarshal(data, &valueDouble); err == nil { - m.typ = "Double" - m.Double = valueDouble - return nil - } - var valueString string - if err := json.Unmarshal(data, &valueString); err == nil { - m.typ = "String" - m.String = valueString - return nil - } - var valueBoolean bool - if err := json.Unmarshal(data, &valueBoolean); err == nil { - m.typ = "Boolean" - m.Boolean = valueBoolean - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, m) -} - -func (m MetadataValue) MarshalJSON() ([]byte, error) { - if m.typ == "Double" || m.Double != 0 { - return json.Marshal(m.Double) - } - if m.typ == "String" || m.String != "" { - return json.Marshal(m.String) - } - if m.typ == "Boolean" || m.Boolean != false { - return json.Marshal(m.Boolean) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataValueVisitor interface { - VisitDouble(float64) error - VisitString(string) error - VisitBoolean(bool) error -} - -func (m *MetadataValue) Accept(visitor MetadataValueVisitor) error { - if m.typ == "Double" || m.Double != 0 { - return visitor.VisitDouble(m.Double) - } - if m.typ == "String" || m.String != "" { - return visitor.VisitString(m.String) - } - if m.typ == "Boolean" || m.Boolean != false { - return visitor.VisitBoolean(m.Boolean) - } - return fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type NamespaceSummary struct { - Count *int `json:"count,omitempty" url:"count,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (n *NamespaceSummary) GetCount() *int { - if n == nil { - return nil - } - return n.Count -} - -func (n *NamespaceSummary) GetExtraProperties() map[string]interface{} { - return n.extraProperties -} - -func (n *NamespaceSummary) UnmarshalJSON(data []byte) error { - type unmarshaler NamespaceSummary - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *n = NamespaceSummary(value) - - extraProperties, err := core.ExtractExtraProperties(data, *n) - if err != nil { - return err - } - n.extraProperties = extraProperties - - n._rawJSON = json.RawMessage(data) - return nil -} - -func (n *NamespaceSummary) String() string { - if len(n._rawJSON) > 0 { - if value, err := core.StringifyJSON(n._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(n); err == nil { - return value - } - return fmt.Sprintf("%#v", n) -} - -type Pagination struct { - Next *string `json:"next,omitempty" url:"next,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (p *Pagination) GetNext() *string { - if p == nil { - return nil - } - return p.Next -} - -func (p *Pagination) GetExtraProperties() map[string]interface{} { - return p.extraProperties -} - -func (p *Pagination) UnmarshalJSON(data []byte) error { - type unmarshaler Pagination - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *p = Pagination(value) - - extraProperties, err := core.ExtractExtraProperties(data, *p) - if err != nil { - return err - } - p.extraProperties = extraProperties - - p._rawJSON = json.RawMessage(data) - return nil -} - -func (p *Pagination) String() string { - if len(p._rawJSON) > 0 { - if value, err := core.StringifyJSON(p._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(p); err == nil { - return value - } - return fmt.Sprintf("%#v", p) -} - -type QueryColumn struct { - Values []float64 `json:"values,omitempty" url:"values,omitempty"` - TopK *int `json:"topK,omitempty" url:"topK,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - Filter *Metadata `json:"filter,omitempty" url:"filter,omitempty"` - IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (q *QueryColumn) GetValues() []float64 { - if q == nil { - return nil - } - return q.Values -} - -func (q *QueryColumn) GetTopK() *int { - if q == nil { - return nil - } - return q.TopK -} - -func (q *QueryColumn) GetNamespace() *string { - if q == nil { - return nil - } - return q.Namespace -} - -func (q *QueryColumn) GetFilter() *Metadata { - if q == nil { - return nil - } - return q.Filter -} - -func (q *QueryColumn) GetIndexedData() *IndexedData { - if q == nil { - return nil - } - return q.IndexedData -} - -func (q *QueryColumn) GetExtraProperties() map[string]interface{} { - return q.extraProperties -} - -func (q *QueryColumn) UnmarshalJSON(data []byte) error { - type unmarshaler QueryColumn - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *q = QueryColumn(value) - - extraProperties, err := core.ExtractExtraProperties(data, *q) - if err != nil { - return err - } - q.extraProperties = extraProperties - - q._rawJSON = json.RawMessage(data) - return nil -} - -func (q *QueryColumn) String() string { - if len(q._rawJSON) > 0 { - if value, err := core.StringifyJSON(q._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(q); err == nil { - return value - } - return fmt.Sprintf("%#v", q) -} - -type QueryResponse struct { - Results []*QueryResult `json:"results,omitempty" url:"results,omitempty"` - Matches []*ScoredColumn `json:"matches,omitempty" url:"matches,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - Usage *Usage `json:"usage,omitempty" url:"usage,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (q *QueryResponse) GetResults() []*QueryResult { - if q == nil { - return nil - } - return q.Results -} - -func (q *QueryResponse) GetMatches() []*ScoredColumn { - if q == nil { - return nil - } - return q.Matches -} - -func (q *QueryResponse) GetNamespace() *string { - if q == nil { - return nil - } - return q.Namespace -} - -func (q *QueryResponse) GetUsage() *Usage { - if q == nil { - return nil - } - return q.Usage -} - -func (q *QueryResponse) GetExtraProperties() map[string]interface{} { - return q.extraProperties -} - -func (q *QueryResponse) UnmarshalJSON(data []byte) error { - type unmarshaler QueryResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *q = QueryResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *q) - if err != nil { - return err - } - q.extraProperties = extraProperties - - q._rawJSON = json.RawMessage(data) - return nil -} - -func (q *QueryResponse) String() string { - if len(q._rawJSON) > 0 { - if value, err := core.StringifyJSON(q._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(q); err == nil { - return value - } - return fmt.Sprintf("%#v", q) -} - -type QueryResult struct { - Matches []*ScoredColumn `json:"matches,omitempty" url:"matches,omitempty"` - Namespace *string `json:"namespace,omitempty" url:"namespace,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (q *QueryResult) GetMatches() []*ScoredColumn { - if q == nil { - return nil - } - return q.Matches -} - -func (q *QueryResult) GetNamespace() *string { - if q == nil { - return nil - } - return q.Namespace -} - -func (q *QueryResult) GetExtraProperties() map[string]interface{} { - return q.extraProperties -} - -func (q *QueryResult) UnmarshalJSON(data []byte) error { - type unmarshaler QueryResult - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *q = QueryResult(value) - - extraProperties, err := core.ExtractExtraProperties(data, *q) - if err != nil { - return err - } - q.extraProperties = extraProperties - - q._rawJSON = json.RawMessage(data) - return nil -} - -func (q *QueryResult) String() string { - if len(q._rawJSON) > 0 { - if value, err := core.StringifyJSON(q._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(q); err == nil { - return value - } - return fmt.Sprintf("%#v", q) -} - -type ScoredColumn struct { - Id string `json:"id" url:"id"` - Score *float64 `json:"score,omitempty" url:"score,omitempty"` - Values []float64 `json:"values,omitempty" url:"values,omitempty"` - Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` - IndexedData *IndexedData `json:"indexedData,omitempty" url:"indexedData,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (s *ScoredColumn) GetId() string { - if s == nil { - return "" - } - return s.Id -} - -func (s *ScoredColumn) GetScore() *float64 { - if s == nil { - return nil - } - return s.Score -} - -func (s *ScoredColumn) GetValues() []float64 { - if s == nil { - return nil - } - return s.Values -} - -func (s *ScoredColumn) GetMetadata() *Metadata { - if s == nil { - return nil - } - return s.Metadata -} - -func (s *ScoredColumn) GetIndexedData() *IndexedData { - if s == nil { - return nil - } - return s.IndexedData -} - -func (s *ScoredColumn) GetExtraProperties() map[string]interface{} { - return s.extraProperties -} - -func (s *ScoredColumn) UnmarshalJSON(data []byte) error { - type unmarshaler ScoredColumn - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = ScoredColumn(value) - - extraProperties, err := core.ExtractExtraProperties(data, *s) - if err != nil { - return err - } - s.extraProperties = extraProperties - - s._rawJSON = json.RawMessage(data) - return nil -} - -func (s *ScoredColumn) String() string { - if len(s._rawJSON) > 0 { - if value, err := core.StringifyJSON(s._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(s); err == nil { - return value - } - return fmt.Sprintf("%#v", s) -} - -type UpdateResponse struct { - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (u *UpdateResponse) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UpdateResponse) UnmarshalJSON(data []byte) error { - type unmarshaler UpdateResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UpdateResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *UpdateResponse) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UploadResponse struct { - Count *int `json:"count,omitempty" url:"count,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (u *UploadResponse) GetCount() *int { - if u == nil { - return nil - } - return u.Count -} - -func (u *UploadResponse) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UploadResponse) UnmarshalJSON(data []byte) error { - type unmarshaler UploadResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UploadResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *UploadResponse) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type Usage struct { - Units *int `json:"units,omitempty" url:"units,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (u *Usage) GetUnits() *int { - if u == nil { - return nil - } - return u.Units -} - -func (u *Usage) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *Usage) UnmarshalJSON(data []byte) error { - type unmarshaler Usage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = Usage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *Usage) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/seed/go-sdk/grpc-proto/types.go b/seed/go-sdk/grpc-proto/types.go deleted file mode 100644 index 7495963edd6..00000000000 --- a/seed/go-sdk/grpc-proto/types.go +++ /dev/null @@ -1,302 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package api - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/grpc-proto/fern/core" -) - -type CreateResponse struct { - User *UserModel `json:"user,omitempty" url:"user,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (c *CreateResponse) GetUser() *UserModel { - if c == nil { - return nil - } - return c.User -} - -func (c *CreateResponse) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *CreateResponse) UnmarshalJSON(data []byte) error { - type unmarshaler CreateResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = CreateResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - c._rawJSON = json.RawMessage(data) - return nil -} - -func (c *CreateResponse) String() string { - if len(c._rawJSON) > 0 { - if value, err := core.StringifyJSON(c._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type Metadata struct { - StringMetadataValueMap map[string]*MetadataValue - StringUnknownMap map[string]interface{} - - typ string -} - -func NewMetadataFromStringMetadataValueMap(value map[string]*MetadataValue) *Metadata { - return &Metadata{typ: "StringMetadataValueMap", StringMetadataValueMap: value} -} - -func NewMetadataFromStringUnknownMap(value map[string]interface{}) *Metadata { - return &Metadata{typ: "StringUnknownMap", StringUnknownMap: value} -} - -func (m *Metadata) GetStringMetadataValueMap() map[string]*MetadataValue { - if m == nil { - return nil - } - return m.StringMetadataValueMap -} - -func (m *Metadata) GetStringUnknownMap() map[string]interface{} { - if m == nil { - return nil - } - return m.StringUnknownMap -} - -func (m *Metadata) UnmarshalJSON(data []byte) error { - var valueStringMetadataValueMap map[string]*MetadataValue - if err := json.Unmarshal(data, &valueStringMetadataValueMap); err == nil { - m.typ = "StringMetadataValueMap" - m.StringMetadataValueMap = valueStringMetadataValueMap - return nil - } - var valueStringUnknownMap map[string]interface{} - if err := json.Unmarshal(data, &valueStringUnknownMap); err == nil { - m.typ = "StringUnknownMap" - m.StringUnknownMap = valueStringUnknownMap - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, m) -} - -func (m Metadata) MarshalJSON() ([]byte, error) { - if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { - return json.Marshal(m.StringMetadataValueMap) - } - if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { - return json.Marshal(m.StringUnknownMap) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataVisitor interface { - VisitStringMetadataValueMap(map[string]*MetadataValue) error - VisitStringUnknownMap(map[string]interface{}) error -} - -func (m *Metadata) Accept(visitor MetadataVisitor) error { - if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { - return visitor.VisitStringMetadataValueMap(m.StringMetadataValueMap) - } - if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { - return visitor.VisitStringUnknownMap(m.StringUnknownMap) - } - return fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataValue struct { - Double float64 - String string - Boolean bool - - typ string -} - -func NewMetadataValueFromDouble(value float64) *MetadataValue { - return &MetadataValue{typ: "Double", Double: value} -} - -func NewMetadataValueFromString(value string) *MetadataValue { - return &MetadataValue{typ: "String", String: value} -} - -func NewMetadataValueFromBoolean(value bool) *MetadataValue { - return &MetadataValue{typ: "Boolean", Boolean: value} -} - -func (m *MetadataValue) GetDouble() float64 { - if m == nil { - return 0 - } - return m.Double -} - -func (m *MetadataValue) GetString() string { - if m == nil { - return "" - } - return m.String -} - -func (m *MetadataValue) GetBoolean() bool { - if m == nil { - return false - } - return m.Boolean -} - -func (m *MetadataValue) UnmarshalJSON(data []byte) error { - var valueDouble float64 - if err := json.Unmarshal(data, &valueDouble); err == nil { - m.typ = "Double" - m.Double = valueDouble - return nil - } - var valueString string - if err := json.Unmarshal(data, &valueString); err == nil { - m.typ = "String" - m.String = valueString - return nil - } - var valueBoolean bool - if err := json.Unmarshal(data, &valueBoolean); err == nil { - m.typ = "Boolean" - m.Boolean = valueBoolean - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, m) -} - -func (m MetadataValue) MarshalJSON() ([]byte, error) { - if m.typ == "Double" || m.Double != 0 { - return json.Marshal(m.Double) - } - if m.typ == "String" || m.String != "" { - return json.Marshal(m.String) - } - if m.typ == "Boolean" || m.Boolean != false { - return json.Marshal(m.Boolean) - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type MetadataValueVisitor interface { - VisitDouble(float64) error - VisitString(string) error - VisitBoolean(bool) error -} - -func (m *MetadataValue) Accept(visitor MetadataValueVisitor) error { - if m.typ == "Double" || m.Double != 0 { - return visitor.VisitDouble(m.Double) - } - if m.typ == "String" || m.String != "" { - return visitor.VisitString(m.String) - } - if m.typ == "Boolean" || m.Boolean != false { - return visitor.VisitBoolean(m.Boolean) - } - return fmt.Errorf("type %T does not include a non-empty union type", m) -} - -type UserModel struct { - Username *string `json:"username,omitempty" url:"username,omitempty"` - Email *string `json:"email,omitempty" url:"email,omitempty"` - Age *int `json:"age,omitempty" url:"age,omitempty"` - Weight *float64 `json:"weight,omitempty" url:"weight,omitempty"` - Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (u *UserModel) GetUsername() *string { - if u == nil { - return nil - } - return u.Username -} - -func (u *UserModel) GetEmail() *string { - if u == nil { - return nil - } - return u.Email -} - -func (u *UserModel) GetAge() *int { - if u == nil { - return nil - } - return u.Age -} - -func (u *UserModel) GetWeight() *float64 { - if u == nil { - return nil - } - return u.Weight -} - -func (u *UserModel) GetMetadata() *Metadata { - if u == nil { - return nil - } - return u.Metadata -} - -func (u *UserModel) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserModel) UnmarshalJSON(data []byte) error { - type unmarshaler UserModel - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserModel(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *UserModel) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/seed/go-sdk/grpc-proto/userservice.go b/seed/go-sdk/grpc-proto/userservice.go index 54b4428f9a3..cbadca02982 100644 --- a/seed/go-sdk/grpc-proto/userservice.go +++ b/seed/go-sdk/grpc-proto/userservice.go @@ -2,6 +2,12 @@ package api +import ( + json "encoding/json" + fmt "fmt" + core "github.com/grpc-proto/fern/core" +) + type CreateRequest struct { Username *string `json:"username,omitempty" url:"-"` Email *string `json:"email,omitempty" url:"-"` @@ -9,3 +15,296 @@ type CreateRequest struct { Weight *float64 `json:"weight,omitempty" url:"-"` Metadata *Metadata `json:"metadata,omitempty" url:"-"` } + +type CreateResponse struct { + User *UserModel `json:"user,omitempty" url:"user,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (c *CreateResponse) GetUser() *UserModel { + if c == nil { + return nil + } + return c.User +} + +func (c *CreateResponse) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *CreateResponse) UnmarshalJSON(data []byte) error { + type unmarshaler CreateResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = CreateResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + c._rawJSON = json.RawMessage(data) + return nil +} + +func (c *CreateResponse) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type Metadata struct { + StringMetadataValueMap map[string]*MetadataValue + StringUnknownMap map[string]interface{} + + typ string +} + +func NewMetadataFromStringMetadataValueMap(value map[string]*MetadataValue) *Metadata { + return &Metadata{typ: "StringMetadataValueMap", StringMetadataValueMap: value} +} + +func NewMetadataFromStringUnknownMap(value map[string]interface{}) *Metadata { + return &Metadata{typ: "StringUnknownMap", StringUnknownMap: value} +} + +func (m *Metadata) GetStringMetadataValueMap() map[string]*MetadataValue { + if m == nil { + return nil + } + return m.StringMetadataValueMap +} + +func (m *Metadata) GetStringUnknownMap() map[string]interface{} { + if m == nil { + return nil + } + return m.StringUnknownMap +} + +func (m *Metadata) UnmarshalJSON(data []byte) error { + var valueStringMetadataValueMap map[string]*MetadataValue + if err := json.Unmarshal(data, &valueStringMetadataValueMap); err == nil { + m.typ = "StringMetadataValueMap" + m.StringMetadataValueMap = valueStringMetadataValueMap + return nil + } + var valueStringUnknownMap map[string]interface{} + if err := json.Unmarshal(data, &valueStringUnknownMap); err == nil { + m.typ = "StringUnknownMap" + m.StringUnknownMap = valueStringUnknownMap + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, m) +} + +func (m Metadata) MarshalJSON() ([]byte, error) { + if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { + return json.Marshal(m.StringMetadataValueMap) + } + if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { + return json.Marshal(m.StringUnknownMap) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataVisitor interface { + VisitStringMetadataValueMap(map[string]*MetadataValue) error + VisitStringUnknownMap(map[string]interface{}) error +} + +func (m *Metadata) Accept(visitor MetadataVisitor) error { + if m.typ == "StringMetadataValueMap" || m.StringMetadataValueMap != nil { + return visitor.VisitStringMetadataValueMap(m.StringMetadataValueMap) + } + if m.typ == "StringUnknownMap" || m.StringUnknownMap != nil { + return visitor.VisitStringUnknownMap(m.StringUnknownMap) + } + return fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataValue struct { + Double float64 + String string + Boolean bool + + typ string +} + +func NewMetadataValueFromDouble(value float64) *MetadataValue { + return &MetadataValue{typ: "Double", Double: value} +} + +func NewMetadataValueFromString(value string) *MetadataValue { + return &MetadataValue{typ: "String", String: value} +} + +func NewMetadataValueFromBoolean(value bool) *MetadataValue { + return &MetadataValue{typ: "Boolean", Boolean: value} +} + +func (m *MetadataValue) GetDouble() float64 { + if m == nil { + return 0 + } + return m.Double +} + +func (m *MetadataValue) GetString() string { + if m == nil { + return "" + } + return m.String +} + +func (m *MetadataValue) GetBoolean() bool { + if m == nil { + return false + } + return m.Boolean +} + +func (m *MetadataValue) UnmarshalJSON(data []byte) error { + var valueDouble float64 + if err := json.Unmarshal(data, &valueDouble); err == nil { + m.typ = "Double" + m.Double = valueDouble + return nil + } + var valueString string + if err := json.Unmarshal(data, &valueString); err == nil { + m.typ = "String" + m.String = valueString + return nil + } + var valueBoolean bool + if err := json.Unmarshal(data, &valueBoolean); err == nil { + m.typ = "Boolean" + m.Boolean = valueBoolean + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, m) +} + +func (m MetadataValue) MarshalJSON() ([]byte, error) { + if m.typ == "Double" || m.Double != 0 { + return json.Marshal(m.Double) + } + if m.typ == "String" || m.String != "" { + return json.Marshal(m.String) + } + if m.typ == "Boolean" || m.Boolean != false { + return json.Marshal(m.Boolean) + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type MetadataValueVisitor interface { + VisitDouble(float64) error + VisitString(string) error + VisitBoolean(bool) error +} + +func (m *MetadataValue) Accept(visitor MetadataValueVisitor) error { + if m.typ == "Double" || m.Double != 0 { + return visitor.VisitDouble(m.Double) + } + if m.typ == "String" || m.String != "" { + return visitor.VisitString(m.String) + } + if m.typ == "Boolean" || m.Boolean != false { + return visitor.VisitBoolean(m.Boolean) + } + return fmt.Errorf("type %T does not include a non-empty union type", m) +} + +type UserModel struct { + Username *string `json:"username,omitempty" url:"username,omitempty"` + Email *string `json:"email,omitempty" url:"email,omitempty"` + Age *int `json:"age,omitempty" url:"age,omitempty"` + Weight *float64 `json:"weight,omitempty" url:"weight,omitempty"` + Metadata *Metadata `json:"metadata,omitempty" url:"metadata,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (u *UserModel) GetUsername() *string { + if u == nil { + return nil + } + return u.Username +} + +func (u *UserModel) GetEmail() *string { + if u == nil { + return nil + } + return u.Email +} + +func (u *UserModel) GetAge() *int { + if u == nil { + return nil + } + return u.Age +} + +func (u *UserModel) GetWeight() *float64 { + if u == nil { + return nil + } + return u.Weight +} + +func (u *UserModel) GetMetadata() *Metadata { + if u == nil { + return nil + } + return u.Metadata +} + +func (u *UserModel) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserModel) UnmarshalJSON(data []byte) error { + type unmarshaler UserModel + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserModel(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UserModel) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} diff --git a/seed/go-sdk/license/.github/workflows/ci.yml b/seed/go-sdk/license/.github/workflows/ci.yml new file mode 100644 index 00000000000..d4c0a5dcd95 --- /dev/null +++ b/seed/go-sdk/license/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: ci + +on: [push] + +jobs: + compile: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up go + uses: actions/setup-go@v4 + + - name: Compile + run: go build ./... + test: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up go + uses: actions/setup-go@v4 + + - name: Test + run: go test ./... diff --git a/seed/go-sdk/license/.mock/definition/__package__.yml b/seed/go-sdk/license/.mock/definition/__package__.yml new file mode 100644 index 00000000000..b1e4d4a878f --- /dev/null +++ b/seed/go-sdk/license/.mock/definition/__package__.yml @@ -0,0 +1,13 @@ +types: + Type: + docs: A simple type with just a name. + properties: + name: string + +service: + auth: false + base-path: / + endpoints: + get: + path: "/" + method: GET diff --git a/seed/go-sdk/license/.mock/definition/api.yml b/seed/go-sdk/license/.mock/definition/api.yml new file mode 100644 index 00000000000..5523ff1f181 --- /dev/null +++ b/seed/go-sdk/license/.mock/definition/api.yml @@ -0,0 +1 @@ +name: license diff --git a/seed/go-sdk/license/.mock/fern.config.json b/seed/go-sdk/license/.mock/fern.config.json new file mode 100644 index 00000000000..4c8e54ac313 --- /dev/null +++ b/seed/go-sdk/license/.mock/fern.config.json @@ -0,0 +1 @@ +{"organization": "fern-test", "version": "*"} \ No newline at end of file diff --git a/seed/go-sdk/license/.mock/generators.yml b/seed/go-sdk/license/.mock/generators.yml new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/seed/go-sdk/license/.mock/generators.yml @@ -0,0 +1 @@ +{} diff --git a/seed/go-sdk/license/client/client.go b/seed/go-sdk/license/client/client.go new file mode 100644 index 00000000000..6efa9bf14d8 --- /dev/null +++ b/seed/go-sdk/license/client/client.go @@ -0,0 +1,64 @@ +// This file was auto-generated by Fern from our API Definition. + +package client + +import ( + context "context" + core "github.com/license/fern/core" + option "github.com/license/fern/option" + http "net/http" +) + +type Client struct { + baseURL string + caller *core.Caller + header http.Header +} + +func NewClient(opts ...option.RequestOption) *Client { + options := core.NewRequestOptions(opts...) + return &Client{ + baseURL: options.BaseURL, + caller: core.NewCaller( + &core.CallerParams{ + Client: options.HTTPClient, + MaxAttempts: options.MaxAttempts, + }, + ), + header: options.ToHeader(), + } +} + +func (c *Client) Get( + ctx context.Context, + opts ...option.RequestOption, +) error { + options := core.NewRequestOptions(opts...) + + baseURL := "" + if c.baseURL != "" { + baseURL = c.baseURL + } + if options.BaseURL != "" { + baseURL = options.BaseURL + } + endpointURL := baseURL + + headers := core.MergeHeaders(c.header.Clone(), options.ToHeader()) + + if err := c.caller.Call( + ctx, + &core.CallParams{ + URL: endpointURL, + Method: http.MethodGet, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + }, + ); err != nil { + return err + } + return nil +} diff --git a/seed/go-sdk/license/client/client_test.go b/seed/go-sdk/license/client/client_test.go new file mode 100644 index 00000000000..8f8d389b1ef --- /dev/null +++ b/seed/go-sdk/license/client/client_test.go @@ -0,0 +1,45 @@ +// This file was auto-generated by Fern from our API Definition. + +package client + +import ( + option "github.com/license/fern/option" + assert "github.com/stretchr/testify/assert" + http "net/http" + testing "testing" + time "time" +) + +func TestNewClient(t *testing.T) { + t.Run("default", func(t *testing.T) { + c := NewClient() + assert.Empty(t, c.baseURL) + }) + + t.Run("base url", func(t *testing.T) { + c := NewClient( + option.WithBaseURL("test.co"), + ) + assert.Equal(t, "test.co", c.baseURL) + }) + + t.Run("http client", func(t *testing.T) { + httpClient := &http.Client{ + Timeout: 5 * time.Second, + } + c := NewClient( + option.WithHTTPClient(httpClient), + ) + assert.Empty(t, c.baseURL) + }) + + t.Run("http header", func(t *testing.T) { + header := make(http.Header) + header.Set("X-API-Tenancy", "test") + c := NewClient( + option.WithHTTPHeader(header), + ) + assert.Empty(t, c.baseURL) + assert.Equal(t, "test", c.header.Get("X-API-Tenancy")) + }) +} diff --git a/seed/go-sdk/license/core/core.go b/seed/go-sdk/license/core/core.go new file mode 100644 index 00000000000..6b5a8f3c011 --- /dev/null +++ b/seed/go-sdk/license/core/core.go @@ -0,0 +1,321 @@ +package core + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "mime/multipart" + "net/http" + "net/url" + "reflect" + "strings" +) + +const ( + // contentType specifies the JSON Content-Type header value. + contentType = "application/json" + contentTypeHeader = "Content-Type" +) + +// HTTPClient is an interface for a subset of the *http.Client. +type HTTPClient interface { + Do(*http.Request) (*http.Response, error) +} + +// EncodeURL encodes the given arguments into the URL, escaping +// values as needed. +func EncodeURL(urlFormat string, args ...interface{}) string { + escapedArgs := make([]interface{}, 0, len(args)) + for _, arg := range args { + escapedArgs = append(escapedArgs, url.PathEscape(fmt.Sprintf("%v", arg))) + } + return fmt.Sprintf(urlFormat, escapedArgs...) +} + +// MergeHeaders merges the given headers together, where the right +// takes precedence over the left. +func MergeHeaders(left, right http.Header) http.Header { + for key, values := range right { + if len(values) > 1 { + left[key] = values + continue + } + if value := right.Get(key); value != "" { + left.Set(key, value) + } + } + return left +} + +// WriteMultipartJSON writes the given value as a JSON part. +// This is used to serialize non-primitive multipart properties +// (i.e. lists, objects, etc). +func WriteMultipartJSON(writer *multipart.Writer, field string, value interface{}) error { + bytes, err := json.Marshal(value) + if err != nil { + return err + } + return writer.WriteField(field, string(bytes)) +} + +// APIError is a lightweight wrapper around the standard error +// interface that preserves the status code from the RPC, if any. +type APIError struct { + err error + + StatusCode int `json:"-"` +} + +// NewAPIError constructs a new API error. +func NewAPIError(statusCode int, err error) *APIError { + return &APIError{ + err: err, + StatusCode: statusCode, + } +} + +// Unwrap returns the underlying error. This also makes the error compatible +// with errors.As and errors.Is. +func (a *APIError) Unwrap() error { + if a == nil { + return nil + } + return a.err +} + +// Error returns the API error's message. +func (a *APIError) Error() string { + if a == nil || (a.err == nil && a.StatusCode == 0) { + return "" + } + if a.err == nil { + return fmt.Sprintf("%d", a.StatusCode) + } + if a.StatusCode == 0 { + return a.err.Error() + } + return fmt.Sprintf("%d: %s", a.StatusCode, a.err.Error()) +} + +// ErrorDecoder decodes *http.Response errors and returns a +// typed API error (e.g. *APIError). +type ErrorDecoder func(statusCode int, body io.Reader) error + +// Caller calls APIs and deserializes their response, if any. +type Caller struct { + client HTTPClient + retrier *Retrier +} + +// CallerParams represents the parameters used to constrcut a new *Caller. +type CallerParams struct { + Client HTTPClient + MaxAttempts uint +} + +// NewCaller returns a new *Caller backed by the given parameters. +func NewCaller(params *CallerParams) *Caller { + var httpClient HTTPClient = http.DefaultClient + if params.Client != nil { + httpClient = params.Client + } + var retryOptions []RetryOption + if params.MaxAttempts > 0 { + retryOptions = append(retryOptions, WithMaxAttempts(params.MaxAttempts)) + } + return &Caller{ + client: httpClient, + retrier: NewRetrier(retryOptions...), + } +} + +// CallParams represents the parameters used to issue an API call. +type CallParams struct { + URL string + Method string + MaxAttempts uint + Headers http.Header + BodyProperties map[string]interface{} + QueryParameters url.Values + Client HTTPClient + Request interface{} + Response interface{} + ResponseIsOptional bool + ErrorDecoder ErrorDecoder +} + +// Call issues an API call according to the given call parameters. +func (c *Caller) Call(ctx context.Context, params *CallParams) error { + url := buildURL(params.URL, params.QueryParameters) + req, err := newRequest( + ctx, + url, + params.Method, + params.Headers, + params.Request, + params.BodyProperties, + ) + if err != nil { + return err + } + + // If the call has been cancelled, don't issue the request. + if err := ctx.Err(); err != nil { + return err + } + + client := c.client + if params.Client != nil { + // Use the HTTP client scoped to the request. + client = params.Client + } + + var retryOptions []RetryOption + if params.MaxAttempts > 0 { + retryOptions = append(retryOptions, WithMaxAttempts(params.MaxAttempts)) + } + + resp, err := c.retrier.Run( + client.Do, + req, + params.ErrorDecoder, + retryOptions..., + ) + if err != nil { + return err + } + + // Close the response body after we're done. + defer resp.Body.Close() + + // Check if the call was cancelled before we return the error + // associated with the call and/or unmarshal the response data. + if err := ctx.Err(); err != nil { + return err + } + + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + return decodeError(resp, params.ErrorDecoder) + } + + // Mutate the response parameter in-place. + if params.Response != nil { + if writer, ok := params.Response.(io.Writer); ok { + _, err = io.Copy(writer, resp.Body) + } else { + err = json.NewDecoder(resp.Body).Decode(params.Response) + } + if err != nil { + if err == io.EOF { + if params.ResponseIsOptional { + // The response is optional, so we should ignore the + // io.EOF error + return nil + } + return fmt.Errorf("expected a %T response, but the server responded with nothing", params.Response) + } + return err + } + } + + return nil +} + +// buildURL constructs the final URL by appending the given query parameters (if any). +func buildURL( + url string, + queryParameters url.Values, +) string { + if len(queryParameters) == 0 { + return url + } + if strings.ContainsRune(url, '?') { + url += "&" + } else { + url += "?" + } + url += queryParameters.Encode() + return url +} + +// newRequest returns a new *http.Request with all of the fields +// required to issue the call. +func newRequest( + ctx context.Context, + url string, + method string, + endpointHeaders http.Header, + request interface{}, + bodyProperties map[string]interface{}, +) (*http.Request, error) { + requestBody, err := newRequestBody(request, bodyProperties) + if err != nil { + return nil, err + } + req, err := http.NewRequestWithContext(ctx, method, url, requestBody) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + req.Header.Set(contentTypeHeader, contentType) + for name, values := range endpointHeaders { + req.Header[name] = values + } + return req, nil +} + +// newRequestBody returns a new io.Reader that represents the HTTP request body. +func newRequestBody(request interface{}, bodyProperties map[string]interface{}) (io.Reader, error) { + if isNil(request) { + if len(bodyProperties) == 0 { + return nil, nil + } + requestBytes, err := json.Marshal(bodyProperties) + if err != nil { + return nil, err + } + return bytes.NewReader(requestBytes), nil + } + if body, ok := request.(io.Reader); ok { + return body, nil + } + requestBytes, err := MarshalJSONWithExtraProperties(request, bodyProperties) + if err != nil { + return nil, err + } + return bytes.NewReader(requestBytes), nil +} + +// decodeError decodes the error from the given HTTP response. Note that +// it's the caller's responsibility to close the response body. +func decodeError(response *http.Response, errorDecoder ErrorDecoder) error { + if errorDecoder != nil { + // This endpoint has custom errors, so we'll + // attempt to unmarshal the error into a structured + // type based on the status code. + return errorDecoder(response.StatusCode, response.Body) + } + // This endpoint doesn't have any custom error + // types, so we just read the body as-is, and + // put it into a normal error. + bytes, err := io.ReadAll(response.Body) + if err != nil && err != io.EOF { + return err + } + if err == io.EOF { + // The error didn't have a response body, + // so all we can do is return an error + // with the status code. + return NewAPIError(response.StatusCode, nil) + } + return NewAPIError(response.StatusCode, errors.New(string(bytes))) +} + +// isNil is used to determine if the request value is equal to nil (i.e. an interface +// value that holds a nil concrete value is itself non-nil). +func isNil(value interface{}) bool { + return value == nil || reflect.ValueOf(value).IsNil() +} diff --git a/seed/go-sdk/license/core/core_test.go b/seed/go-sdk/license/core/core_test.go new file mode 100644 index 00000000000..e6eaef3a86a --- /dev/null +++ b/seed/go-sdk/license/core/core_test.go @@ -0,0 +1,390 @@ +package core + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "net/http/httptest" + "net/url" + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// TestCase represents a single test case. +type TestCase struct { + description string + + // Server-side assertions. + givePathSuffix string + giveMethod string + giveResponseIsOptional bool + giveHeader http.Header + giveErrorDecoder ErrorDecoder + giveRequest *Request + giveQueryParams url.Values + giveBodyProperties map[string]interface{} + + // Client-side assertions. + wantResponse *Response + wantError error +} + +// Request a simple request body. +type Request struct { + Id string `json:"id"` +} + +// Response a simple response body. +type Response struct { + Id string `json:"id"` + ExtraBodyProperties map[string]interface{} `json:"extraBodyProperties,omitempty"` + QueryParameters url.Values `json:"queryParameters,omitempty"` +} + +// NotFoundError represents a 404. +type NotFoundError struct { + *APIError + + Message string `json:"message"` +} + +func TestCall(t *testing.T) { + tests := []*TestCase{ + { + description: "GET success", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: &Request{ + Id: "123", + }, + wantResponse: &Response{ + Id: "123", + }, + }, + { + description: "GET success with query", + givePathSuffix: "?limit=1", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: &Request{ + Id: "123", + }, + wantResponse: &Response{ + Id: "123", + QueryParameters: url.Values{ + "limit": []string{"1"}, + }, + }, + }, + { + description: "GET not found", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"fail"}, + }, + giveRequest: &Request{ + Id: strconv.Itoa(http.StatusNotFound), + }, + giveErrorDecoder: newTestErrorDecoder(t), + wantError: &NotFoundError{ + APIError: NewAPIError( + http.StatusNotFound, + errors.New(`{"message":"ID \"404\" not found"}`), + ), + }, + }, + { + description: "POST empty body", + giveMethod: http.MethodPost, + giveHeader: http.Header{ + "X-API-Status": []string{"fail"}, + }, + giveRequest: nil, + wantError: NewAPIError( + http.StatusBadRequest, + errors.New("invalid request"), + ), + }, + { + description: "POST optional response", + giveMethod: http.MethodPost, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: &Request{ + Id: "123", + }, + giveResponseIsOptional: true, + }, + { + description: "POST API error", + giveMethod: http.MethodPost, + giveHeader: http.Header{ + "X-API-Status": []string{"fail"}, + }, + giveRequest: &Request{ + Id: strconv.Itoa(http.StatusInternalServerError), + }, + wantError: NewAPIError( + http.StatusInternalServerError, + errors.New("failed to process request"), + ), + }, + { + description: "POST extra properties", + giveMethod: http.MethodPost, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: new(Request), + giveBodyProperties: map[string]interface{}{ + "key": "value", + }, + wantResponse: &Response{ + ExtraBodyProperties: map[string]interface{}{ + "key": "value", + }, + }, + }, + { + description: "GET extra query parameters", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveQueryParams: url.Values{ + "extra": []string{"true"}, + }, + giveRequest: &Request{ + Id: "123", + }, + wantResponse: &Response{ + Id: "123", + QueryParameters: url.Values{ + "extra": []string{"true"}, + }, + }, + }, + { + description: "GET merge extra query parameters", + givePathSuffix: "?limit=1", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: &Request{ + Id: "123", + }, + giveQueryParams: url.Values{ + "extra": []string{"true"}, + }, + wantResponse: &Response{ + Id: "123", + QueryParameters: url.Values{ + "limit": []string{"1"}, + "extra": []string{"true"}, + }, + }, + }, + } + for _, test := range tests { + t.Run(test.description, func(t *testing.T) { + var ( + server = newTestServer(t, test) + client = server.Client() + ) + caller := NewCaller( + &CallerParams{ + Client: client, + }, + ) + var response *Response + err := caller.Call( + context.Background(), + &CallParams{ + URL: server.URL + test.givePathSuffix, + Method: test.giveMethod, + Headers: test.giveHeader, + BodyProperties: test.giveBodyProperties, + QueryParameters: test.giveQueryParams, + Request: test.giveRequest, + Response: &response, + ResponseIsOptional: test.giveResponseIsOptional, + ErrorDecoder: test.giveErrorDecoder, + }, + ) + if test.wantError != nil { + assert.EqualError(t, err, test.wantError.Error()) + return + } + require.NoError(t, err) + assert.Equal(t, test.wantResponse, response) + }) + } +} + +func TestMergeHeaders(t *testing.T) { + t.Run("both empty", func(t *testing.T) { + merged := MergeHeaders(make(http.Header), make(http.Header)) + assert.Empty(t, merged) + }) + + t.Run("empty left", func(t *testing.T) { + left := make(http.Header) + + right := make(http.Header) + right.Set("X-API-Version", "0.0.1") + + merged := MergeHeaders(left, right) + assert.Equal(t, "0.0.1", merged.Get("X-API-Version")) + }) + + t.Run("empty right", func(t *testing.T) { + left := make(http.Header) + left.Set("X-API-Version", "0.0.1") + + right := make(http.Header) + + merged := MergeHeaders(left, right) + assert.Equal(t, "0.0.1", merged.Get("X-API-Version")) + }) + + t.Run("single value override", func(t *testing.T) { + left := make(http.Header) + left.Set("X-API-Version", "0.0.0") + + right := make(http.Header) + right.Set("X-API-Version", "0.0.1") + + merged := MergeHeaders(left, right) + assert.Equal(t, []string{"0.0.1"}, merged.Values("X-API-Version")) + }) + + t.Run("multiple value override", func(t *testing.T) { + left := make(http.Header) + left.Set("X-API-Versions", "0.0.0") + + right := make(http.Header) + right.Add("X-API-Versions", "0.0.1") + right.Add("X-API-Versions", "0.0.2") + + merged := MergeHeaders(left, right) + assert.Equal(t, []string{"0.0.1", "0.0.2"}, merged.Values("X-API-Versions")) + }) + + t.Run("disjoint merge", func(t *testing.T) { + left := make(http.Header) + left.Set("X-API-Tenancy", "test") + + right := make(http.Header) + right.Set("X-API-Version", "0.0.1") + + merged := MergeHeaders(left, right) + assert.Equal(t, []string{"test"}, merged.Values("X-API-Tenancy")) + assert.Equal(t, []string{"0.0.1"}, merged.Values("X-API-Version")) + }) +} + +// newTestServer returns a new *httptest.Server configured with the +// given test parameters. +func newTestServer(t *testing.T, tc *TestCase) *httptest.Server { + return httptest.NewServer( + http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, tc.giveMethod, r.Method) + assert.Equal(t, contentType, r.Header.Get(contentTypeHeader)) + for header, value := range tc.giveHeader { + assert.Equal(t, value, r.Header.Values(header)) + } + + request := new(Request) + + bytes, err := io.ReadAll(r.Body) + if tc.giveRequest == nil { + require.Empty(t, bytes) + w.WriteHeader(http.StatusBadRequest) + _, err = w.Write([]byte("invalid request")) + require.NoError(t, err) + return + } + require.NoError(t, err) + require.NoError(t, json.Unmarshal(bytes, request)) + + switch request.Id { + case strconv.Itoa(http.StatusNotFound): + notFoundError := &NotFoundError{ + APIError: &APIError{ + StatusCode: http.StatusNotFound, + }, + Message: fmt.Sprintf("ID %q not found", request.Id), + } + bytes, err = json.Marshal(notFoundError) + require.NoError(t, err) + + w.WriteHeader(http.StatusNotFound) + _, err = w.Write(bytes) + require.NoError(t, err) + return + + case strconv.Itoa(http.StatusInternalServerError): + w.WriteHeader(http.StatusInternalServerError) + _, err = w.Write([]byte("failed to process request")) + require.NoError(t, err) + return + } + + if tc.giveResponseIsOptional { + w.WriteHeader(http.StatusOK) + return + } + + extraBodyProperties := make(map[string]interface{}) + require.NoError(t, json.Unmarshal(bytes, &extraBodyProperties)) + delete(extraBodyProperties, "id") + + response := &Response{ + Id: request.Id, + ExtraBodyProperties: extraBodyProperties, + QueryParameters: r.URL.Query(), + } + bytes, err = json.Marshal(response) + require.NoError(t, err) + + _, err = w.Write(bytes) + require.NoError(t, err) + }, + ), + ) +} + +// newTestErrorDecoder returns an error decoder suitable for tests. +func newTestErrorDecoder(t *testing.T) func(int, io.Reader) error { + return func(statusCode int, body io.Reader) error { + raw, err := io.ReadAll(body) + require.NoError(t, err) + + var ( + apiError = NewAPIError(statusCode, errors.New(string(raw))) + decoder = json.NewDecoder(bytes.NewReader(raw)) + ) + if statusCode == http.StatusNotFound { + value := new(NotFoundError) + value.APIError = apiError + require.NoError(t, decoder.Decode(value)) + + return value + } + return apiError + } +} diff --git a/seed/go-sdk/license/core/extra_properties.go b/seed/go-sdk/license/core/extra_properties.go new file mode 100644 index 00000000000..a6af3e12410 --- /dev/null +++ b/seed/go-sdk/license/core/extra_properties.go @@ -0,0 +1,141 @@ +package core + +import ( + "bytes" + "encoding/json" + "fmt" + "reflect" + "strings" +) + +// MarshalJSONWithExtraProperty marshals the given value to JSON, including the extra property. +func MarshalJSONWithExtraProperty(marshaler interface{}, key string, value interface{}) ([]byte, error) { + return MarshalJSONWithExtraProperties(marshaler, map[string]interface{}{key: value}) +} + +// MarshalJSONWithExtraProperties marshals the given value to JSON, including any extra properties. +func MarshalJSONWithExtraProperties(marshaler interface{}, extraProperties map[string]interface{}) ([]byte, error) { + bytes, err := json.Marshal(marshaler) + if err != nil { + return nil, err + } + if len(extraProperties) == 0 { + return bytes, nil + } + keys, err := getKeys(marshaler) + if err != nil { + return nil, err + } + for _, key := range keys { + if _, ok := extraProperties[key]; ok { + return nil, fmt.Errorf("cannot add extra property %q because it is already defined on the type", key) + } + } + extraBytes, err := json.Marshal(extraProperties) + if err != nil { + return nil, err + } + if isEmptyJSON(bytes) { + if isEmptyJSON(extraBytes) { + return bytes, nil + } + return extraBytes, nil + } + result := bytes[:len(bytes)-1] + result = append(result, ',') + result = append(result, extraBytes[1:len(extraBytes)-1]...) + result = append(result, '}') + return result, nil +} + +// ExtractExtraProperties extracts any extra properties from the given value. +func ExtractExtraProperties(bytes []byte, value interface{}, exclude ...string) (map[string]interface{}, error) { + val := reflect.ValueOf(value) + for val.Kind() == reflect.Ptr { + if val.IsNil() { + return nil, fmt.Errorf("value must be non-nil to extract extra properties") + } + val = val.Elem() + } + if err := json.Unmarshal(bytes, &value); err != nil { + return nil, err + } + var extraProperties map[string]interface{} + if err := json.Unmarshal(bytes, &extraProperties); err != nil { + return nil, err + } + for i := 0; i < val.Type().NumField(); i++ { + key := jsonKey(val.Type().Field(i)) + if key == "" || key == "-" { + continue + } + delete(extraProperties, key) + } + for _, key := range exclude { + delete(extraProperties, key) + } + if len(extraProperties) == 0 { + return nil, nil + } + return extraProperties, nil +} + +// getKeys returns the keys associated with the given value. The value must be a +// a struct or a map with string keys. +func getKeys(value interface{}) ([]string, error) { + val := reflect.ValueOf(value) + if val.Kind() == reflect.Ptr { + val = val.Elem() + } + if !val.IsValid() { + return nil, nil + } + switch val.Kind() { + case reflect.Struct: + return getKeysForStructType(val.Type()), nil + case reflect.Map: + var keys []string + if val.Type().Key().Kind() != reflect.String { + return nil, fmt.Errorf("cannot extract keys from %T; only structs and maps with string keys are supported", value) + } + for _, key := range val.MapKeys() { + keys = append(keys, key.String()) + } + return keys, nil + default: + return nil, fmt.Errorf("cannot extract keys from %T; only structs and maps with string keys are supported", value) + } +} + +// getKeysForStructType returns all the keys associated with the given struct type, +// visiting embedded fields recursively. +func getKeysForStructType(structType reflect.Type) []string { + if structType.Kind() == reflect.Pointer { + structType = structType.Elem() + } + if structType.Kind() != reflect.Struct { + return nil + } + var keys []string + for i := 0; i < structType.NumField(); i++ { + field := structType.Field(i) + if field.Anonymous { + keys = append(keys, getKeysForStructType(field.Type)...) + continue + } + keys = append(keys, jsonKey(field)) + } + return keys +} + +// jsonKey returns the JSON key from the struct tag of the given field, +// excluding the omitempty flag (if any). +func jsonKey(field reflect.StructField) string { + return strings.TrimSuffix(field.Tag.Get("json"), ",omitempty") +} + +// isEmptyJSON returns true if the given data is empty, the empty JSON object, or +// an explicit null. +func isEmptyJSON(data []byte) bool { + return len(data) <= 2 || bytes.Equal(data, []byte("null")) +} diff --git a/seed/go-sdk/license/core/extra_properties_test.go b/seed/go-sdk/license/core/extra_properties_test.go new file mode 100644 index 00000000000..dc66fccd7f1 --- /dev/null +++ b/seed/go-sdk/license/core/extra_properties_test.go @@ -0,0 +1,228 @@ +package core + +import ( + "encoding/json" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +type testMarshaler struct { + Name string `json:"name"` + BirthDate time.Time `json:"birthDate"` + CreatedAt time.Time `json:"created_at"` +} + +func (t *testMarshaler) MarshalJSON() ([]byte, error) { + type embed testMarshaler + var marshaler = struct { + embed + BirthDate string `json:"birthDate"` + CreatedAt string `json:"created_at"` + }{ + embed: embed(*t), + BirthDate: t.BirthDate.Format("2006-01-02"), + CreatedAt: t.CreatedAt.Format(time.RFC3339), + } + return MarshalJSONWithExtraProperty(marshaler, "type", "test") +} + +func TestMarshalJSONWithExtraProperties(t *testing.T) { + tests := []struct { + desc string + giveMarshaler interface{} + giveExtraProperties map[string]interface{} + wantBytes []byte + wantError string + }{ + { + desc: "invalid type", + giveMarshaler: []string{"invalid"}, + giveExtraProperties: map[string]interface{}{"key": "overwrite"}, + wantError: `cannot extract keys from []string; only structs and maps with string keys are supported`, + }, + { + desc: "invalid key type", + giveMarshaler: map[int]interface{}{42: "value"}, + giveExtraProperties: map[string]interface{}{"key": "overwrite"}, + wantError: `cannot extract keys from map[int]interface {}; only structs and maps with string keys are supported`, + }, + { + desc: "invalid map overwrite", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{"key": "overwrite"}, + wantError: `cannot add extra property "key" because it is already defined on the type`, + }, + { + desc: "invalid struct overwrite", + giveMarshaler: new(testMarshaler), + giveExtraProperties: map[string]interface{}{"birthDate": "2000-01-01"}, + wantError: `cannot add extra property "birthDate" because it is already defined on the type`, + }, + { + desc: "invalid struct overwrite embedded type", + giveMarshaler: new(testMarshaler), + giveExtraProperties: map[string]interface{}{"name": "bob"}, + wantError: `cannot add extra property "name" because it is already defined on the type`, + }, + { + desc: "nil", + giveMarshaler: nil, + giveExtraProperties: nil, + wantBytes: []byte(`null`), + }, + { + desc: "empty", + giveMarshaler: map[string]interface{}{}, + giveExtraProperties: map[string]interface{}{}, + wantBytes: []byte(`{}`), + }, + { + desc: "no extra properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{}, + wantBytes: []byte(`{"key":"value"}`), + }, + { + desc: "only extra properties", + giveMarshaler: map[string]interface{}{}, + giveExtraProperties: map[string]interface{}{"key": "value"}, + wantBytes: []byte(`{"key":"value"}`), + }, + { + desc: "single extra property", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{"extra": "property"}, + wantBytes: []byte(`{"key":"value","extra":"property"}`), + }, + { + desc: "multiple extra properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{"one": 1, "two": 2}, + wantBytes: []byte(`{"key":"value","one":1,"two":2}`), + }, + { + desc: "nested properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{ + "user": map[string]interface{}{ + "age": 42, + "name": "alice", + }, + }, + wantBytes: []byte(`{"key":"value","user":{"age":42,"name":"alice"}}`), + }, + { + desc: "multiple nested properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{ + "metadata": map[string]interface{}{ + "ip": "127.0.0.1", + }, + "user": map[string]interface{}{ + "age": 42, + "name": "alice", + }, + }, + wantBytes: []byte(`{"key":"value","metadata":{"ip":"127.0.0.1"},"user":{"age":42,"name":"alice"}}`), + }, + { + desc: "custom marshaler", + giveMarshaler: &testMarshaler{ + Name: "alice", + BirthDate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), + CreatedAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC), + }, + giveExtraProperties: map[string]interface{}{ + "extra": "property", + }, + wantBytes: []byte(`{"name":"alice","birthDate":"2000-01-01","created_at":"2024-01-01T00:00:00Z","type":"test","extra":"property"}`), + }, + } + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + bytes, err := MarshalJSONWithExtraProperties(tt.giveMarshaler, tt.giveExtraProperties) + if tt.wantError != "" { + require.EqualError(t, err, tt.wantError) + assert.Nil(t, tt.wantBytes) + return + } + require.NoError(t, err) + assert.Equal(t, tt.wantBytes, bytes) + + value := make(map[string]interface{}) + require.NoError(t, json.Unmarshal(bytes, &value)) + }) + } +} + +func TestExtractExtraProperties(t *testing.T) { + t.Run("none", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := &user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice"}`), value) + require.NoError(t, err) + assert.Nil(t, extraProperties) + }) + + t.Run("non-nil pointer", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := &user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + require.NoError(t, err) + assert.Equal(t, map[string]interface{}{"age": float64(42)}, extraProperties) + }) + + t.Run("nil pointer", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + var value *user + _, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + assert.EqualError(t, err, "value must be non-nil to extract extra properties") + }) + + t.Run("non-zero value", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + require.NoError(t, err) + assert.Equal(t, map[string]interface{}{"age": float64(42)}, extraProperties) + }) + + t.Run("zero value", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + var value user + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + require.NoError(t, err) + assert.Equal(t, map[string]interface{}{"age": float64(42)}, extraProperties) + }) + + t.Run("exclude", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := &user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value, "age") + require.NoError(t, err) + assert.Nil(t, extraProperties) + }) +} diff --git a/seed/go-sdk/license/core/multipart.go b/seed/go-sdk/license/core/multipart.go new file mode 100644 index 00000000000..40f84bcec76 --- /dev/null +++ b/seed/go-sdk/license/core/multipart.go @@ -0,0 +1,195 @@ +package core + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "mime/multipart" + "net/textproto" + "strings" +) + +// Named is implemented by types that define a name. +type Named interface { + Name() string +} + +// ContentTyped is implemented by types that define a Content-Type. +type ContentTyped interface { + ContentType() string +} + +// WriteMultipartOption adapts the behavior of the multipart writer. +type WriteMultipartOption func(*writeMultipartOptions) + +// WithMultipartContentType sets the Content-Type for the multipart writer. +func WithMultipartContentType(contentType string) WriteMultipartOption { + return func(options *writeMultipartOptions) { + options.contentType = contentType + } +} + +// MultipartWriter writes multipart/form-data requests. +type MultipartWriter struct { + buffer *bytes.Buffer + writer *multipart.Writer +} + +// NewMultipartWriter creates a new multipart writer. +func NewMultipartWriter() *MultipartWriter { + buffer := bytes.NewBuffer(nil) + return &MultipartWriter{ + buffer: buffer, + writer: multipart.NewWriter(buffer), + } +} + +// Buffer returns the underlying buffer. +func (w *MultipartWriter) Buffer() *bytes.Buffer { + return w.buffer +} + +// ContentType returns the Content-Type for an HTTP multipart/form-data. +func (w *MultipartWriter) ContentType() string { + return w.writer.FormDataContentType() +} + +// WriteFile writes the given file part. +func (w *MultipartWriter) WriteFile( + field string, + file io.Reader, + opts ...WriteMultipartOption, +) error { + options := newWriteMultipartOptions(opts...) + return w.writeFile(field, file, options.contentType) +} + +// WriteField writes the given value as a form field. +func (w *MultipartWriter) WriteField( + field string, + value string, + opts ...WriteMultipartOption, +) error { + options := newWriteMultipartOptions(opts...) + return w.writeField(field, value, options.contentType) +} + +// WriteJSON writes the given value as a JSON form field. +func (w *MultipartWriter) WriteJSON( + field string, + value interface{}, + opts ...WriteMultipartOption, +) error { + bytes, err := json.Marshal(value) + if err != nil { + return err + } + return w.WriteField(field, string(bytes), opts...) +} + +// Close closes the writer. +func (w *MultipartWriter) Close() error { + return w.writer.Close() +} + +func (w *MultipartWriter) writeField( + field string, + value string, + contentType string, +) error { + part, err := w.newFormField(field, contentType) + if err != nil { + return err + } + _, err = part.Write([]byte(value)) + return err +} + +func (w *MultipartWriter) writeFile( + field string, + file io.Reader, + contentType string, +) error { + filename := getFilename(file) + if contentType == "" { + contentType = getContentType(file) + } + part, err := w.newFormPart(field, filename, contentType) + if err != nil { + return err + } + _, err = io.Copy(part, file) + return err +} + +// newFormField creates a new form field. +func (w *MultipartWriter) newFormField( + field string, + contentType string, +) (io.Writer, error) { + return w.newFormPart(field, "" /* filename */, contentType) +} + +// newFormPart creates a new form data part. +func (w *MultipartWriter) newFormPart( + field string, + filename string, + contentType string, +) (io.Writer, error) { + h := make(textproto.MIMEHeader) + h.Set("Content-Disposition", getContentDispositionHeaderValue(field, filename)) + if contentType != "" { + h.Set("Content-Type", contentType) + } + return w.writer.CreatePart(h) +} + +// writeMultipartOptions are options used to adapt the behavior of the multipart writer. +type writeMultipartOptions struct { + contentType string +} + +// newWriteMultipartOptions returns a new write multipart options. +func newWriteMultipartOptions(opts ...WriteMultipartOption) *writeMultipartOptions { + options := new(writeMultipartOptions) + for _, opt := range opts { + opt(options) + } + return options +} + +// getContentType returns the Content-Type for the given file, if any. +func getContentType(file io.Reader) string { + if v, ok := file.(ContentTyped); ok { + return v.ContentType() + } + return "" +} + +// getFilename returns the name for the given file, if any. +func getFilename(file io.Reader) string { + if v, ok := file.(Named); ok { + return v.Name() + } + return "" +} + +// getContentDispositionHeaderValue returns the value for the Content-Disposition header. +func getContentDispositionHeaderValue(field string, filename string) string { + contentDisposition := fmt.Sprintf("form-data; name=%q", field) + if filename != "" { + contentDisposition += fmt.Sprintf(`; filename=%q`, escapeQuotes(filename)) + } + return contentDisposition +} + +// https://cs.opensource.google/go/go/+/refs/tags/go1.23.2:src/mime/multipart/writer.go;l=132 +var quoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"") + +// escapeQuotes is directly referenced from the standard library. +// +// https://cs.opensource.google/go/go/+/refs/tags/go1.23.2:src/mime/multipart/writer.go;l=134 +func escapeQuotes(s string) string { + return quoteEscaper.Replace(s) +} diff --git a/seed/go-sdk/license/core/multipart_test.go b/seed/go-sdk/license/core/multipart_test.go new file mode 100644 index 00000000000..ba73d413f0c --- /dev/null +++ b/seed/go-sdk/license/core/multipart_test.go @@ -0,0 +1,251 @@ +package core + +import ( + "encoding/json" + "io" + "mime/multipart" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +const maxFormMemory = 32 << 20 // 32MB + +type mockFile struct { + name string + content string + contentType string + + reader io.Reader +} + +func (f *mockFile) Read(p []byte) (n int, err error) { + if f.reader == nil { + f.reader = strings.NewReader(f.content) + } + return f.reader.Read(p) +} + +func (f *mockFile) Name() string { + return f.name +} + +func (f *mockFile) ContentType() string { + return f.contentType +} + +func TestMultipartWriter(t *testing.T) { + t.Run("empty", func(t *testing.T) { + w := NewMultipartWriter() + assert.NotNil(t, w.Buffer()) + assert.Contains(t, w.ContentType(), "multipart/form-data; boundary=") + require.NoError(t, w.Close()) + }) + + t.Run("write field", func(t *testing.T) { + tests := []struct { + desc string + giveField string + giveValue string + giveContentType string + }{ + { + desc: "empty field", + giveField: "empty", + giveValue: "", + }, + { + desc: "simple field", + giveField: "greeting", + giveValue: "hello world", + }, + { + desc: "field with content type", + giveField: "message", + giveValue: "hello", + giveContentType: "text/plain", + }, + } + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + w := NewMultipartWriter() + + var opts []WriteMultipartOption + if tt.giveContentType != "" { + opts = append(opts, WithMultipartContentType(tt.giveContentType)) + } + + require.NoError(t, w.WriteField(tt.giveField, tt.giveValue, opts...)) + require.NoError(t, w.Close()) + + reader := multipart.NewReader(w.Buffer(), w.writer.Boundary()) + form, err := reader.ReadForm(maxFormMemory) + require.NoError(t, err) + + assert.Equal(t, []string{tt.giveValue}, form.Value[tt.giveField]) + require.NoError(t, form.RemoveAll()) + }) + } + }) + + t.Run("write file", func(t *testing.T) { + tests := []struct { + desc string + giveField string + giveFile *mockFile + giveContentType string + }{ + { + desc: "simple file", + giveField: "file", + giveFile: &mockFile{ + name: "test.txt", + content: "hello world", + contentType: "text/plain", + }, + }, + { + desc: "override content type", + giveField: "file", + giveFile: &mockFile{ + name: "test.txt", + content: "hello world", + contentType: "text/plain", + }, + giveContentType: "application/octet-stream", + }, + } + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + w := NewMultipartWriter() + + var opts []WriteMultipartOption + if tt.giveContentType != "" { + opts = append(opts, WithMultipartContentType(tt.giveContentType)) + } + + require.NoError(t, w.WriteFile(tt.giveField, tt.giveFile, opts...)) + require.NoError(t, w.Close()) + + reader := multipart.NewReader(w.Buffer(), w.writer.Boundary()) + form, err := reader.ReadForm(maxFormMemory) + require.NoError(t, err) + defer func() { + require.NoError(t, form.RemoveAll()) + }() + + files := form.File[tt.giveField] + require.Len(t, files, 1) + + file := files[0] + assert.Equal(t, tt.giveFile.name, file.Filename) + + f, err := file.Open() + require.NoError(t, err) + defer func() { + require.NoError(t, f.Close()) + }() + + content, err := io.ReadAll(f) + require.NoError(t, err) + assert.Equal(t, tt.giveFile.content, string(content)) + + expectedContentType := tt.giveContentType + if expectedContentType == "" { + expectedContentType = tt.giveFile.contentType + } + if expectedContentType != "" { + assert.Equal(t, expectedContentType, file.Header.Get("Content-Type")) + } + }) + } + }) + + t.Run("write JSON", func(t *testing.T) { + type testStruct struct { + Name string `json:"name"` + Value int `json:"value"` + } + + tests := []struct { + desc string + giveField string + giveValue interface{} + }{ + { + desc: "struct", + giveField: "data", + giveValue: testStruct{Name: "test", Value: 123}, + }, + { + desc: "map", + giveField: "data", + giveValue: map[string]string{"key": "value"}, + }, + } + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + w := NewMultipartWriter() + + require.NoError(t, w.WriteJSON(tt.giveField, tt.giveValue)) + require.NoError(t, w.Close()) + + reader := multipart.NewReader(w.Buffer(), w.writer.Boundary()) + form, err := reader.ReadForm(maxFormMemory) + require.NoError(t, err) + defer func() { + require.NoError(t, form.RemoveAll()) + }() + + expected, err := json.Marshal(tt.giveValue) + require.NoError(t, err) + assert.Equal(t, []string{string(expected)}, form.Value[tt.giveField]) + }) + } + }) + + t.Run("complex", func(t *testing.T) { + w := NewMultipartWriter() + + // Add multiple fields and files + require.NoError(t, w.WriteField("foo", "bar")) + require.NoError(t, w.WriteField("baz", "qux")) + + hello := mockFile{name: "file.txt", content: "Hello, world!", contentType: "text/plain"} + require.NoError(t, w.WriteFile("file", &hello)) + require.NoError(t, w.WriteJSON("data", map[string]string{"key": "value"})) + require.NoError(t, w.Close()) + + reader := multipart.NewReader(w.Buffer(), w.writer.Boundary()) + form, err := reader.ReadForm(maxFormMemory) + require.NoError(t, err) + defer func() { + require.NoError(t, form.RemoveAll()) + }() + + assert.Equal(t, []string{"bar"}, form.Value["foo"]) + assert.Equal(t, []string{"qux"}, form.Value["baz"]) + assert.Equal(t, []string{`{"key":"value"}`}, form.Value["data"]) + + files := form.File["file"] + require.Len(t, files, 1) + + file := files[0] + assert.Equal(t, "file.txt", file.Filename) + + f, err := file.Open() + require.NoError(t, err) + defer func() { + require.NoError(t, f.Close()) + }() + + content, err := io.ReadAll(f) + require.NoError(t, err) + assert.Equal(t, "Hello, world!", string(content)) + }) +} diff --git a/seed/go-sdk/license/core/query.go b/seed/go-sdk/license/core/query.go new file mode 100644 index 00000000000..2670ff7feda --- /dev/null +++ b/seed/go-sdk/license/core/query.go @@ -0,0 +1,231 @@ +package core + +import ( + "encoding/base64" + "fmt" + "net/url" + "reflect" + "strings" + "time" + + "github.com/google/uuid" +) + +var ( + bytesType = reflect.TypeOf([]byte{}) + queryEncoderType = reflect.TypeOf(new(QueryEncoder)).Elem() + timeType = reflect.TypeOf(time.Time{}) + uuidType = reflect.TypeOf(uuid.UUID{}) +) + +// QueryEncoder is an interface implemented by any type that wishes to encode +// itself into URL values in a non-standard way. +type QueryEncoder interface { + EncodeQueryValues(key string, v *url.Values) error +} + +// QueryValues encodes url.Values from request objects. +// +// Note: This type is inspired by Google's query encoding library, but +// supports far less customization and is tailored to fit this SDK's use case. +// +// Ref: https://github.com/google/go-querystring +func QueryValues(v interface{}) (url.Values, error) { + values := make(url.Values) + val := reflect.ValueOf(v) + for val.Kind() == reflect.Ptr { + if val.IsNil() { + return values, nil + } + val = val.Elem() + } + + if v == nil { + return values, nil + } + + if val.Kind() != reflect.Struct { + return nil, fmt.Errorf("query: Values() expects struct input. Got %v", val.Kind()) + } + + err := reflectValue(values, val, "") + return values, err +} + +// reflectValue populates the values parameter from the struct fields in val. +// Embedded structs are followed recursively (using the rules defined in the +// Values function documentation) breadth-first. +func reflectValue(values url.Values, val reflect.Value, scope string) error { + typ := val.Type() + for i := 0; i < typ.NumField(); i++ { + sf := typ.Field(i) + if sf.PkgPath != "" && !sf.Anonymous { + // Skip unexported fields. + continue + } + + sv := val.Field(i) + tag := sf.Tag.Get("url") + if tag == "" || tag == "-" { + continue + } + + name, opts := parseTag(tag) + if name == "" { + name = sf.Name + } + + if scope != "" { + name = scope + "[" + name + "]" + } + + if opts.Contains("omitempty") && isEmptyValue(sv) { + continue + } + + if sv.Type().Implements(queryEncoderType) { + // If sv is a nil pointer and the custom encoder is defined on a non-pointer + // method receiver, set sv to the zero value of the underlying type + if !reflect.Indirect(sv).IsValid() && sv.Type().Elem().Implements(queryEncoderType) { + sv = reflect.New(sv.Type().Elem()) + } + + m := sv.Interface().(QueryEncoder) + if err := m.EncodeQueryValues(name, &values); err != nil { + return err + } + continue + } + + // Recursively dereference pointers, but stop at nil pointers. + for sv.Kind() == reflect.Ptr { + if sv.IsNil() { + break + } + sv = sv.Elem() + } + + if sv.Type() == uuidType || sv.Type() == bytesType || sv.Type() == timeType { + values.Add(name, valueString(sv, opts, sf)) + continue + } + + if sv.Kind() == reflect.Slice || sv.Kind() == reflect.Array { + if sv.Len() == 0 { + // Skip if slice or array is empty. + continue + } + for i := 0; i < sv.Len(); i++ { + value := sv.Index(i) + if isStructPointer(value) && !value.IsNil() { + if err := reflectValue(values, value.Elem(), name); err != nil { + return err + } + } else { + values.Add(name, valueString(value, opts, sf)) + } + } + continue + } + + if sv.Kind() == reflect.Struct { + if err := reflectValue(values, sv, name); err != nil { + return err + } + continue + } + + values.Add(name, valueString(sv, opts, sf)) + } + + return nil +} + +// valueString returns the string representation of a value. +func valueString(v reflect.Value, opts tagOptions, sf reflect.StructField) string { + for v.Kind() == reflect.Ptr { + if v.IsNil() { + return "" + } + v = v.Elem() + } + + if v.Type() == timeType { + t := v.Interface().(time.Time) + if format := sf.Tag.Get("format"); format == "date" { + return t.Format("2006-01-02") + } + return t.Format(time.RFC3339) + } + + if v.Type() == uuidType { + u := v.Interface().(uuid.UUID) + return u.String() + } + + if v.Type() == bytesType { + b := v.Interface().([]byte) + return base64.StdEncoding.EncodeToString(b) + } + + return fmt.Sprint(v.Interface()) +} + +// isEmptyValue checks if a value should be considered empty for the purposes +// of omitting fields with the "omitempty" option. +func isEmptyValue(v reflect.Value) bool { + type zeroable interface { + IsZero() bool + } + + if !v.IsZero() { + if z, ok := v.Interface().(zeroable); ok { + return z.IsZero() + } + } + + switch v.Kind() { + case reflect.Array, reflect.Map, reflect.Slice, reflect.String: + return v.Len() == 0 + case reflect.Bool: + return !v.Bool() + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return v.Uint() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.Interface, reflect.Ptr: + return v.IsNil() + case reflect.Invalid, reflect.Complex64, reflect.Complex128, reflect.Chan, reflect.Func, reflect.Struct, reflect.UnsafePointer: + return false + } + + return false +} + +// isStructPointer returns true if the given reflect.Value is a pointer to a struct. +func isStructPointer(v reflect.Value) bool { + return v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Struct +} + +// tagOptions is the string following a comma in a struct field's "url" tag, or +// the empty string. It does not include the leading comma. +type tagOptions []string + +// parseTag splits a struct field's url tag into its name and comma-separated +// options. +func parseTag(tag string) (string, tagOptions) { + s := strings.Split(tag, ",") + return s[0], s[1:] +} + +// Contains checks whether the tagOptions contains the specified option. +func (o tagOptions) Contains(option string) bool { + for _, s := range o { + if s == option { + return true + } + } + return false +} diff --git a/seed/go-sdk/license/core/query_test.go b/seed/go-sdk/license/core/query_test.go new file mode 100644 index 00000000000..5498fa92aa5 --- /dev/null +++ b/seed/go-sdk/license/core/query_test.go @@ -0,0 +1,187 @@ +package core + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestQueryValues(t *testing.T) { + t.Run("empty optional", func(t *testing.T) { + type nested struct { + Value *string `json:"value,omitempty" url:"value,omitempty"` + } + type example struct { + Nested *nested `json:"nested,omitempty" url:"nested,omitempty"` + } + + values, err := QueryValues(&example{}) + require.NoError(t, err) + assert.Empty(t, values) + }) + + t.Run("empty required", func(t *testing.T) { + type nested struct { + Value *string `json:"value,omitempty" url:"value,omitempty"` + } + type example struct { + Required string `json:"required" url:"required"` + Nested *nested `json:"nested,omitempty" url:"nested,omitempty"` + } + + values, err := QueryValues(&example{}) + require.NoError(t, err) + assert.Equal(t, "required=", values.Encode()) + }) + + t.Run("allow multiple", func(t *testing.T) { + type example struct { + Values []string `json:"values" url:"values"` + } + + values, err := QueryValues( + &example{ + Values: []string{"foo", "bar", "baz"}, + }, + ) + require.NoError(t, err) + assert.Equal(t, "values=foo&values=bar&values=baz", values.Encode()) + }) + + t.Run("nested object", func(t *testing.T) { + type nested struct { + Value *string `json:"value,omitempty" url:"value,omitempty"` + } + type example struct { + Required string `json:"required" url:"required"` + Nested *nested `json:"nested,omitempty" url:"nested,omitempty"` + } + + nestedValue := "nestedValue" + values, err := QueryValues( + &example{ + Required: "requiredValue", + Nested: &nested{ + Value: &nestedValue, + }, + }, + ) + require.NoError(t, err) + assert.Equal(t, "nested%5Bvalue%5D=nestedValue&required=requiredValue", values.Encode()) + }) + + t.Run("url unspecified", func(t *testing.T) { + type example struct { + Required string `json:"required" url:"required"` + NotFound string `json:"notFound"` + } + + values, err := QueryValues( + &example{ + Required: "requiredValue", + NotFound: "notFound", + }, + ) + require.NoError(t, err) + assert.Equal(t, "required=requiredValue", values.Encode()) + }) + + t.Run("url ignored", func(t *testing.T) { + type example struct { + Required string `json:"required" url:"required"` + NotFound string `json:"notFound" url:"-"` + } + + values, err := QueryValues( + &example{ + Required: "requiredValue", + NotFound: "notFound", + }, + ) + require.NoError(t, err) + assert.Equal(t, "required=requiredValue", values.Encode()) + }) + + t.Run("datetime", func(t *testing.T) { + type example struct { + DateTime time.Time `json:"dateTime" url:"dateTime"` + } + + values, err := QueryValues( + &example{ + DateTime: time.Date(1994, 3, 16, 12, 34, 56, 0, time.UTC), + }, + ) + require.NoError(t, err) + assert.Equal(t, "dateTime=1994-03-16T12%3A34%3A56Z", values.Encode()) + }) + + t.Run("date", func(t *testing.T) { + type example struct { + Date time.Time `json:"date" url:"date" format:"date"` + } + + values, err := QueryValues( + &example{ + Date: time.Date(1994, 3, 16, 12, 34, 56, 0, time.UTC), + }, + ) + require.NoError(t, err) + assert.Equal(t, "date=1994-03-16", values.Encode()) + }) + + t.Run("optional time", func(t *testing.T) { + type example struct { + Date *time.Time `json:"date,omitempty" url:"date,omitempty" format:"date"` + } + + values, err := QueryValues( + &example{}, + ) + require.NoError(t, err) + assert.Empty(t, values.Encode()) + }) + + t.Run("omitempty with non-pointer zero value", func(t *testing.T) { + type enum string + + type example struct { + Enum enum `json:"enum,omitempty" url:"enum,omitempty"` + } + + values, err := QueryValues( + &example{}, + ) + require.NoError(t, err) + assert.Empty(t, values.Encode()) + }) + + t.Run("object array", func(t *testing.T) { + type object struct { + Key string `json:"key" url:"key"` + Value string `json:"value" url:"value"` + } + type example struct { + Objects []*object `json:"objects,omitempty" url:"objects,omitempty"` + } + + values, err := QueryValues( + &example{ + Objects: []*object{ + { + Key: "hello", + Value: "world", + }, + { + Key: "foo", + Value: "bar", + }, + }, + }, + ) + require.NoError(t, err) + assert.Equal(t, "objects%5Bkey%5D=hello&objects%5Bkey%5D=foo&objects%5Bvalue%5D=world&objects%5Bvalue%5D=bar", values.Encode()) + }) +} diff --git a/seed/go-sdk/license/core/request_option.go b/seed/go-sdk/license/core/request_option.go new file mode 100644 index 00000000000..b6de5a1efe3 --- /dev/null +++ b/seed/go-sdk/license/core/request_option.go @@ -0,0 +1,108 @@ +// This file was auto-generated by Fern from our API Definition. + +package core + +import ( + http "net/http" + url "net/url" +) + +// RequestOption adapts the behavior of the client or an individual request. +type RequestOption interface { + applyRequestOptions(*RequestOptions) +} + +// RequestOptions defines all of the possible request options. +// +// This type is primarily used by the generated code and is not meant +// to be used directly; use the option package instead. +type RequestOptions struct { + BaseURL string + HTTPClient HTTPClient + HTTPHeader http.Header + BodyProperties map[string]interface{} + QueryParameters url.Values + MaxAttempts uint +} + +// NewRequestOptions returns a new *RequestOptions value. +// +// This function is primarily used by the generated code and is not meant +// to be used directly; use RequestOption instead. +func NewRequestOptions(opts ...RequestOption) *RequestOptions { + options := &RequestOptions{ + HTTPHeader: make(http.Header), + BodyProperties: make(map[string]interface{}), + QueryParameters: make(url.Values), + } + for _, opt := range opts { + opt.applyRequestOptions(options) + } + return options +} + +// ToHeader maps the configured request options into a http.Header used +// for the request(s). +func (r *RequestOptions) ToHeader() http.Header { return r.cloneHeader() } + +func (r *RequestOptions) cloneHeader() http.Header { + headers := r.HTTPHeader.Clone() + headers.Set("X-Fern-Language", "Go") + headers.Set("X-Fern-SDK-Name", "github.com/license/fern") + headers.Set("X-Fern-SDK-Version", "0.0.1") + return headers +} + +// BaseURLOption implements the RequestOption interface. +type BaseURLOption struct { + BaseURL string +} + +func (b *BaseURLOption) applyRequestOptions(opts *RequestOptions) { + opts.BaseURL = b.BaseURL +} + +// HTTPClientOption implements the RequestOption interface. +type HTTPClientOption struct { + HTTPClient HTTPClient +} + +func (h *HTTPClientOption) applyRequestOptions(opts *RequestOptions) { + opts.HTTPClient = h.HTTPClient +} + +// HTTPHeaderOption implements the RequestOption interface. +type HTTPHeaderOption struct { + HTTPHeader http.Header +} + +func (h *HTTPHeaderOption) applyRequestOptions(opts *RequestOptions) { + opts.HTTPHeader = h.HTTPHeader +} + +// BodyPropertiesOption implements the RequestOption interface. +type BodyPropertiesOption struct { + BodyProperties map[string]interface{} +} + +func (b *BodyPropertiesOption) applyRequestOptions(opts *RequestOptions) { + opts.BodyProperties = b.BodyProperties +} + +// QueryParametersOption implements the RequestOption interface. +type QueryParametersOption struct { + QueryParameters url.Values +} + +func (q *QueryParametersOption) applyRequestOptions(opts *RequestOptions) { + opts.QueryParameters = q.QueryParameters +} + +// MaxAttemptsOption implements the RequestOption interface. +type MaxAttemptsOption struct { + MaxAttempts uint +} + +func (m *MaxAttemptsOption) applyRequestOptions(opts *RequestOptions) { + opts.MaxAttempts = m.MaxAttempts +} diff --git a/seed/go-sdk/license/core/retrier.go b/seed/go-sdk/license/core/retrier.go new file mode 100644 index 00000000000..ea24916b786 --- /dev/null +++ b/seed/go-sdk/license/core/retrier.go @@ -0,0 +1,166 @@ +package core + +import ( + "crypto/rand" + "math/big" + "net/http" + "time" +) + +const ( + defaultRetryAttempts = 2 + minRetryDelay = 500 * time.Millisecond + maxRetryDelay = 5000 * time.Millisecond +) + +// RetryOption adapts the behavior the *Retrier. +type RetryOption func(*retryOptions) + +// RetryFunc is a retriable HTTP function call (i.e. *http.Client.Do). +type RetryFunc func(*http.Request) (*http.Response, error) + +// WithMaxAttempts configures the maximum number of attempts +// of the *Retrier. +func WithMaxAttempts(attempts uint) RetryOption { + return func(opts *retryOptions) { + opts.attempts = attempts + } +} + +// Retrier retries failed requests a configurable number of times with an +// exponential back-off between each retry. +type Retrier struct { + attempts uint +} + +// NewRetrier constructs a new *Retrier with the given options, if any. +func NewRetrier(opts ...RetryOption) *Retrier { + options := new(retryOptions) + for _, opt := range opts { + opt(options) + } + attempts := uint(defaultRetryAttempts) + if options.attempts > 0 { + attempts = options.attempts + } + return &Retrier{ + attempts: attempts, + } +} + +// Run issues the request and, upon failure, retries the request if possible. +// +// The request will be retried as long as the request is deemed retriable and the +// number of retry attempts has not grown larger than the configured retry limit. +func (r *Retrier) Run( + fn RetryFunc, + request *http.Request, + errorDecoder ErrorDecoder, + opts ...RetryOption, +) (*http.Response, error) { + options := new(retryOptions) + for _, opt := range opts { + opt(options) + } + maxRetryAttempts := r.attempts + if options.attempts > 0 { + maxRetryAttempts = options.attempts + } + var ( + retryAttempt uint + previousError error + ) + return r.run( + fn, + request, + errorDecoder, + maxRetryAttempts, + retryAttempt, + previousError, + ) +} + +func (r *Retrier) run( + fn RetryFunc, + request *http.Request, + errorDecoder ErrorDecoder, + maxRetryAttempts uint, + retryAttempt uint, + previousError error, +) (*http.Response, error) { + if retryAttempt >= maxRetryAttempts { + return nil, previousError + } + + // If the call has been cancelled, don't issue the request. + if err := request.Context().Err(); err != nil { + return nil, err + } + + response, err := fn(request) + if err != nil { + return nil, err + } + + if r.shouldRetry(response) { + defer response.Body.Close() + + delay, err := r.retryDelay(retryAttempt) + if err != nil { + return nil, err + } + + time.Sleep(delay) + + return r.run( + fn, + request, + errorDecoder, + maxRetryAttempts, + retryAttempt+1, + decodeError(response, errorDecoder), + ) + } + + return response, nil +} + +// shouldRetry returns true if the request should be retried based on the given +// response status code. +func (r *Retrier) shouldRetry(response *http.Response) bool { + return response.StatusCode == http.StatusTooManyRequests || + response.StatusCode == http.StatusRequestTimeout || + response.StatusCode == http.StatusConflict || + response.StatusCode >= http.StatusInternalServerError +} + +// retryDelay calculates the delay time in milliseconds based on the retry attempt. +func (r *Retrier) retryDelay(retryAttempt uint) (time.Duration, error) { + // Apply exponential backoff. + delay := minRetryDelay + minRetryDelay*time.Duration(retryAttempt*retryAttempt) + + // Do not allow the number to exceed maxRetryDelay. + if delay > maxRetryDelay { + delay = maxRetryDelay + } + + // Apply some itter by randomizing the value in the range of 75%-100%. + max := big.NewInt(int64(delay / 4)) + jitter, err := rand.Int(rand.Reader, max) + if err != nil { + return 0, err + } + + delay -= time.Duration(jitter.Int64()) + + // Never sleep less than the base sleep seconds. + if delay < minRetryDelay { + delay = minRetryDelay + } + + return delay, nil +} + +type retryOptions struct { + attempts uint +} diff --git a/seed/go-sdk/license/core/stringer.go b/seed/go-sdk/license/core/stringer.go new file mode 100644 index 00000000000..000cf448641 --- /dev/null +++ b/seed/go-sdk/license/core/stringer.go @@ -0,0 +1,13 @@ +package core + +import "encoding/json" + +// StringifyJSON returns a pretty JSON string representation of +// the given value. +func StringifyJSON(value interface{}) (string, error) { + bytes, err := json.MarshalIndent(value, "", " ") + if err != nil { + return "", err + } + return string(bytes), nil +} diff --git a/seed/go-sdk/license/core/time.go b/seed/go-sdk/license/core/time.go new file mode 100644 index 00000000000..d009ab30c90 --- /dev/null +++ b/seed/go-sdk/license/core/time.go @@ -0,0 +1,137 @@ +package core + +import ( + "encoding/json" + "time" +) + +const dateFormat = "2006-01-02" + +// DateTime wraps time.Time and adapts its JSON representation +// to conform to a RFC3339 date (e.g. 2006-01-02). +// +// Ref: https://ijmacd.github.io/rfc3339-iso8601 +type Date struct { + t *time.Time +} + +// NewDate returns a new *Date. If the given time.Time +// is nil, nil will be returned. +func NewDate(t time.Time) *Date { + return &Date{t: &t} +} + +// NewOptionalDate returns a new *Date. If the given time.Time +// is nil, nil will be returned. +func NewOptionalDate(t *time.Time) *Date { + if t == nil { + return nil + } + return &Date{t: t} +} + +// Time returns the Date's underlying time, if any. If the +// date is nil, the zero value is returned. +func (d *Date) Time() time.Time { + if d == nil || d.t == nil { + return time.Time{} + } + return *d.t +} + +// TimePtr returns a pointer to the Date's underlying time.Time, if any. +func (d *Date) TimePtr() *time.Time { + if d == nil || d.t == nil { + return nil + } + if d.t.IsZero() { + return nil + } + return d.t +} + +func (d *Date) MarshalJSON() ([]byte, error) { + if d == nil || d.t == nil { + return nil, nil + } + return json.Marshal(d.t.Format(dateFormat)) +} + +func (d *Date) UnmarshalJSON(data []byte) error { + var raw string + if err := json.Unmarshal(data, &raw); err != nil { + return err + } + + parsedTime, err := time.Parse(dateFormat, raw) + if err != nil { + return err + } + + *d = Date{t: &parsedTime} + return nil +} + +// DateTime wraps time.Time and adapts its JSON representation +// to conform to a RFC3339 date-time (e.g. 2017-07-21T17:32:28Z). +// +// Ref: https://ijmacd.github.io/rfc3339-iso8601 +type DateTime struct { + t *time.Time +} + +// NewDateTime returns a new *DateTime. +func NewDateTime(t time.Time) *DateTime { + return &DateTime{t: &t} +} + +// NewOptionalDateTime returns a new *DateTime. If the given time.Time +// is nil, nil will be returned. +func NewOptionalDateTime(t *time.Time) *DateTime { + if t == nil { + return nil + } + return &DateTime{t: t} +} + +// Time returns the DateTime's underlying time, if any. If the +// date-time is nil, the zero value is returned. +func (d *DateTime) Time() time.Time { + if d == nil || d.t == nil { + return time.Time{} + } + return *d.t +} + +// TimePtr returns a pointer to the DateTime's underlying time.Time, if any. +func (d *DateTime) TimePtr() *time.Time { + if d == nil || d.t == nil { + return nil + } + if d.t.IsZero() { + return nil + } + return d.t +} + +func (d *DateTime) MarshalJSON() ([]byte, error) { + if d == nil || d.t == nil { + return nil, nil + } + return json.Marshal(d.t.Format(time.RFC3339)) +} + +func (d *DateTime) UnmarshalJSON(data []byte) error { + var raw string + if err := json.Unmarshal(data, &raw); err != nil { + return err + } + + parsedTime, err := time.Parse(time.RFC3339, raw) + if err != nil { + return err + } + + *d = DateTime{t: &parsedTime} + return nil +} diff --git a/seed/go-sdk/license/dynamic-snippets/example0/snippet.go b/seed/go-sdk/license/dynamic-snippets/example0/snippet.go new file mode 100644 index 00000000000..2fc52a3e67f --- /dev/null +++ b/seed/go-sdk/license/dynamic-snippets/example0/snippet.go @@ -0,0 +1,13 @@ +package example + +import ( + client "github.com/license/fern/client" + context "context" +) + +func do() () { + client := client.NewClient() + client.Get( + context.TODO(), + ) +} diff --git a/seed/go-sdk/license/file_param.go b/seed/go-sdk/license/file_param.go new file mode 100644 index 00000000000..ed384da1fa6 --- /dev/null +++ b/seed/go-sdk/license/file_param.go @@ -0,0 +1,41 @@ +package license + +import ( + "io" +) + +// FileParam is a file type suitable for multipart/form-data uploads. +type FileParam struct { + io.Reader + filename string + contentType string +} + +// FileParamOption adapts the behavior of the FileParam. No options are +// implemented yet, but this interface allows for future extensibility. +type FileParamOption interface { + apply() +} + +// NewFileParam returns a *FileParam type suitable for multipart/form-data uploads. All file +// upload endpoints accept a simple io.Reader, which is usually created by opening a file +// via os.Open. +// +// However, some endpoints require additional metadata about the file such as a specific +// Content-Type or custom filename. FileParam makes it easier to create the correct type +// signature for these endpoints. +func NewFileParam( + reader io.Reader, + filename string, + contentType string, + opts ...FileParamOption, +) *FileParam { + return &FileParam{ + Reader: reader, + filename: filename, + contentType: contentType, + } +} + +func (f *FileParam) Name() string { return f.filename } +func (f *FileParam) ContentType() string { return f.contentType } diff --git a/seed/go-sdk/license/go.mod b/seed/go-sdk/license/go.mod new file mode 100644 index 00000000000..304dd21e8fb --- /dev/null +++ b/seed/go-sdk/license/go.mod @@ -0,0 +1,9 @@ +module github.com/license/fern + +go 1.13 + +require ( + github.com/google/uuid v1.4.0 + github.com/stretchr/testify v1.7.0 + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/seed/go-sdk/license/go.sum b/seed/go-sdk/license/go.sum new file mode 100644 index 00000000000..b3766d4366b --- /dev/null +++ b/seed/go-sdk/license/go.sum @@ -0,0 +1,14 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/seed/go-sdk/license/option/request_option.go b/seed/go-sdk/license/option/request_option.go new file mode 100644 index 00000000000..1af32c60c04 --- /dev/null +++ b/seed/go-sdk/license/option/request_option.go @@ -0,0 +1,64 @@ +// This file was auto-generated by Fern from our API Definition. + +package option + +import ( + core "github.com/license/fern/core" + http "net/http" + url "net/url" +) + +// RequestOption adapts the behavior of an indivdual request. +type RequestOption = core.RequestOption + +// WithBaseURL sets the base URL, overriding the default +// environment, if any. +func WithBaseURL(baseURL string) *core.BaseURLOption { + return &core.BaseURLOption{ + BaseURL: baseURL, + } +} + +// WithHTTPClient uses the given HTTPClient to issue the request. +func WithHTTPClient(httpClient core.HTTPClient) *core.HTTPClientOption { + return &core.HTTPClientOption{ + HTTPClient: httpClient, + } +} + +// WithHTTPHeader adds the given http.Header to the request. +func WithHTTPHeader(httpHeader http.Header) *core.HTTPHeaderOption { + return &core.HTTPHeaderOption{ + // Clone the headers so they can't be modified after the option call. + HTTPHeader: httpHeader.Clone(), + } +} + +// WithBodyProperties adds the given body properties to the request. +func WithBodyProperties(bodyProperties map[string]interface{}) *core.BodyPropertiesOption { + copiedBodyProperties := make(map[string]interface{}, len(bodyProperties)) + for key, value := range bodyProperties { + copiedBodyProperties[key] = value + } + return &core.BodyPropertiesOption{ + BodyProperties: copiedBodyProperties, + } +} + +// WithQueryParameters adds the given query parameters to the request. +func WithQueryParameters(queryParameters url.Values) *core.QueryParametersOption { + copiedQueryParameters := make(url.Values, len(queryParameters)) + for key, values := range queryParameters { + copiedQueryParameters[key] = values + } + return &core.QueryParametersOption{ + QueryParameters: copiedQueryParameters, + } +} + +// WithMaxAttempts configures the maximum number of retry attempts. +func WithMaxAttempts(attempts uint) *core.MaxAttemptsOption { + return &core.MaxAttemptsOption{ + MaxAttempts: attempts, + } +} diff --git a/seed/go-sdk/license/pointer.go b/seed/go-sdk/license/pointer.go new file mode 100644 index 00000000000..26fb6ef2d92 --- /dev/null +++ b/seed/go-sdk/license/pointer.go @@ -0,0 +1,132 @@ +package license + +import ( + "time" + + "github.com/google/uuid" +) + +// Bool returns a pointer to the given bool value. +func Bool(b bool) *bool { + return &b +} + +// Byte returns a pointer to the given byte value. +func Byte(b byte) *byte { + return &b +} + +// Complex64 returns a pointer to the given complex64 value. +func Complex64(c complex64) *complex64 { + return &c +} + +// Complex128 returns a pointer to the given complex128 value. +func Complex128(c complex128) *complex128 { + return &c +} + +// Float32 returns a pointer to the given float32 value. +func Float32(f float32) *float32 { + return &f +} + +// Float64 returns a pointer to the given float64 value. +func Float64(f float64) *float64 { + return &f +} + +// Int returns a pointer to the given int value. +func Int(i int) *int { + return &i +} + +// Int8 returns a pointer to the given int8 value. +func Int8(i int8) *int8 { + return &i +} + +// Int16 returns a pointer to the given int16 value. +func Int16(i int16) *int16 { + return &i +} + +// Int32 returns a pointer to the given int32 value. +func Int32(i int32) *int32 { + return &i +} + +// Int64 returns a pointer to the given int64 value. +func Int64(i int64) *int64 { + return &i +} + +// Rune returns a pointer to the given rune value. +func Rune(r rune) *rune { + return &r +} + +// String returns a pointer to the given string value. +func String(s string) *string { + return &s +} + +// Uint returns a pointer to the given uint value. +func Uint(u uint) *uint { + return &u +} + +// Uint8 returns a pointer to the given uint8 value. +func Uint8(u uint8) *uint8 { + return &u +} + +// Uint16 returns a pointer to the given uint16 value. +func Uint16(u uint16) *uint16 { + return &u +} + +// Uint32 returns a pointer to the given uint32 value. +func Uint32(u uint32) *uint32 { + return &u +} + +// Uint64 returns a pointer to the given uint64 value. +func Uint64(u uint64) *uint64 { + return &u +} + +// Uintptr returns a pointer to the given uintptr value. +func Uintptr(u uintptr) *uintptr { + return &u +} + +// UUID returns a pointer to the given uuid.UUID value. +func UUID(u uuid.UUID) *uuid.UUID { + return &u +} + +// Time returns a pointer to the given time.Time value. +func Time(t time.Time) *time.Time { + return &t +} + +// MustParseDate attempts to parse the given string as a +// date time.Time, and panics upon failure. +func MustParseDate(date string) time.Time { + t, err := time.Parse("2006-01-02", date) + if err != nil { + panic(err) + } + return t +} + +// MustParseDateTime attempts to parse the given string as a +// datetime time.Time, and panics upon failure. +func MustParseDateTime(datetime string) time.Time { + t, err := time.Parse(time.RFC3339, datetime) + if err != nil { + panic(err) + } + return t +} diff --git a/seed/go-sdk/license/snippet-templates.json b/seed/go-sdk/license/snippet-templates.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/seed/go-sdk/license/snippet.json b/seed/go-sdk/license/snippet.json new file mode 100644 index 00000000000..b2e36019405 --- /dev/null +++ b/seed/go-sdk/license/snippet.json @@ -0,0 +1,15 @@ +{ + "endpoints": [ + { + "id": { + "path": "/", + "method": "GET", + "identifier_override": "endpoint_.get" + }, + "snippet": { + "type": "go", + "client": "import (\n\tcontext \"context\"\n\tfernclient \"github.com/license/fern/client\"\n)\n\nclient := fernclient.NewClient()\nerr := client.Get(\n\tcontext.TODO(),\n)\n" + } + } + ] +} \ No newline at end of file diff --git a/seed/go-sdk/license/types.go b/seed/go-sdk/license/types.go new file mode 100644 index 00000000000..1bd3630699a --- /dev/null +++ b/seed/go-sdk/license/types.go @@ -0,0 +1,58 @@ +// This file was auto-generated by Fern from our API Definition. + +package license + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/license/fern/core" +) + +// A simple type with just a name. +type Type struct { + Name string `json:"name" url:"name"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (t *Type) GetName() string { + if t == nil { + return "" + } + return t.Name +} + +func (t *Type) GetExtraProperties() map[string]interface{} { + return t.extraProperties +} + +func (t *Type) UnmarshalJSON(data []byte) error { + type unmarshaler Type + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = Type(value) + + extraProperties, err := core.ExtractExtraProperties(data, *t) + if err != nil { + return err + } + t.extraProperties = extraProperties + + t._rawJSON = json.RawMessage(data) + return nil +} + +func (t *Type) String() string { + if len(t._rawJSON) > 0 { + if value, err := core.StringifyJSON(t._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} diff --git a/seed/go-sdk/literal/inlined.go b/seed/go-sdk/literal/inlined.go index 78e2de3738f..96af6d4bf2c 100644 --- a/seed/go-sdk/literal/inlined.go +++ b/seed/go-sdk/literal/inlined.go @@ -53,6 +53,72 @@ func (s *SendLiteralsInlinedRequest) MarshalJSON() ([]byte, error) { return json.Marshal(marshaler) } +type ANestedLiteral struct { + myLiteral string + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (a *ANestedLiteral) MyLiteral() string { + return a.myLiteral +} + +func (a *ANestedLiteral) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *ANestedLiteral) UnmarshalJSON(data []byte) error { + type embed ANestedLiteral + var unmarshaler = struct { + embed + MyLiteral string `json:"myLiteral"` + }{ + embed: embed(*a), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *a = ANestedLiteral(unmarshaler.embed) + if unmarshaler.MyLiteral != "How super cool" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", a, "How super cool", unmarshaler.MyLiteral) + } + a.myLiteral = unmarshaler.MyLiteral + + extraProperties, err := core.ExtractExtraProperties(data, *a, "myLiteral") + if err != nil { + return err + } + a.extraProperties = extraProperties + + a._rawJSON = json.RawMessage(data) + return nil +} + +func (a *ANestedLiteral) MarshalJSON() ([]byte, error) { + type embed ANestedLiteral + var marshaler = struct { + embed + MyLiteral string `json:"myLiteral"` + }{ + embed: embed(*a), + MyLiteral: "How super cool", + } + return json.Marshal(marshaler) +} + +func (a *ANestedLiteral) String() string { + if len(a._rawJSON) > 0 { + if value, err := core.StringifyJSON(a._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} + type ATopLevelLiteral struct { NestedLiteral *ANestedLiteral `json:"nestedLiteral,omitempty" url:"nestedLiteral,omitempty"` diff --git a/seed/go-sdk/literal/reference.go b/seed/go-sdk/literal/reference.go index c16da5ca92f..d9ca1239e0c 100644 --- a/seed/go-sdk/literal/reference.go +++ b/seed/go-sdk/literal/reference.go @@ -8,6 +8,140 @@ import ( core "github.com/literal/fern/core" ) +type ContainerObject struct { + NestedObjects []*NestedObjectWithLiterals `json:"nestedObjects,omitempty" url:"nestedObjects,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (c *ContainerObject) GetNestedObjects() []*NestedObjectWithLiterals { + if c == nil { + return nil + } + return c.NestedObjects +} + +func (c *ContainerObject) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *ContainerObject) UnmarshalJSON(data []byte) error { + type unmarshaler ContainerObject + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ContainerObject(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + c._rawJSON = json.RawMessage(data) + return nil +} + +func (c *ContainerObject) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type NestedObjectWithLiterals struct { + StrProp string `json:"strProp" url:"strProp"` + literal1 string + literal2 string + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (n *NestedObjectWithLiterals) GetStrProp() string { + if n == nil { + return "" + } + return n.StrProp +} + +func (n *NestedObjectWithLiterals) Literal1() string { + return n.literal1 +} + +func (n *NestedObjectWithLiterals) Literal2() string { + return n.literal2 +} + +func (n *NestedObjectWithLiterals) GetExtraProperties() map[string]interface{} { + return n.extraProperties +} + +func (n *NestedObjectWithLiterals) UnmarshalJSON(data []byte) error { + type embed NestedObjectWithLiterals + var unmarshaler = struct { + embed + Literal1 string `json:"literal1"` + Literal2 string `json:"literal2"` + }{ + embed: embed(*n), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *n = NestedObjectWithLiterals(unmarshaler.embed) + if unmarshaler.Literal1 != "literal1" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", n, "literal1", unmarshaler.Literal1) + } + n.literal1 = unmarshaler.Literal1 + if unmarshaler.Literal2 != "literal2" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", n, "literal2", unmarshaler.Literal2) + } + n.literal2 = unmarshaler.Literal2 + + extraProperties, err := core.ExtractExtraProperties(data, *n, "literal1", "literal2") + if err != nil { + return err + } + n.extraProperties = extraProperties + + n._rawJSON = json.RawMessage(data) + return nil +} + +func (n *NestedObjectWithLiterals) MarshalJSON() ([]byte, error) { + type embed NestedObjectWithLiterals + var marshaler = struct { + embed + Literal1 string `json:"literal1"` + Literal2 string `json:"literal2"` + }{ + embed: embed(*n), + Literal1: "literal1", + Literal2: "literal2", + } + return json.Marshal(marshaler) +} + +func (n *NestedObjectWithLiterals) String() string { + if len(n._rawJSON) > 0 { + if value, err := core.StringifyJSON(n._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + type SendRequest struct { Query string `json:"query" url:"query"` Context SomeLiteral `json:"context,omitempty" url:"context,omitempty"` @@ -103,3 +237,5 @@ func (s *SendRequest) String() string { } return fmt.Sprintf("%#v", s) } + +type SomeLiteral = string diff --git a/seed/go-sdk/literal/types.go b/seed/go-sdk/literal/types.go index 3f83d340a7a..0c136986831 100644 --- a/seed/go-sdk/literal/types.go +++ b/seed/go-sdk/literal/types.go @@ -89,205 +89,3 @@ func (s *SendResponse) String() string { } return fmt.Sprintf("%#v", s) } - -type ANestedLiteral struct { - myLiteral string - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (a *ANestedLiteral) MyLiteral() string { - return a.myLiteral -} - -func (a *ANestedLiteral) GetExtraProperties() map[string]interface{} { - return a.extraProperties -} - -func (a *ANestedLiteral) UnmarshalJSON(data []byte) error { - type embed ANestedLiteral - var unmarshaler = struct { - embed - MyLiteral string `json:"myLiteral"` - }{ - embed: embed(*a), - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - *a = ANestedLiteral(unmarshaler.embed) - if unmarshaler.MyLiteral != "How super cool" { - return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", a, "How super cool", unmarshaler.MyLiteral) - } - a.myLiteral = unmarshaler.MyLiteral - - extraProperties, err := core.ExtractExtraProperties(data, *a, "myLiteral") - if err != nil { - return err - } - a.extraProperties = extraProperties - - a._rawJSON = json.RawMessage(data) - return nil -} - -func (a *ANestedLiteral) MarshalJSON() ([]byte, error) { - type embed ANestedLiteral - var marshaler = struct { - embed - MyLiteral string `json:"myLiteral"` - }{ - embed: embed(*a), - MyLiteral: "How super cool", - } - return json.Marshal(marshaler) -} - -func (a *ANestedLiteral) String() string { - if len(a._rawJSON) > 0 { - if value, err := core.StringifyJSON(a._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(a); err == nil { - return value - } - return fmt.Sprintf("%#v", a) -} - -type ContainerObject struct { - NestedObjects []*NestedObjectWithLiterals `json:"nestedObjects,omitempty" url:"nestedObjects,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (c *ContainerObject) GetNestedObjects() []*NestedObjectWithLiterals { - if c == nil { - return nil - } - return c.NestedObjects -} - -func (c *ContainerObject) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *ContainerObject) UnmarshalJSON(data []byte) error { - type unmarshaler ContainerObject - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = ContainerObject(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - c._rawJSON = json.RawMessage(data) - return nil -} - -func (c *ContainerObject) String() string { - if len(c._rawJSON) > 0 { - if value, err := core.StringifyJSON(c._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type NestedObjectWithLiterals struct { - StrProp string `json:"strProp" url:"strProp"` - literal1 string - literal2 string - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (n *NestedObjectWithLiterals) GetStrProp() string { - if n == nil { - return "" - } - return n.StrProp -} - -func (n *NestedObjectWithLiterals) Literal1() string { - return n.literal1 -} - -func (n *NestedObjectWithLiterals) Literal2() string { - return n.literal2 -} - -func (n *NestedObjectWithLiterals) GetExtraProperties() map[string]interface{} { - return n.extraProperties -} - -func (n *NestedObjectWithLiterals) UnmarshalJSON(data []byte) error { - type embed NestedObjectWithLiterals - var unmarshaler = struct { - embed - Literal1 string `json:"literal1"` - Literal2 string `json:"literal2"` - }{ - embed: embed(*n), - } - if err := json.Unmarshal(data, &unmarshaler); err != nil { - return err - } - *n = NestedObjectWithLiterals(unmarshaler.embed) - if unmarshaler.Literal1 != "literal1" { - return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", n, "literal1", unmarshaler.Literal1) - } - n.literal1 = unmarshaler.Literal1 - if unmarshaler.Literal2 != "literal2" { - return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", n, "literal2", unmarshaler.Literal2) - } - n.literal2 = unmarshaler.Literal2 - - extraProperties, err := core.ExtractExtraProperties(data, *n, "literal1", "literal2") - if err != nil { - return err - } - n.extraProperties = extraProperties - - n._rawJSON = json.RawMessage(data) - return nil -} - -func (n *NestedObjectWithLiterals) MarshalJSON() ([]byte, error) { - type embed NestedObjectWithLiterals - var marshaler = struct { - embed - Literal1 string `json:"literal1"` - Literal2 string `json:"literal2"` - }{ - embed: embed(*n), - Literal1: "literal1", - Literal2: "literal2", - } - return json.Marshal(marshaler) -} - -func (n *NestedObjectWithLiterals) String() string { - if len(n._rawJSON) > 0 { - if value, err := core.StringifyJSON(n._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(n); err == nil { - return value - } - return fmt.Sprintf("%#v", n) -} - -type SomeLiteral = string diff --git a/seed/go-sdk/mixed-case/service.go b/seed/go-sdk/mixed-case/service.go index a93b98bae0d..abd6d838bdb 100644 --- a/seed/go-sdk/mixed-case/service.go +++ b/seed/go-sdk/mixed-case/service.go @@ -14,6 +14,110 @@ type ListResourcesRequest struct { BeforeDate time.Time `json:"-" url:"beforeDate" format:"date"` } +type NestedUser struct { + Name string `json:"Name" url:"Name"` + NestedUser *User `json:"NestedUser,omitempty" url:"NestedUser,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (n *NestedUser) GetName() string { + if n == nil { + return "" + } + return n.Name +} + +func (n *NestedUser) GetNestedUser() *User { + if n == nil { + return nil + } + return n.NestedUser +} + +func (n *NestedUser) GetExtraProperties() map[string]interface{} { + return n.extraProperties +} + +func (n *NestedUser) UnmarshalJSON(data []byte) error { + type unmarshaler NestedUser + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NestedUser(value) + + extraProperties, err := core.ExtractExtraProperties(data, *n) + if err != nil { + return err + } + n.extraProperties = extraProperties + + n._rawJSON = json.RawMessage(data) + return nil +} + +func (n *NestedUser) String() string { + if len(n._rawJSON) > 0 { + if value, err := core.StringifyJSON(n._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + +type Organization struct { + Name string `json:"name" url:"name"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (o *Organization) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *Organization) GetExtraProperties() map[string]interface{} { + return o.extraProperties +} + +func (o *Organization) UnmarshalJSON(data []byte) error { + type unmarshaler Organization + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *o = Organization(value) + + extraProperties, err := core.ExtractExtraProperties(data, *o) + if err != nil { + return err + } + o.extraProperties = extraProperties + + o._rawJSON = json.RawMessage(data) + return nil +} + +func (o *Organization) String() string { + if len(o._rawJSON) > 0 { + if value, err := core.StringifyJSON(o._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(o); err == nil { + return value + } + return fmt.Sprintf("%#v", o) +} + type Resource struct { ResourceType string Status ResourceStatus @@ -113,3 +217,89 @@ func (r *Resource) Accept(visitor ResourceVisitor) error { return visitor.VisitOrganization(r.Organization) } } + +type ResourceStatus string + +const ( + ResourceStatusActive ResourceStatus = "ACTIVE" + ResourceStatusInactive ResourceStatus = "INACTIVE" +) + +func NewResourceStatusFromString(s string) (ResourceStatus, error) { + switch s { + case "ACTIVE": + return ResourceStatusActive, nil + case "INACTIVE": + return ResourceStatusInactive, nil + } + var t ResourceStatus + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (r ResourceStatus) Ptr() *ResourceStatus { + return &r +} + +type User struct { + UserName string `json:"userName" url:"userName"` + MetadataTags []string `json:"metadata_tags,omitempty" url:"metadata_tags,omitempty"` + ExtraProperties map[string]string `json:"EXTRA_PROPERTIES,omitempty" url:"EXTRA_PROPERTIES,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (u *User) GetUserName() string { + if u == nil { + return "" + } + return u.UserName +} + +func (u *User) GetMetadataTags() []string { + if u == nil { + return nil + } + return u.MetadataTags +} + +func (u *User) GetExtraProperties() map[string]string { + if u == nil { + return nil + } + return u.ExtraProperties +} + +func (u *User) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *User) UnmarshalJSON(data []byte) error { + type unmarshaler User + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = User(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *User) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} diff --git a/seed/go-sdk/mixed-case/types.go b/seed/go-sdk/mixed-case/types.go deleted file mode 100644 index 355c912571a..00000000000 --- a/seed/go-sdk/mixed-case/types.go +++ /dev/null @@ -1,199 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package mixedcase - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/mixed-case/fern/core" -) - -type NestedUser struct { - Name string `json:"Name" url:"Name"` - NestedUser *User `json:"NestedUser,omitempty" url:"NestedUser,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (n *NestedUser) GetName() string { - if n == nil { - return "" - } - return n.Name -} - -func (n *NestedUser) GetNestedUser() *User { - if n == nil { - return nil - } - return n.NestedUser -} - -func (n *NestedUser) GetExtraProperties() map[string]interface{} { - return n.extraProperties -} - -func (n *NestedUser) UnmarshalJSON(data []byte) error { - type unmarshaler NestedUser - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *n = NestedUser(value) - - extraProperties, err := core.ExtractExtraProperties(data, *n) - if err != nil { - return err - } - n.extraProperties = extraProperties - - n._rawJSON = json.RawMessage(data) - return nil -} - -func (n *NestedUser) String() string { - if len(n._rawJSON) > 0 { - if value, err := core.StringifyJSON(n._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(n); err == nil { - return value - } - return fmt.Sprintf("%#v", n) -} - -type Organization struct { - Name string `json:"name" url:"name"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (o *Organization) GetName() string { - if o == nil { - return "" - } - return o.Name -} - -func (o *Organization) GetExtraProperties() map[string]interface{} { - return o.extraProperties -} - -func (o *Organization) UnmarshalJSON(data []byte) error { - type unmarshaler Organization - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *o = Organization(value) - - extraProperties, err := core.ExtractExtraProperties(data, *o) - if err != nil { - return err - } - o.extraProperties = extraProperties - - o._rawJSON = json.RawMessage(data) - return nil -} - -func (o *Organization) String() string { - if len(o._rawJSON) > 0 { - if value, err := core.StringifyJSON(o._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(o); err == nil { - return value - } - return fmt.Sprintf("%#v", o) -} - -type ResourceStatus string - -const ( - ResourceStatusActive ResourceStatus = "ACTIVE" - ResourceStatusInactive ResourceStatus = "INACTIVE" -) - -func NewResourceStatusFromString(s string) (ResourceStatus, error) { - switch s { - case "ACTIVE": - return ResourceStatusActive, nil - case "INACTIVE": - return ResourceStatusInactive, nil - } - var t ResourceStatus - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (r ResourceStatus) Ptr() *ResourceStatus { - return &r -} - -type User struct { - UserName string `json:"userName" url:"userName"` - MetadataTags []string `json:"metadata_tags,omitempty" url:"metadata_tags,omitempty"` - ExtraProperties map[string]string `json:"EXTRA_PROPERTIES,omitempty" url:"EXTRA_PROPERTIES,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (u *User) GetUserName() string { - if u == nil { - return "" - } - return u.UserName -} - -func (u *User) GetMetadataTags() []string { - if u == nil { - return nil - } - return u.MetadataTags -} - -func (u *User) GetExtraProperties() map[string]string { - if u == nil { - return nil - } - return u.ExtraProperties -} - -func (u *User) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *User) UnmarshalJSON(data []byte) error { - type unmarshaler User - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = User(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *User) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/seed/go-sdk/oauth-client-credentials-nested-root/auth/auth.go b/seed/go-sdk/oauth-client-credentials-nested-root/auth/auth.go deleted file mode 100644 index 135aac9bba9..00000000000 --- a/seed/go-sdk/oauth-client-credentials-nested-root/auth/auth.go +++ /dev/null @@ -1,74 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package auth - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/oauth-client-credentials-nested-root/fern/core" -) - -// An OAuth token response. -type TokenResponse struct { - AccessToken string `json:"access_token" url:"access_token"` - ExpiresIn int `json:"expires_in" url:"expires_in"` - RefreshToken *string `json:"refresh_token,omitempty" url:"refresh_token,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (t *TokenResponse) GetAccessToken() string { - if t == nil { - return "" - } - return t.AccessToken -} - -func (t *TokenResponse) GetExpiresIn() int { - if t == nil { - return 0 - } - return t.ExpiresIn -} - -func (t *TokenResponse) GetRefreshToken() *string { - if t == nil { - return nil - } - return t.RefreshToken -} - -func (t *TokenResponse) GetExtraProperties() map[string]interface{} { - return t.extraProperties -} - -func (t *TokenResponse) UnmarshalJSON(data []byte) error { - type unmarshaler TokenResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *t = TokenResponse(value) - - extraProperties, err := core.ExtractExtraProperties(data, *t) - if err != nil { - return err - } - t.extraProperties = extraProperties - - t._rawJSON = json.RawMessage(data) - return nil -} - -func (t *TokenResponse) String() string { - if len(t._rawJSON) > 0 { - if value, err := core.StringifyJSON(t._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(t); err == nil { - return value - } - return fmt.Sprintf("%#v", t) -} diff --git a/seed/go-sdk/oauth-client-credentials-nested-root/auth/types.go b/seed/go-sdk/oauth-client-credentials-nested-root/auth/types.go index c05ee1427c8..7d3f3a14a8e 100644 --- a/seed/go-sdk/oauth-client-credentials-nested-root/auth/types.go +++ b/seed/go-sdk/oauth-client-credentials-nested-root/auth/types.go @@ -4,6 +4,8 @@ package auth import ( json "encoding/json" + fmt "fmt" + core "github.com/oauth-client-credentials-nested-root/fern/core" ) type GetTokenRequest struct { @@ -47,3 +49,68 @@ func (g *GetTokenRequest) MarshalJSON() ([]byte, error) { } return json.Marshal(marshaler) } + +// An OAuth token response. +type TokenResponse struct { + AccessToken string `json:"access_token" url:"access_token"` + ExpiresIn int `json:"expires_in" url:"expires_in"` + RefreshToken *string `json:"refresh_token,omitempty" url:"refresh_token,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (t *TokenResponse) GetAccessToken() string { + if t == nil { + return "" + } + return t.AccessToken +} + +func (t *TokenResponse) GetExpiresIn() int { + if t == nil { + return 0 + } + return t.ExpiresIn +} + +func (t *TokenResponse) GetRefreshToken() *string { + if t == nil { + return nil + } + return t.RefreshToken +} + +func (t *TokenResponse) GetExtraProperties() map[string]interface{} { + return t.extraProperties +} + +func (t *TokenResponse) UnmarshalJSON(data []byte) error { + type unmarshaler TokenResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = TokenResponse(value) + + extraProperties, err := core.ExtractExtraProperties(data, *t) + if err != nil { + return err + } + t.extraProperties = extraProperties + + t._rawJSON = json.RawMessage(data) + return nil +} + +func (t *TokenResponse) String() string { + if len(t._rawJSON) > 0 { + if value, err := core.StringifyJSON(t._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} diff --git a/seed/go-sdk/objects-with-imports/commons/types.go b/seed/go-sdk/objects-with-imports/commons/metadata.go similarity index 100% rename from seed/go-sdk/objects-with-imports/commons/types.go rename to seed/go-sdk/objects-with-imports/commons/metadata.go diff --git a/seed/go-sdk/objects-with-imports/file.go b/seed/go-sdk/objects-with-imports/file.go new file mode 100644 index 00000000000..5c90407f662 --- /dev/null +++ b/seed/go-sdk/objects-with-imports/file.go @@ -0,0 +1,97 @@ +// This file was auto-generated by Fern from our API Definition. + +package objectswithimports + +import ( + json "encoding/json" + fmt "fmt" + core "github.com/objects-with-imports/fern/core" +) + +type File struct { + Name string `json:"name" url:"name"` + Contents string `json:"contents" url:"contents"` + Info FileInfo `json:"info" url:"info"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (f *File) GetName() string { + if f == nil { + return "" + } + return f.Name +} + +func (f *File) GetContents() string { + if f == nil { + return "" + } + return f.Contents +} + +func (f *File) GetInfo() FileInfo { + if f == nil { + return "" + } + return f.Info +} + +func (f *File) GetExtraProperties() map[string]interface{} { + return f.extraProperties +} + +func (f *File) UnmarshalJSON(data []byte) error { + type unmarshaler File + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *f = File(value) + + extraProperties, err := core.ExtractExtraProperties(data, *f) + if err != nil { + return err + } + f.extraProperties = extraProperties + + f._rawJSON = json.RawMessage(data) + return nil +} + +func (f *File) String() string { + if len(f._rawJSON) > 0 { + if value, err := core.StringifyJSON(f._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(f); err == nil { + return value + } + return fmt.Sprintf("%#v", f) +} + +type FileInfo string + +const ( + // A regular file (e.g. foo.txt). + FileInfoRegular FileInfo = "REGULAR" + // A directory (e.g. foo/). + FileInfoDirectory FileInfo = "DIRECTORY" +) + +func NewFileInfoFromString(s string) (FileInfo, error) { + switch s { + case "REGULAR": + return FileInfoRegular, nil + case "DIRECTORY": + return FileInfoDirectory, nil + } + var t FileInfo + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (f FileInfo) Ptr() *FileInfo { + return &f +} diff --git a/seed/go-sdk/objects-with-imports/file/types.go b/seed/go-sdk/objects-with-imports/file/directory.go similarity index 100% rename from seed/go-sdk/objects-with-imports/file/types.go rename to seed/go-sdk/objects-with-imports/file/directory.go diff --git a/seed/go-sdk/objects-with-imports/types.go b/seed/go-sdk/objects-with-imports/types.go index 99a26377d33..7e01b967105 100644 --- a/seed/go-sdk/objects-with-imports/types.go +++ b/seed/go-sdk/objects-with-imports/types.go @@ -120,91 +120,3 @@ func (t *Tree) String() string { } return fmt.Sprintf("%#v", t) } - -type File struct { - Name string `json:"name" url:"name"` - Contents string `json:"contents" url:"contents"` - Info FileInfo `json:"info" url:"info"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (f *File) GetName() string { - if f == nil { - return "" - } - return f.Name -} - -func (f *File) GetContents() string { - if f == nil { - return "" - } - return f.Contents -} - -func (f *File) GetInfo() FileInfo { - if f == nil { - return "" - } - return f.Info -} - -func (f *File) GetExtraProperties() map[string]interface{} { - return f.extraProperties -} - -func (f *File) UnmarshalJSON(data []byte) error { - type unmarshaler File - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *f = File(value) - - extraProperties, err := core.ExtractExtraProperties(data, *f) - if err != nil { - return err - } - f.extraProperties = extraProperties - - f._rawJSON = json.RawMessage(data) - return nil -} - -func (f *File) String() string { - if len(f._rawJSON) > 0 { - if value, err := core.StringifyJSON(f._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(f); err == nil { - return value - } - return fmt.Sprintf("%#v", f) -} - -type FileInfo string - -const ( - // A regular file (e.g. foo.txt). - FileInfoRegular FileInfo = "REGULAR" - // A directory (e.g. foo/). - FileInfoDirectory FileInfo = "DIRECTORY" -) - -func NewFileInfoFromString(s string) (FileInfo, error) { - switch s { - case "REGULAR": - return FileInfoRegular, nil - case "DIRECTORY": - return FileInfoDirectory, nil - } - var t FileInfo - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (f FileInfo) Ptr() *FileInfo { - return &f -} diff --git a/seed/go-sdk/pagination/types.go b/seed/go-sdk/pagination/types.go deleted file mode 100644 index a78a2a58eea..00000000000 --- a/seed/go-sdk/pagination/types.go +++ /dev/null @@ -1,459 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package pagination - -import ( - json "encoding/json" - fmt "fmt" - uuid "github.com/google/uuid" - core "github.com/pagination/fern/core" -) - -type UsernamePage struct { - After *string `json:"after,omitempty" url:"after,omitempty"` - Data []string `json:"data,omitempty" url:"data,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (u *UsernamePage) GetAfter() *string { - if u == nil { - return nil - } - return u.After -} - -func (u *UsernamePage) GetData() []string { - if u == nil { - return nil - } - return u.Data -} - -func (u *UsernamePage) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UsernamePage) UnmarshalJSON(data []byte) error { - type unmarshaler UsernamePage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UsernamePage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *UsernamePage) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type NextPage struct { - Page int `json:"page" url:"page"` - StartingAfter string `json:"starting_after" url:"starting_after"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (n *NextPage) GetPage() int { - if n == nil { - return 0 - } - return n.Page -} - -func (n *NextPage) GetStartingAfter() string { - if n == nil { - return "" - } - return n.StartingAfter -} - -func (n *NextPage) GetExtraProperties() map[string]interface{} { - return n.extraProperties -} - -func (n *NextPage) UnmarshalJSON(data []byte) error { - type unmarshaler NextPage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *n = NextPage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *n) - if err != nil { - return err - } - n.extraProperties = extraProperties - - n._rawJSON = json.RawMessage(data) - return nil -} - -func (n *NextPage) String() string { - if len(n._rawJSON) > 0 { - if value, err := core.StringifyJSON(n._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(n); err == nil { - return value - } - return fmt.Sprintf("%#v", n) -} - -type Page struct { - // The current page - Page int `json:"page" url:"page"` - Next *NextPage `json:"next,omitempty" url:"next,omitempty"` - PerPage int `json:"per_page" url:"per_page"` - TotalPage int `json:"total_page" url:"total_page"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (p *Page) GetPage() int { - if p == nil { - return 0 - } - return p.Page -} - -func (p *Page) GetNext() *NextPage { - if p == nil { - return nil - } - return p.Next -} - -func (p *Page) GetPerPage() int { - if p == nil { - return 0 - } - return p.PerPage -} - -func (p *Page) GetTotalPage() int { - if p == nil { - return 0 - } - return p.TotalPage -} - -func (p *Page) GetExtraProperties() map[string]interface{} { - return p.extraProperties -} - -func (p *Page) UnmarshalJSON(data []byte) error { - type unmarshaler Page - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *p = Page(value) - - extraProperties, err := core.ExtractExtraProperties(data, *p) - if err != nil { - return err - } - p.extraProperties = extraProperties - - p._rawJSON = json.RawMessage(data) - return nil -} - -func (p *Page) String() string { - if len(p._rawJSON) > 0 { - if value, err := core.StringifyJSON(p._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(p); err == nil { - return value - } - return fmt.Sprintf("%#v", p) -} - -type User struct { - Name string `json:"name" url:"name"` - Id int `json:"id" url:"id"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (u *User) GetName() string { - if u == nil { - return "" - } - return u.Name -} - -func (u *User) GetId() int { - if u == nil { - return 0 - } - return u.Id -} - -func (u *User) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *User) UnmarshalJSON(data []byte) error { - type unmarshaler User - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = User(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *User) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserListContainer struct { - Users []*User `json:"users,omitempty" url:"users,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (u *UserListContainer) GetUsers() []*User { - if u == nil { - return nil - } - return u.Users -} - -func (u *UserListContainer) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserListContainer) UnmarshalJSON(data []byte) error { - type unmarshaler UserListContainer - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserListContainer(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *UserListContainer) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserOptionalListContainer struct { - Users []*User `json:"users,omitempty" url:"users,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (u *UserOptionalListContainer) GetUsers() []*User { - if u == nil { - return nil - } - return u.Users -} - -func (u *UserOptionalListContainer) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserOptionalListContainer) UnmarshalJSON(data []byte) error { - type unmarshaler UserOptionalListContainer - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserOptionalListContainer(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *UserOptionalListContainer) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserOptionalListPage struct { - Data *UserOptionalListContainer `json:"data,omitempty" url:"data,omitempty"` - Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (u *UserOptionalListPage) GetData() *UserOptionalListContainer { - if u == nil { - return nil - } - return u.Data -} - -func (u *UserOptionalListPage) GetNext() *uuid.UUID { - if u == nil { - return nil - } - return u.Next -} - -func (u *UserOptionalListPage) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserOptionalListPage) UnmarshalJSON(data []byte) error { - type unmarshaler UserOptionalListPage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserOptionalListPage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *UserOptionalListPage) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} - -type UserPage struct { - Data *UserListContainer `json:"data,omitempty" url:"data,omitempty"` - Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (u *UserPage) GetData() *UserListContainer { - if u == nil { - return nil - } - return u.Data -} - -func (u *UserPage) GetNext() *uuid.UUID { - if u == nil { - return nil - } - return u.Next -} - -func (u *UserPage) GetExtraProperties() map[string]interface{} { - return u.extraProperties -} - -func (u *UserPage) UnmarshalJSON(data []byte) error { - type unmarshaler UserPage - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *u = UserPage(value) - - extraProperties, err := core.ExtractExtraProperties(data, *u) - if err != nil { - return err - } - u.extraProperties = extraProperties - - u._rawJSON = json.RawMessage(data) - return nil -} - -func (u *UserPage) String() string { - if len(u._rawJSON) > 0 { - if value, err := core.StringifyJSON(u._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(u); err == nil { - return value - } - return fmt.Sprintf("%#v", u) -} diff --git a/seed/go-sdk/pagination/users.go b/seed/go-sdk/pagination/users.go index 74261c5bfe7..9480e9553be 100644 --- a/seed/go-sdk/pagination/users.go +++ b/seed/go-sdk/pagination/users.go @@ -129,6 +129,62 @@ func (u *UsernameCursor) String() string { return fmt.Sprintf("%#v", u) } +type UsernamePage struct { + After *string `json:"after,omitempty" url:"after,omitempty"` + Data []string `json:"data,omitempty" url:"data,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (u *UsernamePage) GetAfter() *string { + if u == nil { + return nil + } + return u.After +} + +func (u *UsernamePage) GetData() []string { + if u == nil { + return nil + } + return u.Data +} + +func (u *UsernamePage) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UsernamePage) UnmarshalJSON(data []byte) error { + type unmarshaler UsernamePage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UsernamePage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UsernamePage) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + type ListUsersExtendedOptionalListResponse struct { Data *UserOptionalListContainer `json:"data,omitempty" url:"data,omitempty"` Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` @@ -332,6 +388,62 @@ func (l *ListUsersPaginationResponse) String() string { return fmt.Sprintf("%#v", l) } +type NextPage struct { + Page int `json:"page" url:"page"` + StartingAfter string `json:"starting_after" url:"starting_after"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (n *NextPage) GetPage() int { + if n == nil { + return 0 + } + return n.Page +} + +func (n *NextPage) GetStartingAfter() string { + if n == nil { + return "" + } + return n.StartingAfter +} + +func (n *NextPage) GetExtraProperties() map[string]interface{} { + return n.extraProperties +} + +func (n *NextPage) UnmarshalJSON(data []byte) error { + type unmarshaler NextPage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *n = NextPage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *n) + if err != nil { + return err + } + n.extraProperties = extraProperties + + n._rawJSON = json.RawMessage(data) + return nil +} + +func (n *NextPage) String() string { + if len(n._rawJSON) > 0 { + if value, err := core.StringifyJSON(n._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(n); err == nil { + return value + } + return fmt.Sprintf("%#v", n) +} + type Order string const ( @@ -354,6 +466,343 @@ func (o Order) Ptr() *Order { return &o } +type Page struct { + // The current page + Page int `json:"page" url:"page"` + Next *NextPage `json:"next,omitempty" url:"next,omitempty"` + PerPage int `json:"per_page" url:"per_page"` + TotalPage int `json:"total_page" url:"total_page"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (p *Page) GetPage() int { + if p == nil { + return 0 + } + return p.Page +} + +func (p *Page) GetNext() *NextPage { + if p == nil { + return nil + } + return p.Next +} + +func (p *Page) GetPerPage() int { + if p == nil { + return 0 + } + return p.PerPage +} + +func (p *Page) GetTotalPage() int { + if p == nil { + return 0 + } + return p.TotalPage +} + +func (p *Page) GetExtraProperties() map[string]interface{} { + return p.extraProperties +} + +func (p *Page) UnmarshalJSON(data []byte) error { + type unmarshaler Page + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = Page(value) + + extraProperties, err := core.ExtractExtraProperties(data, *p) + if err != nil { + return err + } + p.extraProperties = extraProperties + + p._rawJSON = json.RawMessage(data) + return nil +} + +func (p *Page) String() string { + if len(p._rawJSON) > 0 { + if value, err := core.StringifyJSON(p._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type User struct { + Name string `json:"name" url:"name"` + Id int `json:"id" url:"id"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (u *User) GetName() string { + if u == nil { + return "" + } + return u.Name +} + +func (u *User) GetId() int { + if u == nil { + return 0 + } + return u.Id +} + +func (u *User) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *User) UnmarshalJSON(data []byte) error { + type unmarshaler User + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = User(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *User) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UserListContainer struct { + Users []*User `json:"users,omitempty" url:"users,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (u *UserListContainer) GetUsers() []*User { + if u == nil { + return nil + } + return u.Users +} + +func (u *UserListContainer) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserListContainer) UnmarshalJSON(data []byte) error { + type unmarshaler UserListContainer + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserListContainer(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UserListContainer) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UserOptionalListContainer struct { + Users []*User `json:"users,omitempty" url:"users,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (u *UserOptionalListContainer) GetUsers() []*User { + if u == nil { + return nil + } + return u.Users +} + +func (u *UserOptionalListContainer) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserOptionalListContainer) UnmarshalJSON(data []byte) error { + type unmarshaler UserOptionalListContainer + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserOptionalListContainer(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UserOptionalListContainer) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UserOptionalListPage struct { + Data *UserOptionalListContainer `json:"data,omitempty" url:"data,omitempty"` + Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (u *UserOptionalListPage) GetData() *UserOptionalListContainer { + if u == nil { + return nil + } + return u.Data +} + +func (u *UserOptionalListPage) GetNext() *uuid.UUID { + if u == nil { + return nil + } + return u.Next +} + +func (u *UserOptionalListPage) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserOptionalListPage) UnmarshalJSON(data []byte) error { + type unmarshaler UserOptionalListPage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserOptionalListPage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UserOptionalListPage) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UserPage struct { + Data *UserListContainer `json:"data,omitempty" url:"data,omitempty"` + Next *uuid.UUID `json:"next,omitempty" url:"next,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (u *UserPage) GetData() *UserListContainer { + if u == nil { + return nil + } + return u.Data +} + +func (u *UserPage) GetNext() *uuid.UUID { + if u == nil { + return nil + } + return u.Next +} + +func (u *UserPage) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UserPage) UnmarshalJSON(data []byte) error { + type unmarshaler UserPage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UserPage(value) + + extraProperties, err := core.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UserPage) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + type UsernameContainer struct { Results []string `json:"results,omitempty" url:"results,omitempty"` diff --git a/seed/go-sdk/response-property/service.go b/seed/go-sdk/response-property/service.go index d2279d8f77e..860bb29371f 100644 --- a/seed/go-sdk/response-property/service.go +++ b/seed/go-sdk/response-property/service.go @@ -58,6 +58,110 @@ func (s *StringResponse) String() string { return fmt.Sprintf("%#v", s) } +type WithMetadata struct { + Metadata map[string]string `json:"metadata,omitempty" url:"metadata,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (w *WithMetadata) GetMetadata() map[string]string { + if w == nil { + return nil + } + return w.Metadata +} + +func (w *WithMetadata) GetExtraProperties() map[string]interface{} { + return w.extraProperties +} + +func (w *WithMetadata) UnmarshalJSON(data []byte) error { + type unmarshaler WithMetadata + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *w = WithMetadata(value) + + extraProperties, err := core.ExtractExtraProperties(data, *w) + if err != nil { + return err + } + w.extraProperties = extraProperties + + w._rawJSON = json.RawMessage(data) + return nil +} + +func (w *WithMetadata) String() string { + if len(w._rawJSON) > 0 { + if value, err := core.StringifyJSON(w._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(w); err == nil { + return value + } + return fmt.Sprintf("%#v", w) +} + +type Movie struct { + Id string `json:"id" url:"id"` + Name string `json:"name" url:"name"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (m *Movie) GetId() string { + if m == nil { + return "" + } + return m.Id +} + +func (m *Movie) GetName() string { + if m == nil { + return "" + } + return m.Name +} + +func (m *Movie) GetExtraProperties() map[string]interface{} { + return m.extraProperties +} + +func (m *Movie) UnmarshalJSON(data []byte) error { + type unmarshaler Movie + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *m = Movie(value) + + extraProperties, err := core.ExtractExtraProperties(data, *m) + if err != nil { + return err + } + m.extraProperties = extraProperties + + m._rawJSON = json.RawMessage(data) + return nil +} + +func (m *Movie) String() string { + if len(m._rawJSON) > 0 { + if value, err := core.StringifyJSON(m._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(m); err == nil { + return value + } + return fmt.Sprintf("%#v", m) +} + type OptionalWithDocs = *WithDocs type Response struct { @@ -123,3 +227,51 @@ func (r *Response) String() string { } return fmt.Sprintf("%#v", r) } + +type WithDocs struct { + Docs string `json:"docs" url:"docs"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (w *WithDocs) GetDocs() string { + if w == nil { + return "" + } + return w.Docs +} + +func (w *WithDocs) GetExtraProperties() map[string]interface{} { + return w.extraProperties +} + +func (w *WithDocs) UnmarshalJSON(data []byte) error { + type unmarshaler WithDocs + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *w = WithDocs(value) + + extraProperties, err := core.ExtractExtraProperties(data, *w) + if err != nil { + return err + } + w.extraProperties = extraProperties + + w._rawJSON = json.RawMessage(data) + return nil +} + +func (w *WithDocs) String() string { + if len(w._rawJSON) > 0 { + if value, err := core.StringifyJSON(w._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(w); err == nil { + return value + } + return fmt.Sprintf("%#v", w) +} diff --git a/seed/go-sdk/response-property/types.go b/seed/go-sdk/response-property/types.go deleted file mode 100644 index dfc49e1e863..00000000000 --- a/seed/go-sdk/response-property/types.go +++ /dev/null @@ -1,161 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package responseproperty - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/response-property/fern/core" -) - -type WithMetadata struct { - Metadata map[string]string `json:"metadata,omitempty" url:"metadata,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (w *WithMetadata) GetMetadata() map[string]string { - if w == nil { - return nil - } - return w.Metadata -} - -func (w *WithMetadata) GetExtraProperties() map[string]interface{} { - return w.extraProperties -} - -func (w *WithMetadata) UnmarshalJSON(data []byte) error { - type unmarshaler WithMetadata - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *w = WithMetadata(value) - - extraProperties, err := core.ExtractExtraProperties(data, *w) - if err != nil { - return err - } - w.extraProperties = extraProperties - - w._rawJSON = json.RawMessage(data) - return nil -} - -func (w *WithMetadata) String() string { - if len(w._rawJSON) > 0 { - if value, err := core.StringifyJSON(w._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(w); err == nil { - return value - } - return fmt.Sprintf("%#v", w) -} - -type Movie struct { - Id string `json:"id" url:"id"` - Name string `json:"name" url:"name"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (m *Movie) GetId() string { - if m == nil { - return "" - } - return m.Id -} - -func (m *Movie) GetName() string { - if m == nil { - return "" - } - return m.Name -} - -func (m *Movie) GetExtraProperties() map[string]interface{} { - return m.extraProperties -} - -func (m *Movie) UnmarshalJSON(data []byte) error { - type unmarshaler Movie - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *m = Movie(value) - - extraProperties, err := core.ExtractExtraProperties(data, *m) - if err != nil { - return err - } - m.extraProperties = extraProperties - - m._rawJSON = json.RawMessage(data) - return nil -} - -func (m *Movie) String() string { - if len(m._rawJSON) > 0 { - if value, err := core.StringifyJSON(m._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(m); err == nil { - return value - } - return fmt.Sprintf("%#v", m) -} - -type WithDocs struct { - Docs string `json:"docs" url:"docs"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (w *WithDocs) GetDocs() string { - if w == nil { - return "" - } - return w.Docs -} - -func (w *WithDocs) GetExtraProperties() map[string]interface{} { - return w.extraProperties -} - -func (w *WithDocs) UnmarshalJSON(data []byte) error { - type unmarshaler WithDocs - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *w = WithDocs(value) - - extraProperties, err := core.ExtractExtraProperties(data, *w) - if err != nil { - return err - } - w.extraProperties = extraProperties - - w._rawJSON = json.RawMessage(data) - return nil -} - -func (w *WithDocs) String() string { - if len(w._rawJSON) > 0 { - if value, err := core.StringifyJSON(w._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(w); err == nil { - return value - } - return fmt.Sprintf("%#v", w) -} diff --git a/seed/go-sdk/undiscriminated-unions/types.go b/seed/go-sdk/undiscriminated-unions/types.go deleted file mode 100644 index 9b29c33668d..00000000000 --- a/seed/go-sdk/undiscriminated-unions/types.go +++ /dev/null @@ -1,145 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package undiscriminated - -import ( - json "encoding/json" - fmt "fmt" - core "github.com/fern-api/undiscriminated-go/core" -) - -type Key struct { - KeyType KeyType - defaultStringLiteral string - - typ string -} - -func NewKeyWithDefaultStringLiteral() *Key { - return &Key{typ: "defaultStringLiteral", defaultStringLiteral: "default"} -} - -func (k *Key) GetKeyType() KeyType { - if k == nil { - return "" - } - return k.KeyType -} - -func (k *Key) DefaultStringLiteral() string { - return k.defaultStringLiteral -} - -func (k *Key) UnmarshalJSON(data []byte) error { - var valueKeyType KeyType - if err := json.Unmarshal(data, &valueKeyType); err == nil { - k.typ = "KeyType" - k.KeyType = valueKeyType - return nil - } - var valueDefaultStringLiteral string - if err := json.Unmarshal(data, &valueDefaultStringLiteral); err == nil { - k.typ = "defaultStringLiteral" - k.defaultStringLiteral = valueDefaultStringLiteral - if k.defaultStringLiteral != "default" { - return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", k, "default", valueDefaultStringLiteral) - } - return nil - } - return fmt.Errorf("%s cannot be deserialized as a %T", data, k) -} - -func (k Key) MarshalJSON() ([]byte, error) { - if k.typ == "KeyType" || k.KeyType != "" { - return json.Marshal(k.KeyType) - } - if k.typ == "defaultStringLiteral" || k.defaultStringLiteral != "" { - return json.Marshal("default") - } - return nil, fmt.Errorf("type %T does not include a non-empty union type", k) -} - -type KeyVisitor interface { - VisitKeyType(KeyType) error - VisitDefaultStringLiteral(string) error -} - -func (k *Key) Accept(visitor KeyVisitor) error { - if k.typ == "KeyType" || k.KeyType != "" { - return visitor.VisitKeyType(k.KeyType) - } - if k.typ == "defaultStringLiteral" || k.defaultStringLiteral != "" { - return visitor.VisitDefaultStringLiteral(k.defaultStringLiteral) - } - return fmt.Errorf("type %T does not include a non-empty union type", k) -} - -type KeyType string - -const ( - KeyTypeName KeyType = "name" - KeyTypeValue KeyType = "value" -) - -func NewKeyTypeFromString(s string) (KeyType, error) { - switch s { - case "name": - return KeyTypeName, nil - case "value": - return KeyTypeValue, nil - } - var t KeyType - return "", fmt.Errorf("%s is not a valid %T", s, t) -} - -func (k KeyType) Ptr() *KeyType { - return &k -} - -type TypeWithOptionalUnion struct { - MyUnion *MyUnion `json:"myUnion,omitempty" url:"myUnion,omitempty"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (t *TypeWithOptionalUnion) GetMyUnion() *MyUnion { - if t == nil { - return nil - } - return t.MyUnion -} - -func (t *TypeWithOptionalUnion) GetExtraProperties() map[string]interface{} { - return t.extraProperties -} - -func (t *TypeWithOptionalUnion) UnmarshalJSON(data []byte) error { - type unmarshaler TypeWithOptionalUnion - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *t = TypeWithOptionalUnion(value) - - extraProperties, err := core.ExtractExtraProperties(data, *t) - if err != nil { - return err - } - t.extraProperties = extraProperties - - t._rawJSON = json.RawMessage(data) - return nil -} - -func (t *TypeWithOptionalUnion) String() string { - if len(t._rawJSON) > 0 { - if value, err := core.StringifyJSON(t._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(t); err == nil { - return value - } - return fmt.Sprintf("%#v", t) -} diff --git a/seed/go-sdk/undiscriminated-unions/union.go b/seed/go-sdk/undiscriminated-unions/union.go index e6582245750..2282bdbe602 100644 --- a/seed/go-sdk/undiscriminated-unions/union.go +++ b/seed/go-sdk/undiscriminated-unions/union.go @@ -5,8 +5,97 @@ package undiscriminated import ( json "encoding/json" fmt "fmt" + core "github.com/fern-api/undiscriminated-go/core" ) +type Key struct { + KeyType KeyType + defaultStringLiteral string + + typ string +} + +func NewKeyWithDefaultStringLiteral() *Key { + return &Key{typ: "defaultStringLiteral", defaultStringLiteral: "default"} +} + +func (k *Key) GetKeyType() KeyType { + if k == nil { + return "" + } + return k.KeyType +} + +func (k *Key) DefaultStringLiteral() string { + return k.defaultStringLiteral +} + +func (k *Key) UnmarshalJSON(data []byte) error { + var valueKeyType KeyType + if err := json.Unmarshal(data, &valueKeyType); err == nil { + k.typ = "KeyType" + k.KeyType = valueKeyType + return nil + } + var valueDefaultStringLiteral string + if err := json.Unmarshal(data, &valueDefaultStringLiteral); err == nil { + k.typ = "defaultStringLiteral" + k.defaultStringLiteral = valueDefaultStringLiteral + if k.defaultStringLiteral != "default" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", k, "default", valueDefaultStringLiteral) + } + return nil + } + return fmt.Errorf("%s cannot be deserialized as a %T", data, k) +} + +func (k Key) MarshalJSON() ([]byte, error) { + if k.typ == "KeyType" || k.KeyType != "" { + return json.Marshal(k.KeyType) + } + if k.typ == "defaultStringLiteral" || k.defaultStringLiteral != "" { + return json.Marshal("default") + } + return nil, fmt.Errorf("type %T does not include a non-empty union type", k) +} + +type KeyVisitor interface { + VisitKeyType(KeyType) error + VisitDefaultStringLiteral(string) error +} + +func (k *Key) Accept(visitor KeyVisitor) error { + if k.typ == "KeyType" || k.KeyType != "" { + return visitor.VisitKeyType(k.KeyType) + } + if k.typ == "defaultStringLiteral" || k.defaultStringLiteral != "" { + return visitor.VisitDefaultStringLiteral(k.defaultStringLiteral) + } + return fmt.Errorf("type %T does not include a non-empty union type", k) +} + +type KeyType string + +const ( + KeyTypeName KeyType = "name" + KeyTypeValue KeyType = "value" +) + +func NewKeyTypeFromString(s string) (KeyType, error) { + switch s { + case "name": + return KeyTypeName, nil + case "value": + return KeyTypeValue, nil + } + var t KeyType + return "", fmt.Errorf("%s is not a valid %T", s, t) +} + +func (k KeyType) Ptr() *KeyType { + return &k +} + // Undiscriminated unions can act as a map key // as long as all of their values are valid keys // (i.e. do they have a valid string representation). @@ -158,3 +247,51 @@ func (m *MyUnion) Accept(visitor MyUnionVisitor) error { } return fmt.Errorf("type %T does not include a non-empty union type", m) } + +type TypeWithOptionalUnion struct { + MyUnion *MyUnion `json:"myUnion,omitempty" url:"myUnion,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (t *TypeWithOptionalUnion) GetMyUnion() *MyUnion { + if t == nil { + return nil + } + return t.MyUnion +} + +func (t *TypeWithOptionalUnion) GetExtraProperties() map[string]interface{} { + return t.extraProperties +} + +func (t *TypeWithOptionalUnion) UnmarshalJSON(data []byte) error { + type unmarshaler TypeWithOptionalUnion + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = TypeWithOptionalUnion(value) + + extraProperties, err := core.ExtractExtraProperties(data, *t) + if err != nil { + return err + } + t.extraProperties = extraProperties + + t._rawJSON = json.RawMessage(data) + return nil +} + +func (t *TypeWithOptionalUnion) String() string { + if len(t._rawJSON) > 0 { + if value, err := core.StringifyJSON(t._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} diff --git a/seed/go-sdk/unions/types.go b/seed/go-sdk/unions/types.go index 61fdf4e0490..4d0cc07fe99 100644 --- a/seed/go-sdk/unions/types.go +++ b/seed/go-sdk/unions/types.go @@ -1076,147 +1076,3 @@ func (u *UnionWithoutKey) Accept(visitor UnionWithoutKeyVisitor) error { } return fmt.Errorf("type %T does not define a non-empty union type", u) } - -type Circle struct { - Radius float64 `json:"radius" url:"radius"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (c *Circle) GetRadius() float64 { - if c == nil { - return 0 - } - return c.Radius -} - -func (c *Circle) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *Circle) UnmarshalJSON(data []byte) error { - type unmarshaler Circle - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = Circle(value) - - extraProperties, err := core.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - - c._rawJSON = json.RawMessage(data) - return nil -} - -func (c *Circle) String() string { - if len(c._rawJSON) > 0 { - if value, err := core.StringifyJSON(c._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -type GetShapeRequest struct { - Id string `json:"id" url:"id"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (g *GetShapeRequest) GetId() string { - if g == nil { - return "" - } - return g.Id -} - -func (g *GetShapeRequest) GetExtraProperties() map[string]interface{} { - return g.extraProperties -} - -func (g *GetShapeRequest) UnmarshalJSON(data []byte) error { - type unmarshaler GetShapeRequest - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *g = GetShapeRequest(value) - - extraProperties, err := core.ExtractExtraProperties(data, *g) - if err != nil { - return err - } - g.extraProperties = extraProperties - - g._rawJSON = json.RawMessage(data) - return nil -} - -func (g *GetShapeRequest) String() string { - if len(g._rawJSON) > 0 { - if value, err := core.StringifyJSON(g._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(g); err == nil { - return value - } - return fmt.Sprintf("%#v", g) -} - -type Square struct { - Length float64 `json:"length" url:"length"` - - extraProperties map[string]interface{} - _rawJSON json.RawMessage -} - -func (s *Square) GetLength() float64 { - if s == nil { - return 0 - } - return s.Length -} - -func (s *Square) GetExtraProperties() map[string]interface{} { - return s.extraProperties -} - -func (s *Square) UnmarshalJSON(data []byte) error { - type unmarshaler Square - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = Square(value) - - extraProperties, err := core.ExtractExtraProperties(data, *s) - if err != nil { - return err - } - s.extraProperties = extraProperties - - s._rawJSON = json.RawMessage(data) - return nil -} - -func (s *Square) String() string { - if len(s._rawJSON) > 0 { - if value, err := core.StringifyJSON(s._rawJSON); err == nil { - return value - } - } - if value, err := core.StringifyJSON(s); err == nil { - return value - } - return fmt.Sprintf("%#v", s) -} diff --git a/seed/go-sdk/unions/union.go b/seed/go-sdk/unions/union.go index 7aca76207aa..cdd40b0e29e 100644 --- a/seed/go-sdk/unions/union.go +++ b/seed/go-sdk/unions/union.go @@ -8,6 +8,102 @@ import ( core "github.com/fern-api/unions-go/core" ) +type Circle struct { + Radius float64 `json:"radius" url:"radius"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (c *Circle) GetRadius() float64 { + if c == nil { + return 0 + } + return c.Radius +} + +func (c *Circle) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *Circle) UnmarshalJSON(data []byte) error { + type unmarshaler Circle + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = Circle(value) + + extraProperties, err := core.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + + c._rawJSON = json.RawMessage(data) + return nil +} + +func (c *Circle) String() string { + if len(c._rawJSON) > 0 { + if value, err := core.StringifyJSON(c._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type GetShapeRequest struct { + Id string `json:"id" url:"id"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (g *GetShapeRequest) GetId() string { + if g == nil { + return "" + } + return g.Id +} + +func (g *GetShapeRequest) GetExtraProperties() map[string]interface{} { + return g.extraProperties +} + +func (g *GetShapeRequest) UnmarshalJSON(data []byte) error { + type unmarshaler GetShapeRequest + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *g = GetShapeRequest(value) + + extraProperties, err := core.ExtractExtraProperties(data, *g) + if err != nil { + return err + } + g.extraProperties = extraProperties + + g._rawJSON = json.RawMessage(data) + return nil +} + +func (g *GetShapeRequest) String() string { + if len(g._rawJSON) > 0 { + if value, err := core.StringifyJSON(g._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(g); err == nil { + return value + } + return fmt.Sprintf("%#v", g) +} + type Shape struct { Type string Id string @@ -97,3 +193,51 @@ func (s *Shape) Accept(visitor ShapeVisitor) error { } return fmt.Errorf("type %T does not define a non-empty union type", s) } + +type Square struct { + Length float64 `json:"length" url:"length"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (s *Square) GetLength() float64 { + if s == nil { + return 0 + } + return s.Length +} + +func (s *Square) GetExtraProperties() map[string]interface{} { + return s.extraProperties +} + +func (s *Square) UnmarshalJSON(data []byte) error { + type unmarshaler Square + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *s = Square(value) + + extraProperties, err := core.ExtractExtraProperties(data, *s) + if err != nil { + return err + } + s.extraProperties = extraProperties + + s._rawJSON = json.RawMessage(data) + return nil +} + +func (s *Square) String() string { + if len(s._rawJSON) > 0 { + if value, err := core.StringifyJSON(s._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(s); err == nil { + return value + } + return fmt.Sprintf("%#v", s) +} diff --git a/seed/go-sdk/unknown/types.go b/seed/go-sdk/unknown/types.go deleted file mode 100644 index 500e23e0ba2..00000000000 --- a/seed/go-sdk/unknown/types.go +++ /dev/null @@ -1,5 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package unknownasany - -type MyAlias = interface{} diff --git a/seed/go-sdk/unknown/unknown.go b/seed/go-sdk/unknown/unknown.go index 402bc660642..0b3e828aa73 100644 --- a/seed/go-sdk/unknown/unknown.go +++ b/seed/go-sdk/unknown/unknown.go @@ -8,6 +8,8 @@ import ( core "github.com/unknown/fern/core" ) +type MyAlias = interface{} + type MyObject struct { Unknown interface{} `json:"unknown,omitempty" url:"unknown,omitempty"`