2 // ========================LICENSE_START=================================
5 // Copyright (C) 2022: Nordix Foundation
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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===================================
34 apiDir = flag.String("apidir", "", "Directory containing API definitions to fix")
37 m := getData("TS29571_CommonData.yaml")
38 components := m["components"]
39 cMap := components.(map[interface{}]interface{})
40 schemas := cMap["schemas"].(map[interface{}]interface{})
41 snssaiExtensionData := schemas["SnssaiExtension"].(map[interface{}]interface{})
42 props := snssaiExtensionData["properties"].(map[interface{}]interface{})
43 wildcardSdData := props["wildcardSd"].(map[interface{}]interface{})
44 delete(wildcardSdData, "enum")
46 writeFile("TS29571_CommonData.yaml", m)
48 m = getData("TS29222_CAPIF_Security_API.yaml")
49 components = m["components"]
50 cMap = components.(map[interface{}]interface{})
51 schemas = cMap["schemas"].(map[interface{}]interface{})
52 accessTokenReq := schemas["AccessTokenReq"].(map[interface{}]interface{})
53 accessTokenReq["type"] = "object"
55 writeFile("TS29222_CAPIF_Security_API.yaml", m)
58 func getData(filename string) map[string]interface{} {
59 yamlFile, err := ioutil.ReadFile(*apiDir + "/" + filename)
61 log.Fatalf("Error reading yamlFile. #%v ", err)
63 m := make(map[string]interface{})
64 err = yaml.Unmarshal(yamlFile, m)
66 log.Fatalf("Unmarshal: %v", err)
71 func writeFile(filename string, data map[string]interface{}) {
72 modCommon, err := yaml.Marshal(data)
74 log.Fatalf("Marshal: #%v ", err)
76 err = ioutil.WriteFile(*apiDir+"/"+filename, modCommon, 0644)
78 log.Fatalf("Error writing yamlFile. #%v ", err)