public void addDefaultMiddleware()

in codegen/smithy-ruby-codegen/src/main/java/software/amazon/smithy/ruby/codegen/middleware/MiddlewareBuilder.java [104:176]


    public void addDefaultMiddleware(GenerationContext context) {
        ApplicationTransport transport = context.getApplicationTransport();
        SymbolProvider symbolProvider =
                new RubySymbolProvider(context.getModel(), context.getRubySettings(), "Client", false);

        ClientConfig validateInput = (new ClientConfig.Builder())
                .name("validate_input")
                .type("Boolean")
                .defaultValue("true")
                .documentation(
                        "When `true`, request parameters are validated using the modeled shapes.")
                .build();

        Middleware validate = (new Middleware.Builder())
                .klass("Seahorse::Middleware::Validate")
                .step(MiddlewareStackStep.INITIALIZE)
                .operationParams((ctx, operation) -> {
                    ShapeId inputShapeId = operation.getInputShape();
                    Shape inputShape = ctx.getModel().expectShape(inputShapeId);
                    Map<String, String> params = new HashMap<>();
                    params.put("validator",
                            "Validators::" + symbolProvider.toSymbol(inputShape).getName());
                    return params;
                })
                .addConfig(validateInput)
                .build();

        Middleware build = (new Middleware.Builder())
                .klass("Seahorse::Middleware::Build")
                .step(MiddlewareStackStep.SERIALIZE)
                .operationParams((ctx, operation) -> {
                    Map<String, String> params = new HashMap<>();
                    params.put("builder",
                            "Builders::" + symbolProvider.toSymbol(operation).getName());
                    return params;
                })
                .build();

        ClientConfig stubResponses = (new ClientConfig.Builder())
                .name("stub_responses")
                .type("Bool")
                .defaultValue("false")
                .documentation(
                        "Enable response stubbing. See documentation for {#stub_responses}")
                .build();

        ClientConfig stubs = (new ClientConfig.Builder())
                .name("stubs")
                .type("Seahorse::Stubbing::Stubs")
                .initializationCustomization(
                        "@stubs = Seahorse::Stubbing::Stubs.new")
                .build();

        Middleware send = (new Middleware.Builder())
                .klass("Seahorse::Middleware::Send")
                .step(MiddlewareStackStep.SEND)
                .addParam("client",
                        transport.getTransportClient().render(context))
                .operationParams((ctx, operation) -> {
                    Map<String, String> params = new HashMap<>();
                    params.put("stub_class", "Stubs::" + symbolProvider.toSymbol(operation).getName());
                    return params;
                })
                .addConfig(stubResponses)
                .addConfig(stubs)
                .build();

        register(validate);
        register(build);
        register(send);

        register(transport.defaultMiddleware(context));
    }