ari_model_validators.h.mustache 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2013, Digium, Inc.
  5. *
  6. * See http://www.asterisk.org for more information about
  7. * the Asterisk project. Please do not directly contact
  8. * any of the maintainers of this project for assistance;
  9. * the project provides a web site, mailing lists and IRC
  10. * channels for your use.
  11. *
  12. * This program is free software, distributed under the terms of
  13. * the GNU General Public License Version 2. See the LICENSE file
  14. * at the top of the source tree.
  15. */
  16. /*! \file
  17. *
  18. * \brief Generated file - Build validators for ARI model objects.
  19. *
  20. * In addition to the normal validation functions one would normally expect,
  21. * each validator has a ast_ari_validate_{id}_fn() companion function that returns
  22. * the validator's function pointer.
  23. *
  24. * The reason for this seamingly useless indirection is the way function
  25. * pointers interfere with module loading. Asterisk attempts to dlopen() each
  26. * module using \c RTLD_LAZY in order to read some metadata from the module.
  27. * Unfortunately, if you take the address of a function, the function has to be
  28. * resolvable at load time, even if \c RTLD_LAZY is specified. By moving the
  29. * function-address-taking into this module, we can once again be lazy.
  30. */
  31. /*
  32. {{> do-not-edit}}
  33. * This file is generated by a mustache template. Please see the original
  34. * template in rest-api-templates/ari_model_validators.h.mustache
  35. */
  36. #ifndef _ASTERISK_ARI_MODEL_H
  37. #define _ASTERISK_ARI_MODEL_H
  38. #include "asterisk/json.h"
  39. /*! @{ */
  40. /*!
  41. * \brief Validator for native Swagger void.
  42. *
  43. * \param json JSON object to validate.
  44. * \returns True (non-zero) if valid.
  45. * \returns False (zero) if invalid.
  46. */
  47. int ast_ari_validate_void(struct ast_json *json);
  48. /*!
  49. * \brief Validator for native Swagger object.
  50. *
  51. * \param json JSON object to validate.
  52. * \returns True (non-zero) if valid.
  53. * \returns False (zero) if invalid.
  54. */
  55. int ast_ari_validate_object(struct ast_json *json);
  56. /*!
  57. * \brief Validator for native Swagger byte.
  58. *
  59. * \param json JSON object to validate.
  60. * \returns True (non-zero) if valid.
  61. * \returns False (zero) if invalid.
  62. */
  63. int ast_ari_validate_byte(struct ast_json *json);
  64. /*!
  65. * \brief Validator for native Swagger boolean.
  66. *
  67. * \param json JSON object to validate.
  68. * \returns True (non-zero) if valid.
  69. * \returns False (zero) if invalid.
  70. */
  71. int ast_ari_validate_boolean(struct ast_json *json);
  72. /*!
  73. * \brief Validator for native Swagger int.
  74. *
  75. * \param json JSON object to validate.
  76. * \returns True (non-zero) if valid.
  77. * \returns False (zero) if invalid.
  78. */
  79. int ast_ari_validate_int(struct ast_json *json);
  80. /*!
  81. * \brief Validator for native Swagger long.
  82. *
  83. * \param json JSON object to validate.
  84. * \returns True (non-zero) if valid.
  85. * \returns False (zero) if invalid.
  86. */
  87. int ast_ari_validate_long(struct ast_json *json);
  88. /*!
  89. * \brief Validator for native Swagger float.
  90. *
  91. * \param json JSON object to validate.
  92. * \returns True (non-zero) if valid.
  93. * \returns False (zero) if invalid.
  94. */
  95. int ast_ari_validate_float(struct ast_json *json);
  96. /*!
  97. * \brief Validator for native Swagger double.
  98. *
  99. * \param json JSON object to validate.
  100. * \returns True (non-zero) if valid.
  101. * \returns False (zero) if invalid.
  102. */
  103. int ast_ari_validate_double(struct ast_json *json);
  104. /*!
  105. * \brief Validator for native Swagger string.
  106. *
  107. * \param json JSON object to validate.
  108. * \returns True (non-zero) if valid.
  109. * \returns False (zero) if invalid.
  110. */
  111. int ast_ari_validate_string(struct ast_json *json);
  112. /*!
  113. * \brief Validator for native Swagger date.
  114. *
  115. * \param json JSON object to validate.
  116. * \returns True (non-zero) if valid.
  117. * \returns False (zero) if invalid.
  118. */
  119. int ast_ari_validate_date(struct ast_json *json);
  120. /*!
  121. * \brief Validator for a Swagger List[]/JSON array.
  122. *
  123. * \param json JSON object to validate.
  124. * \param fn Validator to call on every element in the array.
  125. * \returns True (non-zero) if valid.
  126. * \returns False (zero) if invalid.
  127. */
  128. int ast_ari_validate_list(struct ast_json *json, int (*fn)(struct ast_json *));
  129. /*! @} */
  130. /*!
  131. * \brief Function type for validator functions. Allows for
  132. */
  133. typedef int (*ari_validator)(struct ast_json *json);
  134. {{#apis}}
  135. {{#api_declaration}}
  136. {{#models}}
  137. /*!
  138. * \brief Validator for {{id}}.
  139. *
  140. * {{{description_dox}}}
  141. *
  142. * \param json JSON object to validate.
  143. * \returns True (non-zero) if valid.
  144. * \returns False (zero) if invalid.
  145. */
  146. int ast_ari_validate_{{c_id}}(struct ast_json *json);
  147. /*!
  148. * \brief Function pointer to ast_ari_validate_{{c_id}}().
  149. *
  150. * See \ref ast_ari_model_validators.h for more details.
  151. */
  152. ari_validator ast_ari_validate_{{c_id}}_fn(void);
  153. {{/models}}
  154. {{/api_declaration}}
  155. {{/apis}}
  156. /*
  157. * JSON models
  158. *
  159. {{#apis}}
  160. {{#api_declaration}}
  161. {{#models}}
  162. * {{id}}
  163. {{#properties}}
  164. * - {{name}}: {{type.name}}{{#required}} (required){{/required}}
  165. {{/properties}}
  166. {{/models}}
  167. {{/api_declaration}}
  168. {{/apis}} */
  169. #endif /* _ASTERISK_ARI_MODEL_H */