Explorar el Código

Merge pull request #41 from inkhey/fix/fix_swagger_path_for_pyramid

Damien Accorsi hace 6 años
padre
commit
7d2dc899b4
No account linked to committer's email
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      hapic/ext/pyramid/context.py

+ 6 - 0
hapic/ext/pyramid/context.py Ver fichero

143
     def get_swagger_path(self, contextualised_rule: str) -> str:
143
     def get_swagger_path(self, contextualised_rule: str) -> str:
144
         # TODO BS 20171110: Pyramid allow route like '/{foo:\d+}', so adapt
144
         # TODO BS 20171110: Pyramid allow route like '/{foo:\d+}', so adapt
145
         # and USE regular expression (see https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/urldispatch.html#custom-route-predicates)  # nopep8
145
         # and USE regular expression (see https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/urldispatch.html#custom-route-predicates)  # nopep8
146
+
147
+        # INFO - G.M - 27-04-2018 - route_pattern of pyramid without '/' case.
148
+        # For example, when using config.include with route_prefix param,
149
+        # there is no '/' at beginning of the path.
150
+        if contextualised_rule[0] != '/':
151
+            contextualised_rule = '/{}'.format(contextualised_rule)
146
         return contextualised_rule
152
         return contextualised_rule
147
 
153
 
148
     def by_pass_output_wrapping(self, response: typing.Any) -> bool:
154
     def by_pass_output_wrapping(self, response: typing.Any) -> bool: