use of com.google.api.codegen.viewmodel.ViewModel in project toolkit by googleapis.
the class ViewModelGapicProvider method generate.
@Override
public Map<String, Doc> generate(String snippetFileName) {
// Establish required stage for generation.
model.establishStage(Merged.KEY);
if (model.getDiagCollector().getErrorCount() > 0) {
return null;
}
List<ViewModel> surfaceDocs = modelToViewTransformer.transform(new ProtoApiModel(model), productConfig);
if (model.getDiagCollector().getErrorCount() > 0) {
return null;
}
Map<String, Doc> docs = new TreeMap<>();
for (ViewModel surfaceDoc : surfaceDocs) {
if (snippetFileName != null && !surfaceDoc.templateFileName().equals(snippetFileName)) {
continue;
}
Doc doc = snippetSetRunner.generate(surfaceDoc);
if (doc == null) {
// generation failed; failures are captured in the model.
continue;
}
docs.put(surfaceDoc.outputPath(), doc);
}
return docs;
}
use of com.google.api.codegen.viewmodel.ViewModel in project toolkit by googleapis.
the class ViewModelDiscoGapicProvider method generate.
@Override
public Map<String, Doc> generate(String snippetFileName) {
List<ViewModel> surfaceDocs = modelToViewTransformer.transform(model, productConfig);
if (model.getDiagCollector().getErrorCount() > 0) {
return null;
}
Map<String, Doc> docs = new TreeMap<>();
for (ViewModel surfaceDoc : surfaceDocs) {
if (snippetFileName != null && !surfaceDoc.templateFileName().equals(snippetFileName)) {
continue;
}
Doc doc = snippetSetRunner.generate(surfaceDoc);
if (doc == null) {
// generation failed; failures are captured in the model.
continue;
}
docs.put(surfaceDoc.outputPath(), doc);
}
return docs;
}
use of com.google.api.codegen.viewmodel.ViewModel in project toolkit by googleapis.
the class CSharpGapicSmokeTestTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
SurfaceNamer namer = new CSharpSurfaceNamer(productConfig.getPackageName());
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, csharpCommonTransformer.createTypeTable(namer.getPackageName()), namer, new CSharpFeatureConfig());
csharpCommonTransformer.addCommonImports(context);
SmokeTestClassView smokeTests = generateSmokeTest(context);
if (smokeTests != null) {
surfaceDocs.add(smokeTests);
surfaceDocs.add(generateSmokeTestCsproj(context));
}
}
return surfaceDocs;
}
use of com.google.api.codegen.viewmodel.ViewModel in project toolkit by googleapis.
the class CSharpGapicSnippetsTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
SurfaceNamer namer = new CSharpSurfaceNamer(productConfig.getPackageName());
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, csharpCommonTransformer.createTypeTable(namer.getExamplePackageName()), namer, new CSharpFeatureConfig());
csharpCommonTransformer.addCommonImports(context);
context.getImportTypeTable().saveNicknameFor("Google.Protobuf.Bytestring");
context.getImportTypeTable().saveNicknameFor("System.Linq.__import__");
SnippetsFileView snippets = generateSnippets(context);
surfaceDocs.add(snippets);
}
return surfaceDocs;
}
use of com.google.api.codegen.viewmodel.ViewModel in project toolkit by googleapis.
the class CSharpGapicUnitTestTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
SurfaceNamer namer = new CSharpSurfaceNamer(productConfig.getPackageName());
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, csharpCommonTransformer.createTypeTable(namer.getPackageName()), namer, new CSharpFeatureConfig());
csharpCommonTransformer.addCommonImports(context);
ModelTypeTable typeTable = context.getImportTypeTable();
typeTable.saveNicknameFor("Xunit.FactAttribute");
typeTable.saveNicknameFor("Moq.Mock");
if (context.getLongRunningMethods().iterator().hasNext()) {
typeTable.saveNicknameFor("Google.LongRunning.Operations");
}
surfaceDocs.add(generateUnitTest(context));
surfaceDocs.add(generateUnitTestCsproj(context));
}
return surfaceDocs;
}
Aggregations