ari_model_validators.h.mustache 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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 used to interfere with module loading. Previously, Asterisk
  26. * attempted to dlopen() each module using \c RTLD_LAZY in order to read some
  27. * metadata from the module. Using functions to get the function pointer
  28. * allowed us to be lazy.
  29. */
  30. /*
  31. {{> do-not-edit}}
  32. * This file is generated by a mustache template. Please see the original
  33. * template in rest-api-templates/ari_model_validators.h.mustache
  34. */
  35. #ifndef _ASTERISK_ARI_MODEL_H
  36. #define _ASTERISK_ARI_MODEL_H
  37. #include "asterisk/json.h"
  38. /*! @{ */
  39. /*!
  40. * \brief Validator for native Swagger void.
  41. *
  42. * \param json JSON object to validate.
  43. * \retval True (non-zero) if valid.
  44. * \retval False (zero) if invalid.
  45. */
  46. int ast_ari_validate_void(struct ast_json *json);
  47. /*!
  48. * \brief Validator for native Swagger object.
  49. *
  50. * \param json JSON object to validate.
  51. * \retval True (non-zero) if valid.
  52. * \retval False (zero) if invalid.
  53. */
  54. int ast_ari_validate_object(struct ast_json *json);
  55. /*!
  56. * \brief Validator for native Swagger byte.
  57. *
  58. * \param json JSON object to validate.
  59. * \retval True (non-zero) if valid.
  60. * \retval False (zero) if invalid.
  61. */
  62. int ast_ari_validate_byte(struct ast_json *json);
  63. /*!
  64. * \brief Validator for native Swagger boolean.
  65. *
  66. * \param json JSON object to validate.
  67. * \retval True (non-zero) if valid.
  68. * \retval False (zero) if invalid.
  69. */
  70. int ast_ari_validate_boolean(struct ast_json *json);
  71. /*!
  72. * \brief Validator for native Swagger int.
  73. *
  74. * \param json JSON object to validate.
  75. * \retval True (non-zero) if valid.
  76. * \retval False (zero) if invalid.
  77. */
  78. int ast_ari_validate_int(struct ast_json *json);
  79. /*!
  80. * \brief Validator for native Swagger long.
  81. *
  82. * \param json JSON object to validate.
  83. * \retval True (non-zero) if valid.
  84. * \retval False (zero) if invalid.
  85. */
  86. int ast_ari_validate_long(struct ast_json *json);
  87. /*!
  88. * \brief Validator for native Swagger float.
  89. *
  90. * \param json JSON object to validate.
  91. * \retval True (non-zero) if valid.
  92. * \retval False (zero) if invalid.
  93. */
  94. int ast_ari_validate_float(struct ast_json *json);
  95. /*!
  96. * \brief Validator for native Swagger double.
  97. *
  98. * \param json JSON object to validate.
  99. * \retval True (non-zero) if valid.
  100. * \retval False (zero) if invalid.
  101. */
  102. int ast_ari_validate_double(struct ast_json *json);
  103. /*!
  104. * \brief Validator for native Swagger string.
  105. *
  106. * \param json JSON object to validate.
  107. * \retval True (non-zero) if valid.
  108. * \retval False (zero) if invalid.
  109. */
  110. int ast_ari_validate_string(struct ast_json *json);
  111. /*!
  112. * \brief Validator for native Swagger date.
  113. *
  114. * \param json JSON object to validate.
  115. * \retval True (non-zero) if valid.
  116. * \retval False (zero) if invalid.
  117. */
  118. int ast_ari_validate_date(struct ast_json *json);
  119. /*!
  120. * \brief Validator for a Swagger List[]/JSON array.
  121. *
  122. * \param json JSON object to validate.
  123. * \param fn Validator to call on every element in the array.
  124. * \retval True (non-zero) if valid.
  125. * \retval False (zero) if invalid.
  126. */
  127. int ast_ari_validate_list(struct ast_json *json, int (*fn)(struct ast_json *));
  128. /*! @} */
  129. /*!
  130. * \brief Function type for validator functions. Allows for
  131. */
  132. typedef int (*ari_validator)(struct ast_json *json);
  133. {{#apis}}
  134. {{#api_declaration}}
  135. {{#models}}
  136. /*!
  137. * \brief Validator for {{id}}.
  138. *
  139. * {{{description_dox}}}
  140. *
  141. * \param json JSON object to validate.
  142. * \retval True (non-zero) if valid.
  143. * \retval False (zero) if invalid.
  144. */
  145. int ast_ari_validate_{{c_id}}(struct ast_json *json);
  146. /*!
  147. * \brief Function pointer to ast_ari_validate_{{c_id}}().
  148. */
  149. ari_validator ast_ari_validate_{{c_id}}_fn(void);
  150. {{/models}}
  151. {{/api_declaration}}
  152. {{/apis}}
  153. /*
  154. * JSON models
  155. *
  156. {{#apis}}
  157. {{#api_declaration}}
  158. {{#models}}
  159. * {{id}}
  160. {{#properties}}
  161. * - {{name}}: {{type.name}}{{#required}} (required){{/required}}
  162. {{/properties}}
  163. {{/models}}
  164. {{/api_declaration}}
  165. {{/apis}} */
  166. #endif /* _ASTERISK_ARI_MODEL_H */