Open alfet81 opened 2 weeks ago
The spring-http-interface library doesn't allow to use @ResponseStatus when option useResponseEntity is disabled.
When useResponseEntity is set to false the generator should add @ResponseStatus similar it does for default spring generator.
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}}`
PR is ready: https://github.com/OpenAPITools/openapi-generator/pull/20071
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}}
{{/operation}} } {{/operations}}`