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

requestBody and requestModels not being generated. #34

Open
Mike-Van opened this issue Apr 29, 2019 · 11 comments
Open

requestBody and requestModels not being generated. #34

Mike-Van opened this issue Apr 29, 2019 · 11 comments

Comments

@Mike-Van
Copy link

i try to follow the example in the documentation. But i cant get the requestBody, and requestModels to generated in the documentation file.

service: hasuraLambda # NOTE: update this with your service name

provider:
  name: aws
  runtime: nodejs8.10
  stage: ekyc-testing
  region: ap-southeast-1
custom:
  documentation:
    version: '1.0.0'
    title: 'EKMC API'
    description: 'This APIs are EKYC and EKYM service serve for client.'
    models:
      - name: SuccessResponse
        contentType: "application/json"
        schema:
          $schema: "http://json-schema.org/draft-04/schema#"
          type: object
          properties:
            statusCode:
              type: integer
            message:
              type: string
            body:
              type: object
      - name: FailureResponse
        contentType: "application/json"
        schema:
          $schema: "http://json-schema.org/draft-04/schema#"
          type: object
          properties:
            statusCode:
              type: integer
            message:
              type: string
            body:
              type: object
      - name: EkycPostRequest
        contentType: "application/json"
        schema:
          $schema: "http://json-schema.org/draft-04/schema#"
          type: object
          properties:
            firstName:
              type: string
            lastName:
              type: string
            status:
              type: string
functions:
  ekyc-post:
    handler: functions/Ekyc/post.handler
    events:
      - http:
          path: ekyc
          method: post
          documentation:
            tags: ['ekyc']
            summary: "Post new record to server."
            requestBody:
              description: "Can insert an empty object. This will still create a new record inside the server."
            requestModels:
              application/json: "EkycPostRequest"
            methodResponses:
              - statusCode: '200'
                responseBody:
                  description: "Successfully created new ekyc record in server."
                responseModels:
                  application/json: SuccessResponse
              - statusCode: '500'
                responseBody:
                  description: "Can't create new ekyc record in server."
                responseModels:
                  application/json: FailureResponse
plugins:
  - serverless-offline
  - serverless-mocha-plugin
  - serverless-openapi-documentation

im not sure what went wrong. but the responseModels work just fine.

@kzhou57
Copy link

kzhou57 commented Apr 29, 2019

THe project is kinda dead, and this bug has been reported couple of times but fixes are not approved and merged back. So there are couple of efforts to fix this issue and other issues in different folks.

The one I just created have this issue and other issues fixed. Please try it out :

https://github.com/kzhou57/serverless-openapi-documentation

And you can also the modify the package.json to point direct from my version :

"serverless-openapi-documentation": "github:kzhou57/serverless-openapi-documentation",

@Mike-Van
Copy link
Author

Mike-Van commented May 2, 2019

Thank you so much. It works like a clock now.

@Mike-Van Mike-Van closed this as completed May 2, 2019
@kzhou57
Copy link

kzhou57 commented May 2, 2019

Glad it helps you .

@Mike-Van Mike-Van reopened this May 3, 2019
@Mike-Van
Copy link
Author

Mike-Van commented May 3, 2019

@kzhou57 hi...so this solved things on my Mac machine. And im really grateful to u for that. But now i just got new laptop, and try to clone my repo back. When i run npm install or yarn install. Everything seems to work fine. But when i try starting my serverless application it gives me errors

Serverless Error ---------------------------------------

  Serverless plugin "serverless-openapi-documentation" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file.

  Stack Trace --------------------------------------------

ServerlessError: Serverless plugin "serverless-openapi-documentation" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file.
    at plugins.forEach (C:\Users\miike\Desktop\CRM-Node\node_modules\serverless\lib\classes\PluginManager.js:125:17)
    at Array.forEach (<anonymous>)
    at PluginManager.loadPlugins (C:\Users\miike\Desktop\CRM-Node\node_modules\serverless\lib\classes\PluginManager.js:98:13)
    at PluginManager.loadServicePlugins (C:\Users\miike\Desktop\CRM-Node\node_modules\serverless\lib\classes\PluginManager.js:151:10)
    at PluginManager.loadAllPlugins (C:\Users\miike\Desktop\CRM-Node\node_modules\serverless\lib\classes\PluginManager.js:94:10)
    at pluginManager.loadConfigFile.then.then (C:\Users\miike\Desktop\CRM-Node\node_modules\serverless\lib\Serverless.js:72:26)
From previous event:
    at Serverless.init (C:\Users\miike\Desktop\CRM-Node\node_modules\serverless\lib\Serverless.js:70:8)
    at initializeErrorReporter.then (C:\Users\miike\Desktop\CRM-Node\node_modules\serverless\bin\serverless:42:21)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    at process.topLevelDomainCallback (domain.js:120:23)
From previous event:
    at C:\Users\miike\Desktop\CRM-Node\node_modules\serverless\bin\serverless:28:46
    at Object.<anonymous> (C:\Users\miike\Desktop\CRM-Node\node_modules\serverless\bin\serverless:65:4)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     OS:                     win32
     Node Version:           10.15.3
     Serverless Version:     1.41.1

Im not sure why this is happening. Looks like there's a conflict between the plugins. If i erase the plugin from package.json, and readded the official one. I can run the application just fine. This happened on both my linux and window 10.

@kzhou57
Copy link

kzhou57 commented May 3, 2019

Hi Mike,

it probably related to the npm version , the line

"serverless-openapi-documentation": "github:kzhou57/serverless-openapi-documentation",

in package json is requiring a version of npm > 5.0 .

Unfortunately if the npm didn't install my patch version correctly, it didn't report a failure, so later on when serverless trying to call the plugin, it said not found.

Please check the npm version,

npm -v will tell you.

@Mike-Van
Copy link
Author

Mike-Van commented May 4, 2019

my npm version is 6.9.0. and node is 10.15.3.

@kzhou57
Copy link

kzhou57 commented May 6, 2019

hmmm, it's interesting, can you check in your node_modules folder, does this file exists ?

node_modules/serverless-openapi-documentation/dist/index.js

The issue usually the error 'Serverless plugin "serverless-openapi-documentation" not found.' means node cannot find the installed package as a valid node component. If the above file not exists, it means it's the npm problem, which should compile the type script from github and setup the package correctly.

If the file exists, then it's a problem somewhere else.

@Mike-Van
Copy link
Author

Mike-Van commented May 7, 2019

i guess ure rite. I cant find the index.js. the compilation from typescript must've gone wrong somehow.

@Mike-Van
Copy link
Author

Mike-Van commented May 7, 2019

i think i figured out the problem. npm cant compile the source typescript file until i install typescript as global npm package. Once i installed typescript package, npm install would install the package correctly, and compile the scripts in my linux. But on Window, it doesnt auto compiled. i have to go into the node_modules/serverless-openapi-documentation and run tsc command manually to compile souce files.

@kzhou57
Copy link

kzhou57 commented May 7, 2019

I am glad you figured it out.

@medin-n
Copy link

medin-n commented Dec 9, 2019

@kzhou57 @Mike-Van
I fork your repo and i replaced yarn with npm because i had build issues building on server and i didnt want to install yarn.
I also published the package as serverless-openapi-documentation-v2
Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants