schema.json 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. {
  2. "$schema": "http://json-schema.org/draft-07/schema",
  3. "$id": "SchematicsAngularGuard",
  4. "title": "Angular Guard Options Schema",
  5. "type": "object",
  6. "description": "Creates a new route guard in your project. Route guards are used to control access to parts of your application by checking certain conditions before a route is activated. This schematic generates a new guard with the specified name, type, and options.",
  7. "additionalProperties": false,
  8. "properties": {
  9. "name": {
  10. "type": "string",
  11. "description": "The name for the new route guard. This will be used to create the guard's class and spec files (e.g., `my-guard.guard.ts` and `my-guard.guard.spec.ts`).",
  12. "$default": {
  13. "$source": "argv",
  14. "index": 0
  15. },
  16. "x-prompt": "What name would you like to use for the guard?"
  17. },
  18. "skipTests": {
  19. "type": "boolean",
  20. "description": "Skip the generation of a unit test file `spec.ts` for the new guard.",
  21. "default": false
  22. },
  23. "flat": {
  24. "type": "boolean",
  25. "description": "Creates the new guard files at the top level of the current project. If set to false, a new folder with the guard's name will be created to contain the files.",
  26. "default": true
  27. },
  28. "path": {
  29. "type": "string",
  30. "format": "path",
  31. "$default": {
  32. "$source": "workingDirectory"
  33. },
  34. "description": "The path where the guard files should be created, relative to the current workspace. If not provided, the guard will be created in the current directory.",
  35. "visible": false
  36. },
  37. "project": {
  38. "type": "string",
  39. "description": "The name of the project where the guard should be created. If not specified, the CLI will determine the project from the current directory.",
  40. "$default": {
  41. "$source": "projectName"
  42. }
  43. },
  44. "functional": {
  45. "type": "boolean",
  46. "description": "Generate the guard as a function instead of a class. Functional guards can be simpler for basic scenarios.",
  47. "default": true
  48. },
  49. "implements": {
  50. "alias": "guardType",
  51. "type": "array",
  52. "description": "Specifies the type(s) of guard to create. You can choose one or more of the following: `CanActivate` (controls access to a route), `CanActivateChild` (controls access to child routes), `CanDeactivate` (asks for confirmation before leaving a route), `CanMatch` (determines if a route can be matched).",
  53. "uniqueItems": true,
  54. "minItems": 1,
  55. "items": {
  56. "enum": ["CanActivate", "CanActivateChild", "CanDeactivate", "CanMatch"],
  57. "type": "string"
  58. },
  59. "default": ["CanActivate"],
  60. "x-prompt": "Which type of guard would you like to create?"
  61. }
  62. },
  63. "required": ["name", "project"]
  64. }