def init_swagger(self): # only initialize once if self._doc: return info_block = swagger.Info(title=self.api_title, version=self.api_version) if "API_LICENSE_NAME" in self.config: license_block = swagger.License( name=self.config["API_LICENSE_NAME"], url=self.config.get("API_LICENSE_URL"), ) info_block.license = license_block if "API_CONTACT_NAME" in self.config: contact_block = swagger.Contact(name=self.config["API_CONTACT_NAME"]) contact_block.email = self.config.get("API_CONTACT_EMAIL") contact_block.url = self.config.get("API_CONTACT_URL") info_block.contact = contact_block self._doc = swagger.OpenApi( version=self.open_api_version, info=info_block, paths=swagger.Paths(), ) self.add_url_rule("/openapi.json", view_func=self.register_json_path, methods=["GET"]) self.add_url_rule("/openapi.yaml", view_func=self.register_yaml_path, methods=["GET"])
def test_contact_model(): # assert c1 = swagger.Contact() d = c1.to_dict() assert d == {} c1.name = "Test Smith" c1.email = "*****@*****.**" d = c1.to_dict() assert d["name"] == "Test Smith" assert d["email"] == "*****@*****.**"
type="string", format="email", ), ), swagger.QueryParameter(name="age", description="age of user", schema=swagger.Integer()), ], responses={"200": swagger.ResponseObject(description="Echos whatever")}, ) info = swagger.Info( title="Test", version="1.2.2", contact=swagger.Contact(name="nuke", email="*****@*****.**", url="https://github.com/kulgan"), license=swagger.License(name="Apache 2.0", url="https://www.example.com/license"), ) tags = [ swagger.Tag(name="getEcho", description="gets echos no matter where they are hiding"), swagger.Tag(name="postEcho", description="posts echos to hidden locations"), ] servers = [ swagger.Server( url="https://{sample}.sample/com",
import flask from flaskdoc import jo, swagger blp = flask.Blueprint("inventory", __name__, url_prefix="/inventory") info = swagger.Info( title="Test", version="1.2.2", contact=swagger.Contact(name="Rowland", email="r.ogra@daemonmailer" "+++.com", url="https://github.com/kulgan"), license=swagger.License(name="Apache 2.0", url="https://www.example.com/license"), ) servers = [swagger.Server(url="http://localhost:15172")] tags = [ swagger.Tag(name="admin", description="Secured Admin-Only calls"), swagger.Tag(name="developers", description="Operations available to regular developers"), ] @jo.schema() class Manufacturer(object): name = jo.string(example="ACME Corporation", required=True) phone = jo.string(example="408-867-5309") homepage = jo.string(str_format="url", example="https://www.acme-corp.com") @jo.schema(camel_case_props=True)
update_user_spec, upload_image_spec, ) pet = flask.Blueprint("pet", __name__, url_prefix="/pet") store = flask.Blueprint("store", __name__, url_prefix="/store") user = flask.Blueprint("user", __name__, url_prefix="/user") info = swagger.Info( title="Swagger Petstore", version="1.0.5", description="This is a sample server Petstore server. You can find out more about Swagger at [" "http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](" "http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the " "authorization filters.", contact=swagger.Contact( email="*****@*****.**", ), license=swagger.License( name="Apache 2.0", url="http://www.apache.org/licenses/LICENSE-2.0.html", ), terms_of_service="http://swagger.io/terms/", ) external_docs = swagger.ExternalDocumentation( description="Find out more about Swagger", url="http://swagger.io" ) servers = [ swagger.Server(url="https://petstore.swagger.io/v2"), swagger.Server(url="http://petstore.swagger.io/v2"), ] tags = [