swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
http://swagger.io
Apache License 2.0
7.39k stars 2.19k forks source link

How to use swagger-core for Java Servlets #2659

Closed abhisheklakra007 closed 6 years ago

abhisheklakra007 commented 6 years ago
Q A
Bug or feature request? None
Which Swagger-Core version? 2.0.0-rc2
Which Java version? 1.8
Which JAX-RS framework & version? No JAX-RS, Servlets

How can I use it for Servlets that isn't JAX-RS or any popular framework like RESTEasy ?

This link is broken or it doesn't redirect to the right resource. https://github.com/wordnik/swagger-core/wiki/Servlet-Quickstart

This is an un answered stackoverflow question

abhisheklakra007 commented 6 years ago

Moreover is swagger-annotation included in swagger-core.

webron commented 6 years ago

You'd have to use version 1.5.X for it. There's no formal documentation, but you can follow the sample for guidance - https://github.com/swagger-api/swagger-samples/tree/master/java/java-servlet.

abhisheklakra007 commented 6 years ago

As per the project README, I should be using 2.X because my project is written in Java8, right ?

webron commented 6 years ago

No, you can use 1.5 with Java 8.

renannprado commented 6 years ago

Is there a way to use swagger-core2 with Spring MVC without depending on any library (such as springfox)? If I couldn't use swagger-core2 just like it was being used for servlets, but annotating spring MVC methods, that could work for me. I don't want any spring MVC integration, I just want my openapi spec to be generated out of the annotations.

webron commented 6 years ago

@renannprado depending on swagger-core is depending on a library. Springfox provides a way to read those annotations in the context of Spring MVC which we don't provide in swagger-core. You can theoretically write your own Reader based on swagger-core, but you're better off using Sprintfox.

renannprado commented 6 years ago

@webron rephrasing: I'd to depend on swagger-core/swagger-annotations alone, without depending on speingfox while it doesn't have support for swagger-core2

webron commented 6 years ago

Same answer applies. swagger-core does not support Spring-based REST frameworks. You'll need to implement your own Reader to do that work, and that would prove very time consuming.

codeAnoise commented 1 year ago

Can somebody add some reference to how can I integrate swagger ui in java pure servlet without Jax rs or any other framework.