Last active
August 29, 2015 14:13
-
-
Save ciscoheat/0059d2ef76b6b114b69b to your computer and use it in GitHub Desktop.
Brainstorming a simple API description format, generic but with Haxe externs in mind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The format is JSON, but using js for comments. | |
{ | |
// Type (Starts with Uppercase to differentiate from the primitive types) | |
"IncomingForm": { | |
"" : "Empty key leaves room for a description.", | |
// A function ends with (). Array value signifies overloading | |
"parse()": [{ | |
"" : "Parse a form", | |
// Parameter: Type | |
"req": "js.npm.express.Request", | |
// Parameter: Function | |
"cb": ["mixed", "mixed", "array<File>", "void"], | |
}, { | |
"req": "js.npm.express.Request", | |
// Parameter: function with Haxe-syntax. Easier to use? | |
"cb": "mixed -> mixed -> File -> void", | |
}], | |
// Object = only one signature, no overloads | |
"test()": { | |
"param": "mixed", | |
// -> for return value (if not specified void is assumed) | |
"->": "IncomingForm" | |
} | |
}, | |
"File": { | |
"size": "integer", | |
"path": "string", | |
"name": "string", | |
"type": "string", | |
"lastModifiedDate": "date", | |
"hash": "string", | |
// String = no parameters, return value only. | |
"toJSON()" : "mixed" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
integer signed 32 bits | |
long signed 64 bits | |
float | |
double | |
string | |
byte | |
boolean | |
date as defined by full-date - RFC3339 | |
dateTime as defined by date-time - RFC3339 | |
mixed any type | |
void no return value | |
array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment