-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
45 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## Accessing url parameters from the class schema | ||
|
||
You can now get a list of url parameters inside the getSchema function. | ||
This can be very helpful when auto generating schemas | ||
|
||
```ts | ||
import { OpenAPIRoute } from './route' | ||
|
||
// Define route | ||
router.get("/v1/:account_id/gateways/:gateway_id", GetGateway); | ||
|
||
export class GetAccountStats extends OpenAPIRoute { | ||
getSchema() { | ||
console.log(this.params.urlParams) | ||
|
||
// The line above will print this: ["account_id", "gateway_id"] | ||
// You can use this to manipulate the schema, adding or removing fields | ||
|
||
return this.schema | ||
} | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters