
com.reprezen.genflow.swagger.doc.TopMatter Maven / Gradle / Ivy
The 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.swagger.doc;
import com.reprezen.genflow.swagger.doc.DocHelper;
import com.reprezen.genflow.swagger.doc.HelperHelper;
import io.swagger.models.Contact;
import io.swagger.models.Info;
import io.swagger.models.License;
import io.swagger.models.Scheme;
import io.swagger.models.Swagger;
import java.util.Collections;
import java.util.List;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.ListExtensions;
@SuppressWarnings("all")
public class TopMatter {
@Extension
private DocHelper _docHelper = HelperHelper.getDocHelper();
public CharSequence get(final Swagger swagger) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("");
_builder.newLine();
_builder.append(" ");
_builder.append("");
_builder.newLine();
_builder.append(" ");
_builder.append("");
Info _info = swagger.getInfo();
String _title = null;
if (_info!=null) {
_title=_info.getTitle();
}
_builder.append(_title, " ");
_builder.append(" ");
CharSequence _baseUri = this.getBaseUri(swagger);
_builder.append(_baseUri, " ");
_builder.append("
");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("");
_builder.newLine();
_builder.append(" ");
_builder.append("");
_builder.newLine();
_builder.append(" ");
Info _info_1 = swagger.getInfo();
String _description = null;
if (_info_1!=null) {
_description=_info_1.getDescription();
}
String _docHtml = null;
if (_description!=null) {
_docHtml=this._docHelper.getDocHtml(_description);
}
_builder.append(_docHtml, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("");
_builder.newLine();
_builder.append(" ");
_builder.append("Version ");
Info _info_2 = swagger.getInfo();
String _version = null;
if (_info_2!=null) {
_version=_info_2.getVersion();
}
_builder.append(_version, " ");
_builder.append(" ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("Contact ");
CharSequence _contactInfoHtml = this.getContactInfoHtml(swagger);
_builder.append(_contactInfoHtml, " ");
_builder.append(" ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("Terms of Service ");
Info _info_3 = swagger.getInfo();
String _termsOfService = null;
if (_info_3!=null) {
_termsOfService=_info_3.getTermsOfService();
}
String _docHtml_1 = this._docHelper.getDocHtml(_termsOfService);
_builder.append(_docHtml_1, " ");
_builder.append(" ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("License ");
CharSequence _licenseInfoHtml = this.getLicenseInfoHtml(swagger);
_builder.append(_licenseInfoHtml, " ");
_builder.append(" ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("
");
_builder.newLine();
_builder.append(" ");
_builder.append("");
_builder.newLine();
_builder.append("");
_builder.newLine();
return _builder;
}
private Object getScheme(final Swagger swagger) {
Object _xblockexpression = null;
{
final Function1 _function = (Scheme it) -> {
return it.toString().toLowerCase();
};
final List schemes = ListExtensions.map(swagger.getSchemes(), _function);
for (final String preferredScheme : Collections.unmodifiableList(CollectionLiterals.newArrayList("https", "http"))) {
boolean _contains = schemes.contains(preferredScheme);
if (_contains) {
return preferredScheme;
}
}
Object _xifexpression = null;
int _size = schemes.size();
boolean _greaterThan = (_size > 0);
if (_greaterThan) {
_xifexpression = swagger.getSchemes().get(0);
} else {
_xifexpression = "http";
}
_xblockexpression = ((Object)_xifexpression);
}
return _xblockexpression;
}
private CharSequence getBaseUri(final Swagger swagger) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("(");
Object _scheme = this.getScheme(swagger);
_builder.append(_scheme);
_builder.append("://");
String _host = swagger.getHost();
_builder.append(_host);
String _basePath = swagger.getBasePath();
_builder.append(_basePath);
_builder.append(")");
return _builder;
}
private CharSequence getContactInfoHtml(final Swagger swagger) {
CharSequence _xblockexpression = null;
{
Info _info = swagger.getInfo();
Contact _contact = null;
if (_info!=null) {
_contact=_info.getContact();
}
final Contact contact = _contact;
CharSequence _xifexpression = null;
if ((contact != null)) {
CharSequence _xblockexpression_1 = null;
{
String _elvis = null;
String _name = contact.getName();
if (_name != null) {
_elvis = _name;
} else {
String _url = contact.getUrl();
_elvis = _url;
}
final String primaryText = _elvis;
String _xifexpression_1 = null;
String _url_1 = contact.getUrl();
boolean _tripleNotEquals = (_url_1 != null);
if (_tripleNotEquals) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("");
_builder.append(primaryText);
_builder.append("");
_xifexpression_1 = _builder.toString();
} else {
_xifexpression_1 = primaryText;
}
final String primary = _xifexpression_1;
String _xifexpression_2 = null;
String _email = contact.getEmail();
boolean _tripleNotEquals_1 = (_email != null);
if (_tripleNotEquals_1) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("");
String _email_2 = contact.getEmail();
_builder_1.append(_email_2);
_builder_1.append("");
_xifexpression_2 = _builder_1.toString();
}
final String email = _xifexpression_2;
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append(primary);
_builder_2.append(" ");
_builder_2.append(email);
_xblockexpression_1 = _builder_2;
}
_xifexpression = _xblockexpression_1;
}
_xblockexpression = _xifexpression;
}
return _xblockexpression;
}
private CharSequence getLicenseInfoHtml(final Swagger swagger) {
CharSequence _xblockexpression = null;
{
Info _info = swagger.getInfo();
License _license = null;
if (_info!=null) {
_license=_info.getLicense();
}
final License license = _license;
CharSequence _xifexpression = null;
if ((license != null)) {
CharSequence _xblockexpression_1 = null;
{
String _elvis = null;
String _name = license.getName();
if (_name != null) {
_elvis = _name;
} else {
String _url = license.getUrl();
_elvis = _url;
}
final String text = _elvis;
CharSequence _xifexpression_1 = null;
String _url_1 = license.getUrl();
boolean _tripleNotEquals = (_url_1 != null);
if (_tripleNotEquals) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("");
_builder.append(text);
_builder.append("");
_xifexpression_1 = _builder;
} else {
_xifexpression_1 = text;
}
_xblockexpression_1 = _xifexpression_1;
}
_xifexpression = _xblockexpression_1;
}
_xblockexpression = _xifexpression;
}
return _xblockexpression;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy