blob: fd5e7416d4c4d75eda95ae80534aae47a2529fb3 [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/common29122apidef.zip
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.508/29508-h60.zip -o internal/readonly/api/common29508apidef.zip
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.510/29510-h50.zip -o internal/readonly/api/common29510apidef.zip
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.512/29512-h60.zip -o internal/readonly/api/common29512apidef.zip
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.514/29514-h40.zip -o internal/readonly/api/common29514apidef.zip
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.517/29517-h50.zip -o internal/readonly/api/common29517apidef.zip
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.518/29518-h50.zip -o internal/readonly/api/common29518apidef.zip
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.522/29522-h50.zip -o internal/readonly/api/common29522apidef.zip
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.523/29523-h60.zip -o internal/readonly/api/common29523apidef.zip
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.554/29554-h30.zip -o internal/readonly/api/common29554apidef.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 common29122apidef.zip
jar xvf common29508apidef.zip
jar xvf common29510apidef.zip
jar xvf common29512apidef.zip
jar xvf common29514apidef.zip
jar xvf common29517apidef.zip
jar xvf common29518apidef.zip
jar xvf common29522apidef.zip
jar xvf common29523apidef.zip
jar xvf common29554apidef.zip
jar xvf common29571apidef.zip
jar xvf common29572apidef.zip
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 '/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
sed -i 's/TS29572_Nlmf_Location/CommonData/g' TS29122_CommonData.yaml
sed -i 's/TS29554_Npcf_BDTPolicyControl/CommonData/g' TS29122_CommonData.yaml
sed -i 's/TS29571_CommonData.yaml//g' TS29571_CommonData.yaml
sed -i 's/TS29572_Nlmf_Location/CommonData/g' TS29222_CAPIF_Publish_Service_API.yaml
sed -i 's/TS29520_Nnwdaf_EventsSubscription/CommonData/g' TS29222_CAPIF_Routing_Info_API.yaml
sed -i 's/TS29510_Nnrf_NFManagement/CommonData/g' TS29222_CAPIF_Routing_Info_API.yaml
sed -i 's/TS29523_Npcf_EventExposure/CommonData/g' TS29222_CAPIF_Events_API.yaml
cd $cwd
cd internal/enumfixer
go build .
./enumfixer -apidir=../readonly/api
cd $cwd
cd internal/commoncollector
go build .
./commoncollector -apidir=../readonly/api
cd $cwd
cd internal/specificationfixer
go build .
./specificationfixer -apidir=../readonly/api
cd $cwd
go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen
PATH=$PATH:~/go/bin
echo "Generating TS29122_CommonData"
oapi-codegen --config internal/readonly/common29122/generator_settings.yaml internal/readonly/api/TS29122_CommonData.yaml
echo "Generating aggregated CommonData"
oapi-codegen --config internal/readonly/aggregatecommon/generator_settings.yaml internal/readonly/api/CommonData.yaml
echo "Generating TS29571_CommonData"
oapi-codegen --config internal/readonly/common29571/generator_settings.yaml internal/readonly/api/TS29571_CommonData.yaml
echo "Generating TS29222_CAPIF_Publish_Service_API"
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
echo "Generating TS29222_CAPIF_API_Invoker_Management_API"
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
echo "Generating TS29222_CAPIF_API_Provider_Management_API"
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
echo "Generating TS29222_CAPIF_Discover_Service_API"
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
echo "Generating TS29222_CAPIF_Security_API"
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
echo "Generating TS29222_CAPIF_Logging_API_Invocation_API"
oapi-codegen --config internal/readonly/loggingapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_Logging_API_Invocation_API.yaml
oapi-codegen --config internal/readonly/loggingapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_Logging_API_Invocation_API.yaml
echo "Generating TS29222_CAPIF_Routing_Info_API"
oapi-codegen --config internal/readonly/routinginfoapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_Routing_Info_API.yaml
oapi-codegen --config internal/readonly/routinginfoapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_Routing_Info_API.yaml
echo "Generating TS29222_CAPIF_Access_Control_Policy_API"
oapi-codegen --config internal/readonly/accesscontrolpolicyapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_Access_Control_Policy_API.yaml
oapi-codegen --config internal/readonly/accesscontrolpolicyapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_Access_Control_Policy_API.yaml
echo "Generating TS29222_CAPIF_Events_API"
oapi-codegen --config internal/readonly/eventsapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_Events_API.yaml
oapi-codegen --config internal/readonly/eventsapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_Events_API.yaml
echo "Generating TS29222_CAPIF_Auditing_API"
oapi-codegen --config internal/readonly/auditingapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_Auditing_API.yaml
oapi-codegen --config internal/readonly/auditingapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_Auditing_API.yaml
echo "Generating TS29222_AEF_Security_API"
oapi-codegen --config internal/readonly/aefsecurityapi/generator_settings_types.yaml internal/readonly/api/TS29222_AEF_Security_API.yaml
oapi-codegen --config internal/readonly/aefsecurityapi/generator_settings_server.yaml internal/readonly/api/TS29222_AEF_Security_API.yaml
echo "Generating Go mocks"
go generate ./...
echo "Testing Go application"
go test ./...
echo "Install Java version of CAPIF"
mvn install -f java/capifapi/pom.xml