fmvilas / swagger-node-codegen

An OpenAPI 3.x/Swagger 2 code generator for Node.js
Apache License 2.0
200 stars 55 forks source link

Swagger-node-codegen creates empty directory #16

Closed vijaybernad closed 6 years ago

vijaybernad commented 6 years ago

When i use this project it jsut creates empty directories even after given the json file.

Please provide support

richardklose commented 6 years ago

Can you please provide some more details about how you use it and about your Swagger/OpenAPI definition? Do you use it from the command line or as a module in javascript? How can your issue be reproduced?

vijaybernad commented 6 years ago

It is reproducible when we the swagger node cant find the given basepath. It generates a empty folders. Once it generates an empty folder ,even after that if give the actually path to swagger it generates empty folder.To over come this we have to do a npm cache clean --force then it starts working.

However i have a question,

My requirement is to create a request object from the spec like

"/acc": { "post": { "parameters": [ { "name": "requestbody", "in": "body", "required": true, "schema": { "type": "object", "properties": { "_meta": { "type": "object" }, "data": { "properties": { "name": { "type": "string", "minLength": 1, "maxLength": 256, "title": "Name" }, "description": { "type": "string", "minLength": 1, "maxLength": 256, "title": "Description" }, "metadata": { "type": "object" }, "externalId": { "type": "string", "minLength": 1, "maxLength": 256 }, "type": { "type": "string", "enum": [ "INDIVIDUAL", "JOINT", "ENTERPRISE" ], "title": "Account Type" }, "fi": { "type": "string", "title": "Financial Institution ID", "pattern": "^[a-fA-F0-7]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" }, "channels": { "type": "array", "items": { "type": "string" } }, "members": { "type": "array", "items": { "type": "string", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" } } }, "additionalProperties": false, "required": [ "name", "type", "fi" ] } }, "required": [ "data" ], "additionalProperties": false } } ]

Now for the above spec i want a object to be created with all property like the request object "acc" so i can set the values in request object ex

acc.setMember(mem) acc.setExternalId (id)

How can i achieve this .Any help is appreciated.

richardklose commented 6 years ago

This not valid JSON and far away from being a valid OpenAPI Spec.

Please consider the official OpenAPI [3.0] (https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md) or 2.0 Documentation for the required properties and valid Specs.

Also please create a new issue if this is not relation with your initial issue.

At least you need a basePath property (for OAS/Swagger 2.0) or a servers property (for OAS 3.0) at top level in your spec. The absence of one of these properties might lead to problems, but this is not intended to be handled by a code generator but rather by a validator. The code generator expects that you use a valid spec. For checking if your spec is valid you could also use one of the validators listed here

If you have any questions on creating valid specs, you should ask them on stack overflow because there will be more people that can help you with that.

vijaybernad commented 6 years ago

The spec mentioned above was just give to show what i a trying to generate from my spec.

As i mentioned earlier is it possible to generate a request object .

fmvilas commented 6 years ago

Please provide more meaningful information so we are able to reproduce the bug. Thanks!

fmvilas commented 6 years ago

Closing as there has been a month without response. Feel free to keep commenting.