Package: pyramid-swagger-router
view’s code generation from a swagger’s definition file.motiviationthis package’s motivation is below.Code generation is better than meta-programming, and onetime scaffold is simply bad.Code generation is better than meta-programmingRational:Reading generated code is more easier than reading meta-programming codeIf you want to stop the code generation, just stop it (stopping using code generation is more easier than stopping meta-programming)Onetime scaffold is simply badOnetime scaffold (like a cookiecutter) is good for first creation. But, after scaffold implementation is changed, the migration about past generated code, handling manually(by yourself). So, this is bad.It is ok, pyramid-swagger-router command called multiple times(because of merging code via FST(full syntax tree) (thunks toredbaron)).Where is the Router?Nothing. This is the code generation tool for routing setting(including view configuration).How to useHow to use this.$pipinstallpyramid-swagger-router$pyramid-swagger-router<swagger.yaml><dst>if you passing swagger.yaml such as below.swagger:'2.0'info:title:Pet Shop Example APIversion:"0.1"consumes:-app.pet.views.ication/jsonproduces:-app.pet.views.ication/jsonpaths:/pets:x-pyramid-route-name:petsget:tags:[Pets]operationId:app.pet.views.get_petssummary:Get all petsparameters:-name:animal_typein:querytype:stringpattern:"^[a-zA-Z0-9]*$"-name:limitin:querytype:integerminimum:0default:100responses:200:description:Return petsschema:type:arrayitems:$ref:'#/definitions/Pet'/pets/{pet_id}:x-pyramid-route-name:petget:tags:[Pets]operationId:app.pet.views.get_petsummary:Get a single petparameters:-$ref:'#/parameters/pet_id'responses:200:description:Return petschema:$ref:'#/definitions/Pet'404:description:Pet does not existput:tags:[Pets]operationId:app.pet.views.put_petsummary:Create or update a petparameters:-$ref:'#/parameters/pet_id'-name:petin:bodyschema:$ref:'#/definitions/Pet'responses:200:description:Pet updated201:description:New pet createddelete:tags:[Pets]operationId:app.pet.views.delete_petsummary:Remove a petparameters:-$ref:'#/parameters/pet_id'responses:204:description:Pet was deleted404:description:Pet does not existparameters:pet_id:name:pet_iddescription:Pet's Unique identifierin:pathtype:stringrequired:truepattern:"^[a-zA-Z0-9-]+$"definitions:Pet:type:objectrequired:-name-animal_typeproperties:id:type:stringdescription:Unique identifierexample:"123"readOnly:truename:type:stringdescription:Pet's nameexample:"Susie"minLength:1maxLength:100animal_type:type:stringdescription:Kind of animalexample:"cat"minLength:1tags:type:objectdescription:Custom tagscreated:type:stringformat:date-timedescription:Creation timeexample:"2015-07-07T15:49:51.230+02:00"readOnly:trueoutput code are like these.app/pet/__init__.pydefincludeme_swagger_router(config):config.add_route('pets','/pets')config.add_route('pet','/pets/{pet_id}')config.scan('.views')defincludeme(config):config.include(includeme_swagger_router)app/pet/views.pyfrompyramid.viewimport(view_config)@view_config(renderer='json',request_method='GET',route_name='pets')defget_pets(context,request):"""
    Get all pets

    request.GET:

        * 'animal_type'  -  `{"type": "string", "pattern": "^[a-zA-Z0-9]*$"}`
        * 'limit'  -  `{"type": "integer", "minimum": 0, "default": 100}`
    """return{}@view_config(renderer='json',request_method='GET',route_name='pet')defget_pet(context,request):"""
    Get a single pet

    request.matchdict:

        * 'pet_id'  Pet's Unique identifier  `{"type": "string", "required": true, "pattern": "^[a-zA-Z0-9-]+$"}`
    """return{}@view_config(renderer='json',request_method='PUT',route_name='pet')defput_pet(context,request):"""
    Create or update a pet

    request.matchdict:

        * 'pet_id'  Pet's Unique identifier  `{"type": "string", "required": true, "pattern": "^[a-zA-Z0-9-]+$"}`

    request.json_body:

    ```
        {
          "type": "object",
          "required": [
            "name",
            "animal_type"
          ],
          "properties": {
            "id": {
              "type": "string",
              "description": "Unique identifier",
              "example": "123",
              "readOnly": true
            },
            "name": {
              "type": "string",
              "description": "Pet's name",
              "example": "Susie",
              "minLength": 1,
              "maxLength": 100
            },
            "animal_type": {
              "type": "string",
              "description": "Kind of animal",
              "example": "cat",
              "minLength": 1
            },
            "tags": {
              "type": "object",
              "description": "Custom tags"
            },
            "created": {
              "type": "string",
              "format": "date-time",
              "description": "Creation time",
              "example": "2015-07-07T15:49:51.230+02:00",
              "readOnly": true
            }
          }
        }
    ```
    """return{}@view_config(renderer='json',request_method='DELETE',route_name='pet')defdelete_pet(context,request):"""
    Remove a pet

    request.matchdict:

        * 'pet_id'  Pet's Unique identifier  `{"type": "string", "required": true, "pattern": "^[a-zA-Z0-9-]+$"}`
    """return{}appendix 1if you want to set custom route_name, usingx-pyramid-route-name.appendix 2When desrialization from json request,swagger-marshmallow-codegenis helpful, maybe.0.1.3fix paths level’s paramaters are not existed in docstring0.1.2fix merge detection bugfix error is occured when including parameters in methods section