@Override
    public OpenApi after(Context<? extends Trait> context, OpenApi openapi) {
        // Find each known request validator on operation shapes.
        Set<String> validators = context.getModel()
                .shapes(OperationShape.class)
                .flatMap(shape -> OptionalUtils.stream(shape.getTrait(RequestValidatorTrait.class)))
                .map(RequestValidatorTrait::getValue)
                .filter(KNOWN_VALIDATORS::containsKey)
                .collect(Collectors.toSet());

        // Check if the service has a request validator.
        String serviceValidator = null;
        if (context.getService().hasTrait(RequestValidatorTrait.ID)) {
            serviceValidator = context.getService().expectTrait(RequestValidatorTrait.class).getValue();
            validators.add(serviceValidator);
        }

        if (validators.isEmpty()) {
            return openapi;
        }

        OpenApi.Builder builder = openapi.toBuilder();

        if (serviceValidator != null) {
            builder.putExtension(REQUEST_VALIDATOR, serviceValidator);
        }

        // Add the known request validators to the OpenAPI model.
        ObjectNode.Builder objectBuilder = Node.objectNodeBuilder();
        for (String validator : validators) {
            objectBuilder.withMember(validator, KNOWN_VALIDATORS.get(validator));
        }

        builder.putExtension(REQUEST_VALIDATORS, objectBuilder.build());
        return builder.build();
    }
Adds the API Gateway x-amazon-apigateway-request-validators object
to the service and x-amazon-apigateway-request-validator to the
service/operations.

<p>Any operation or service shape with the {@link RequestValidatorTrait}
applied to it will cause that operation to have the {@code x-amazon-apigateway-request-validator}
extension, and adds a {@code x-amazon-apigateway-request-validators} extension
to the top-level OpenAPI document.

@see <a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-request-validators.html">Request validators</a>
smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddRequestValidators.java