Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alfet81 opened this issue Nov 9, 2024 · 1 comment
Open

Comments

@alfet81
Copy link

alfet81 commented Nov 9, 2024

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}}`

@alfet81 alfet81 changed the title [REQ] Add support of @ResposeStatus for spring-http-interface library [REQ] Add support of @ResponseStatus for spring-http-interface library Nov 9, 2024
@alfet81
Copy link
Author

alfet81 commented Nov 9, 2024

PR is ready: #20071

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant