/** * Retrieves example payloads for body parameter either from examples or from vendor extensions. * @param parameter parameter to get the examples for * @return examples if found otherwise null */ private static Object getExamplesFromBodyParameter(Parameter parameter) { Object examples = ((BodyParameter) parameter).getExamples(); if (examples == null) { examples = parameter.getVendorExtensions().get("x-examples"); } return examples; }
@Override public void bodyParameter(BodyParameter bodyParameter) { bodyParameter.setExamples(fillMap(bodyParameter.getExamples())); }
private Object getAttribute(final BodyParameter param, final String attr) { Object _xblockexpression = null; { Object _switchResult = null; if (attr != null) { switch (attr) { case "examples": _switchResult = param.getExamples(); break; case "schema": _switchResult = param.getSchema(); break; } } final Object value = _switchResult; Object _elvis = null; if (value != null) { _elvis = value; } else { Object _attribute = this.getAttribute(((AbstractParameter) param), attr); _elvis = _attribute; } _xblockexpression = _elvis; } return _xblockexpression; }
private static void copyFields(BodyParameter from, BodyParameter to) { copyFields((AbstractParameter) from, (AbstractParameter) to); to.setExamples(from.getExamples()); to.setSchema(from.getSchema()); }
private RequestBody convertParameterToRequestBody(io.swagger.models.parameters.Parameter param, List<String> consumes) { RequestBody body = new RequestBody(); BodyParameter bp = (BodyParameter) param; List<String> mediaTypes = new ArrayList<>(globalConsumes); if (consumes != null && consumes.size() > 0) { mediaTypes.clear(); mediaTypes.addAll(consumes); } if (mediaTypes.size() == 0) { mediaTypes.add("*/*"); } if (StringUtils.isNotBlank(param.getDescription())) { body.description(param.getDescription()); } body.required(param.getRequired()); Content content = new Content(); for (String type : mediaTypes) { content.addMediaType(type, new MediaType().schema( convert(bp.getSchema()))); if (StringUtils.isNotBlank(bp.getDescription())) { body.setDescription(bp.getDescription()); } } convertExamples(((BodyParameter) param).getExamples(), content); body.content(content); return body; }
private RequestBody convertParameterToRequestBody(io.swagger.models.parameters.Parameter param, List<String> consumes) { RequestBody body = new RequestBody(); BodyParameter bp = (BodyParameter) param; List<String> mediaTypes = new ArrayList<>(globalConsumes); if (consumes != null && consumes.size() > 0) { mediaTypes.clear(); mediaTypes.addAll(consumes); } if (mediaTypes.size() == 0) { mediaTypes.add("*/*"); } if (StringUtils.isNotBlank(param.getDescription())) { body.description(param.getDescription()); } body.required(param.getRequired()); Content content = new Content(); for (String type : mediaTypes) { content.addMediaType(type, new MediaType().schema( convert(bp.getSchema()))); if (StringUtils.isNotBlank(bp.getDescription())) { body.setDescription(bp.getDescription()); } } convertExamples(((BodyParameter) param).getExamples(), content); body.content(content); return body; }
private RequestBody convertParameterToRequestBody(io.swagger.models.parameters.Parameter param, List<String> consumes) { RequestBody body = new RequestBody(); BodyParameter bp = (BodyParameter) param; List<String> mediaTypes = new ArrayList<>(globalConsumes); if (consumes != null && consumes.size() > 0) { mediaTypes.clear(); mediaTypes.addAll(consumes); } if (mediaTypes.size() == 0) { mediaTypes.add("*/*"); } if (StringUtils.isNotBlank(param.getDescription())) { body.description(param.getDescription()); } body.required(param.getRequired()); Content content = new Content(); for (String type : mediaTypes) { content.addMediaType(type, new MediaType().schema( convert(bp.getSchema()))); if (StringUtils.isNotBlank(bp.getDescription())) { body.setDescription(bp.getDescription()); } } convertExamples(((BodyParameter) param).getExamples(), content); body.content(content); return body; }
Object example = null; if (parameter instanceof BodyParameter) { example = ((BodyParameter) parameter).getExamples(); if (example == null) { Model schema = ((BodyParameter) parameter).getSchema();
public CharSequence bodyParamHtml(final Parameter param) { CharSequence _xblockexpression = null; { final BodyParameter bodyParam = ((BodyParameter) param); StringConcatenation _builder = new StringConcatenation(); String _docHtml = this._docHelper.getDocHtml(param.getDescription()); _builder.append(_docHtml); _builder.newLineIfNotEmpty(); CharSequence _renderSchema = this._schemaHelper.renderSchema(bodyParam.getSchema()); _builder.append(_renderSchema); _builder.newLineIfNotEmpty(); CharSequence _renderExamples = this._examplesHelper.<String>renderExamples(bodyParam.getExamples()); _builder.append(_renderExamples); _builder.newLineIfNotEmpty(); _xblockexpression = _builder; } return _xblockexpression; }
public CharSequence getRequestHtml(final BodyParameter bodyParam) { StringConcatenation _builder = new StringConcatenation(); _builder.append("<li class=\"list-group-item\">"); _builder.newLine(); _builder.append(" "); _builder.append("<strong>Request</strong> "); String _chevron = this.chevron(); _builder.append(_chevron, " "); _builder.append(" "); String _schemaTitle = this._schemaHelper.getSchemaTitle(bodyParam.getSchema()); _builder.append(_schemaTitle, " "); _builder.newLineIfNotEmpty(); _builder.append(" "); CharSequence _renderSchema = this._schemaHelper.renderSchema(bodyParam.getSchema()); _builder.append(_renderSchema, " "); _builder.newLineIfNotEmpty(); _builder.append(" "); CharSequence _renderExamples = this._examplesHelper.<String>renderExamples(bodyParam.getExamples()); _builder.append(_renderExamples, " "); _builder.newLineIfNotEmpty(); _builder.append("</li>"); _builder.newLine(); return _builder; }