Search in sources :

Example 1 with Document

use of com.google.api.codegen.discovery.Document in project toolkit by googleapis.

the class DiscoConfigGeneratorApi method setupDocument.

/**
 * Initializes the Discovery document document.
 */
private Document setupDocument() {
    // Prevent INFO messages from polluting the log.
    Logger.getLogger("").setLevel(Level.WARNING);
    String discoveryDocPath = options.get(DiscoGapicGeneratorApi.DISCOVERY_DOC);
    Document document = null;
    try {
        document = DocumentGenerator.createDocumentAndLog(discoveryDocPath, getDiagCollector());
    } catch (FileNotFoundException e) {
        getDiagCollector().addDiag(Diag.error(SimpleLocation.TOPLEVEL, "File not found: " + discoveryDocPath));
    } catch (IOException e) {
        getDiagCollector().addDiag(Diag.error(SimpleLocation.TOPLEVEL, "Failed to read Discovery Doc: " + discoveryDocPath));
    }
    return document;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Document(com.google.api.codegen.discovery.Document)

Example 2 with Document

use of com.google.api.codegen.discovery.Document in project toolkit by googleapis.

the class DiscoConfigGeneratorApi method generateConfig.

private Map<String, Doc> generateConfig(String outputPath) {
    Document document = setupDocument();
    ViewModel viewModel = new DiscoConfigTransformer().generateConfig(new DiscoApiModel(document, ""), outputPath);
    Doc generatedConfig = new CommonSnippetSetRunner(new CommonRenderingUtil()).generate(viewModel);
    return ImmutableMap.of(outputPath, generatedConfig);
}
Also used : DiscoApiModel(com.google.api.codegen.config.DiscoApiModel) CommonRenderingUtil(com.google.api.codegen.util.CommonRenderingUtil) CommonSnippetSetRunner(com.google.api.codegen.rendering.CommonSnippetSetRunner) Doc(com.google.api.tools.framework.snippet.Doc) ViewModel(com.google.api.codegen.viewmodel.ViewModel) DiscoConfigTransformer(com.google.api.codegen.configgen.transformer.DiscoConfigTransformer) Document(com.google.api.codegen.discovery.Document)

Aggregations

Document (com.google.api.codegen.discovery.Document)2 DiscoApiModel (com.google.api.codegen.config.DiscoApiModel)1 DiscoConfigTransformer (com.google.api.codegen.configgen.transformer.DiscoConfigTransformer)1 CommonSnippetSetRunner (com.google.api.codegen.rendering.CommonSnippetSetRunner)1 CommonRenderingUtil (com.google.api.codegen.util.CommonRenderingUtil)1 ViewModel (com.google.api.codegen.viewmodel.ViewModel)1 Doc (com.google.api.tools.framework.snippet.Doc)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1