| { | ||
| "$schema": "http://json-schema.org/draft-04/schema#", | ||
| "id" : "genericArray.schema.json", | ||
| "title": "GenericArray", | ||
| "description": "A single array", | ||
| "type": "array" | ||
| } |
| { | ||
| "$schema": "http://json-schema.org/draft-04/schema#", | ||
| "id" : "genericMap.schema.json", | ||
| "title": "genericMap", | ||
| "description": "A generic map", | ||
| "type": "object" | ||
| } |
| { | ||
| "$schema": "http://json-schema.org/draft-04/schema#", | ||
| "id" : "genericArray.schema.json", | ||
| "title": "GenericArray", | ||
| "description": "A single array", | ||
| "type": "array", | ||
| "items":{ | ||
| "$ref": "cat.schema.json" | ||
| } | ||
| } |
| { | ||
| "$schema": "http://json-schema.org/draft-04/schema#", | ||
| "id" : "genericArray.schema.json", | ||
| "title": "GenericArray", | ||
| "description": "A single array", | ||
| "type": "array", | ||
| "items":{ | ||
| "type": "string" | ||
| } | ||
| } |
@@ -24,4 +24,5 @@ var commonHelpers, dirname, fs, generator, path, template, util, _; | ||
| generator.parser = function(data) { | ||
| var annotations, first, k, mapping, methodParse, model, parsed, resource, resourceGroup, v, _i, _len, _ref; | ||
| var annotations, first, k, mapping, methodParse, model, parsed, resource, resourceGroup, schemas, v, _i, _len, _ref; | ||
| parsed = []; | ||
| schemas = util.loadSchemas(data); | ||
| methodParse = []; | ||
@@ -47,3 +48,3 @@ annotations = { | ||
| resource = _ref[_i]; | ||
| util.parseResource(resource, methodParse, annotations, mapping); | ||
| util.parseResource(resource, methodParse, annotations, mapping, schemas); | ||
| } | ||
@@ -50,0 +51,0 @@ resourceGroup = _.groupBy(methodParse, function(method) { |
@@ -33,3 +33,3 @@ var cmPartial, commonHelpers, deref, dirname, fs, generator, path, template, util; | ||
| generator.parser = function(datos) { | ||
| var data, mapping, model, normSchema, parsed, row, schema, schemaName, schemas, someData, _base, _i, _j, _len, _len1, _ref, _ref1; | ||
| var mapping, model, normSchema, parsed, schema, schemas, someData, _base, _i, _len, _ref; | ||
| mapping = { | ||
@@ -45,3 +45,3 @@ 'string': "String", | ||
| parsed = []; | ||
| schemas = []; | ||
| schemas = util.loadSchemas(datos); | ||
| if (datos.extra) { | ||
@@ -53,16 +53,8 @@ datos.extra["package"] = "" + datos.extra["package"] + "." + datos.version; | ||
| } | ||
| _ref = datos.schemas; | ||
| for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
| row = _ref[_i]; | ||
| for (schemaName in row) { | ||
| data = JSON.parse(row[schemaName]); | ||
| schemas.push(data); | ||
| } | ||
| } | ||
| for (_j = 0, _len1 = schemas.length; _j < _len1; _j++) { | ||
| schema = schemas[_j]; | ||
| for (_i = 0, _len = schemas.length; _i < _len; _i++) { | ||
| schema = schemas[_i]; | ||
| normSchema = deref(schema, schemas); | ||
| model = {}; | ||
| model.className = util.capitalize(normSchema.title); | ||
| model.classDescription = (_ref1 = normSchema.description) != null ? _ref1 : ""; | ||
| model.classDescription = (_ref = normSchema.description) != null ? _ref : ""; | ||
| someData = util.mapProperties(normSchema, deref.refs, mapping); | ||
@@ -69,0 +61,0 @@ model.classMembers = someData.classMembers; |
@@ -22,4 +22,5 @@ var commonHelpers, dirname, fs, generator, path, template, util; | ||
| generator.parser = function(data) { | ||
| var annotations, mapping, methodParse, model, parsed, resource, _i, _len, _ref; | ||
| var annotations, mapping, methodParse, model, parsed, resource, schemas, _i, _len, _ref; | ||
| parsed = []; | ||
| schemas = util.loadSchemas(data); | ||
| methodParse = []; | ||
@@ -45,3 +46,3 @@ annotations = { | ||
| resource = _ref[_i]; | ||
| util.parseResource(resource, methodParse, annotations, mapping); | ||
| util.parseResource(resource, methodParse, annotations, mapping, schemas); | ||
| } | ||
@@ -48,0 +49,0 @@ model = {}; |
@@ -16,3 +16,3 @@ package {{extra.package}} | ||
| /*** | ||
| * @return Response This must be a valid {{{respond}}} JSON object. | ||
| * @return Response This must be a valid {{{respondComment}}} JSON object. | ||
| */ | ||
@@ -22,3 +22,3 @@ @{{annotation}}{{#if consumes}} | ||
| Response {{{name}}}({{#each args}}{{#if @index}},{{/if}} | ||
| {{{kind}}}{{type}} {{name}}{{/each}}); | ||
| {{{kind}}}{{{type}}} {{name}}{{/each}}); | ||
@@ -25,0 +25,0 @@ {{/methods}} |
@@ -19,6 +19,6 @@ package {{extra.package}}; | ||
| {{/if}} | ||
| Observable<{{{respond}}}> {{{name}}}({{#each args}}{{#if @index}},{{/if}} | ||
| {{{kind}}} {{type}} {{name}}{{/each}}); | ||
| Observable{{{respond}}} {{{name}}}({{#each args}}{{#if @index}},{{/if}} | ||
| {{{kind}}} {{{type}}} {{name}}{{/each}}); | ||
| {{/methods}} | ||
| } |
@@ -1,6 +0,6 @@ | ||
| var deref, util, _; | ||
| var Deref, util, _; | ||
| _ = require('lodash'); | ||
| deref = require('deref')(); | ||
| Deref = require('deref'); | ||
@@ -63,3 +63,3 @@ util = {}; | ||
| keyRef = expandedSchema.properties.$ref; | ||
| expandedSchema.properties = deref.util.findByRef(keyRef, refMap); | ||
| expandedSchema.properties = Deref.util.findByRef(keyRef, refMap); | ||
| } | ||
@@ -89,3 +89,3 @@ for (key in expandedSchema.properties) { | ||
| data.type = ""; | ||
| innerSchema = deref.util.findByRef(keyRef, refMap); | ||
| innerSchema = Deref.util.findByRef(keyRef, refMap); | ||
| if (innerSchema) { | ||
@@ -214,4 +214,18 @@ if (isArray) { | ||
| util.parseResource = function(resource, parsed, annotations, mapping, parentUri, parentUriArgs) { | ||
| var formData, innerResource, m, methodDef, request, respond, uriArgs, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3; | ||
| util.loadSchemas = function(data) { | ||
| var row, schema, schemaName, schemas, _i, _len, _ref; | ||
| schemas = []; | ||
| _ref = data.schemas; | ||
| for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
| row = _ref[_i]; | ||
| for (schemaName in row) { | ||
| schema = util.parseSchema(row[schemaName], "Trouble parsing schema: " + schemaName); | ||
| schemas.push(schema); | ||
| } | ||
| } | ||
| return schemas; | ||
| }; | ||
| util.parseResource = function(resource, parsed, annotations, mapping, schemas, parentUri, parentUriArgs) { | ||
| var formData, innerResource, m, methodDef, request, respond, responseType, type, uriArgs, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3; | ||
| if (parentUri == null) { | ||
@@ -232,9 +246,10 @@ parentUri = ""; | ||
| methodDef.args = methodDef.args.concat(util.parseForm(m.body, annotations, mapping)); | ||
| request = util.parseSchema(m.body, "" + methodDef.uri + " body"); | ||
| respond = util.parseSchema(util.getBestValidResponse(m.responses).body, "" + methodDef.uri + " response"); | ||
| request = util.parseBodyJson(m.body, "" + methodDef.uri + " body"); | ||
| respond = util.parseBodyJson(util.getBestValidResponse(m.responses).body, "" + methodDef.uri + " response"); | ||
| if (request.title) { | ||
| methodDef.args = (_ref1 = methodDef.args) != null ? _ref1 : []; | ||
| type = util.mapRequestResponse(request, schemas, mapping); | ||
| methodDef.args.push({ | ||
| 'kind': annotations.body, | ||
| 'type': util.capitalize(request.title), | ||
| 'type': type, | ||
| 'name': request.title.toLowerCase() | ||
@@ -244,3 +259,7 @@ }); | ||
| methodDef.request = (_ref2 = request.title) != null ? _ref2 : null; | ||
| methodDef.respond = respond.title; | ||
| responseType = util.mapRequestResponse(respond, schemas, mapping); | ||
| methodDef.respondComment = respond.title; | ||
| if (responseType) { | ||
| methodDef.respond = "<" + responseType + ">"; | ||
| } | ||
| methodDef.annotation = m.method.toUpperCase(); | ||
@@ -262,3 +281,3 @@ formData = _.find(methodDef.args, function(arg) { | ||
| innerResource = _ref3[_j]; | ||
| util.parseResource(innerResource, parsed, annotations, mapping, methodDef.uri, uriArgs); | ||
| util.parseResource(innerResource, parsed, annotations, mapping, schemas, methodDef.uri, uriArgs); | ||
| } | ||
@@ -269,3 +288,57 @@ } | ||
| util.parseSchema = function(body, meta) { | ||
| util.mapRequestResponse = function(scheme, schemas, mapping) { | ||
| var dataRef, deref, normSchema, primitiveType, type; | ||
| type = ""; | ||
| switch (scheme.type) { | ||
| case "array": | ||
| if (scheme.items) { | ||
| type = "List<Maps>"; | ||
| if (scheme.items.$ref) { | ||
| deref = Deref(); | ||
| normSchema = deref(scheme, schemas); | ||
| dataRef = deref.util.findByRef(normSchema.items.$ref, deref.refs); | ||
| if (dataRef && dataRef.title) { | ||
| type = "List<" + (util.capitalize(dataRef.title)) + ">"; | ||
| } else { | ||
| type = "List"; | ||
| } | ||
| } else if (scheme.items.title) { | ||
| type = "List<" + (util.capitalize(scheme.title)) + ">"; | ||
| } else if (scheme.items.type) { | ||
| primitiveType = mapping[scheme.items.type]; | ||
| if (primitiveType) { | ||
| type = "List<" + primitiveType + ">"; | ||
| } | ||
| } | ||
| } else { | ||
| type = "List"; | ||
| } | ||
| break; | ||
| case "object": | ||
| if (scheme.properties) { | ||
| type = util.capitalize(scheme.title); | ||
| } else { | ||
| type = "Map"; | ||
| } | ||
| break; | ||
| default: | ||
| console.warn("-------the following scheme doesn't have type: -------"); | ||
| console.warn("" + (JSON.stringify(scheme)) + " "); | ||
| } | ||
| return type; | ||
| }; | ||
| util.parseBodyJson = function(body, meta) { | ||
| var schema; | ||
| if (meta == null) { | ||
| meta = ''; | ||
| } | ||
| schema = {}; | ||
| if (body && body['application/json']) { | ||
| schema = util.parseSchema(body['application/json'].schema, meta); | ||
| } | ||
| return schema; | ||
| }; | ||
| util.parseSchema = function(raw, meta) { | ||
| var e, schema; | ||
@@ -276,9 +349,8 @@ if (meta == null) { | ||
| schema = {}; | ||
| if (body && body['application/json']) { | ||
| if (raw) { | ||
| try { | ||
| schema = JSON.parse(body['application/json'].schema); | ||
| schema = JSON.parse(raw); | ||
| } catch (_error) { | ||
| e = _error; | ||
| console.log("-----JSON ERROR on " + meta + "---------"); | ||
| console.log(body['application/json'].schema); | ||
| throw e; | ||
@@ -285,0 +357,0 @@ } |
+1
-1
| { | ||
| "name": "raml2code", | ||
| "version": "0.0.29", | ||
| "version": "0.0.30", | ||
| "description": "Raml spec to code", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -22,3 +22,10 @@ var test = require("../helpers").test; | ||
| }; | ||
| var settingsResource = function (done) { | ||
| test(generator, done, {package: 'org.gex', importPojos: 'org.gex.dto'}, "SettingsResource.groovy", "v1/SettingsResource.groovy") | ||
| }; | ||
| var arrayPrimitivesResource = function (done) { | ||
| test(generator, done, {package: 'org.gex', importPojos: 'org.gex.dto'}, "ArrayPrimitivesResource.groovy", "v1/ArrayPrimitivesResource.groovy") | ||
| }; | ||
| it('should generate a resource interface', gatitosResource); | ||
@@ -28,3 +35,4 @@ it('should generate a resourceById interface', gatitoByIdResource); | ||
| it('should generate a GatitopByIdFormResource upload interface', gatitopByIdFormResource); | ||
| it('should generate a SettingsResource', settingsResource); | ||
| it('should generate a SettingsResource', arrayPrimitivesResource); | ||
| }); |
+1
-1
@@ -42,3 +42,3 @@ var path = require('path'); | ||
| content.split('\n').forEach(function (e, i) { | ||
| e.trim().should.equal(exampleContents[i].trim(), "In line " + i); | ||
| e.trim().should.equal(exampleContents[i].trim(), "In line " + i + " " + sampleFile + " " + validateWith); | ||
| }); | ||
@@ -45,0 +45,0 @@ }, done); |
@@ -5,2 +5,3 @@ { | ||
| "description": "A cats collection", | ||
| "type": "object", | ||
| "properties": { | ||
@@ -7,0 +8,0 @@ "cats" : { |
Sorry, the diff of this file is not supported yet
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="CompilerConfiguration"> | ||
| <option name="DEFAULT_COMPILER" value="Javac" /> | ||
| <resourceExtensions /> | ||
| <wildcardResourcePatterns> | ||
| <entry name="!?*.java" /> | ||
| <entry name="!?*.form" /> | ||
| <entry name="!?*.class" /> | ||
| <entry name="!?*.groovy" /> | ||
| <entry name="!?*.scala" /> | ||
| <entry name="!?*.flex" /> | ||
| <entry name="!?*.kt" /> | ||
| <entry name="!?*.clj" /> | ||
| </wildcardResourcePatterns> | ||
| <annotationProcessing> | ||
| <profile default="true" name="Default" enabled="false"> | ||
| <processorPath useClasspath="true" /> | ||
| </profile> | ||
| </annotationProcessing> | ||
| </component> | ||
| </project> | ||
| <component name="CopyrightManager"> | ||
| <settings default="" /> | ||
| </component> |
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> | ||
| </project> | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="JavaScriptLibraryMappings"> | ||
| <file url="file://$PROJECT_DIR$" libraries="{raml2code node_modules}" /> | ||
| <file url="PROJECT" libraries="{Node.js v0.10.31 Core Modules}" /> | ||
| <includedPredefinedLibrary name="Node.js Globals" /> | ||
| </component> | ||
| </project> | ||
| <component name="libraryTable"> | ||
| <library name="raml2code node_modules" type="javaScript"> | ||
| <properties> | ||
| <option name="frameworkName" value="node_modules" /> | ||
| <sourceFilesUrls> | ||
| <item url="file://$PROJECT_DIR$/node_modules" /> | ||
| </sourceFilesUrls> | ||
| </properties> | ||
| <CLASSES> | ||
| <root url="file://$PROJECT_DIR$/node_modules" /> | ||
| </CLASSES> | ||
| <JAVADOC /> | ||
| <SOURCES /> | ||
| </library> | ||
| </component> |
-131
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="DaemonCodeAnalyzer"> | ||
| <disable_hints /> | ||
| </component> | ||
| <component name="EntryPointsManager"> | ||
| <entry_points version="2.0" /> | ||
| </component> | ||
| <component name="IdProvider" IDEtalkID="24348AC0B6358EDD28F11256796A07BC" /> | ||
| <component name="ProjectLevelVcsManager" settingsEditedManually="false"> | ||
| <OptionsSetting value="true" id="Add" /> | ||
| <OptionsSetting value="true" id="Remove" /> | ||
| <OptionsSetting value="true" id="Checkout" /> | ||
| <OptionsSetting value="true" id="Update" /> | ||
| <OptionsSetting value="true" id="Status" /> | ||
| <OptionsSetting value="true" id="Edit" /> | ||
| <ConfirmationsSetting value="0" id="Add" /> | ||
| <ConfirmationsSetting value="0" id="Remove" /> | ||
| </component> | ||
| <component name="ProjectPlainTextFileTypeManager"> | ||
| <file url="file://$PROJECT_DIR$/test/examples/CatDTO.groovy" /> | ||
| <file url="file://$PROJECT_DIR$/test/examples/CatDTOJSR303.groovy" /> | ||
| <file url="file://$PROJECT_DIR$/test/examples/GatitoByIdPictureResource.groovy" /> | ||
| <file url="file://$PROJECT_DIR$/test/examples/GatitoByIdResource.groovy" /> | ||
| <file url="file://$PROJECT_DIR$/test/examples/GatitopByIdFormResource.groovy" /> | ||
| <file url="file://$PROJECT_DIR$/test/examples/GatitosResource.groovy" /> | ||
| <file url="file://$PROJECT_DIR$/test/examples/WidgetInline.groovy" /> | ||
| <file url="file://$PROJECT_DIR$/test/examples/WidgetInlineProperty.groovy" /> | ||
| </component> | ||
| <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true"> | ||
| <output url="file://$PROJECT_DIR$/out" /> | ||
| </component> | ||
| <component name="RunManager"> | ||
| <configuration default="true" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" factoryName="Plugin"> | ||
| <module name="" /> | ||
| <option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" /> | ||
| <option name="PROGRAM_PARAMETERS" /> | ||
| <method /> | ||
| </configuration> | ||
| <configuration default="true" type="Remote" factoryName="Remote"> | ||
| <option name="USE_SOCKET_TRANSPORT" value="true" /> | ||
| <option name="SERVER_MODE" value="false" /> | ||
| <option name="SHMEM_ADDRESS" value="javadebug" /> | ||
| <option name="HOST" value="localhost" /> | ||
| <option name="PORT" value="5005" /> | ||
| <method /> | ||
| </configuration> | ||
| <configuration default="true" type="Applet" factoryName="Applet"> | ||
| <module name="" /> | ||
| <option name="MAIN_CLASS_NAME" /> | ||
| <option name="HTML_FILE_NAME" /> | ||
| <option name="HTML_USED" value="false" /> | ||
| <option name="WIDTH" value="400" /> | ||
| <option name="HEIGHT" value="300" /> | ||
| <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" /> | ||
| <option name="VM_PARAMETERS" /> | ||
| <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> | ||
| <option name="ALTERNATIVE_JRE_PATH" /> | ||
| <method /> | ||
| </configuration> | ||
| <configuration default="true" type="TestNG" factoryName="TestNG"> | ||
| <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> | ||
| <module name="" /> | ||
| <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> | ||
| <option name="ALTERNATIVE_JRE_PATH" /> | ||
| <option name="SUITE_NAME" /> | ||
| <option name="PACKAGE_NAME" /> | ||
| <option name="MAIN_CLASS_NAME" /> | ||
| <option name="METHOD_NAME" /> | ||
| <option name="GROUP_NAME" /> | ||
| <option name="TEST_OBJECT" value="CLASS" /> | ||
| <option name="VM_PARAMETERS" value="-ea" /> | ||
| <option name="PARAMETERS" /> | ||
| <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> | ||
| <option name="OUTPUT_DIRECTORY" /> | ||
| <option name="ANNOTATION_TYPE" /> | ||
| <option name="ENV_VARIABLES" /> | ||
| <option name="PASS_PARENT_ENVS" value="true" /> | ||
| <option name="TEST_SEARCH_SCOPE"> | ||
| <value defaultName="moduleWithDependencies" /> | ||
| </option> | ||
| <option name="USE_DEFAULT_REPORTERS" value="false" /> | ||
| <option name="PROPERTIES_FILE" /> | ||
| <envs /> | ||
| <properties /> | ||
| <listeners /> | ||
| <method /> | ||
| </configuration> | ||
| <configuration default="true" type="Application" factoryName="Application"> | ||
| <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> | ||
| <option name="MAIN_CLASS_NAME" /> | ||
| <option name="VM_PARAMETERS" /> | ||
| <option name="PROGRAM_PARAMETERS" /> | ||
| <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> | ||
| <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> | ||
| <option name="ALTERNATIVE_JRE_PATH" /> | ||
| <option name="ENABLE_SWING_INSPECTOR" value="false" /> | ||
| <option name="ENV_VARIABLES" /> | ||
| <option name="PASS_PARENT_ENVS" value="true" /> | ||
| <module name="" /> | ||
| <envs /> | ||
| <method /> | ||
| </configuration> | ||
| <configuration default="true" type="JUnit" factoryName="JUnit"> | ||
| <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> | ||
| <module name="" /> | ||
| <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> | ||
| <option name="ALTERNATIVE_JRE_PATH" /> | ||
| <option name="PACKAGE_NAME" /> | ||
| <option name="MAIN_CLASS_NAME" /> | ||
| <option name="METHOD_NAME" /> | ||
| <option name="TEST_OBJECT" value="class" /> | ||
| <option name="VM_PARAMETERS" value="-ea" /> | ||
| <option name="PARAMETERS" /> | ||
| <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> | ||
| <option name="ENV_VARIABLES" /> | ||
| <option name="PASS_PARENT_ENVS" value="true" /> | ||
| <option name="TEST_SEARCH_SCOPE"> | ||
| <value defaultName="moduleWithDependencies" /> | ||
| </option> | ||
| <envs /> | ||
| <patterns /> | ||
| <method /> | ||
| </configuration> | ||
| <list size="0" /> | ||
| <configuration name="<template>" type="WebApp" default="true" selected="false"> | ||
| <Host>localhost</Host> | ||
| <Port>5050</Port> | ||
| </configuration> | ||
| </component> | ||
| </project> |
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="ProjectModuleManager"> | ||
| <modules> | ||
| <module fileurl="file://$PROJECT_DIR$/raml2code.iml" filepath="$PROJECT_DIR$/raml2code.iml" /> | ||
| </modules> | ||
| </component> | ||
| </project> | ||
| <component name="ProjectRunConfigurationManager"> | ||
| <configuration default="false" name="gulp coffee" type="NodeJSConfigurationType" factoryName="Node.js" path-to-node="$USER_HOME$/.nvm/v0.10.31/bin/gulp" working-dir="$PROJECT_DIR$"> | ||
| <envs> | ||
| <env name="DEBUG" value="raml2code" /> | ||
| </envs> | ||
| <browser url="http://localhost:3000/" /> | ||
| <RunnerSettings RunnerId="NodeJS.run" /> | ||
| <ConfigurationWrapper RunnerId="NodeJS.run" /> | ||
| <method /> | ||
| </configuration> | ||
| </component> |
| <component name="DependencyValidationManager"> | ||
| <state> | ||
| <option name="SKIP_IMPORT_STATEMENTS" value="false" /> | ||
| </state> | ||
| </component> |
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="Palette2"> | ||
| <group name="Swing"> | ||
| <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> | ||
| <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" /> | ||
| </item> | ||
| <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> | ||
| <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" /> | ||
| </item> | ||
| <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false"> | ||
| <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" /> | ||
| </item> | ||
| <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true"> | ||
| <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" /> | ||
| </item> | ||
| <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false"> | ||
| <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" /> | ||
| <initial-values> | ||
| <property name="text" value="Button" /> | ||
| </initial-values> | ||
| </item> | ||
| <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false"> | ||
| <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> | ||
| <initial-values> | ||
| <property name="text" value="RadioButton" /> | ||
| </initial-values> | ||
| </item> | ||
| <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false"> | ||
| <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> | ||
| <initial-values> | ||
| <property name="text" value="CheckBox" /> | ||
| </initial-values> | ||
| </item> | ||
| <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false"> | ||
| <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" /> | ||
| <initial-values> | ||
| <property name="text" value="Label" /> | ||
| </initial-values> | ||
| </item> | ||
| <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true"> | ||
| <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> | ||
| <preferred-size width="150" height="-1" /> | ||
| </default-constraints> | ||
| </item> | ||
| <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true"> | ||
| <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> | ||
| <preferred-size width="150" height="-1" /> | ||
| </default-constraints> | ||
| </item> | ||
| <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true"> | ||
| <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> | ||
| <preferred-size width="150" height="-1" /> | ||
| </default-constraints> | ||
| </item> | ||
| <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true"> | ||
| <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | ||
| <preferred-size width="150" height="50" /> | ||
| </default-constraints> | ||
| </item> | ||
| <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> | ||
| <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | ||
| <preferred-size width="150" height="50" /> | ||
| </default-constraints> | ||
| </item> | ||
| <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> | ||
| <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | ||
| <preferred-size width="150" height="50" /> | ||
| </default-constraints> | ||
| </item> | ||
| <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true"> | ||
| <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" /> | ||
| </item> | ||
| <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false"> | ||
| <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | ||
| <preferred-size width="150" height="50" /> | ||
| </default-constraints> | ||
| </item> | ||
| <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false"> | ||
| <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3"> | ||
| <preferred-size width="150" height="50" /> | ||
| </default-constraints> | ||
| </item> | ||
| <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false"> | ||
| <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | ||
| <preferred-size width="150" height="50" /> | ||
| </default-constraints> | ||
| </item> | ||
| <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false"> | ||
| <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> | ||
| <preferred-size width="200" height="200" /> | ||
| </default-constraints> | ||
| </item> | ||
| <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false"> | ||
| <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> | ||
| <preferred-size width="200" height="200" /> | ||
| </default-constraints> | ||
| </item> | ||
| <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true"> | ||
| <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> | ||
| </item> | ||
| <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false"> | ||
| <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> | ||
| </item> | ||
| <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false"> | ||
| <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" /> | ||
| </item> | ||
| <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> | ||
| <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" /> | ||
| </item> | ||
| <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false"> | ||
| <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1"> | ||
| <preferred-size width="-1" height="20" /> | ||
| </default-constraints> | ||
| </item> | ||
| <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false"> | ||
| <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" /> | ||
| </item> | ||
| <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> | ||
| <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" /> | ||
| </item> | ||
| </group> | ||
| </component> | ||
| </project> | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="VcsDirectoryMappings"> | ||
| <mapping directory="" vcs="" /> | ||
| <mapping directory="$PROJECT_DIR$" vcs="Git" /> | ||
| </component> | ||
| </project> |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
| fs = require('fs') | ||
| _ = require('lodash') | ||
| util = require('./util.js') | ||
| commonHelpers = require("../helpers/common.js").helpers() | ||
| path = require('path') | ||
| generator = {} | ||
| generator.helpers = commonHelpers | ||
| dirname = path.dirname(__filename) | ||
| template = path.resolve(dirname, "tmpl/jaxrsResources.hbs") | ||
| generator.template = fs.readFileSync(template).toString() | ||
| generator.parser = (data) -> | ||
| parsed = [] | ||
| methodParse = [] | ||
| annotations = | ||
| path: "@PathParam" | ||
| query: "@QueryParam" | ||
| body: "" | ||
| multiPart: "@FormDataParam" | ||
| form: "@FormDataParam" | ||
| mapping = | ||
| 'string' : "String" | ||
| 'boolean' : "Boolean" | ||
| 'number' : "BigDecimal" | ||
| 'integer' : "Long" | ||
| 'array' : "List" | ||
| 'object' : "Map" | ||
| 'file' : "InputStream" | ||
| for resource in data.resources | ||
| util.parseResource(resource, methodParse, annotations, mapping) | ||
| resourceGroup = _.groupBy(methodParse, (method) -> | ||
| method.displayName | ||
| ) | ||
| if data.extra | ||
| data.extra.package = "#{data.extra.package}.#{data.version}" | ||
| data.extra.importPojos = "#{data.extra.importPojos}.#{data.version}" | ||
| for k,v of resourceGroup | ||
| model = {} | ||
| model.extra = data.extra | ||
| first = _.first(v) | ||
| model.uri = first.uri | ||
| model.className = "#{first.displayName}Resource" | ||
| model.methods = v | ||
| parsed.push {name: "#{data.version}/#{model.className}.groovy" , model} | ||
| parsed | ||
| module.exports = generator |
| fs = require('fs') | ||
| commonHelpers = require("../helpers/common.js").helpers() | ||
| util = require('./util.js') | ||
| path = require('path') | ||
| generator = {} | ||
| generator.helpers = commonHelpers | ||
| dirname = path.dirname(__filename) | ||
| template = path.resolve(dirname, "tmpl/pojo.hbs") | ||
| cmPartial = path.resolve(dirname, "tmpl/classMembersPartial.hbs") | ||
| generator.template = fs.readFileSync(template).toString() | ||
| generator.partials = [ | ||
| name : "classMembers" | ||
| str : fs.readFileSync(cmPartial).toString() | ||
| ] | ||
| deref = require('deref')(); | ||
| generator.parser = (datos) -> | ||
| mapping = | ||
| 'string' : "String" | ||
| 'boolean' : "Boolean" | ||
| 'number' : "BigDecimal" | ||
| 'integer' : "Long" | ||
| 'array' : "List" | ||
| 'object' : "Map" | ||
| 'file' : "InputStream" | ||
| parsed = [] | ||
| schemas = [] | ||
| if datos.extra | ||
| datos.extra.package = "#{datos.extra.package}.#{datos.version}" | ||
| datos.extra.enableAnnotations ?= true | ||
| for row in datos.schemas | ||
| for schemaName of row | ||
| data = JSON.parse(row[schemaName]) | ||
| schemas.push data | ||
| for schema in schemas | ||
| # normSchema = deref(schema, schemas, true) #Expanded | ||
| normSchema = deref(schema, schemas) #Expanded | ||
| model = {} | ||
| model.className = util.capitalize(normSchema.title) | ||
| model.classDescription = normSchema.description ? "" | ||
| someData = util.mapProperties(normSchema, deref.refs, mapping) | ||
| model.classMembers = someData.classMembers | ||
| model.innerClasses = someData.innerClasses | ||
| model.extra = datos.extra | ||
| if someData.classMembers.length > 0 | ||
| parsed.push {name: datos.version + "/#{model.className}.groovy" , model} | ||
| else | ||
| #if there is not properties it must be a Map maps are not created | ||
| console.log "----> #{model.className}.groovy is too abstract to create a file using List or Map" | ||
| parsed | ||
| module.exports = generator | ||
| fs = require('fs') | ||
| commonHelpers = require("../helpers/common.js").helpers() | ||
| util = require('./util.js') | ||
| path = require('path') | ||
| generator = {} | ||
| generator.helpers = commonHelpers | ||
| dirname = path.dirname(__filename) | ||
| template = path.resolve(dirname, "tmpl/retrofitClient.hbs") | ||
| generator.template = fs.readFileSync(template).toString() | ||
| generator.parser = (data) -> | ||
| parsed = [] | ||
| methodParse = [] | ||
| annotations = | ||
| path: "@Path" | ||
| query: "@Query" | ||
| body: "@Body" | ||
| multiPart: "@Part" | ||
| form: "@Field" | ||
| mapping = | ||
| 'string' : "String" | ||
| 'boolean' : "Boolean" | ||
| 'number' : "BigDecimal" | ||
| 'integer' : "Long" | ||
| 'array' : "List" | ||
| 'object' : "Map" | ||
| 'file' : "TypedFile" | ||
| for resource in data.resources | ||
| util.parseResource(resource, methodParse, annotations, mapping) | ||
| model = {} | ||
| model.methods = methodParse | ||
| model.version = data.version | ||
| if data.extra | ||
| data.extra.package = "#{data.extra.package}.#{data.version}" | ||
| data.extra.importPojos = "#{data.extra.importPojos}.#{data.version}" | ||
| model.extra = data.extra | ||
| model.className = data.title.split(" ").join("") | ||
| parsed.push {name: "#{data.version}/#{model.className}.java" , model} | ||
| parsed | ||
| module.exports = generator |
| {{#classMembers}} | ||
| {{#if comment}}/* {{comment}} */{{/if}}{{#if ../extra.enableAnnotations}}{{#if notNull}} | ||
| @NotNull{{/if}}{{#if min}} | ||
| @Min({{min}}l){{/if}}{{#if max}} | ||
| @Max({{max}}l){{/if}}{{#if decimalMin}} | ||
| @DecimalMin("{{decimalMin}}"){{/if}}{{#if decimalMax}} | ||
| @DecimalMax("{{decimalMax}}"){{/if}}{{#if size}} | ||
| @Size({{#each size}}{{#if @index}}, {{/if}}{{this.name}}={{value}}{{/each}}){{/if}}{{/if}} | ||
| {{{type}}} {{name}} | ||
| {{/classMembers}} |
| package {{extra.package}} | ||
| import javax.ws.rs.* | ||
| import javax.ws.rs.core.* | ||
| {{#if extra.importPojos}}import {{extra.importPojos}}.*{{/if}} | ||
| import org.glassfish.jersey.media.multipart.* | ||
| import static javax.ws.rs.core.MediaType.APPLICATION_JSON | ||
| @Path("{{{uri}}}") | ||
| @Consumes(APPLICATION_JSON) | ||
| @Produces(APPLICATION_JSON) | ||
| interface {{className}} { | ||
| {{#methods}} | ||
| /*** | ||
| * @return Response This must be a valid {{{respond}}} JSON object. | ||
| */ | ||
| @{{annotation}}{{#if consumes}} | ||
| @Consumes({{consumes}}){{/if}} | ||
| Response {{{name}}}({{#each args}}{{#if @index}},{{/if}} | ||
| {{{kind}}}{{type}} {{name}}{{/each}}); | ||
| {{/methods}} | ||
| } |
| package {{extra.package}} | ||
| import groovy.transform.*{{#if extra.enableAnnotations}} | ||
| import javax.validation.constraints.*{{/if}} | ||
| {{#if classDescription}} | ||
| /** | ||
| *{{{classDescription}}} | ||
| **/{{/if}} | ||
| @CompileStatic | ||
| @Canonical | ||
| public class {{{className}}} implements Serializable { | ||
| {{>classMembers}} | ||
| } | ||
| {{#innerClasses}} | ||
| class {{{className}}} implements Serializable { | ||
| {{>classMembers}} | ||
| } | ||
| {{/innerClasses}} |
| package {{extra.package}}; | ||
| import retrofit.http.*; | ||
| import java.util.List; | ||
| import rx.Observable; | ||
| import retrofit.mime.TypedFile; | ||
| {{#if extra.importPojos}} | ||
| import {{extra.importPojos}}.*; | ||
| {{/if}} | ||
| public interface {{{className}}} { | ||
| {{#methods}} | ||
| @{{annotation}}("/{{{../version}}}{{{uri}}}") | ||
| {{#if additionalAnnotation}} | ||
| @{{additionalAnnotation}} | ||
| {{/if}} | ||
| Observable<{{{respond}}}> {{{name}}}({{#each args}}{{#if @index}},{{/if}} | ||
| {{{kind}}} {{type}} {{name}}{{/each}}); | ||
| {{/methods}} | ||
| } |
| _ = require('lodash') | ||
| deref = require('deref')(); | ||
| util = {} | ||
| util.getUriParameter = (resource, annotation, mapping)-> | ||
| uriParameters = [] | ||
| for key of resource.uriParameters | ||
| p = resource.uriParameters[key] | ||
| uriParameters.push util.mapProperty(p, key, annotation, mapping).property | ||
| uriParameters | ||
| util.getQueryparams = (queryParams, annotation, mapping)-> | ||
| params = [] | ||
| for key of queryParams | ||
| p = queryParams[key] | ||
| params.push util.mapProperty(p, key, annotation, mapping).property | ||
| params | ||
| util.parseForm = (body, annotations, mapping) -> | ||
| args = [] | ||
| if body and (body['multipart/form-data'] or body["application/x-www-form-urlencoded"]) | ||
| form = body["multipart/form-data"] or body["application/x-www-form-urlencoded"] | ||
| if body["multipart/form-data"] isnt undefined | ||
| annotation = annotations.multiPart | ||
| else | ||
| annotation = annotations.form | ||
| data = form.formParameters or form.formParameters | ||
| for key of data | ||
| p = data[key] | ||
| parsedProperty = util.mapProperty(p, key, annotation, mapping).property | ||
| args.push parsedProperty | ||
| if parsedProperty.type is "InputStream" | ||
| args.push {name: parsedProperty.name + "Data" , type: "FormDataContentDisposition", kind: annotation + "(\"#{parsedProperty.name}\")"} | ||
| args | ||
| util.mapProperties = (expandedSchema, refMap, mapping)-> | ||
| data = {} | ||
| data.classMembers = [] | ||
| data.innerClasses = [] | ||
| if expandedSchema.properties and expandedSchema.properties.$ref | ||
| keyRef = expandedSchema.properties.$ref | ||
| expandedSchema.properties = deref.util.findByRef(keyRef, refMap) | ||
| for key of expandedSchema.properties | ||
| property = expandedSchema.properties[key] | ||
| #Canonical dereferencing and inline dereferencing | ||
| #http://json-schema.org/latest/json-schema-core.html#anchor30 | ||
| if typeof property isnt 'string' | ||
| property.required = true if expandedSchema.required and _.contains(expandedSchema.required, key) | ||
| propParsed = util.mapProperty(property, key, '', mapping, refMap) | ||
| data.classMembers.push propParsed.property | ||
| data.innerClasses.push propParsed.innerClass if propParsed.innerClass | ||
| data | ||
| util.resolveTypeByRef = (keyRef, refMap, propertyName, isArray=false)-> | ||
| data = {} | ||
| data.type = "" | ||
| innerSchema = deref.util.findByRef(keyRef, refMap) | ||
| if innerSchema | ||
| if isArray | ||
| data.innnerSchema ={} | ||
| data.innnerSchema.items = innerSchema | ||
| else | ||
| data.innnerSchema = innerSchema | ||
| data.type = util.resolveType(innerSchema, propertyName) | ||
| else if keyRef | ||
| console.error "$ref not found: #{keyRef} RefMap.keys -> [#{Object.keys(refMap)}]" | ||
| console.error JSON.stringify(refMap) | ||
| data | ||
| util.resolveType = (schema, propertyName)-> | ||
| type = "" | ||
| if schema | ||
| if schema.title | ||
| type = util.capitalize(schema.title) | ||
| else | ||
| type = util.capitalize(propertyName) | ||
| type | ||
| util.mapProperty = (property, name, annotation, mapping, refMap)-> | ||
| data = {} | ||
| data.property = {} | ||
| data.property.name = name | ||
| data.property.notNull = true if property.required | ||
| data.property.size = [] | ||
| data.property.size.push {"name" : "min", "value" : property.minLength} if property.minLength | ||
| data.property.size.push {"name" : "max", "value" : property.maxLength} if property.maxLength | ||
| data.property.comment = property.description | ||
| if property.items and property.items["$ref"] | ||
| keyRef = property.items["$ref"] | ||
| keyRefData = | ||
| keyRefData = util.resolveTypeByRef(keyRef, refMap, name, true) | ||
| else if property["$ref"] | ||
| keyRef = property["$ref"] | ||
| keyRefData = util.resolveTypeByRef(keyRef, refMap, name) | ||
| data.property.type = keyRefData.type | ||
| if keyRefData.innnerSchema.type | ||
| property.type = keyRefData.innnerSchema.type | ||
| else | ||
| property.properties = keyRefData.innnerSchema | ||
| data.innerClass = util.resolveInnerClass(keyRefData.type, property, refMap, mapping) | ||
| property.type = util.resolveType(data.innerClass, name) | ||
| data.property.comment = property.description | ||
| switch property.type | ||
| when 'array' | ||
| auxType = "List" | ||
| if keyRefData and keyRefData.innnerSchema.items isnt undefined | ||
| primitiveType = mapping[keyRefData.innnerSchema.items.type] | ||
| if keyRefData.innnerSchema.items.title | ||
| auxType += "<#{keyRefData.type}>" | ||
| else if primitiveType | ||
| auxType += "<#{primitiveType}>" | ||
| data.property.type = auxType | ||
| when 'object' | ||
| #if object has no references we made a inner class | ||
| if property.properties | ||
| if keyRefData and keyRefData.type | ||
| data.property.type = keyRefData.type | ||
| else | ||
| data.property.type = util.resolveType(property, name) | ||
| innerClass = util.resolveInnerClass( data.property.type, property, refMap, mapping) | ||
| data.innerClass = innerClass | ||
| else if keyRefData and keyRefData.innnerSchema and keyRefData.innnerSchema.properties | ||
| data.property.type = keyRefData.type | ||
| property.properties = keyRefData.innnerSchema | ||
| data.innerClass = util.resolveInnerClass(keyRefData.type, property, refMap, mapping) | ||
| else | ||
| data.property.type = 'Map' | ||
| else | ||
| data.property.type = mapping[property.type] ? property.type | ||
| if data.property.type == "BigDecimal" | ||
| data.property.decimalMax = property.maximum | ||
| data.property.decimalMin = property.minimum | ||
| else if data.property.type == "Long" | ||
| data.property.max = property.maximum | ||
| data.property.min = property.minimum | ||
| data.property.kind = annotation + "(\"#{data.property.name}\")" | ||
| data | ||
| util.resolveInnerClass = (name, property, refMap, mapping)-> | ||
| data = null | ||
| #if the property has #ref and title we don't need innerClass | ||
| if property and not property.properties.title | ||
| data = {} | ||
| data.className = name | ||
| data.classDescription = property.description | ||
| aux = util.mapProperties(property, refMap, mapping) | ||
| data.classMembers = aux.classMembers | ||
| data | ||
| util.parseResource = (resource, parsed, annotations, mapping, parentUri = "", parentUriArgs = []) -> | ||
| for m in resource.methods | ||
| methodDef = {} | ||
| methodDef.uri = parentUri + resource.relativeUri | ||
| uriArgs = util.getUriParameter(resource, annotations.path, mapping) | ||
| methodDef.args = parentUriArgs.concat(uriArgs) | ||
| methodDef.args = methodDef.args.concat(util.getQueryparams(m.queryParameters, annotations.query, mapping)) | ||
| methodDef.args = methodDef.args.concat(util.parseForm(m.body, annotations, mapping)) | ||
| request = util.parseSchema(m.body, "#{methodDef.uri} body" ) | ||
| respond = util.parseSchema(util.getBestValidResponse(m.responses).body, "#{methodDef.uri} response" ) | ||
| if request.title | ||
| methodDef.args = methodDef.args ? [] | ||
| methodDef.args.push {'kind': annotations.body, 'type': util.capitalize(request.title), 'name': request.title.toLowerCase()} | ||
| methodDef.request = request.title ? null | ||
| methodDef.respond = respond.title | ||
| methodDef.annotation = m.method.toUpperCase() | ||
| formData = _.find(methodDef.args, (arg)-> | ||
| arg.type is "InputStream" or arg.type is "TypedFile" | ||
| ) | ||
| if formData | ||
| methodDef.consumes = "MediaType.MULTIPART_FORM_DATA" | ||
| methodDef.additionalAnnotation = "Multipart" | ||
| methodDef.name = m.method + resource.displayName | ||
| methodDef.displayName = resource.displayName | ||
| parsed.push methodDef | ||
| if resource.resources | ||
| for innerResource in resource.resources | ||
| util.parseResource(innerResource, parsed, annotations, mapping, methodDef.uri, uriArgs) | ||
| undefined | ||
| util.parseSchema = (body, meta = '') -> | ||
| schema = {} | ||
| if body and body['application/json'] | ||
| try | ||
| schema = JSON.parse(body['application/json'].schema) | ||
| catch e | ||
| console.log "-----JSON ERROR on #{meta}---------" | ||
| console.log body['application/json'].schema | ||
| throw e | ||
| schema | ||
| util.getBestValidResponse = (responses) -> | ||
| response = responses["304"] ? | ||
| response = responses["204"] ? | ||
| response = responses["201"] ? | ||
| response = responses["200"] ? | ||
| response | ||
| util.capitalize = (str)-> | ||
| str.charAt(0).toUpperCase() + str.slice(1) | ||
| util.sanitize = (str)-> | ||
| aux = str.split(".") | ||
| res = '' | ||
| aux.forEach (it)-> | ||
| res += util.capitalize(it) | ||
| res | ||
| module.exports = util |
| module.exports.helpers = -> | ||
| [{name:'debug', fn: (optionalValue)-> | ||
| console.log "Current Context" | ||
| console.log "====================" | ||
| console.log this | ||
| if optionalValue | ||
| console.log "Value" | ||
| console.log "====================" | ||
| console.log optionalValue | ||
| return | ||
| }] |
| { | ||
| "$schema": "http://json-schema.org/draft-04/schema#", | ||
| "id" : "genericArray.schema.json", | ||
| "title": "GenericArray", | ||
| "description": "A single array", | ||
| "type": "array" | ||
| } |
| { | ||
| "$schema": "http://json-schema.org/draft-04/schema#", | ||
| "id" : "genericMap.schema.json", | ||
| "title": "genericMap", | ||
| "description": "A generic map", | ||
| "type": "object" | ||
| } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1070
9.18%42824
-72.74%33
-38.89%