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

com.reprezen.genflow.openapi3.doc.ResponseDoc Maven / Gradle / Ivy

package com.reprezen.genflow.openapi3.doc;

import com.reprezen.genflow.openapi3.doc.DocHelper;
import com.reprezen.genflow.openapi3.doc.ExamplesHelper;
import com.reprezen.genflow.openapi3.doc.HelperHelper;
import com.reprezen.genflow.openapi3.doc.HtmlHelper;
import com.reprezen.genflow.openapi3.doc.ResponseHelper;
import com.reprezen.genflow.openapi3.doc.SchemaHelper;
import com.reprezen.kaizen.oasparser.model3.Example;
import com.reprezen.kaizen.oasparser.model3.MediaType;
import com.reprezen.kaizen.oasparser.model3.OpenApi3;
import com.reprezen.kaizen.oasparser.model3.Response;
import com.reprezen.kaizen.oasparser.model3.Schema;
import java.util.Map;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.IterableExtensions;

@SuppressWarnings("all")
public class ResponseDoc {
  private final OpenApi3 model = HelperHelper.getModel();
  
  private final String status;
  
  @Extension
  private DocHelper _docHelper = HelperHelper.getDocHelper();
  
  @Extension
  private ResponseHelper _responseHelper = HelperHelper.getResponseHelper();
  
  @Extension
  private SchemaHelper _schemaHelper = HelperHelper.getSchemaHelper();
  
  @Extension
  private HtmlHelper _htmlHelper = HelperHelper.getHtmlHelper();
  
  @Extension
  private ExamplesHelper _examplesHelper = HelperHelper.getExamplesHelper();
  
  public ResponseDoc(final String status) {
    this.status = status;
  }
  
  public CharSequence getHtml() {
    StringConcatenation _builder = new StringConcatenation();
    Response _get = this.model.getResponses().get(this.status);
    CharSequence _responseHtml = null;
    if (_get!=null) {
      _responseHtml=this.getResponseHtml(_get);
    }
    _builder.append(_responseHtml);
    return _builder;
  }
  
  public CharSequence getResponseHtml(final Response response) {
    CharSequence _xblockexpression = null;
    {
      final MediaType mediaType = IterableExtensions.head(response.getContentMediaTypes().values());
      Schema _schema = null;
      if (mediaType!=null) {
        _schema=mediaType.getSchema();
      }
      final Schema schema = _schema;
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("");
      _builder.newLineIfNotEmpty();
      _builder.append("
"); _builder.newLine(); _builder.append(" "); _builder.append("
"); _builder.newLine(); _builder.append(" "); _builder.append("

"); _builder.append(this.status, " "); _builder.append("

"); _builder.newLineIfNotEmpty(); _builder.append(" "); _builder.append("
"); _builder.newLine(); _builder.append(" "); _builder.append("
"); _builder.newLine(); _builder.append(" "); _builder.append("Response "); String _chevron = this.chevron(); _builder.append(_chevron, " "); _builder.append(" "); String _schemaTitle = null; if (schema!=null) { _schemaTitle=this._schemaHelper.getSchemaTitle(schema); } _builder.append(_schemaTitle, " "); _builder.append(""); _builder.newLineIfNotEmpty(); _builder.append(" "); String _description = response.getDescription(); String _docHtml = null; if (_description!=null) { _docHtml=this._docHelper.getDocHtml(_description); } _builder.append(_docHtml, " "); _builder.newLineIfNotEmpty(); _builder.append(" "); CharSequence _renderSchema = null; if (schema!=null) { _renderSchema=this._schemaHelper.renderSchema(schema); } _builder.append(_renderSchema, " "); _builder.newLineIfNotEmpty(); _builder.append(" "); CharSequence _responseHeaders = this.getResponseHeaders(response); _builder.append(_responseHeaders, " "); _builder.newLineIfNotEmpty(); _builder.append(" "); Map _examples = null; if (mediaType!=null) { _examples=mediaType.getExamples(); } String _renderExamples = this._examplesHelper.renderExamples(_examples); _builder.append(_renderExamples, " "); _builder.newLineIfNotEmpty(); _builder.append(" "); _builder.append("
"); _builder.newLine(); _builder.append("
"); _builder.newLine(); _xblockexpression = _builder; } return _xblockexpression; } private CharSequence getResponseHeaders(final Response response) { CharSequence _xblockexpression = null; { final CharSequence html = this._responseHelper.getHeadersHtml(response); CharSequence _xifexpression = null; if ((html != null)) { StringConcatenation _builder = new StringConcatenation(); _builder.append("

Headers

"); _builder.newLine(); _builder.append(html); _builder.newLineIfNotEmpty(); _xifexpression = _builder; } _xblockexpression = _xifexpression; } return _xblockexpression; } public String chevron() { return ""; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy