All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.reprezen.genflow.openapi.swaggerui.v2.XGenerateSwaggerUI Maven / Gradle / Ivy

There is a newer version: 1.4.2
Show newest version
/**
 * Copyright © 2013, 2016 Modelsolv, Inc.
 * All Rights Reserved.
 * 
 * NOTICE: All information contained herein is, and remains the property
 * of ModelSolv, Inc. See the file license.html in the root directory of
 * this project for further information.
 */
package com.reprezen.genflow.openapi.swaggerui.v2;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Strings;
import com.reprezen.genflow.api.template.IGenTemplateContext;
import com.reprezen.genflow.common.HtmlInjections;
import com.reprezen.genflow.openapi.swaggerui.v2.SwaggerUiOptions;
import io.swagger.models.Swagger;
import java.net.URL;
import java.util.Map;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function0;

@SuppressWarnings("all")
public class XGenerateSwaggerUI {
  private final static ObjectMapper mapper = new Function0() {
    public ObjectMapper apply() {
      ObjectMapper _xifexpression = null;
      Boolean _valueOf = Boolean.valueOf(true);
      if ((_valueOf).booleanValue()) {
        ObjectMapper _xblockexpression = null;
        {
          final ObjectMapper m = new ObjectMapper();
          m.setSerializationInclusion(JsonInclude.Include.NON_NULL);
          _xblockexpression = m;
        }
        _xifexpression = _xblockexpression;
      }
      return _xifexpression;
    }
  }.apply();
  
  public String generateForSwaggerSpec(final Swagger swagger, final String urlPrefix, final URL resolutionBase, final boolean isLiveView, final SwaggerUiOptions options, final IGenTemplateContext context) {
    try {
      String _xblockexpression = null;
      {
        final String spec = XGenerateSwaggerUI.mapper.writeValueAsString(swagger);
        _xblockexpression = this.generateForSwaggerSpec(spec, urlPrefix, resolutionBase, isLiveView, options, context);
      }
      return _xblockexpression;
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
    }
  }
  
  @Extension
  private HtmlInjections htmlInjections;
  
  public String generateForSwaggerSpec(final String spec, final String urlPrefix, final URL resolutionBase, final boolean isLiveView, final SwaggerUiOptions options, final IGenTemplateContext context) {
    String _xblockexpression = null;
    {
      HtmlInjections _elvis = null;
      Map _genTargetParameters = context.getGenTargetParameters();
      Object _get = _genTargetParameters.get(HtmlInjections.HTML_INJECTIONS_PARAM);
      if (((HtmlInjections) _get) != null) {
        _elvis = ((HtmlInjections) _get);
      } else {
        HtmlInjections _htmlInjections = new HtmlInjections();
        _elvis = _htmlInjections;
      }
      this.htmlInjections = _elvis;
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("");
      _builder.newLine();
      _builder.append("");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("");
      _builder.newLine();
      _builder.append("\t\t");
      String _inject = this.htmlInjections.inject(HtmlInjections.HEAD_TOP);
      _builder.append(_inject, "\t\t");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("Swagger UI");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      {
        SwaggerUiOptions.Theme _theme = options.getTheme();
        boolean _tripleNotEquals = (_theme != null);
        if (_tripleNotEquals) {
          _builder.append("\t\t");
          _builder.append("");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLine();
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("");
      _builder.newLine();
      _builder.append("\t\t");
      String _inject_1 = this.htmlInjections.inject(HtmlInjections.HEAD_BOTTOM);
      _builder.append(_inject_1, "\t\t");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("");
      _builder.newLine();
      _builder.newLine();
      _builder.append("\t");
      _builder.append("");
      _builder.newLine();
      _builder.append("\t");
      String _inject_2 = this.htmlInjections.inject(HtmlInjections.BODY_TOP);
      _builder.append(_inject_2, "\t");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("
"); _builder.newLine(); _builder.append("\t\t"); _builder.append("
"); _builder.newLine(); _builder.append("\t\t\t"); _builder.append(""); _builder.newLine(); _builder.append("\t\t\t"); _builder.append(""); _builder.newLine(); { boolean _or = false; if (isLiveView) { _or = true; } else { boolean _isShowJsonEditorInSettings = options.isShowJsonEditorInSettings(); _or = _isShowJsonEditorInSettings; } if (_or) { _builder.append("\t\t\t"); _builder.append("
"); _builder.newLine(); _builder.append("\t\t\t"); _builder.append("\t"); _builder.append(""); _builder.newLine(); _builder.append("\t\t\t"); _builder.append("\t"); _builder.append(""); _builder.newLine(); _builder.append("\t\t\t"); _builder.append("
"); _builder.newLine(); } } _builder.append("\t\t"); _builder.append("
"); _builder.newLine(); _builder.append("\t"); _builder.append("
"); _builder.newLine(); _builder.append("\t"); _builder.append(""); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("
 
"); _builder.newLine(); _builder.append("\t"); _builder.append("
"); _builder.newLine(); _builder.append("\t"); String _inject_3 = this.htmlInjections.inject(HtmlInjections.BODY_BOTTOM); _builder.append(_inject_3, "\t"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append(""); _builder.newLine(); _builder.append(""); _builder.newLine(); _xblockexpression = _builder.toString(); } return _xblockexpression; } public CharSequence maybeFunction(final String option) { CharSequence _xifexpression = null; boolean _startsWith = option.startsWith("function"); if (_startsWith) { _xifexpression = option; } else { StringConcatenation _builder = new StringConcatenation(); _builder.append("\""); _builder.append(option, ""); _builder.append("\""); _xifexpression = _builder; } return _xifexpression; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy