CodeEmitter<T> emit(final Parameter parameter) {
        emitter.emit("param");

        emit("name", parameter.getName());
        final String parameterType = parameter.getIn();
        if (ObjectHelper.isNotEmpty(parameterType)) {
            emit("type", RestParamType.valueOf(parameterType));
        }
        if (!"body".equals(parameterType)) {
            final Schema schema = parameter.getSchema();
            if (schema != null) {
                final String dataType = schema.getType();
                if (ObjectHelper.isNotEmpty(dataType)) {
                    emit("dataType", dataType);
                }
                emit("allowableValues", asStringList(schema.getEnum()));
                final StyleEnum style = parameter.getStyle();
                if (ObjectHelper.isNotEmpty(style)) {
                    if (style.equals(StyleEnum.FORM)) {
                        // Guard against null explode value
                        // See: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#fixed-fields-10
                        if (Boolean.FALSE.equals(parameter.getExplode())) {
                            emit("collectionFormat", CollectionFormat.csv);
                        } else {
                            emit("collectionFormat", CollectionFormat.multi);
                        }
                    }
                }
                if (ObjectHelper.isNotEmpty(schema.getDefault())) {
                    final String value = StringHelper.removeLeadingAndEndingQuotes(schema.getDefault().toString());
                    emit("defaultValue", value);
                }

                if ("array".equals(dataType) && schema.getItems() != null) {
                    emit("arrayType", schema.getItems().getType());
                }
            }
        }
        if (parameter.getRequired() != null) {
            emit("required", parameter.getRequired());
        } else {
            emit("required", Boolean.FALSE);
        }
        emit("description", parameter.getDescription());
        emitter.emit("endParam");

        return emitter;
    }
@Test
    public void shouldEmitCodeForOas2ParameterInQuery() {
        final Builder method = MethodSpec.methodBuilder("configure");
        final MethodBodySourceCodeEmitter emitter = new MethodBodySourceCodeEmitter(method);
        final OperationVisitor<?> visitor = new OperationVisitor<>(emitter, null, null, null, null);

        final Parameter parameter = new Parameter();
        parameter.setName("param");
        parameter.setIn("query");

        visitor.emit(parameter);

        assertThat(method.build().toString()).isEqualTo("void configure() {\n"
                                                        + "      param()\n"
                                                        + "        .name(\"param\")\n"
                                                        + "        .type(org.apache.camel.model.rest.RestParamType.query)\n"
                                                        + "        .required(false)\n"
                                                        + "      .endParam()\n"
                                                        + "    }\n");
    }