All Downloads are FREE. Search and download functionalities are using the official Maven repository.

swagger-template.api-docs.jf Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
{
    "swagger": "#(swagger.swaggerVersion)",
    "info": {
        "title": "#(swagger.info_title)",
        "description": "#(swagger.info_description)",
        "termsOfService": "#(swagger.info_termsOfService)",
        "version": "#(swagger.info_version)",
        "contact": {
            "name": "#(swagger.info_contact_name)",
            "email": "#(swagger.info_contact_email)"
        },
        "license": {
            "name": "#(swagger.info_license_name)",
            "url": "#(swagger.info_license_url)"
        }
    },
    "host": "#(host)",
    "basePath": "#(swagger.basePath)",
    "schemes": [
        #for(scheme : swagger.schemes.split(","))
           #(for.index == 0 ? "" : ",")
           "#(scheme.trim())"
        #end
    ],
    "externalDocs": {
        "description": "#(swagger.externalDocs_description)",
        "url": "#(swagger.externalDocs_url)"
    },

    "definitions": {
        #for(model : definitions)
             "#(model.name)": {
                  "type": "object",
                  "title": "#(model.title)",
                  "properties": {
                    #for(item : model.properties)
                        "#(item.key ?? item.name)": {
                            #if(item.type == "object")
                                #if(item.allowMultiple)
                                    "type": "array",
                                    "items": {
                                        "originalRef": "#(item.name)",
                                        "$ref": "#/definitions/#(item.name)"
                                    },
                                #else
                                    "originalRef": "#(item.name)",
                                    "$ref": "#/definitions/#(item.name)",
                                #end
                                "description": "#(item.description)"
                            #else
                                #if(item.allowMultiple)
                                    #if(item.type != "")
                                        "type": "array",
                                         #if(item.example != "")
                                            #switch (item.type)
                                              #case ("integer", "boolean")
                                                "example": [#(item.example)],
                                              #default
                                                "example": ["#(item.example)"],
                                            #end
                                        #end
                                        "items": {
                                            "type": "#(item.type)"
                                        },
                                    #end
                                #else
                                    #if(item.type != "")
                                        "type": "#(item.type)",
                                    #end
                                    #if(item.example != "")
                                        #switch (item.type)
                                          #case ("integer", "boolean")
                                            "example": #(item.example),
                                          #default
                                            "example": "#(item.example)",
                                        #end
                                    #end
                                #end
                                #if(item.exampleEnum != null && item.exampleEnum.length > 0)
                                    "enum": [
                                        #for(exampleEnum : item.exampleEnum)
                                            "#(exampleEnum)"
                                            #(for.last ? "" : ",")
                                        #end
                                    ],
                                #end
                                "description": "#(item.description)"
                            #end
                        }
                        #(for.last ? "" : ",")
                    #end
                  }
              }
            #(for.last ? "" : ",")
        #end
    },
    "securityDefinitions": {
        #for(parameter : swagger.globalSecurityParameters.split(","))
            #set(paras = parameter.split("#"))
            #(for.index == 0 ? "" : ",")
            "#(paras[0].trim())": {
                "type": "apiKey",
                "name": "#(paras[0].trim())",
                "in": "#(paras[1].trim())"
            }
        #end
    },
    "tags": [
        #for(tag : tags)
            {
                "name": "#(tag.name)",
                "description": "#(tag.controllerKey) (#(tag.controllerName))"
            }
            #(for.last ? "" : ",")
        #end
    ],
    "paths": {
        #for(action : paths)
            "/#(action.controllerKey)/#(action.actionName)": {
                #for(method : action.methods)
                    "#(method)": {
                        "tags": [
                            #for(tag : action.tags)
                                "#(tag)"
                                #(for.last ? "" : ",")
                            #end
                        ],
                        "summary": "#(action.summary)",
                        "description": "#(action.description)",
                        "operationId": "#(method)_#(action.controllerKey)_#(action.actionName)",
                        #if(method == "post")
                            "consumes": [
                                #for(consume : action.consumes)
                                    "#(consume)"
                                    #(for.last ? "" : ",")
                                #end
                            ],
                        #end
                        "produces": [
                            #for(produce : action.produces)
                                "#(produce)"
                                #(for.last ? "" : ",")
                            #end
                        ],
                        "parameters": [
                            #for(field : action.parameters)
                                {
                                    "name": "#(field.name)",
                                    "description": "#(field.description)",
                                    "in": "#(field.paramType)",

                                    #if(field.allowMultiple && field.schema)
                                        "schema": {
                                            "type": "array",
                                            "items": {
                                                "originalRef": "#(field.schema)",
                                                "$ref": "#/definitions/#(field.schema)"
                                            }
                                        },
                                    #else if(field.allowMultiple && field.dataType == "file")
                                        "type": "array",
                                        "items": {
                                          "type": "file"
                                        },
                                        "collectionFormat": "multi",
                                    #else if(field.schema)
                                        "schema": {
                                            "originalRef": "#(field.schema)",
                                            "$ref": "#/definitions/#(field.schema)"
                                        },
                                    #else
                                        "type": "#(field.dataType)",
                                        "default": "#(field.defaultValue)",
                                    #end

                                    #if(field.format != "")
                                        "format": "#(field.format)",
                                    #end

                                    "required": #(field.required)
                                }
                                #(for.last ? "" : ",")
                            #end
                        ],
                        "responses": {
                            #for(httpCode : action.responses)
                                "#(httpCode.name)": {
                                    #if(httpCode.schema)
                                        "schema": {
                                            "originalRef": "#(httpCode.schema)",
                                            "$ref": "#/definitions/#(httpCode.schema)"
                                        },
                                    #end
                                    "description": "#(httpCode.description)"
                                }
                                #(for.last ? "" : ",")
                            #end
                        }
                    }
                    #(for.last ? "" : ",")
                #end
            }
            #(for.last ? "" : ",")
        #end
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy