Seed code
[nonrtric/plt/sme.git] / generate.sh
1 # -
2 #   ========================LICENSE_START=================================
3 #   O-RAN-SC
4 #   %%
5 #   Copyright (C) 2022: 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
21 cwd=$(pwd)
22
23 mkdir -p specs
24
25 curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.222/29222-h40.zip -o specs/apidef.zip
26 curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.122/29122-h50.zip -o specs/common29122apidef.zip
27 curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.508/29508-h60.zip -o specs/common29508apidef.zip
28 curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.510/29510-h50.zip -o specs/common29510apidef.zip
29 curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.512/29512-h60.zip -o specs/common29512apidef.zip
30 curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.514/29514-h40.zip -o specs/common29514apidef.zip
31 curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.517/29517-h50.zip -o specs/common29517apidef.zip
32 curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.518/29518-h50.zip -o specs/common29518apidef.zip
33 curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.522/29522-h50.zip -o specs/common29522apidef.zip
34 curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.523/29523-h60.zip -o specs/common29523apidef.zip
35 curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.554/29554-h30.zip -o specs/common29554apidef.zip
36 curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.571/29571-h50.zip -o specs/common29571apidef.zip
37 curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.572/29572-h40.zip -o specs/common29572apidef.zip
38
39 cd specs/
40
41 jar xvf apidef.zip
42 jar xvf common29122apidef.zip
43 jar xvf common29508apidef.zip
44 jar xvf common29510apidef.zip
45 jar xvf common29512apidef.zip
46 jar xvf common29514apidef.zip
47 jar xvf common29517apidef.zip
48 jar xvf common29518apidef.zip
49 jar xvf common29522apidef.zip
50 jar xvf common29523apidef.zip
51 jar xvf common29554apidef.zip
52 jar xvf common29571apidef.zip
53 jar xvf common29572apidef.zip
54
55 sed -e 'H;x;/^\(  *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\CivicAddress/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
56 mv temp.yaml TS29571_CommonData.yaml
57 sed -e 'H;x;/^\(  *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\GeographicArea/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
58 mv temp.yaml TS29571_CommonData.yaml
59 sed '/accessTokenError.*/,+3d' TS29571_CommonData.yaml >temp.yaml
60 mv temp.yaml TS29571_CommonData.yaml
61 sed '/accessTokenRequest.*/,+3d' TS29571_CommonData.yaml >temp.yaml
62 mv temp.yaml TS29571_CommonData.yaml
63
64 sed '/oneOf.*/,+2d' TS29222_CAPIF_Publish_Service_API.yaml >temp.yaml
65 mv temp.yaml TS29222_CAPIF_Publish_Service_API.yaml
66
67 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."
68 mv temp.yaml TS29222_CAPIF_Discover_Service_API.yaml
69
70 cat TS29222_CAPIF_Security_API.yaml | sed -E 's/(    AccessTokenReq*)\:/\1:|      type: object/' | tr '|' '\n' > temp.yaml
71 mv temp.yaml TS29222_CAPIF_Security_API.yaml
72
73 cat TS29122_CommonData.yaml | sed 's/TS29572_Nlmf_Location/CommonData/g' > temp.yaml
74 mv temp.yaml TS29122_CommonData.yaml
75 cat TS29122_CommonData.yaml | sed 's/TS29554_Npcf_BDTPolicyControl/CommonData/g' > temp.yaml
76 mv temp.yaml TS29122_CommonData.yaml
77 cat TS29571_CommonData.yaml | sed 's/TS29571_CommonData.yaml//g' > temp.yaml
78 mv temp.yaml TS29571_CommonData.yaml
79 cat TS29222_CAPIF_Publish_Service_API.yaml | sed 's/TS29572_Nlmf_Location/CommonData/g' > temp.yaml
80 mv temp.yaml TS29222_CAPIF_Publish_Service_API.yaml
81 cat TS29222_CAPIF_Routing_Info_API.yaml | sed 's/TS29520_Nnwdaf_EventsSubscription/CommonData/g' > temp.yaml
82 mv temp.yaml TS29222_CAPIF_Routing_Info_API.yaml
83 cat TS29222_CAPIF_Routing_Info_API.yaml | sed 's/TS29510_Nnrf_NFManagement/CommonData/g' > temp.yaml
84 mv temp.yaml TS29222_CAPIF_Routing_Info_API.yaml
85 cat TS29222_CAPIF_Events_API.yaml | sed 's/TS29523_Npcf_EventExposure/CommonData/g' > temp.yaml
86 mv temp.yaml TS29222_CAPIF_Events_API.yaml
87
88 go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.10.1
89 PATH=$PATH:~/go/bin
90
91 cd $cwd
92
93 echo "Fixing enums"
94 cd internal/gentools/enumfixer
95 go build .
96 ./enumfixer -apidir=../../../specs
97
98 cd $cwd
99 echo "Gathering common references"
100 cd internal/gentools/commoncollector
101 go build .
102 ./commoncollector -apidir=../../../specs
103
104 cd $cwd
105 echo "Fixing misc in specifications"
106 cd internal/gentools/specificationfixer
107 go build .
108 ./specificationfixer -apidir=../../../specs
109
110 cd $cwd
111
112 echo "Generating TS29122_CommonData"
113 mkdir -p internal/common29122
114 oapi-codegen --config gogeneratorspecs/common29122/generator_settings.yaml specs/TS29122_CommonData.yaml
115 echo "Generating aggregated CommonData"
116 mkdir -p internal/common
117 oapi-codegen --config gogeneratorspecs/common/generator_settings.yaml specs/CommonData.yaml
118 echo "Generating TS29571_CommonData"
119 mkdir -p internal/common29571
120 oapi-codegen --config gogeneratorspecs/common29571/generator_settings.yaml specs/TS29571_CommonData.yaml
121 echo "Generating TS29222_CAPIF_Publish_Service_API"
122 mkdir -p internal/publishserviceapi
123 oapi-codegen --config gogeneratorspecs/publishserviceapi/generator_settings_types.yaml specs/TS29222_CAPIF_Publish_Service_API.yaml
124 oapi-codegen --config gogeneratorspecs/publishserviceapi/generator_settings_server.yaml specs/TS29222_CAPIF_Publish_Service_API.yaml
125 echo "Generating TS29222_CAPIF_API_Invoker_Management_API"
126 mkdir -p internal/invokermanagementapi
127 oapi-codegen --config gogeneratorspecs/invokermanagementapi/generator_settings_types.yaml specs/TS29222_CAPIF_API_Invoker_Management_API.yaml
128 oapi-codegen --config gogeneratorspecs/invokermanagementapi/generator_settings_server.yaml specs/TS29222_CAPIF_API_Invoker_Management_API.yaml
129 echo "Generating TS29222_CAPIF_API_Provider_Management_API"
130 mkdir -p internal/providermanagementapi
131 oapi-codegen --config gogeneratorspecs/providermanagementapi/generator_settings_types.yaml specs/TS29222_CAPIF_API_Provider_Management_API.yaml
132 oapi-codegen --config gogeneratorspecs/providermanagementapi/generator_settings_server.yaml specs/TS29222_CAPIF_API_Provider_Management_API.yaml
133 echo "Generating TS29222_CAPIF_Discover_Service_API"
134 mkdir -p internal/discoverserviceapi
135 oapi-codegen --config gogeneratorspecs/discoverserviceapi/generator_settings_types.yaml specs/TS29222_CAPIF_Discover_Service_API.yaml
136 oapi-codegen --config gogeneratorspecs/discoverserviceapi/generator_settings_server.yaml specs/TS29222_CAPIF_Discover_Service_API.yaml
137 echo "Generating TS29222_CAPIF_Security_API"
138 mkdir -p internal/securityapi
139 oapi-codegen --config gogeneratorspecs/securityapi/generator_settings_types.yaml specs/TS29222_CAPIF_Security_API.yaml
140 oapi-codegen --config gogeneratorspecs/securityapi/generator_settings_server.yaml specs/TS29222_CAPIF_Security_API.yaml
141 echo "Generating TS29222_CAPIF_Logging_API_Invocation_API"
142 mkdir -p internal/loggingapi
143 oapi-codegen --config gogeneratorspecs/loggingapi/generator_settings_types.yaml specs/TS29222_CAPIF_Logging_API_Invocation_API.yaml
144 oapi-codegen --config gogeneratorspecs/loggingapi/generator_settings_server.yaml specs/TS29222_CAPIF_Logging_API_Invocation_API.yaml
145 echo "Generating TS29222_CAPIF_Routing_Info_API"
146 mkdir -p internal/routinginfoapi
147 oapi-codegen --config gogeneratorspecs/routinginfoapi/generator_settings_types.yaml specs/TS29222_CAPIF_Routing_Info_API.yaml
148 oapi-codegen --config gogeneratorspecs/routinginfoapi/generator_settings_server.yaml specs/TS29222_CAPIF_Routing_Info_API.yaml
149 echo "Generating TS29222_CAPIF_Access_Control_Policy_API"
150 mkdir -p internal/accesscontrolpolicyapi
151 oapi-codegen --config gogeneratorspecs/accesscontrolpolicyapi/generator_settings_types.yaml specs/TS29222_CAPIF_Access_Control_Policy_API.yaml
152 oapi-codegen --config gogeneratorspecs/accesscontrolpolicyapi/generator_settings_server.yaml specs/TS29222_CAPIF_Access_Control_Policy_API.yaml
153 echo "Generating TS29222_CAPIF_Events_API"
154 mkdir -p internal/eventsapi
155 oapi-codegen --config gogeneratorspecs/eventsapi/generator_settings_types.yaml specs/TS29222_CAPIF_Events_API.yaml
156 oapi-codegen --config gogeneratorspecs/eventsapi/generator_settings_server.yaml specs/TS29222_CAPIF_Events_API.yaml
157 echo "Generating TS29222_CAPIF_Auditing_API"
158 mkdir -p internal/auditingapi
159 oapi-codegen --config gogeneratorspecs/auditingapi/generator_settings_types.yaml specs/TS29222_CAPIF_Auditing_API.yaml
160 oapi-codegen --config gogeneratorspecs/auditingapi/generator_settings_server.yaml specs/TS29222_CAPIF_Auditing_API.yaml
161 echo "Generating TS29222_AEF_Security_API"
162 mkdir -p internal/aefsecurityapi
163 oapi-codegen --config gogeneratorspecs/aefsecurityapi/generator_settings_types.yaml specs/TS29222_AEF_Security_API.yaml
164 oapi-codegen --config gogeneratorspecs/aefsecurityapi/generator_settings_server.yaml specs/TS29222_AEF_Security_API.yaml
165
166 echo "Cleanup"
167 rm -rf specs