blob: 51993da103e577f7627b95b70368be0adc99fe22 [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-g70.zip -o internal/readonly/api/apidef.zip
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.122/29122-g70.zip -o internal/readonly/api/commonapidef.zip
curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.571/29571-g70.zip -o internal/readonly/api/common29571apidef.zip
cd internal/readonly/api/
jar xvf apidef.zip
jar xvf commonapidef.zip
jar xvf common29571apidef.zip
sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\LocationArea/{s/^\( *\).*/ \1/;x;d;}' 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 '/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
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
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/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 ./...