sapienstech / typescript-angular2-swagger-codegen

9 stars 3 forks source link

How to use #1

Closed JonnyBGod closed 8 years ago

JonnyBGod commented 8 years ago

Sorry I am not very familiar with swagger-codegen or java.

Can you document how to use this generator please.

roni-frantchi commented 8 years ago

@JonnyBGod I've added a readme file with more info and links for prerequisites. let me know if that helps.

JonnyBGod commented 8 years ago

Trying to figure it out. maybe you can help me. I am trying to create a docker container with this plugin but for some reason I am getting an error.

Dockerfile:

FROM maven:3.3-jdk-7

ENV SWAGGER_CODEGEN_DIR     /opt/swagger-codegen
ENV SWAGGER_CODEGEN_CLI     $SWAGGER_CODEGEN_DIR/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar

RUN git clone -b master https://github.com/swagger-api/swagger-codegen $SWAGGER_CODEGEN_DIR 
RUN git clone -b master https://github.com/sapienstech/typescript-angular2-swagger-codegen.git $SWAGGER_CODEGEN_DIR/output/typescript-angular2-swagger-codegen

RUN cd $SWAGGER_CODEGEN_DIR \
 && mvn package

RUN cd $SWAGGER_CODEGEN_DIR/output/typescript-angular2-swagger-codegen \
 && mvn package

WORKDIR /opt/swagger-codegen

ENTRYPOINT ["java", "-cp", "modules/swagger-codegen-cli/target/swagger-codegen-cli.jar:output/typescript-angular2-swagger-codegen/target/typescript-angular2-swagger-codegen-1.0.jar", "io.swagger.codegen.SwaggerCodegen"]

CMD ["help"]

run scrip:

docker run -v "${PWD}/codegen:/tmp/codegen" jonnybgod/typescript-angular2-swagger-codegen generate \
            -i http://192.168.1.75:54447/explorer/swagger.json \
            --additional-properties basePath="https://connect.wtf/api" \
            -o /tmp/codegen \
            -l typescript-angular2

console output:

./codegen/generate.sh
Exception in thread "main" java.util.ServiceConfigurationError: io.swagger.codegen.CodegenConfig: Provider com.decision.swagger.codegen.typescript.angular2.TypescriptAngular2Generator could not be instantiated
    at java.util.ServiceLoader.fail(ServiceLoader.java:224)
    at java.util.ServiceLoader.access$100(ServiceLoader.java:181)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:377)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
    at io.swagger.codegen.Codegen.getExtensions(Codegen.java:129)
    at io.swagger.codegen.Codegen.<clinit>(Codegen.java:156)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.ArrayList.elementData(ArrayList.java:400)
    at java.util.ArrayList.get(ArrayList.java:413)
    at com.decision.swagger.codegen.typescript.angular2.TypescriptAngular2Generator.<init>(TypescriptAngular2Generator.java:33)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:383)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:373)
    ... 3 more

Any idea of what am I doing wrong?

roni-frantchi commented 8 years ago

Hi, Look here for @mtsmfm 's pull request: https://github.com/sapienstech/typescript-angular2-swagger-codegen/pull/2

Seems like your issue was due to a dependency of swagger-codegen 2.1.6 . He had the same issue and had submitted a PR. I have tested it, and it works, and so I've merged it back to master, and created the 1.0.x branch to support versions > 2.1.6.

Please reopen this issue if you still have issues