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

webpack error building javascript generated client #1035

Closed
zsimo opened this issue Aug 3, 2016 · 4 comments
Closed

webpack error building javascript generated client #1035

zsimo opened this issue Aug 3, 2016 · 4 comments

Comments

@zsimo
Copy link

zsimo commented Aug 3, 2016

Swagger File

 {
  "swagger": "2.0",
  "info": {
    "title": "Test",
    "description": "Test",
    "version": "1.0.0"
  },
  "host": "localhost",
  "schemes": [
    "http"
  ],
  "basePath": "/services/search",
  "paths": {
    "/institutions": {
      "post": {
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "value",
            "in": "query",
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Records found",
            "schema": {
              "$ref": "#/definitions/QuickSearchRecords"
            }
          },
          "400": {
            "description": "Invalid parameters"
          },
          "404": {
            "description": "No record found"
          },
          "500": {
            "description": "Unexpected error"
          }
        }
      }
    }
  },


  "definitions": {
    "QuickSearchRecords": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/QuickSearchRecord"
      }
    },
    "QuickSearchRecord": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "count": {
          "type": "integer"
        }
      }
    }

  }
}
  • Version:
  • Browser/OS:

Issue
Hello!
It seems Webpack (I'm using 1.13.1) fail to manage AMD syntax: by changing the source code, forcing to use CommonJs syntax Webpack succeeds in compiling the scripts. Can you please try/fix?

Thanks!

@saharj
Copy link
Contributor

saharj commented Aug 3, 2016

Can you provide more details? Are you trying to modify Swagger Editor code base?

@zsimo
Copy link
Author

zsimo commented Aug 4, 2016

Hello,

No, I just try to edit the client source code generated by the Swagger Editor.
It seems Webpack (I'm using 1.13.1) fail to manage AMD syntax: by disabling the Module system the Javascript client works.
Disabling directly edit the code source :

// commenting the first IF branch
  //if (typeof define === 'function' && define.amd) {
  //  // AMD. Register as an anonymous module.
  //  define(['superagent'], factory);
  //} else
  if (typeof module === 'object' && module.exports) {
    // CommonJS-like environments that support module.exports, like Node.
    module.exports = factory(require('superagent'));
  }

or via Webpack configs:

npm install --save-dev imports-loader
// and then add this loader to the webpack configs
{ test: /\.js/, loader: 'imports?define=>false'}

Have you ever try to bundle your Js client generated code via Webpack?

Thanks!

@saharj
Copy link
Contributor

saharj commented Aug 5, 2016

This is a Codegene issue. let me move your issue there.

@saharj
Copy link
Contributor

saharj commented Aug 5, 2016

This issue was moved to swagger-api/swagger-codegen#3537

@saharj saharj closed this as completed Aug 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants