GithubHelp home page GithubHelp logo

nodejs-mircoservice-generator's Introduction

Swagger Code Generator

Swagger code generator takes a fixed set of arguments through the command line interface and creates a micro service with five operations being Create, List, Show, Delete, Update. It takes in a configuration file as an input and generates a mongoose as well as swagger definition along with it.

Getting Started

To get started clone the repo and run the command node bin/codeGenerator.js along with the configuration file.

Prerequisites

We need a minimum of Nodejs 6 to run the project on a stable environment. It's better to have swagger installed globally.

Installing

git clone [email protected]:capiot/codegen.git

Configuration File

The configuration file takes in a JSON Object with an array called list, the list element contains an object with three elements in it name, sequence and fields. Fields is an array which will contain all the fields. Name will be the name of the definition in the swagger.yaml file and the mongoose definition. All the services associated with this object will start at localhost:portNumber/{projectName}/v1/{name}, here the projectName will be taken as an argument over the command line and the name is the part of the configuration file.

Here's the configuration file:-

{
    "name":"Ifsc",
    "collectionName":"IFSC",
    "modelName":"IFSC",
    "api":"ifsc",
    "idPrefix":"IF",
    "definition":{
        "_id":{"type":"String"},
        "ifsc_code":{"type":"String", "enum":["value1", "value2"]},
        "bank_name":{"type":"String", "unique":true},
        "branch_address":{"type":"String", "required":true},
        "complexObject":{
            "definition":{
                "field1":{"type":"String"},
                "field2":{"type":"Number", "enum":[1,2,3,4]}
            }
        },
        "complexObjectArray":[{
            "definition":{
                "field1":{"type":"String","default":"Abcd"},
                "field2":{"type":"Number"}
            }
        }], 
        "simpleArray":[{
            "type":"String"
        }]
    }
}


node bin/codeGenerator.js

Versioning

Version 1.0.0

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • swagger-node

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.