Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble when generating with string type definitions #2

Closed
damir-manapov opened this issue Aug 31, 2018 · 9 comments
Closed

Trouble when generating with string type definitions #2

damir-manapov opened this issue Aug 31, 2018 · 9 comments
Labels
bug Something isn't working

Comments

@damir-manapov
Copy link

Hi!

I'm have trouble when generating with string type definitions.
Example of swagger.json:

{
  "swagger" : "2.0",
  "info" : {
    "version" : "1.0.0",
    "title" : "Test API"
  },
  "host" : "api.test.com",
  "basePath" : "/v1",
  "schemes" : [ "https" ],
  "produces" : [ "application/json" ],
  "paths" : {
  },
  "definitions" : {
    "ContractStatus" : {
      "type" : "string",
      "description" : "Enumeration of contract status",
      "enum" : [ "Placed", "Approved", "Started", "Closed" ]
    }
  }
}

Error:

(node:31783) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at createDefinitionClass (/Users/damir/proj/node_modules/swagger-axios-codegen/dist/definitionCodegen.js:65:39)
    at Object.definitionsCodeGen (/Users/damir/proj/node_modules/swagger-axios-codegen/dist/definitionCodegen.js:101:34)
    at codegen (/Users/damir/proj/node_modules/swagger-axios-codegen/dist/index.js:56:38)
    at Object.<anonymous> (/Users/damir/proj/swag/codegen.js:3:1)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
(node:31783) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:31783) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@Manweill
Copy link
Owner

Manweill commented Aug 31, 2018

I have not seen such a structure like this. How do you got it

@Manweill
Copy link
Owner

@damir-manapov I can fix it,but the codegen will return empty of this swagger.json

@damir-manapov
Copy link
Author

@damir-manapov
Copy link
Author

@Manweill
Copy link
Owner

when you use swagger in your application,it is like this

"Contract": {
      "description": "Model of the contract",
      "type": "object",
      "properties": {
        "contractId": {
          "type": "string",
          "description": "Contract unique identificator in the system"
        },
        "contractName": {
          "type": "string",
          "description": "Short name of the contract"
        },
        "status": {
          "type": "string",
          "enum": [
            "Placed",
            "Approved",
            "Started",
            "Closed"
          ]
        }
      }
    }

@damir-manapov
Copy link
Author

Ok, @Manweill
It will be great if such swagger works

@Manweill Manweill added the bug Something isn't working label Sep 4, 2018
@damir-manapov
Copy link
Author

Hi!
How long it might take to fix this?

@Manweill
Copy link
Owner

Manweill commented Sep 14, 2018

@damir-manapov
Welcome PR!
And then, I will fix it at Mid-October

@Manweill
Copy link
Owner

fix in 0.3

Manweill pushed a commit that referenced this issue Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants