All Downloads are FREE. Search and download functionalities are using the official Maven repository.

JavaSpring.methodBody.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
{{^reactive}}
{{#examples}}
    {{#-first}}
            {{#async}}
return CompletableFuture.supplyAsync(()-> {
            {{/async}}getRequest().ifPresent(request -> {
{{#async}}    {{/async}}            for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
    {{/-first}}
{{#async}}        {{/async}}{{^async}}    {{/async}}            if (mediaType.isCompatibleWith(MediaType.valueOf("{{{contentType}}}"))) {
{{#async}}        {{/async}}{{^async}}    {{/async}}                String exampleString = {{>exampleString}};
{{#async}}        {{/async}}{{^async}}    {{/async}}                ApiUtil.setExampleResponse(request, "{{{contentType}}}", exampleString);
{{#async}}        {{/async}}{{^async}}    {{/async}}                break;
{{#async}}        {{/async}}{{^async}}    {{/async}}            }
    {{#-last}}
{{#async}}        {{/async}}{{^async}}    {{/async}}        }
{{#async}}    {{/async}}        });
{{#async}}    {{/async}}        {{#useResponseEntity}}return new ResponseEntity<>({{#returnSuccessCode}}HttpStatus.valueOf({{{statusCode}}}){{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}});
{{/useResponseEntity}}
{{^useResponseEntity}}throw new IllegalArgumentException("Not implemented");
{{/useResponseEntity}}
            {{#async}}
        }, Runnable::run);
            {{/async}}
    {{/-last}}
{{/examples}}
{{^examples}}
{{#useResponseEntity}}return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}}){{#async}}){{/async}};
{{/useResponseEntity}}
{{^useResponseEntity}}throw new IllegalArgumentException("Not implemented");
{{/useResponseEntity}}
{{/examples}}
{{/reactive}}
{{#reactive}}
{{^vendorExtensions.x-sse}}
Mono result = Mono.empty();
    {{#examples}}
        {{#-first}}
        exchange.getResponse().setStatusCode({{#returnSuccessCode}}HttpStatus.valueOf({{{statusCode}}}){{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}});
        for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
        {{/-first}}
            if (mediaType.isCompatibleWith(MediaType.valueOf("{{{contentType}}}"))) {
                String exampleString = {{>exampleString}};
                result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("{{{generatedContentType}}}"), exampleString);
                break;
            }
        {{#-last}}
        }
        {{/-last}}
    {{/examples}}
{{^examples}}
        exchange.getResponse().setStatusCode({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}});
{{/examples}}
        return result{{#allParams}}{{#isBodyParam}}{{^isArray}}{{#paramName}}.then({{.}}){{/paramName}}{{/isArray}}{{#isArray}}{{#paramName}}.thenMany({{.}}){{/paramName}}{{/isArray}}{{/isBodyParam}}{{/allParams}}.then(Mono.empty());
{{/vendorExtensions.x-sse}}
{{#vendorExtensions.x-sse}}
exchange.getResponse().setStatusCode({{#returnSuccessCode}}HttpStatus.valueOf({{{statusCode}}}){{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}});
        return Flux.empty();
{{/vendorExtensions.x-sse}}
{{/reactive}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy