swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.96k stars 6.04k forks source link

Can't generate server/client : TypeError: Cannot read property 'generate1' of undefined #8304

Open zybjcdl opened 6 years ago

zybjcdl commented 6 years ago

Q&A (please complete the following information) OS: macOS Browser: chrome Version: last, through http://editor.swagger.io/ Method of installation: n/a ,directly through http://editor.swagger.io/ Swagger-Editor version:latest Swagger/OpenAPI version: OpenAPI 3.0.0 Content & configuration A very simple swagger yml:

openapi: 3.0.0 info: title: TEST description: API endpoints for Phase I integration. version: '0.1' paths: /test: post: summary: test requestBody: required: true content: application/json: schema: type: object properties: id: type: string name: type: string responses: '201': description: success

Describe the bug you're encountering I can't generate server or generate client. It will report: TypeError: Cannot read property 'generate1' of undefined at r.downloadGeneratedFile (topbar.jsx:198) at Object.i (ReactErrorUtils.js:24) at s (EventPluginUtils.js:83) at Object.executeDispatchesInOrder (EventPluginUtils.js:106) at f (EventPluginHub.js:41) at p (EventPluginHub.js:52) at Array.forEach () at e.exports (forEachAccumulated.js:22) at Object.processEventQueue (EventPluginHub.js:250) at ReactEventEmitterMixin.js:15

To reproduce... Steps to reproduce the behavior:

Go to 'http://editor.swagger.io/ Use the yml content I provided Click on generate server->python flask See error Expected behavior Could successfully generate server and client

jemerald commented 6 years ago

Cannot reproduce the exact error, here's the tidied up sample spec:

openapi: 3.0.0
info:
  title: TEST
  description: API endpoints for Phase I integration.
  version: '0.1'
paths:
  /test:
    post:
      summary: test
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: string
                name:
                  type: string
      responses:
        '201':
          description: success

The root reason is that the code gen for python is not ready for OpenAPI 3.0 yet. See https://github.com/swagger-api/swagger-codegen/releases

However, the original error you experienced was caused by codegen's breaking change of moving generator.json to swagger.json. Which caused the editor not able to load code gen list for OpenAPI 3.0, and ended up showing list for OpenAPI/swagger 2.0 instead.

This specific problem is now fixed by https://github.com/swagger-api/swagger-codegen/pull/8259, and if you test your scenario again via editor.swagger.io, you will see that python is no longer an option in code gen.

HugoMario commented 6 years ago

That's correct, also to get the generator list, you can use the endpoints /client and server. About python we're waiting for community to help us with that.