swagger-api / swagger-api/swagger-codegen
[typescript/angular2] Handling custom-made exceptions
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I don't know whether it's been written down previously.
I've created this endpoint:
@Path(value = "/users")
@Produces({"application/json"})
@Api(value = "/users")
public interface IUserCommtyEndpoint {
@PUT
@ApiOperation(value = "Add user")
public abstract Response create(
@HeaderParam("user")
@ApiParam(value = "username", required = true)
@NotNull(message = "user.username.notnull")
@Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="{user.username.email}")
String username,
@HeaderParam("passwd")
@ApiParam(value = "passwd", required = true)
@NotNull(message = "user.passwd.notnull")
@Size(min = 6, max = 20, message = "{username.passwd.size}")
String passwd
) throws UsernameAlreadyExistsCommtyException, RepositorySystemException;
@GET
@ApiOperation(value = "User exists", response = Boolean.class)
public abstract Response exists(
@HeaderParam("user")
@ApiParam(value = "username", required = true)
@NotNull(message = "user.username.notnull")
@Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="{user.username.email}")
String username
);
}
As you can see this method throws two custom made exceptions UsernameAlreadyExistsCommtyException and RepositorySystemException.
I'm not able to figure out how codegen deals with that. I've tried to generate artifacts setting typescript-angular2 as language. Nevertheless, it doesn't generate any exception-like class or artifact.
Please, is there some approach over there?
Swagger-codegen version
2.2.3
Swagger declaration file content or url
swagger: '2.0'
info:
description: desc
version: 1.0.2
title: Living API
termsOfService: 'http://swagger.io/terms/'
contact:
name: apiteam@swagger.io
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
host: localhost
basePath: /commty/cmng
tags:
- name: users
schemes:
- http
paths:
/users:
get:
tags:
- users
summary: User exists
description: ''
operationId: exists
produces:
- application/json
parameters:
- name: user
in: header
description: username
required: true
type: string
responses:
'200':
description: successful operation
schema:
type: boolean
put:
tags:
- users
summary: Add user
description: ''
operationId: create
produces:
- application/json
parameters:
- name: user
in: header
description: username
required: true
type: string
- name: passwd
in: header
description: passwd
required: true
type: string
maxItems: 20
minItems: 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied Swagger 2.0 declaration and the typescript-angular2 generator output. Check how the documented responses are represented and whether the generator has an entry point for custom Java exceptions; done means the supported behavior or required generator scope is established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100