Skip to content

[REQ] Add support of @ResponseStatus for spring-http-interface library #20068

@alfet81

Description

@alfet81

Is your feature request related to a problem? Please describe.

The spring-http-interface library doesn't allow to use @ResponseStatus when option useResponseEntity is disabled.

Describe the solution you'd like

When useResponseEntity is set to false the generator should add @ResponseStatus similar it does for default spring generator.

Additional context

Here is what api.mustache should look like after the change:

`/**

{{#imports}}import {{import}};
{{/imports}}
{{^useResponseEntity}}
import org.springframework.http.HttpStatus;
{{/useResponseEntity}}
import org.springframework.http.ResponseEntity;
{{#useResponseEntity}}
import org.springframework.http.ResponseEntity;
{{/useResponseEntity}}
import org.springframework.web.bind.annotation.;
import org.springframework.web.service.annotation.
;
import org.springframework.web.multipart.MultipartFile;
{{#reactive}}

import org.springframework.http.codec.multipart.Part;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
{{/reactive}}

import java.util.List;
import java.util.Map;
import java.util.Optional;
import {{javaxPackage}}.annotation.Generated;

{{>generatedAnnotation}}
{{#operations}}
public interface {{classname}} {
{{#operation}}

/**
 * {{httpMethod}} {{{path}}}{{#summary}} : {{.}}{{/summary}}
{{#notes}}
 * {{.}}
{{/notes}}
 *
{{#allParams}}
 * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}
{{/allParams}}
 * @return {{#responses}}{{message}} (status code {{code}}){{^-last}}
 *         or {{/-last}}{{/responses}}
{{#isDeprecated}}
 * @deprecated
{{/isDeprecated}}
{{#externalDocs}}
 * {{description}}
 * @see <a href="{{url}}">{{summary}} Documentation</a>
{{/externalDocs}}
 */
{{#isDeprecated}}
@Deprecated
{{/isDeprecated}}
{{^useResponseEntity}}
@ResponseStatus({{#springHttpStatus}}{{#responses.0}}{{{code}}}{{/responses.0}}{{/springHttpStatus}})
{{/useResponseEntity}}
@HttpExchange(
    method = "{{{httpMethod}}}",
    value = "{{{path}}}",
    accept = { {{#vendorExtensions.x-accepts}}"{{{.}}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-accepts}} }{{#vendorExtensions.x-content-type}},
    contentType = "{{{vendorExtensions.x-content-type}}}"{{/vendorExtensions.x-content-type}}
)
{{>responseType}} {{operationId}}(
    {{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}},
    {{/-last}}{{/allParams}}
){{#unhandledException}} throws Exception{{/unhandledException}};

{{/operation}}
}
{{/operations}}`

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions