hobbeswalsh/flask-sillywalk — pull request #10 by tarnacious (2014-01-22 16:21:59+00:00)
Title: Fix error using blueprints

Fixes an error which occurs when using Blueprints and multiple routes
with the same name but different parameters.

AssertionError: View function mapping is overwriting an existing
endpoint function: blueprint.hello

Below is an example code listing to demonstrate how to reproduce the
error.

web.py

from flask import Flask
from blueprint import blueprint

app = Flask(__name__)

app.register_blueprint(blueprint)

if __name__ == "__main__":
app.run()

blueprint.py

from flask import Flask
from flask import Blueprint
from flask_sillywalk import SwaggerApiRegistry
from flask_sillywalk import ApiParameter
from flask_sillywalk import ApiErrorResponse

blueprint = Blueprint('blueprint', __name__,
template_folder='templates')

registry = SwaggerApiRegistry(
blueprint,
baseurl="http://localhost:5000",
api_version="1.0",
api_descriptions={})
register = registry.register
registerModel = registry.registerModel

@register("/hello/")
def hello_blank():
return "Hello World!"

@register("/hello//")
def hello_name(name):
return "Hello " + name + "!"

This fixes when using blueprints with no prefix, when using blueprints
with prefixes the URLs returned to not contain the prefix.