swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[Javascript] useES6 is the default even though it shouldn't be

Open tray2100 opened this issue 6 years ago • 10 comments

Description

the ES5 templates should be used by default when generating a javascript client but it seems that the ES6 templates are actually being used by default.

Swagger-codegen version

3.0.19 ... not sure if this has worked in previous versions.

Swagger declaration file content or url

Used the petstore example to verify this issue

Command line used for generation

swagger-codegen generate -i https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml -o testJavascript/ -l javascript

Steps to reproduce

swagger-codegen generate -i https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml -o testJavascript/ -l javascript

Related issues/PRs

tray2100 avatar Jun 07 '20 09:06 tray2100

Is there a way to generate a ES5 client? I run below which doesn't seem to work though

# swagger-codegen: stable 3.0.20, installed via homebrew(`brew install swagger-codegen`)
# macOS: 10.15.5
# JDK: adoptopenjdk8, installed via homebrew(`brew cask install homebrew/cask-versions/adoptopenjdk8`)
swagger-codegen generate -i http://MY_SERVER/v2/swagger/governator-jaxrs.json -l javascript --additional-properties useES6=false

huang47 avatar Jul 29 '20 21:07 huang47

I'm facing this issue also.. I created configuration file and added useES6 option like below

{
    "useES6": false
}

But this options seems like not work;

jimni1222 avatar Jul 05 '21 05:07 jimni1222

anyone ever resolved this?

alexaurus avatar Sep 28 '22 18:09 alexaurus

I'm getting this same issue, I can't work out how to force it to use ES5

waterwheels avatar Feb 06 '24 03:02 waterwheels

I see... well, let's get this fixed :)

HugoMario avatar Feb 06 '24 04:02 HugoMario

I reviewed this issue and it was already fixed, so glong to close it. If you don't want to use ES6 templates. You just need to add the option:

--additional-properties useES6=false

in your CLI for code generation

HugoMario avatar Feb 08 '24 00:02 HugoMario

That's weird, when I try swagger-codegen generate -i $api_url -l javascript -o out --additional-properties useES6=false it still generates code with class keyword classes

waterwheels avatar Feb 08 '24 00:02 waterwheels

What codegen version are you using?

El mié, 7 feb 2024, 7:50 p. m., Jo @.***> escribió:

That's weird, when I try swagger-codegen generate -i $api_url -l javascript -o out --additional-properties useES6=false it still generates code with class keyword classes

— Reply to this email directly, view it on GitHub https://github.com/swagger-api/swagger-codegen/issues/10305#issuecomment-1933185179, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY5QMEE2BPQKOMYHG5TQHTYSQONTAVCNFSM4NW7O4Y2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJTGMYTQNJRG44Q . You are receiving this because you modified the open/close state.Message ID: @.***>

HugoMario avatar Feb 08 '24 01:02 HugoMario

I'm using 3.0.52, I installed via brew

waterwheels avatar Feb 08 '24 02:02 waterwheels

@waterwheels I noted the problem is actually the templates, no the option. Anyway this could be addressed in a different ticket.

HugoMario avatar Feb 08 '24 17:02 HugoMario