Skip to content

Commit

Permalink
Merge pull request #1284 from jokj624/fix/HttpStatusCodeLiteral
Browse files Browse the repository at this point in the history
Fix: Add HttpStatusCodeLiteral 451
  • Loading branch information
WoH authored Jul 25, 2022
2 parents 6299d90 + bdd25f5 commit 0d48d2b
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/runtime/src/interfaces/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export type HttpStatusCodeLiteral =
| 428
| 429
| 431
| 451
| 500
| 501
| 502
Expand Down
13 changes: 11 additions & 2 deletions tests/fixtures/controllers/testController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Controller, Get, Route, SuccessResponse } from '@tsoa/runtime';
import { TestModel } from '../testModel';
import { Controller, Get, Route, SuccessResponse, Response } from '@tsoa/runtime';
import { ErrorResponseModel, TestModel } from '../testModel';
import { NonFactoryDecorator } from '../custom/non-factory-decorator';
import { ModelService } from '../services/modelService';

Expand Down Expand Up @@ -55,4 +55,13 @@ export class TestController extends Controller {
public async getSuccessResponse(): Promise<void> {
return;
}

@Get('unavailableForLegalReasonsStatusCode')
@Response(451)
public async getUnavailableForLegalReasonsError(): Promise<ErrorResponseModel> {
throw {
status: 451,
messgage: 'error'
};
}
}
10 changes: 10 additions & 0 deletions tests/integration/dynamic-controllers-express-server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@ describe('Express Server', () => {
204,
);
});

it('should unavailable for legal reasons status code', () => {
return verifyGetRequest(
basePath + `/Controller/unavailableForLegalReasonsStatusCode`,
(_err, res) => {
expect(res.status).to.equal(451);
},
451,
);
});
});

describe('Validate', () => {
Expand Down
10 changes: 10 additions & 0 deletions tests/integration/express-server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,16 @@ describe('Express Server', () => {
204,
);
});

it('should unavailable for legal reasons status code', () => {
return verifyGetRequest(
basePath + `/Controller/unavailableForLegalReasonsStatusCode`,
(_err, res) => {
expect(res.status).to.equal(451);
},
451,
);
});
});

describe('NoExtends', () => {
Expand Down
10 changes: 10 additions & 0 deletions tests/integration/hapi-server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@ describe('Hapi Server', () => {
204,
);
});

it('should unavailable for legal reasons status code', () => {
return verifyGetRequest(
basePath + `/Controller/unavailableForLegalReasonsStatusCode`,
(_err, res) => {
expect(res.status).to.equal(451);
},
451,
);
});
});

describe('NoExtends', () => {
Expand Down
10 changes: 10 additions & 0 deletions tests/integration/koa-server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,16 @@ describe('Koa Server', () => {
204,
);
});

it('should unavailable for legal reasons status code', () => {
return verifyGetRequest(
basePath + `/Controller/unavailableForLegalReasonsStatusCode`,
(_err, res) => {
expect(res.status).to.equal(451);
},
451,
);
});
});

describe('Custom Content-Type', () => {
Expand Down

0 comments on commit 0d48d2b

Please sign in to comment.