example = getExamplesFromBodyParameter(parameter); if (example == null) { Model schema = ((BodyParameter) parameter).getSchema(); if (schema instanceof RefModel) { String simpleRef = ((RefModel) schema).getSimpleRef();
public BodyParameterAdapter(BodyParameter parameter) { this.model = parameter.getSchema(); }
Model model = bodyParameter.getSchema();
@Override public JavaType convert(SwaggerToClassGenerator swaggerToClassGenerator, Object def) { BodyParameter param = (BodyParameter) def; return swaggerToClassGenerator.convert(param.getSchema()); } }
/** * Provide a method to validate swagger. This method is now implemented to check common errors, and the logic * will be changed when necessary. For internal use only. */ public static void validateSwagger(Swagger swagger) { Map<String, Path> paths = swagger.getPaths(); if(paths != null) { for (Path path : paths.values()) { Operation operation = path.getPost(); if (operation != null) { List<Parameter> parameters = operation.getParameters(); for (Parameter parameter : parameters) { if (BodyParameter.class.isInstance(parameter)) { if (((BodyParameter) parameter).getSchema() == null) { throw new ServiceCombException("swagger validator: body parameter schema is empty."); } } } } } } }
private Parameter replaceArrayModelForOctetStream(Operation operation, Parameter parameter) { if (parameter instanceof BodyParameter && operation.getConsumes() != null && operation.getConsumes().contains("application/octet-stream")) { BodyParameter bodyParam = (BodyParameter) parameter; Model schema = bodyParam.getSchema(); if (schema instanceof ArrayModel) { ArrayModel arrayModel = (ArrayModel) schema; Property items = arrayModel.getItems(); if (items != null && items.getFormat() == "byte" && items.getType() == "string") { ModelImpl model = new ModelImpl(); model.setFormat("byte"); model.setType("string"); bodyParam.setSchema(model); } } } return parameter; }
private Optional<String> getInputModel(BodyParameter p) { io.swagger.models.Model model = p.getSchema(); if (model instanceof RefModel) { String modelName = ((RefModel) model).getSimpleRef(); // assumption: complex ref? return Optional.of(modelName); } return Optional.empty(); }
@Override public JavaType convert(SwaggerToClassGenerator swaggerToClassGenerator, Object def) { BodyParameter param = (BodyParameter) def; return swaggerToClassGenerator.convert(param.getSchema()); } }
static Optional<BodyParameter> findBodyParameter(final Operation operation) { final List<Parameter> operationParameters = operation.getParameters(); return operationParameters.stream().filter(p -> p instanceof BodyParameter && ((BodyParameter) p).getSchema() != null) .map(BodyParameter.class::cast).findFirst(); }
static Optional<BodyParameter> findBodyParameter(final Operation operation) { final List<Parameter> operationParameters = operation.getParameters(); return operationParameters.stream().filter(p -> p instanceof BodyParameter && ((BodyParameter) p).getSchema() != null) .map(BodyParameter.class::cast).findFirst(); }
static Optional<BodyParameter> findBodyParameter(final Operation operation) { final List<Parameter> operationParameters = operation.getParameters(); return operationParameters.stream().filter(p -> p instanceof BodyParameter && ((BodyParameter) p).getSchema() != null) .map(BodyParameter.class::cast).findFirst(); }
protected String _computeType(final BodyParameter bodyParam) { final Model schema = bodyParam.getSchema(); if ((schema == null)) { return SwaggerDiagramTypes.UNRESOLVED; } return this.schemaLabel("Request", schema); }
private static JsonNode createJsonSchemaForBodyOf(final String specification, final Operation operation) { final Optional<BodyParameter> maybeRequestBody = findBodyParameter(operation); if (!maybeRequestBody.isPresent()) { return null; } final BodyParameter requestBody = maybeRequestBody.get(); return createSchemaFromModel(specification, requestBody.getSchema()); }
private static ObjectNode createJsonSchemaForBodyOf(final ObjectNode json, final Operation operation) { final Optional<BodyParameter> maybeRequestBody = findBodyParameter(operation); if (!maybeRequestBody.isPresent()) { return null; } final BodyParameter requestBody = maybeRequestBody.get(); final Model requestSchema = requestBody.getSchema(); final String name = Optional.ofNullable(requestBody.getName()).orElse(requestBody.getDescription()); return createSchemaFromModel(json, name, requestSchema); }
private static ObjectNode createJsonSchemaForBodyOf(final ObjectNode json, final Operation operation) { final Optional<BodyParameter> maybeRequestBody = findBodyParameter(operation); if (!maybeRequestBody.isPresent()) { return null; } final BodyParameter requestBody = maybeRequestBody.get(); final Model requestSchema = requestBody.getSchema(); final String name = Optional.ofNullable(requestBody.getName()).orElse(requestBody.getDescription()); return createSchemaFromModel(json, name, requestSchema); }
private void walkBodyParameter(BodyParameter parameter) { // parameter has already been visited as a parameter and as a body parameter Model schema = parameter.getSchema(); if (schema != null) { callbacks.model(schema); callbacks.any(schema); walkModel(schema); } }
private static void copyFields(BodyParameter from, BodyParameter to) { copyFields((AbstractParameter) from, (AbstractParameter) to); to.setExamples(from.getExamples()); to.setSchema(from.getSchema()); }