blob: 18a4f5baba477de50855310c92548a199d329ba3 [file] [log] [blame]
ychacon71789712023-05-15 11:07:32 +02001# -
2# ========================LICENSE_START=================================
3# O-RAN-SC
4# %%
5# Copyright (C) 2023: Nordix Foundation
6# %%
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18# ========================LICENSE_END===================================
19#
20
21cwd=$(pwd)
22
23mkdir -p specs
24
25curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.222/29222-h60.zip -o specs/apidef.zip
26curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.122/29122-h70.zip -o specs/common29122apidef.zip
27curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.508/29508-h80.zip -o specs/common29508apidef.zip
28curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.510/29510-h70.zip -o specs/common29510apidef.zip
29curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.512/29512-h80.zip -o specs/common29512apidef.zip
30curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.514/29514-h60.zip -o specs/common29514apidef.zip
31curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.517/29517-h70.zip -o specs/common29517apidef.zip
32curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.518/29518-h70.zip -o specs/common29518apidef.zip
33curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.522/29522-h70.zip -o specs/common29522apidef.zip
34curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.523/29523-h80.zip -o specs/common29523apidef.zip
35curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.554/29554-h40.zip -o specs/common29554apidef.zip
36curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.571/29571-h70.zip -o specs/common29571apidef.zip
37curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.572/29572-h60.zip -o specs/common29572apidef.zip
38
39cd specs/
40
41jar xvf apidef.zip
42jar xvf common29122apidef.zip
43jar xvf common29508apidef.zip
44jar xvf common29510apidef.zip
45jar xvf common29512apidef.zip
46jar xvf common29514apidef.zip
47jar xvf common29517apidef.zip
48jar xvf common29518apidef.zip
49jar xvf common29522apidef.zip
50jar xvf common29523apidef.zip
51jar xvf common29554apidef.zip
52jar xvf common29571apidef.zip
53jar xvf common29572apidef.zip
54
55# Remove types that are not used by CAPIF that have dependencies to other specifications.
56sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\CivicAddress/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
57mv temp.yaml TS29571_CommonData.yaml
58sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\ExternalMbsServiceArea/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
59mv temp.yaml TS29571_CommonData.yaml
60sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\GeographicArea/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
61mv temp.yaml TS29571_CommonData.yaml
62sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\GeoServiceArea/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
63mv temp.yaml TS29571_CommonData.yaml
64sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\MbsMediaComp/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
65mv temp.yaml TS29571_CommonData.yaml
66sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\MbsMediaCompRm/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
67mv temp.yaml TS29571_CommonData.yaml
68sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\MbsMediaInfo/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
69mv temp.yaml TS29571_CommonData.yaml
70sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\MbsServiceInfo/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
71mv temp.yaml TS29571_CommonData.yaml
72sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\MbsSession/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
73mv temp.yaml TS29571_CommonData.yaml
74sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\SpatialValidityCond/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
75mv temp.yaml TS29571_CommonData.yaml
76
77# Remove attributes that can not be generated easily.
78sed '/accessTokenError.*/,+3d' TS29571_CommonData.yaml >temp.yaml
79mv temp.yaml TS29571_CommonData.yaml
80sed '/accessTokenRequest.*/,+3d' TS29571_CommonData.yaml >temp.yaml
81mv temp.yaml TS29571_CommonData.yaml
82
83
84sed '/oneOf.*/,+2d' TS29222_CAPIF_Publish_Service_API.yaml >temp.yaml
85mv temp.yaml TS29222_CAPIF_Publish_Service_API.yaml
86
87# Replace references to external specs that are collected to the common spec by the commoncollector
88# <replacements_start>
89cat TS29122_CommonData.yaml | sed 's/TS29572_Nlmf_Location/CommonData/g' > temp.yaml
90mv temp.yaml TS29122_CommonData.yaml
91cat TS29122_CommonData.yaml | sed 's/TS29554_Npcf_BDTPolicyControl/CommonData/g' > temp.yaml
92mv temp.yaml TS29122_CommonData.yaml
93cat TS29122_CommonData.yaml | sed 's/TS29514_Npcf_PolicyAuthorization/CommonData/g' > temp.yaml
94mv temp.yaml TS29122_CommonData.yaml
95cat TS29571_CommonData.yaml | sed 's/TS29514_Npcf_PolicyAuthorization/CommonData/g' > temp.yaml
96mv temp.yaml TS29571_CommonData.yaml
97cat TS29571_CommonData.yaml | sed 's/TS29572_Nlmf_Location/CommonData/g' > temp.yaml
98mv temp.yaml TS29571_CommonData.yaml
99cat TS29222_CAPIF_Publish_Service_API.yaml | sed 's/TS29572_Nlmf_Location/CommonData/g' > temp.yaml
100mv temp.yaml TS29222_CAPIF_Publish_Service_API.yaml
101# <new_replacement>
102
103# This spec has references to itself that need to be removed
104cat TS29571_CommonData.yaml | sed 's/TS29571_CommonData.yaml//g' > temp.yaml
105mv temp.yaml TS29571_CommonData.yaml
106
107cd $cwd
108
109echo "Fixing enums"
110cd internal/gentools/enumfixer
111go build .
112./enumfixer -apidir=../../../specs
113
114cd $cwd
115echo "Gathering common references"
116cd internal/gentools/commoncollector
117go build .
118./commoncollector -apidir=../../../specs
119
120cd $cwd
121echo "Fixing misc in specifications"
122cd internal/gentools/specificationfixer
123go build .
124./specificationfixer -apidir=../../../specs
125
126cd $cwd
127
128go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.10.1
129PATH=$PATH:~/go/bin
130
131echo "Generating TS29122_CommonData"
132mkdir -p internal/common29122
133oapi-codegen --config gogeneratorspecs/common29122/generator_settings.yaml specs/TS29122_CommonData.yaml
134
135echo "Generating aggregated CommonData"
136mkdir -p internal/common
137oapi-codegen --config gogeneratorspecs/common/generator_settings.yaml specs/CommonData.yaml
138
139echo "Generating TS29571_CommonData"
140mkdir -p internal/common29571
141oapi-codegen --config gogeneratorspecs/common29571/generator_settings.yaml specs/TS29571_CommonData.yaml
142
143
144echo "Generating TS29222_CAPIF_API_Provider_Management_API"
145mkdir -p internal/providermanagementapi
146oapi-codegen --config gogeneratorspecs/providermanagementapi/generator_settings_types.yaml specs/TS29222_CAPIF_API_Provider_Management_API.yaml
147
148echo "Generating TS29222_CAPIF_Publish_Service_API"
149mkdir -p internal/publishserviceapi
150oapi-codegen --config gogeneratorspecs/publishserviceapi/generator_settings_types.yaml specs/TS29222_CAPIF_Publish_Service_API.yaml
151
152echo "Generating TS29222_CAPIF_API_Invoker_Management_API"
153mkdir -p internal/invokermanagementapi
154oapi-codegen --config gogeneratorspecs/invokermanagementapi/generator_settings_types.yaml specs/TS29222_CAPIF_API_Invoker_Management_API.yaml
155
156echo "Generating TS29222_CAPIF_Discover_Service_API"
157mkdir -p internal/discoverserviceapi
158oapi-codegen --config gogeneratorspecs/discoverserviceapi/generator_settings_types.yaml specs/TS29222_CAPIF_Discover_Service_API.yaml
159
160echo "Generating TS29222_CAPIF_Security_API"
161mkdir -p internal/securityapi
162oapi-codegen --config gogeneratorspecs/securityapi/generator_settings_types.yaml specs/TS29222_CAPIF_Security_API.yaml
163
164echo "Cleanup"
165rm -rf specs
166
167echo "Generating mocks."
168go generate ./...