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)
49 func getData(filename string) map[string]interface{} {
50 yamlFile, err := ioutil.ReadFile(*apiDir + "/" + filename)
52 log.Fatalf("Error reading yamlFile. #%v ", err)
54 m := make(map[string]interface{})
55 err = yaml.Unmarshal(yamlFile, m)
57 log.Fatalf("Unmarshal: %v", err)
62 func writeFile(filename string, data map[string]interface{}) {
63 modCommon, err := yaml.Marshal(data)
65 log.Fatalf("Marshal: #%v ", err)
67 err = ioutil.WriteFile(*apiDir+"/"+filename, modCommon, 0644)
69 log.Fatalf("Error writing yamlFile. #%v ", err)