Comments (7)
declare float/integer in model
interface Model {
/**
* @isFloat ErrorMessage
*/
public floatValue: number;
/**
* @isInt ErrorMessage
*/
public intValue: number;
}
declare float/integer in parameter
class Controller {
/**
* @isFloat floatValue
* @isInt intValue
*/
public async hello(@Query() floatValue: number, @Query() intValue: number): Promise<void> {...}
}
from tsoa.
Hmm, good call. It should probably be a float; will get that change in soon.
from tsoa.
I can't make it work
`export class MonitorController {
@Get()
/**
* @isInt limit
* @isInt offset
*/
findMonitors(@Query() limit: number, @Query()offset: number, @Query() searchString?: string): Promise<QueryResponse<Monitor>>{
return Promise.resolve(<QueryResponse<Monitor>>{included: [], currentPage: 1, lastPage: true, firstPage: true, })
}
}`
and the swagger gnerated is:
"parameters": [ { "in": "query", "name": "limit", "required": true, "format": "double", "type": "number" }, { "in": "query", "name": "offset", "required": true, "format": "double", "type": "number" }, { "in": "query", "name": "searchString", "required": false, "type": "string" } ]
from tsoa.
I’m reopening so someone can see if this bug really did regress or if there’s simply an issue on @dpinart-uxland’s side.
@dpinart-uxland can you please delete all of your output files (like swagger.json) and rerun tsoa then confirm to us that the issue is still occurring?
from tsoa.
I upgraded swagger to spec 3 and it seems to be working now placing the jsDoc at method declaration. I guess for spec 2 (default one) the jsDoc must be placed at parameter declaration level
from tsoa.
Since they both share the same AST parser, both use the format I suggested, the initial implementation was done in 2017 and has changed for both Swagger and OpenAPI. (If I'm wrong, please correct me and I'll certainly take another look)
Anyway, glad it worked out 👍
from tsoa.
I know that it's closed however I was able to reproduce and then fix - I guess it would be nice to share it here in case someone is affected:
diff --git a/src/history/eventController.ts b/src/history/eventController.ts
index 3c6d5de..8d50c39 100644
--- a/src/history/eventController.ts
+++ b/src/history/eventController.ts
@@ -12,8 +12,6 @@ import { NotFoundError } from './errors';
*/
type Time = string;
-/**
- * @isInt Year
- */
-type Year = number;
-
@Route('history/event')
export class HistoryEventController extends Controller {
@Get()
@@ -34,10 +32,13 @@ export class HistoryEventController extends Controller {
}
}
+ /**
+ * @isInt year
+ */
@Get('/{year}')
async getEventByYear(
@Res() notFoundResponse: TsoaResponse<404, NotFoundEvent>,
- @Path() year: Year,
+ @Path() year: number,
@Query() lang?: Language,
): Promise<SingleHistoryEvent> {
try {
swagger.json
after above changes:
diff --git a/spec/swagger.json b/spec/swagger.json
index 0431628..581d309 100644
--- a/spec/swagger.json
+++ b/spec/swagger.json
@@ -529,7 +529,8 @@
"name": "year",
"required": true,
"schema": {
- "$ref": "#/components/schemas/Year"
+ "format": "int32",
+ "type": "integer"
}
},
{
so the part that was needed in order to take effect was dropping Year
declaration and using number
instead:
- @Path() year: Year,
+ @Path() year: number,
update:
I guess the catch is that type Year
was declared also in external dependency and used in eventService.ts
-> swagger definition was taken from that one ...
from tsoa.
Related Issues (20)
- Can't Handle Optional File Field on multipart/form-data HOT 1
- Proposal/file upload configurations HOT 3
- UnknownType: IndexedAccessType error when using enum to index type object HOT 1
- The latest version 6.1.4 causes new build issues. HOT 10
- Middleware after response HOT 6
- After update 6.1.5 Types of property 'successStatus' are incompatible HOT 16
- Handling parameters that include mapped types with `Date` as a generic argument HOT 1
- ErrorHandlerMiddleware is ignore with 6.1.* HOT 11
- Populate causes error log: Debug Failure. False expression: Node must have a real position for this operation HOT 3
- ' HOT 1
- Treat null values as no value or undefined HOT 2
- jsdoc @example is used for union type but ignored for enum HOT 3
- programmatic way to generate the spec and routes HOT 13
- Custom parameters in controller HOT 3
- Evaluate @Security in order of definition HOT 3
- AuthenticationMiddleware should also depend on authenticationModule being present HOT 2
- Unable to assign null to properties defined as number | null | undefined after updating to version 6.2.0 HOT 3
- Reasoning for always setting defaultNumberType HOT 2
- Can't send stream to injected error responder when using '@Security()` decorator. (Really I'm just trying to create a plain-text error) HOT 2
- Declare Auth schema without need to implement handlers HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tsoa.