[asterisk-commits] dlee: branch dlee/ari-event-remodel2 r392386 - in /team/dlee/ari-event-remode...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 20 16:33:15 CDT 2013


Author: dlee
Date: Thu Jun 20 16:33:14 2013
New Revision: 392386

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392386
Log:
Generate wiki docs

Added:
    team/dlee/ari-event-remodel2/doc/rest-api/   (with props)
    team/dlee/ari-event-remodel2/rest-api-templates/api.wiki.mustache   (with props)
    team/dlee/ari-event-remodel2/rest-api-templates/models.wiki.mustache   (with props)
Modified:
    team/dlee/ari-event-remodel2/rest-api-templates/make_ari_stubs.py
    team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py

Propchange: team/dlee/ari-event-remodel2/doc/rest-api/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Jun 20 16:33:14 2013
@@ -1,0 +1,1 @@
+*.wiki

Added: team/dlee/ari-event-remodel2/rest-api-templates/api.wiki.mustache
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/api.wiki.mustache?view=auto&rev=392386
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/api.wiki.mustache (added)
+++ team/dlee/ari-event-remodel2/rest-api-templates/api.wiki.mustache Thu Jun 20 16:33:14 2013
@@ -1,0 +1,41 @@
+{{#api_declaration}}
+
+h1. {{name}}
+
+|| Method || Path || Return Model || Summary ||
+{{#apis}}
+{{#operations}}
+| {{http_method}} | [{{path}}|#{{nickname}}] | {{response_class}} | {{summary}} |
+{{/operations}}
+{{/apis}}
+{{#apis}}
+{{#operations}}
+
+{anchor:{{nickname}}}
+h2. {{http_method}} {{path}}
+
+{{{summary}}}{{#notes}} {{{notes}}}{{/notes}}
+{{#has_path_parameters}}
+
+h3. Path parameters
+{{#path_parameters}}
+* {{name}}: {{data_type}}{{#default_value}} = {{default_value}}{{/default_value}} - {{description}}
+{{/path_parameters}}
+{{/has_path_parameters}}
+{{#has_query_parameters}}
+
+h3. Query parameters
+{{#query_parameters}}
+* {{name}}: {{data_type}}{{#default_value}} = {{default_value}}{{/default_value}} - {{description}}
+{{/query_parameters}}
+{{/has_query_parameters}}
+{{#has_header_parameters}}
+
+h3. Header parameters
+{{#header_parameters}}
+* {{name}}: {{data_type}}{{#default_value}} = {{default_value}}{{/default_value}} - {{description}}
+{{/header_parameters}}
+{{/has_header_parameters}}
+{{/operations}}
+{{/apis}}
+{{/api_declaration}}

Propchange: team/dlee/ari-event-remodel2/rest-api-templates/api.wiki.mustache
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/dlee/ari-event-remodel2/rest-api-templates/api.wiki.mustache
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/dlee/ari-event-remodel2/rest-api-templates/api.wiki.mustache
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/dlee/ari-event-remodel2/rest-api-templates/make_ari_stubs.py
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/make_ari_stubs.py?view=diff&rev=392386&r1=392385&r2=392386
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/make_ari_stubs.py (original)
+++ team/dlee/ari-event-remodel2/rest-api-templates/make_ari_stubs.py Thu Jun 20 16:33:14 2013
@@ -41,6 +41,8 @@
     return os.path.join(TOPDIR, file)
 
 API_TRANSFORMS = [
+    Transform(rel('api.wiki.mustache'),
+              'doc/rest-api/{{name}}.wiki'),
     Transform(rel('res_stasis_http_resource.c.mustache'),
               'res/res_stasis_http_{{name}}.c'),
     Transform(rel('stasis_http_resource.h.mustache'),
@@ -50,6 +52,7 @@
 ]
 
 RESOURCES_TRANSFORMS = [
+    Transform(rel('models.wiki.mustache'), 'doc/rest-api/models.wiki'),
     Transform(rel('stasis_http.make.mustache'), 'res/stasis_http.make'),
     Transform(rel('ari_model.h.mustache'), 'res/stasis_http/ari_model.h'),
     Transform(rel('ari_model.c.mustache'), 'res/stasis_http/ari_model.c'),

Added: team/dlee/ari-event-remodel2/rest-api-templates/models.wiki.mustache
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/models.wiki.mustache?view=auto&rev=392386
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/models.wiki.mustache (added)
+++ team/dlee/ari-event-remodel2/rest-api-templates/models.wiki.mustache Thu Jun 20 16:33:14 2013
@@ -1,0 +1,22 @@
+{toc}
+
+{{#apis}}
+{{#api_declaration}}
+{{#models}}
+h1. {{id}}
+{{#extends}}Base type: [{{extends}}|#{{extends}}]{{/extends}}
+{{#has_subtypes}}Subtypes:{{#subtypes}} [{{id}}|#{{id}}]{{/subtypes}}{{/has_subtypes}}
+{{#description}}
+
+{{{description}}}
+{{/description}}
+{code:language=javascript|collapse=true}
+{{{model_json}}}
+{code}
+{{#properties}}
+* {{name}}: {{#is_primitive_type}}{{type}}{{/is_primitive_type}}{{^is_primitive_type}}[{{type}}|#{{type}}]{{/is_primitive_type}}{{^required}} _(optional)_{{/required}}{{#description}} - {{{description}}}{{/description}}
+{{/properties}}
+
+{{/models}}
+{{/api_declaration}}
+{{/apis}}

Propchange: team/dlee/ari-event-remodel2/rest-api-templates/models.wiki.mustache
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/dlee/ari-event-remodel2/rest-api-templates/models.wiki.mustache
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/dlee/ari-event-remodel2/rest-api-templates/models.wiki.mustache
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py?view=diff&rev=392386&r1=392385&r2=392386
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py (original)
+++ team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py Thu Jun 20 16:33:14 2013
@@ -40,6 +40,18 @@
 
 SWAGGER_VERSIONS=["1.1", "1.2"]
 
+SWAGGER_PRIMITIVES=[
+    'string',
+    'boolean',
+    'number',
+    'int',
+    'long',
+    'double',
+    'float',
+    'Date',
+    'DISCRIMINATOR',
+]
+
 class Stringify(object):
     """Simple mix-in to make the repr of the model classes more meaningful.
     """
@@ -228,6 +240,7 @@
         self.description = parameter_json.get('description') or ''
         self.data_type = parameter_json.get('dataType')
         self.required = parameter_json.get('required') or False
+        self.default_value = parameter_json.get('defaultValue')
         self.allowable_values = load_allowable_values(
             parameter_json.get('allowableValues'), context)
         self.allow_multiple = parameter_json.get('allowMultiple') or False
@@ -380,6 +393,9 @@
         self.is_list = type_param is not None
         if self.is_list:
             self.type_param = type_param
+            self.is_primitive_type = type_param in SWAGGER_PRIMITIVES
+        else:
+            self.is_primitive_type = self.type in SWAGGER_PRIMITIVES
 
         self.is_discriminator = self.type == 'DISCRIMINATOR'
         if self.is_discriminator:
@@ -439,6 +455,8 @@
 
         if discriminators:
             self.__discriminator = discriminators[0]
+
+        self.model_json = json.dumps(model_json, indent=2, separators=(',', ': '))
 
         processor.process_model(self, context)
         return self




More information about the asterisk-commits mailing list