Open gorru opened 8 years ago
Hi Giancarlo,
I have created a gist that contains a working setup here: https://gist.github.com/ransico/8cfecda95c6b4a28a854d2b6d780c5ec
One thing you might try is making sure that all paths are relative to the Gruntfile.js location (not absolute). Additionally, are your apib files located in the same folder as your Gruntfile, or in a subdirectory (such as 'src' ?) The ['*.apib'] will need to point to that folder
With the fix that already mentioned I could run the script. I used protagonist 1.4.1 that is not compatible with your code. I tried some changes in order to make it usable
function mkdirIgnoreExists(dirPath) {
// try { mkdirp(dirPath, function (err) { if (err.code !== 'EEXIST') { deferred.reject(e); return deferred.promise; } }); // } catch (e) { // if (e.code !== 'EEXIST') { // deferred.reject(e); // return deferred.promise; // } // } }
protagonist.parse(filteredInput, {type: 'ast'}, function(err, result) {
With these changes now it run and tested with your coupon example generate java code but exit with these console logs:
Found 1 resource groups
Rendering group: System Generics
Using default response type 'Object' for action /coupons. Did you
forget the + Attributes (ReturnType)
section?
Found 0 models
Fatal error: Cannot read property 'code' of null
Your work seems to be useful but it seems also to be not working with an updated node stack.
For me is too expensive to try to fix it alone: there are to many aspect that I ignore.
Could you try to test your code in a fresh and updated system (maybe OS X)?
Thanks
Giancarlo
On Tue, Aug 23, 2016 at 2:43 PM, Lewis Weaver notifications@github.com wrote:
Hi Giancarlo,
I have created a gist that contains a working setup here: https://gist.github.com/ransico/8cfecda95c6b4a28a854d2b6d780c5ec
One thing you might try is making sure that all paths are relative to the Gruntfile.js location (not absolute). Additionally, are your apib files located in the same folder as your Gruntfile, or in a subdirectory (such as 'src' ?) The ['*.apib'] will need to point to that folder
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ransico/grunt-apiblueprint-springmvc/issues/1#issuecomment-241717996, or mute the thread https://github.com/notifications/unsubscribe-auth/AD7xLXX34eyq-L_UpOeXMzkjY4MxTNFHks5qiuragaJpZM4JquWz .
I am looking into it - however I probably should point out that by altering the dependency of protagonist to >= is what caused it to use an incompatible pre-release version (1.5)... we have only tested it up to 0.20 (hence the ^).
I will see what happens when I up it to version 1.4.0 and see if I can get it working.
If you are interested, I have created a new version of this grunt task, 0.2.0, which now uses Drafter rather than protagonist directly. Internally, Drafter uses protagonist 1.4.
I had to do quite a few code changes to get it working with protagonist 1.4, as the API Blueprint people have now deprecated the AST format; but I can confirm it does now work on a macbook running El Capitan.
To do a sanity check, you can also now run grunt test
Thank you very much! I'll try it ASAP! Regards Giancarlo
On Thu, Sep 1, 2016 at 9:14 AM, Lewis Weaver notifications@github.com wrote:
If you are interested, I have created a new version of this grunt task, 0.2.0, which now uses Drafter rather than protagonist directly. Internally, Drafter uses protagonist 1.4.
I had to do quite a few code changes to get it working with protagonist 1.4, as the API Blueprint people have now deprecated the AST format; but I can confirm it does now work on a macbook running El Capitan.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ransico/grunt-apiblueprint-springmvc/issues/1#issuecomment-243995789, or mute the thread https://github.com/notifications/unsubscribe-auth/AD7xLRcZw_YbBxB8w2sWYp1Nngd4NizNks5qlnttgaJpZM4JquWz .
Great! It works pretty well :-) Thanks!
I noticed just an error on Enums: my mson model:
generated java code
public class User {
private String username;
private Enum<String, String, String, String> role;
public String getUsername() { return username; } public void setUsername(String username) { this.username = username; }
public Enum<String, String, String, String> getRole() { return role; } public void setRole(Enum<String, String, String, String> role) { this.role = role; }
}
On Thu, Sep 1, 2016 at 9:14 AM, Lewis Weaver notifications@github.com wrote:
If you are interested, I have created a new version of this grunt task, 0.2.0, which now uses Drafter rather than protagonist directly. Internally, Drafter uses protagonist 1.4.
I had to do quite a few code changes to get it working with protagonist 1.4, as the API Blueprint people have now deprecated the AST format; but I can confirm it does now work on a macbook running El Capitan.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ransico/grunt-apiblueprint-springmvc/issues/1#issuecomment-243995789, or mute the thread https://github.com/notifications/unsubscribe-auth/AD7xLRcZw_YbBxB8w2sWYp1Nngd4NizNks5qlnttgaJpZM4JquWz .
Great to hear that you are having more luck!
I can see that there is an issue with Enum usage there - however I am not too sure exactly what the expected output should be. (Normally I don't use DateTime or Enum in my models in an API; I convert to from a String to those objects in the service impl, to better capture errors)
What would you have expected the APIB file to generate, in your example?
Hi. I'm trying to run this task but I have lots of problems. First installation fails: on Os X cannot build protagonist. So I cloned both repositories (grunt-apiblueprint-springmvc and apiblueprint-springmvc) I changed protagonist dependency putting >= instead of ^ and also fixed the version of apiblueprint-springmvc required by the grunt task to 0.1.13 Then I can install locally both modules. When I tried to run the grunt script no task where found.
grunt --help show a apibspringmvc task so I changed Gruntifile.js
module.exports = function(grunt) {
// Project configuration. includePath: '/Users/giancarloorru/Documents/Sviluppo/inpeco/anapath/documentation/' grunt.initConfig({ apibspringmvc: { options: { includePath: '/Users/giancarloorru/Documents/Sviluppo/inpeco/anapath/documentation/', packagePrefix: 'my.package.rest', extraImports: ['my.package.rest.model.response.','my.package.rest.model.request.'], skipModelNames: ['ReadSingleResponse', 'ReadListResponse', 'OperationResponse', 'FilterableRequest'] }, files: { 'destinationPath': ['*.apib'] }, }, })
grunt.loadNpmTasks('grunt-apiblueprint-springmvc');
// Default task(s). grunt.registerTask('default', ['apibspringmvc']);
};
Now the task apparently runs but no output is generated. Debugging with IntelliJIdea I noticed that no apib files are detected at line this.files.forEach(function (file) { in apiblueprint-springmvc.js.
How I can configure where looking for apib file?
Sorry for message length. Thanks in advance. Regards. Giancarlo