@@ -128,18 +128,20 @@ std::map<std::string, std::string> ScaffoldVars(
128128 google::cloud::cpp::generator::ServiceConfiguration const & service,
129129 bool experimental) {
130130 std::map<std::string, std::string> vars;
131- for (auto const & api : index[" apis" ]) {
132- if (!api.contains (" directory" )) continue ;
133- auto const directory = api[" directory" ].get <std::string>() + " /" ;
134- if (!absl::StartsWith (service.service_proto_path (), directory)) continue ;
135- vars.emplace (" id" , api.value (" id" , " " ));
136- vars.emplace (" title" , api.value (" title" , " " ));
137- vars.emplace (" description" , api.value (" description" , " " ));
138- vars.emplace (" directory" , api.value (" directory" , " " ));
139- vars.emplace (" service_config_yaml_name" ,
140- absl::StrCat (api.value (" directory" , " " ), " /" ,
141- api.value (" configFile" , " " )));
142- vars.emplace (" nameInServiceConfig" , api.value (" nameInServiceConfig" , " " ));
131+ if (!index.is_null ()) {
132+ for (auto const & api : index[" apis" ]) {
133+ if (!api.contains (" directory" )) continue ;
134+ auto const directory = api[" directory" ].get <std::string>() + " /" ;
135+ if (!absl::StartsWith (service.service_proto_path (), directory)) continue ;
136+ vars.emplace (" id" , api.value (" id" , " " ));
137+ vars.emplace (" title" , api.value (" title" , " " ));
138+ vars.emplace (" description" , api.value (" description" , " " ));
139+ vars.emplace (" directory" , api.value (" directory" , " " ));
140+ vars.emplace (" service_config_yaml_name" ,
141+ absl::StrCat (api.value (" directory" , " " ), " /" ,
142+ api.value (" configFile" , " " )));
143+ vars.emplace (" nameInServiceConfig" , api.value (" nameInServiceConfig" , " " ));
144+ }
143145 }
144146 if (!service.override_service_config_yaml_name ().empty ()) {
145147 vars.emplace (" service_config_yaml_name" ,
0 commit comments