🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

raml2code

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raml2code - npm Package Compare versions

Comparing version
0.0.28
to
0.0.29
.idea/.name

Sorry, the diff of this file is not supported yet

+23
<?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>
<?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="&lt;template&gt;" 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

{
"$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"
}
{
"id": "widget",
"type": "object",
"title": "Widget",
"description": "A widget is used to generated partials",
"required": ["id", "name", "groupId", "artifactId", "revision", "description"],
"properties": {
"name": {
"description": "The friendly name of the widget ",
"type": "string"
},
"composite":{
"type": "object",
"$ref": "widget#/definitions/innerProperties"
},
"etiquetas":{
"$ref": "widget#/definitions/innerProperties/tags"
}
},
"definitions": {
"innerProperties": {
"xid": {
"description": "The unique identifier of the widget ",
"type": "string"
},
"name": {
"description": "The friendly name of the widget ",
"type": "string"
},
"tags": {
"description": "Common set of keywords to categorize widgets",
"type": "array",
"items": {
"type": "string",
"format": "[a-z]{1,20}"
},
"uniqueItems": true
},
"groupId": {
"description": "The version of the Widget ",
"type": "string"
},
"artifactId": {
"description": "The version of the Widget ",
"type": "string"
},
"revision": {
"description": "The version of the Widget ",
"type": "string"
},
"description": {
"description": "The description of the Widget ",
"type": "string"
}
},
"something": {
"xid": {
"description": "The unique identifier of the widget ",
"type": "string"
},
"colour": {
"description": "The friendly name of the widget ",
"type": "string"
},
"ipsum": {
"description": "The version of the Widget ",
"type": "string"
},
"lorem": {
"description": "The description of the Widget ",
"type": "string"
}
}
}
}
{
"id": "widgetInlineProperty",
"type": "object",
"title": "WidgetInlineProperty",
"description": "A widget is used to generated partials",
"required": ["id", "name", "groupId", "artifactId", "revision", "description"],
"properties": {
"name": {
"description": "The friendly name of the widget ",
"type": "string"
},
"composite":{
"type": "object",
"description": "Inner properties",
"$ref": "widget#/definitions/innerProperties"
},
"zid":{
"$ref": "widget#/definitions/something"
},
"otherColor":{
"$ref": "widget#/definitions/something/colour"
}
}
}
+2
-2

@@ -23,3 +23,3 @@ var gulp = require('gulp');

require: ['chai', 'chai-as-promised'],
reporter: 'nyan',
reporter: 'spec',
growl: true

@@ -30,2 +30,2 @@ }

gulp.task('default', ['test']);
gulp.task('default', [ 'test']);

@@ -1,2 +0,2 @@

var cmPartial, commonHelpers, deref, dirname, fs, generator, path, sanitize, template, util;
var cmPartial, commonHelpers, deref, dirname, fs, generator, path, template, util;

@@ -32,12 +32,2 @@ fs = require('fs');

sanitize = function(str) {
var aux, res;
aux = str.split(".");
res = '';
aux.forEach(function(it) {
return res += util.capitalize(it);
});
return res;
};
generator.parser = function(datos) {

@@ -80,6 +70,10 @@ var data, mapping, model, normSchema, parsed, row, schema, schemaName, schemas, someData, _base, _i, _j, _len, _len1, _ref, _ref1;

model.extra = datos.extra;
parsed.push({
name: datos.version + ("/" + model.className + ".groovy"),
model: model
});
if (someData.classMembers.length > 0) {
parsed.push({
name: datos.version + ("/" + model.className + ".groovy"),
model: model
});
} else {
console.log("----> " + model.className + ".groovy is too abstract to create a file using List or Map");
}
}

@@ -86,0 +80,0 @@ return parsed;

@@ -57,16 +57,45 @@ var deref, util, _;

util.mapProperties = function(expandedSchema, refMap, mapping) {
var data, key, propParsed, property;
var data, key, keyRef, propParsed, property;
data = {};
data.classMembers = [];
data.innerClasses = [];
if (expandedSchema.properties && expandedSchema.properties.$ref) {
keyRef = expandedSchema.properties.$ref;
expandedSchema.properties = deref.util.findByRef(keyRef, refMap);
}
for (key in expandedSchema.properties) {
property = expandedSchema.properties[key];
if (expandedSchema.required && _.contains(expandedSchema.required, key)) {
property.required = true;
if (typeof property !== 'string') {
if (expandedSchema.required && _.contains(expandedSchema.required, key)) {
property.required = true;
}
propParsed = util.mapProperty(property, key, '', mapping, refMap);
data.classMembers.push(propParsed.property);
if (propParsed.innerClass) {
data.innerClasses.push(propParsed.innerClass);
}
}
propParsed = util.mapProperty(property, key, '', mapping, refMap);
data.classMembers.push(propParsed.property);
if (propParsed.innerClass) {
data.innerClasses.push(propParsed.innerClass);
}
return data;
};
util.resolveTypeByRef = function(keyRef, refMap, propertyName, isArray) {
var data, innerSchema;
if (isArray == null) {
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));
}

@@ -76,10 +105,11 @@ return data;

util.resolveTypeByRef = function(keyRef, refMap) {
var innnerSchema, type;
innnerSchema = deref.util.findByRef(keyRef, refMap);
util.resolveType = function(schema, propertyName) {
var type;
type = "";
if (innnerSchema && innnerSchema.title) {
type = util.capitalize(innnerSchema.title);
} else if (keyRef) {
console.error("$ref not found: " + keyRef + " }");
if (schema) {
if (schema.title) {
type = util.capitalize(schema.title);
} else {
type = util.capitalize(propertyName);
}
}

@@ -90,3 +120,3 @@ return type;

util.mapProperty = function(property, name, annotation, mapping, refMap) {
var aux, auxType, data, keyRef;
var auxType, data, innerClass, keyRef, keyRefData, primitiveType, _ref;
data = {};

@@ -114,10 +144,26 @@ data.property = {};

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) {
case 'array':
auxType = "List";
if (keyRef) {
auxType += "<" + (util.resolveTypeByRef(keyRef, refMap)) + ">";
if (keyRefData && keyRefData.innnerSchema.items !== void 0) {
primitiveType = mapping[keyRefData.innnerSchema.items.type];
if (keyRefData.innnerSchema.items.title) {
auxType += "<" + keyRefData.type + ">";
} else if (primitiveType) {
auxType += "<" + primitiveType + ">";
}
}

@@ -128,13 +174,13 @@ data.property.type = auxType;

if (property.properties) {
if (!property.title) {
console.error("Please provide a title for property:", name);
if (keyRefData && 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;
}
data.property.type = util.capitalize(property.title);
data.innerClass = {};
data.innerClass.className = data.property.type;
data.innerClass.classDescription = property.description;
aux = util.mapProperties(property, refMap, mapping);
data.innerClass.classMembers = aux.classMembers;
} else if (keyRef) {
data.property.type = util.resolveTypeByRef(keyRef, refMap);
} else if (keyRefData && keyRefData.innnerSchema && keyRefData.innnerSchema.properties) {
data.property.type = keyRefData.type;
property.properties = keyRefData.innnerSchema;
data.innerClass = util.resolveInnerClass(keyRefData.type, property, refMap, mapping);
} else {

@@ -144,16 +190,4 @@ data.property.type = 'Map';

break;
case 'string':
data.property.type = mapping[property.type];
break;
case 'boolean':
data.property.type = mapping[property.type];
break;
case 'number':
data.property.type = mapping[property.type];
break;
case 'integer':
data.property.type = mapping[property.type];
break;
case 'file':
data.property.type = mapping[property.type];
default:
data.property.type = (_ref = mapping[property.type]) != null ? _ref : property.type;
}

@@ -171,2 +205,15 @@ if (data.property.type === "BigDecimal") {

util.resolveInnerClass = function(name, property, refMap, mapping) {
var aux, data;
data = null;
if (property && !property.properties.title) {
data = {};
data.className = name;
data.classDescription = property.description;
aux = util.mapProperties(property, refMap, mapping);
data.classMembers = aux.classMembers;
}
return data;
};
util.parseResource = function(resource, parsed, annotations, mapping, parentUri, parentUriArgs) {

@@ -173,0 +220,0 @@ var formData, innerResource, m, methodDef, request, respond, uriArgs, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3;

{
"name": "raml2code",
"version": "0.0.28",
"version": "0.0.29",
"description": "Raml spec to code",

@@ -27,15 +27,14 @@ "main": "index.js",

"raml-parser": "~0.8.7",
"through2": "~0.6.1",
"through2": "~0.6.3",
"lodash": "^2.4.1",
"deref": "0.2.5"
"deref": "0.2.6"
},
"devDependencies": {
"chai": "^1.9.1",
"gulp": "3.8.8",
"chai": "^1.10.0",
"gulp": "3.8.10",
"gulp-coffee": "2.2.0",
"gulp-jasmine": "^1.0.1",
"gulp-mocha": "1.0.0",
"gulp-util": "3.0.1",
"mocha": "^1.20.1"
"gulp-mocha": "2.0.0",
"mocha": "^2.0.1"
}
}

@@ -19,7 +19,11 @@ # Raml to code generator

## generators included and tested
## Generators included and tested
* Groovy POJO
If the json schema has $ref, it would try to use the title to make references, if the title doesn't exits
it would generate a inner classes with the name of the property.
If there are $ref definitions, consider the following http://json-schema.org/latest/json-schema-core.html#anchor30
* JAX-RS Interface
* RETROFIT Client

@@ -26,0 +30,0 @@ ## Gulp-plugin

@@ -19,9 +19,2 @@ fs = require('fs')

sanitize = (str)->
aux = str.split(".")
res = ''
aux.forEach (it)->
res += util.capitalize(it)
res
generator.parser = (datos) ->

@@ -50,3 +43,6 @@ mapping =

for schema in schemas
normSchema = deref(schema, schemas)
# normSchema = deref(schema, schemas, true) #Expanded
normSchema = deref(schema, schemas) #Expanded
model = {}

@@ -57,7 +53,13 @@ model.className = util.capitalize(normSchema.title)

someData = util.mapProperties(normSchema, deref.refs, mapping)
model.classMembers = someData.classMembers
model.innerClasses = someData.innerClasses
model.extra = datos.extra
parsed.push {name: datos.version + "/#{model.className}.groovy" , model}
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"

@@ -64,0 +66,0 @@ parsed

@@ -32,3 +32,2 @@ fs = require('fs')

util.parseResource(resource, methodParse, annotations, mapping)
model = {}

@@ -41,3 +40,2 @@ model.methods = methodParse

model.extra = data.extra
model.className = data.title.split(" ").join("")

@@ -44,0 +42,0 @@ parsed.push {name: "#{data.version}/#{model.className}.java" , model}

@@ -39,19 +39,46 @@ _ = require('lodash')

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]
property.required = true if expandedSchema.required and _.contains(expandedSchema.required, 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
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.resolveTypeByRef = (keyRef, refMap)->
innnerSchema = deref.util.findByRef(keyRef, refMap)
util.resolveType = (schema, propertyName)->
type = ""
if innnerSchema and innnerSchema.title
type = util.capitalize(innnerSchema.title)
else if keyRef
console.error "$ref not found: #{keyRef} }"
if schema
if schema.title
type = util.capitalize(schema.title)
else
type = util.capitalize(propertyName)
type

@@ -71,32 +98,48 @@

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 keyRef
auxType += "<#{util.resolveTypeByRef(keyRef, refMap)}>"
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 not property.title
console.error "Please provide a title for property:", name
data.property.type = util.capitalize(property.title)
data.innerClass = {}
data.innerClass.className = data.property.type
data.innerClass.classDescription = property.description
aux = util.mapProperties(property, refMap, mapping)
data.innerClass.classMembers = aux.classMembers
else if keyRef
data.property.type = util.resolveTypeByRef(keyRef, refMap)
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'
when 'string' then data.property.type = mapping[property.type]
when 'boolean' then data.property.type = mapping[property.type]
when 'number' then data.property.type = mapping[property.type]
when 'integer' then data.property.type = mapping[property.type]
when 'file' then data.property.type = mapping[property.type]
else
data.property.type = mapping[property.type] ? property.type

@@ -115,6 +158,14 @@

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

@@ -148,2 +199,3 @@ methodDef = {}

util.parseResource(innerResource, parsed, annotations, mapping, methodDef.uri, uriArgs)
undefined

@@ -167,6 +219,6 @@

response = responses["304"] ?
response = responses["204"] ?
response = responses["201"] ?
response = responses["200"] ?
response
response = responses["204"] ?
response = responses["201"] ?
response = responses["200"] ?
response

@@ -173,0 +225,0 @@ util.capitalize = (str)->

@@ -5,4 +5,2 @@ var test = require("../helpers").test;

describe('RAML to JAX-RS', function () {

@@ -9,0 +7,0 @@ var generator = require("../../lib/generators/groovy/jaxrsInterface");

@@ -9,3 +9,3 @@ var test = require("../helpers").test;

var catDTO = function(done){
test(generator, done, {package: 'org.gex', enableAnnotations: false}, "CatDTO.groovy" , "v1/Cat.groovy" )
test(generator, done, {package: 'org.gex', enableAnnotations: false}, "CatDTO.groovy" , "v1/Cat.groovy")
};

@@ -15,7 +15,15 @@ var catDTOJSR303 = function(done){

};
var widgetDTOInlineRef = function(done){
test(generator, done, {package: 'org.gex'}, "WidgetInline.groovy", "v1/Widget.groovy")
};
var widgetDTOInlinePropertyRef = function(done){
test(generator, done, {package: 'org.gex'}, "WidgetInlineProperty.groovy", "v1/WidgetInlineProperty.groovy")
};
it('from a RAML file', catDTO );
it('from a RAML file with bean validation', catDTOJSR303 );
it('from a Schema with inline ref', widgetDTOInlineRef );
it('from a Schema with inline Property ref', widgetDTOInlinePropertyRef );
});

@@ -15,3 +15,2 @@ var test = require("../helpers").test;

});

@@ -42,3 +42,3 @@ var path = require('path');

content.split('\n').forEach(function (e, i) {
e.should.equal(exampleContents[i]);
e.trim().should.equal(exampleContents[i].trim(), "In line " + i);
});

@@ -45,0 +45,0 @@ }, done);

@@ -18,6 +18,14 @@ {

},
"toy":{
"toy": {
"description": "Something to play",
"type": "object"
},
"friends": {
"description": "friends",
"$ref": "genericArray.schema.json"
},
"sings": {
"description": "characteristics",
"$ref": "genericMap.schema.json"
},
"age": {

@@ -27,6 +35,6 @@ "description": "The age of the cat",

"minimum": 1,
"maximum" : 15
"maximum": 15
},
"weight":{
"description" : "The weight of the cat",
"weight": {
"description": "The weight of the cat",
"type": "number",

@@ -36,8 +44,8 @@ "minimum": ".1",

},
"food":{
"food": {
"description": "Something to eat",
"type": "object",
"title" : "food",
"properties" : {
"name":{
"title": "food",
"properties": {
"name": {
"description": "what the cat eats",

@@ -48,3 +56,3 @@ "type": "string"

},
"owner":{
"owner": {
"type": "object",

@@ -54,10 +62,14 @@ "description": "The owner of the cat.",

},
"errors":{
"title": "Errors",
"description": "Errores al procesar la petición",
"errors": {
"title": "Errors",
"description": "Errores al procesar la petición",
"type": "array",
"items": { "$ref": "error/error.schema.json" }
"items": {"$ref": "error/error.schema.json"}
}
},
"required": ["id", "name", "errors"]
"required": [
"id",
"name",
"errors"
]
}
apply plugin: 'groovy'
defaultTasks 'build'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "be.filipblondeel.gradle:gradle-gulp-plugin:${gulpPluginVersion}"
}
}
repositories{
mavenCentral()
mavenLocal()
jcenter()
maven { url "http://repo.spring.io/libs-release" }
maven { url "http://repo.spring.io/libs-snapshot" }
}
dependencies {
compile "org.codehaus.groovy:groovy-all:${project.groovyVersion}"
compile 'org.hibernate:hibernate-validator:5.1.3.Final'
compile "com.squareup.retrofit:retrofit:${project.retrofitVersion}"
compile("io.reactivex:rxgroovy:${rxVersion}"){
exclude module:"groovy-all"
}
compile "javax.ws.rs:javax.ws.rs-api:${rsApiVersion}"
compile "org.glassfish.jersey.media:jersey-media-multipart:${jerseyVersion}"
}
apply plugin: 'gulp'
node {
// Version of node to use.
version = '0.10.28'
// Enabled the automatic download. False is the default (for now).
download = true
}
gulp_build.dependsOn 'installGulp'
sourceSets {
main {
java {
srcDirs = []
}
groovy {
srcDirs += ['src/generated/groovy', 'src/generated/java', 'src/main/java']
}
}
integrationTest {
java {
srcDirs = []
}
groovy {
srcDirs += ['src/test/integration/java','src/test/integration/groovy', 'src/generated/groovy', 'src/generated/java', 'src/ma/java']
}
resources {
srcDir 'src/test/integration/resources'
}
}
}
gulpPluginVersion = 0.1
groovyVersion = 2.3.7
retrofitVersion=1.8.0
rxVersion=1.0.0
rsApiVersion=2.0.1
jerseyVersion=2.13
var gulp = require('gulp');
var raml2code = require("raml2code");
var genPojos = require("raml2code/lib/generators/groovy/pojo");
var genJaxRS = require("raml2code/lib/generators/groovy/jaxrsInterface");
var genRetrofitClient = require("raml2code/lib/generators/groovy/retrofitClient");
var raml = require('gulp-raml');
var packagePojo = "gex.catapi.dto";
var packageClient = "gex.catapi.client";
var packageJersey = "gex.catapi.resources";
var ramlResource = '../../test/raml/cats.raml'
gulp.task('raml', function() {
gulp.src(ramlResource)
.pipe(raml())
.pipe(raml.reporter('default'))
.pipe(raml.reporter('fail'));
});
gulp.task("genPojos", ['raml'], function(){
gulp.src(ramlResource)
.pipe(raml2code({generator: genPojos, extra: {package: packagePojo}}))
.pipe(gulp.dest('./src/generated/groovy/gex/catapi/dto'));
});
gulp.task("genRetrofitClient" , ['raml'], function(){
gulp.src(ramlResource)
.pipe(raml2code({generator: genRetrofitClient, extra: {package: packageClient, importPojos: packagePojo}}))
.pipe(gulp.dest('./src/generated/java/gex/catapi/client'));
});
gulp.task("genJaxRS" , ['raml'], function(){
gulp.src(ramlResource)
.pipe(raml2code({generator: genJaxRS, extra: {package: packageJersey, importPojos: packagePojo}}))
.pipe(gulp.dest('./src/generated/groovy/gex/catapi/resources'));
});
gulp.task('build', ['raml', 'genPojos', 'genJaxRS', 'genRetrofitClient']);
gulp.task('default', ['build']);
{
"name": "tempalte-builder-service",
"version": "0.0.1",
"description": "Temaplate builder service API(RAML definitions)",
"devDependencies": {
"gulp": "3.8.8",
"gulp-raml": "0.1.3",
"raml2code": "0.0.27"
}
}
package org.gex.v1
import groovy.transform.*
/**
*A cat from Atoms catalog
**/
@CompileStatic
@Canonical
public class Cat implements Serializable {
/* The unique identifier for a cat */
Long id
/* Name of the cat */
String name
/* Something to play */
Map toy
/* The age of the cat */
Long age
/* The weight of the cat */
BigDecimal weight
/* Something to eat */
Food food
/* The owner of the cat. */
Owner owner
/* Errores al procesar la petición */
List<Error> errors
}
class Food implements Serializable {
/* what the cat eats */
String name
}
package org.gex.v1
import groovy.transform.*
import javax.validation.constraints.*
/**
*A cat from Atoms catalog
**/
@CompileStatic
@Canonical
public class Cat implements Serializable {
/* The unique identifier for a cat */
@NotNull
Long id
/* Name of the cat */
@NotNull
@Size(min=5, max=20)
String name
/* Something to play */
Map toy
/* The age of the cat */
@Min(1l)
@Max(15l)
Long age
/* The weight of the cat */
@DecimalMin(".1")
@DecimalMax("10.00")
BigDecimal weight
/* Something to eat */
Food food
/* The owner of the cat. */
Owner owner
/* Errores al procesar la petición */
@NotNull
List<Error> errors
}
class Food implements Serializable {
/* what the cat eats */
String name
}
package org.gex.v1
import javax.ws.rs.*
import javax.ws.rs.core.*
import org.gex.dto.v1.*
import org.glassfish.jersey.media.multipart.*
import static javax.ws.rs.core.MediaType.APPLICATION_JSON
@Path("/cats/{catId}/picture")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
interface GatitoByIdPictureResource {
/***
* @return Response This must be a valid Cat JSON object.
*/
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
Response postGatitoByIdPicture(
@PathParam("catId")String catId,
@FormDataParam("file")InputStream file,
@FormDataParam("file")FormDataContentDisposition fileData);
}
package org.gex.v1
import javax.ws.rs.*
import javax.ws.rs.core.*
import org.gex.dto.v1.*
import org.glassfish.jersey.media.multipart.*
import static javax.ws.rs.core.MediaType.APPLICATION_JSON
@Path("/cats/{catId}")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
interface GatitoByIdResource {
/***
* @return Response This must be a valid Cat JSON object.
*/
@GET
Response getGatitoById(
@PathParam("catId")String catId,
@QueryParam("filterBy")String filterBy);
/***
* @return Response This must be a valid Cat JSON object.
*/
@PUT
Response putGatitoById(
@PathParam("catId")String catId,
Cat cat);
}
package org.gex.v1
import javax.ws.rs.*
import javax.ws.rs.core.*
import org.gex.dto.v1.*
import org.glassfish.jersey.media.multipart.*
import static javax.ws.rs.core.MediaType.APPLICATION_JSON
@Path("/cats/{catId}/webFormCat")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
interface GatitopByIdFormResource {
/***
* @return Response This must be a valid Cat JSON object.
*/
@POST
Response postGatitopByIdForm(
@PathParam("catId")String catId,
@FormDataParam("name")String name);
}
package org.gex.client.v1;
import retrofit.http.*;
import java.util.List;
import rx.Observable;
import retrofit.mime.TypedFile;
import com.pojos.v1.*;
public interface GatitosAPI {
@GET("/v1/cats")
Observable<Cats> getGatitos(
@Query("search") String search);
@POST("/v1/cats")
Observable<Cat> postGatitos(
@Body Cat cat);
@GET("/v1/cats/{catId}")
Observable<Cat> getGatitoById(
@Path("catId") String catId,
@Query("filterBy") String filterBy);
@PUT("/v1/cats/{catId}")
Observable<Cat> putGatitoById(
@Path("catId") String catId,
@Body Cat cat);
@GET("/v1/cats/{catId}/mapping")
Observable<Cat> getSingleContentTypeMapping(
@Path("catId") String catId);
@POST("/v1/cats/{catId}/picture")
@Multipart
Observable<Cat> postGatitoByIdPicture(
@Path("catId") String catId,
@Part("file") TypedFile file);
@POST("/v1/cats/{catId}/webFormCat")
Observable<Cat> postGatitopByIdForm(
@Path("catId") String catId,
@Field("name") String name);
}
package org.gex.v1
import javax.ws.rs.*
import javax.ws.rs.core.*
import org.gex.dto.v1.*
import org.glassfish.jersey.media.multipart.*
import static javax.ws.rs.core.MediaType.APPLICATION_JSON
@Path("/cats")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
interface GatitosResource {
/***
* @return Response This must be a valid Cats JSON object.
*/
@GET
Response getGatitos(
@QueryParam("search")String search);
/***
* @return Response This must be a valid Cat JSON object.
*/
@POST
Response postGatitos(
Cat cat);
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet