swagger-api/swagger-codegen

[typescript\angular2] Deal with 201 response status

Open

#4.397 geöffnet am 14. Dez. 2016

Auf GitHub ansehen
 (10 Kommentare) (1 Reaktion) (0 zugewiesene Personen)HTML (5.474 Forks)batch import
Client: TypeScriptIssue: Bughelp wanted

Repository-Metriken

Stars
 (12.701 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Description

Currently, typescript\angular2 api.service.mustache template handles 204 responses status in order return an undefined value directly instead of call a response.json:

return this.createWithHttpInfo(user, passwd, extraHttpRequestParams)
            .map((response: Response) => {
                if (response.status === 204) {
                    return undefined;
                } else {
                    return response.json();
                }
            });

I've implemented an JAXRS RESt endpoint like this:

@Override
	public Response create(String username, String passwd) throws UsernameAlreadyExistsCommtyException, RepositorySystemException {
		String userId = this.userService.create(username, passwd);
		return Response.created(this.uriInfo.getAbsolutePathBuilder().path(userId).build()).build();
	}

As you can see, this method returns an create-201 response status code. So, there's no content inresponse's body. Instead, there's a location header.

Could you provide an straightforward approach to deal with this?

Swagger-codegen version

2.2.3-SNAPSHOT

Contributor Guide