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

Swagger-codegen JSON parser fails silently #448

Closed
josephmisiti opened this issue Feb 23, 2015 · 7 comments
Closed

Swagger-codegen JSON parser fails silently #448

josephmisiti opened this issue Feb 23, 2015 · 7 comments

Comments

@josephmisiti
Copy link

I am using swagger-docs to generate my json and then use this project to create my clients. For some reason (which I have not figured out yet), swagger-docs generated invalid json for one of my APIs and when I point swagger-codegen at the api-docs.json file to generate the clients, it fails to produce code but doesnt say why. The only way to track this down is to point swagger-codegen at each individual api.json file to see which one fails.

@josephmisiti josephmisiti changed the title Parse fails silently Swagger-codegen JSON parser fails silently Feb 23, 2015
@webron
Copy link
Contributor

webron commented Feb 23, 2015

Can you share the api-docs.json?

@fehguy
Copy link
Contributor

fehguy commented Feb 23, 2015

I have seen this happen as well. The SwaggerCompatParser will fail completely if a single spec is not valid, and without any indication as to why

@jvieten
Copy link

jvieten commented Feb 24, 2015

also in this vain maybe this would help:

--- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/Codegen.java
+++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/Codegen.java
@@ -89,6 +89,7 @@ public class Codegen extends DefaultGenerator {
     catch (Exception e) {
+               e.printStackTrace();
       usage(options);
       return;
     }

many greetings

@TuomasKiviaho
Copy link

I stumbled also to this as a first impression of the project. It took me a while to figure out that the problem wasn't in the options that I gave.

I suggest that the new SwaggerParser().read() would be simply moved out from try/catch(...){usage(options);return;} block. I guess that the latter try/catch could be removed (and let main() throw exceptions)

java.lang.NullPointerException
    at io.swagger.parser.SwaggerCompatConverter.convertParameter(SwaggerCompatConverter.java:183)
    at io.swagger.parser.SwaggerCompatConverter.convertOperation(SwaggerCompatConverter.java:314)
    at io.swagger.parser.SwaggerCompatConverter.convert(SwaggerCompatConverter.java:454)
    at io.swagger.parser.SwaggerCompatConverter.read(SwaggerCompatConverter.java:111)
    at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:34)
    at com.wordnik.swagger.codegen.Codegen.main(Codegen.java:87)
        ...

@josephmisiti
Copy link
Author

@webron i can email you the file the fails if that would help

@webron
Copy link
Contributor

webron commented Mar 3, 2015

Please do. You can add Tony to the email as well.

@fehguy
Copy link
Contributor

fehguy commented Mar 4, 2015

OK I've made this better in swagger-parser-1.0.2-SNAPSHOT. swagger-api/swagger-parser#17

Expect this to come out in a release shortly

@fehguy fehguy closed this as completed Mar 4, 2015
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

5 participants