Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
implemented new util (DOESN'T WORK WITH CURRENT TESTS YET)
Browse files Browse the repository at this point in the history
Signed-off-by: Holly Hunt <holly.hunt1101@hotmail.com>
  • Loading branch information
Wyvinar committed Jun 7, 2024
1 parent eb2f349 commit fdfd7f3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions openapi2beans/pkg/generator/JavaStructures.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"sort"
"strings"

"github.com/iancoleman/strcase"
"github.com/dev-galasa/buildutils/openapi2beans/pkg/utils"
)

type JavaPackage struct {
Expand Down Expand Up @@ -100,8 +100,8 @@ func NewDataMember(name string, memberType string, description string) *DataMemb
serializedOverrideName = name
}
dataMember := DataMember {
Name: strcase.ToLowerCamel(name),
PascalCaseName: strcase.ToCamel(name),
Name: utils.StringToCamel(name),
PascalCaseName: utils.StringToPascal(name),
MemberType: memberType,
Description: SplitDescription(description),
SerializedNameOverride: serializedOverrideName,
Expand Down Expand Up @@ -162,7 +162,7 @@ func stringArrayToEnumValues(stringEnums []string) []EnumValue {
var constantFormatName string
var stringFormat string
if value != "nil"{
constantFormatName = strcase.ToScreamingSnake(value)
constantFormatName = utils.StringToScreamingSnake(value)
stringFormat = value
enumValue := EnumValue {
ConstFormatName: constantFormatName,
Expand Down
8 changes: 4 additions & 4 deletions openapi2beans/pkg/generator/schema2package.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package generator

import (
"github.com/iancoleman/strcase"
"github.com/dev-galasa/buildutils/openapi2beans/pkg/utils"
)

func translateSchemaTypesToJavaPackage(schemaTypes map[string]*SchemaType, packageName string) (javaPackage *JavaPackage) {
Expand All @@ -15,12 +15,12 @@ func translateSchemaTypesToJavaPackage(schemaTypes map[string]*SchemaType, packa

if schemaType.ownProperty.IsEnum() {
enumValues := mapValuesToArray(schemaType.ownProperty.possibleValues)
javaEnum := NewJavaEnum(strcase.ToCamel(schemaType.name), schemaType.description, enumValues, javaPackage)
javaEnum := NewJavaEnum(utils.StringToPascal(schemaType.name), schemaType.description, enumValues, javaPackage)

javaPackage.Enums[javaEnum.Name] = javaEnum
} else {
dataMembers, requiredMembers, constantDataMembers, hasSerializedNameDataMember := retrieveDataMembersFromSchemaType(schemaType)
javaClass := NewJavaClass(strcase.ToCamel(schemaType.name), schemaType.description, javaPackage, dataMembers, requiredMembers, constantDataMembers, hasSerializedNameDataMember)
javaClass := NewJavaClass(utils.StringToPascal(schemaType.name), schemaType.description, javaPackage, dataMembers, requiredMembers, constantDataMembers, hasSerializedNameDataMember)

javaPackage.Classes[javaClass.Name] = javaClass
}
Expand All @@ -47,7 +47,7 @@ func retrieveDataMembersFromSchemaType(schemaType *SchemaType) (dataMembers []*D
}
if property.IsConstant() {
constVals := mapValuesToArray(property.GetPossibleValues())
dataMember.Name = strcase.ToScreamingSnake(name)
dataMember.Name = utils.StringToScreamingSnake(name)
dataMember.ConstantVal = convertConstValueToJavaReadable(constVals[0], property.typeName)

constantDataMembers = append(constantDataMembers, dataMember)
Expand Down
4 changes: 2 additions & 2 deletions openapi2beans/pkg/generator/schema2package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package generator
import (
"testing"

"github.com/iancoleman/strcase"
"github.com/dev-galasa/buildutils/openapi2beans/pkg/utils"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -371,7 +371,7 @@ func TestTranslateSchemaTypesToJavaPackageWithEnum(t *testing.T) {
javaPackage := translateSchemaTypesToJavaPackage(schemaTypeMap, TARGET_JAVA_PACKAGE)

// Then...
enum, enumExists := javaPackage.Enums[strcase.ToCamel(schemaName)]
enum, enumExists := javaPackage.Enums[utils.StringToPascal(schemaName)]
assert.True(t, enumExists)
assert.Equal(t, "MyEnum", enum.Name)
assert.Equal(t, []string([]string{"test enum description"}), enum.Description)
Expand Down
6 changes: 3 additions & 3 deletions openapi2beans/pkg/generator/yaml2schematypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"

openapi2beans_errors "github.com/dev-galasa/buildutils/openapi2beans/pkg/errors"
"github.com/iancoleman/strcase"
"github.com/dev-galasa/buildutils/openapi2beans/pkg/utils"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -110,7 +110,7 @@ func retrieveSchemaComponentsFromMap(
if parentPath != OPENAPI_YAML_SCHEMAS_PATH {
varName = resolveNestedObjectName(varName, parentPath)
}
schemaType = NewSchemaType(strcase.ToCamel(varName), description, property, nil)
schemaType = NewSchemaType(utils.StringToPascal(varName), description, property, nil)
property.SetResolvedType(schemaType)
schemaTypes[apiSchemaPartPath] = schemaType
if typeName == "object" {
Expand Down Expand Up @@ -272,7 +272,7 @@ func resolveNestedObjectName(objectName string, parentPath string) string {
for _, element := range nameComponents {
newName += element
}
newName += strcase.ToCamel(objectName)
newName += utils.StringToPascal(objectName)
return newName
}

Expand Down

0 comments on commit fdfd7f3

Please sign in to comment.