Skip to content

Commit

Permalink
fix: make sh script compatible with Mac OSX sed (#21)
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Mortari <[email protected]>
  • Loading branch information
tarilabs authored Mar 5, 2024
1 parent ed52ec7 commit ece101a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scripts/gen_openapi_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ openapi-generator-cli generate \
--ignore-file-override $ROOT_FOLDER/.openapi-generator-ignore --additional-properties=outputAsLibrary=true,enumClassPrefix=true,router=chi,sourceFolder=,onlyInterfaces=true,isGoSubmodule=true,enumClassPrefix=true,useOneOfDiscriminatorLookup=true \
--template-dir $ROOT_FOLDER/templates/go-server

sed -i 's/, orderByParam/, model.OrderByField(orderByParam)/g' $ROOT_FOLDER/internal/server/openapi/api_model_registry_service.go
sed -i 's/, sortOrderParam/, model.SortOrder(sortOrderParam)/g' $ROOT_FOLDER/internal/server/openapi/api_model_registry_service.go
if [[ $(uname) == "Darwin" ]]; then
# introduce -i parameter for Mac OSX sed compatibility
sed -i '' 's/, orderByParam/, model.OrderByField(orderByParam)/g' $ROOT_FOLDER/internal/server/openapi/api_model_registry_service.go
sed -i '' 's/, sortOrderParam/, model.SortOrder(sortOrderParam)/g' $ROOT_FOLDER/internal/server/openapi/api_model_registry_service.go
else
sed -i 's/, orderByParam/, model.OrderByField(orderByParam)/g' $ROOT_FOLDER/internal/server/openapi/api_model_registry_service.go
sed -i 's/, sortOrderParam/, model.SortOrder(sortOrderParam)/g' $ROOT_FOLDER/internal/server/openapi/api_model_registry_service.go
fi

echo "Assembling type_assert Go file"
./scripts/gen_type_asserts.sh
Expand Down

0 comments on commit ece101a

Please sign in to comment.