blob: 7b04711f88f2cecc1ea3e64a833bad9914fa2f85 [file] [log] [blame]
# -
# ========================LICENSE_START=================================
# O-RAN-SC
# %%
# Copyright (C) 2022: Nordix Foundation
# %%
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========================LICENSE_END===================================
#
cwd=$(pwd)
mkdir internal/readonly/api
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.222/29222-h40.zip -o internal/readonly/api/apidef.zip
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.122/29122-h50.zip -o internal/readonly/api/commonapidef.zip
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.571/29571-h50.zip -o internal/readonly/api/common29571apidef.zip
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.572/29572-h40.zip -o internal/readonly/api/common29572apidef.zip
cd internal/readonly/api/
jar xvf apidef.zip
jar xvf commonapidef.zip
jar xvf common29571apidef.zip
jar xvf common29572apidef.zip
sed '/nwAreaInfo.*/,+1d' TS29122_CommonData.yaml >temp.yaml
mv temp.yaml TS29122_CommonData.yaml
sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\DddTrafficDescriptor/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
mv temp.yaml TS29571_CommonData.yaml
sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\CivicAddress/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
mv temp.yaml TS29571_CommonData.yaml
sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\GeographicArea/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
mv temp.yaml TS29571_CommonData.yaml
sed '/accessTokenError.*/,+3d' TS29571_CommonData.yaml >temp.yaml
mv temp.yaml TS29571_CommonData.yaml
sed '/accessTokenRequest.*/,+3d' TS29571_CommonData.yaml >temp.yaml
mv temp.yaml TS29571_CommonData.yaml
sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\moAssistanceDataTypes/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
mv temp.yaml TS29572_Nlmf_Location.yaml
sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\RelativeCartesianLocation/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
mv temp.yaml TS29572_Nlmf_Location.yaml
sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\Local2dPointUncertaintyEllipse/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
mv temp.yaml TS29572_Nlmf_Location.yaml
sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\Local3dPointUncertaintyEllipsoid/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
mv temp.yaml TS29572_Nlmf_Location.yaml
sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\oneOf/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
mv temp.yaml TS29572_Nlmf_Location.yaml
sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\ueAreaInd/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
mv temp.yaml TS29572_Nlmf_Location.yaml
sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\UeAreaIndication/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
mv temp.yaml TS29572_Nlmf_Location.yaml
sed '/connectivitystate.*/,+2d' TS29572_Nlmf_Location.yaml >temp.yaml
mv temp.yaml TS29572_Nlmf_Location.yaml
sed '/oneOf.*/,+2d' TS29222_CAPIF_Publish_Service_API.yaml >temp.yaml
mv temp.yaml TS29222_CAPIF_Publish_Service_API.yaml
sed '64,68d' TS29222_CAPIF_Discover_Service_API.yaml >temp.yaml # Remove parameter preferred-aef-loc since it doesn't follow the OpenApi specification, "The behavior for nested objects and arrays is undefined."
mv temp.yaml TS29222_CAPIF_Discover_Service_API.yaml
cat TS29222_CAPIF_Security_API.yaml | sed -E 's/( AccessTokenReq*)\:/\1:| type: object/' | tr '|' '\n' > temp.yaml
mv temp.yaml TS29222_CAPIF_Security_API.yaml
cd $cwd
cd internal/enumfixer
go build .
./enumfixer -apidir=../readonly/api
cd $cwd
go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen
PATH=$PATH:~/go/bin
oapi-codegen --config internal/readonly/common/generator_settings.yaml internal/readonly/api/TS29122_CommonData.yaml
oapi-codegen --config internal/readonly/common29571/generator_settings.yaml internal/readonly/api/TS29571_CommonData.yaml
oapi-codegen --config internal/readonly/nlfm/generator_settings.yaml internal/readonly/api/TS29572_Nlmf_Location.yaml
oapi-codegen --config internal/readonly/publishserviceapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_Publish_Service_API.yaml
oapi-codegen --config internal/readonly/publishserviceapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_Publish_Service_API.yaml
oapi-codegen --config internal/readonly/invokermanagementapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_API_Invoker_Management_API.yaml
oapi-codegen --config internal/readonly/invokermanagementapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_API_Invoker_Management_API.yaml
oapi-codegen --config internal/readonly/providermanagementapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_API_Provider_Management_API.yaml
oapi-codegen --config internal/readonly/providermanagementapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_API_Provider_Management_API.yaml
oapi-codegen --config internal/readonly/discoverserviceapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_Discover_Service_API.yaml
oapi-codegen --config internal/readonly/discoverserviceapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_Discover_Service_API.yaml
oapi-codegen --config internal/readonly/securityapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_Security_API.yaml
oapi-codegen --config internal/readonly/securityapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_Security_API.yaml
go generate ./...
go test ./...