smartbear / swagger4j Goto Github PK
View Code? Open in Web Editor NEWA simple java library for reading and writing swagger definitions
A simple java library for reading and writing swagger definitions
This is to support SmartBear/readyapi-swagger-plugin#66
Hello,
I am using Swagger4J to parse Swagger descriptions available on the iServe website (e.g., http://iserve.kmi.open.ac.uk/iserve/id/documents/18ee0842-f492-4f43-9073-ade556155526).
The website returns the swagger UI when "Accept: text/html" appears in the HTTP request header. Otherwise, it will return the JSON-based Swagger document when the header contains "Accept: application/json".
It looks like that Swagger4J is not able to fetch such JSON documents because in the HTTP request header contains "Accept: text/html, image/gif, image/jpeg, *; q=.2, /; q=.2".
I suppose that the header should contain "application/json" instead of "text/html". Isn't it?
Thank you very much for your help.
Cheers,
Luca
Hi
I am using the following code in order to add api declaration without using annotations:
ResourceListing resourceListing = null;
resourceListing = Swagger.createResourceListing(SwaggerVersion.DEFAULT_VERSION);
resourceListing.setBasePath("http://localhost:8080/Spring/rest");
SwaggerFactory factory = Swagger.createSwaggerFactory();
ApiDeclaration apiDeclaration = factory.createApiDeclaration("http://localhost:8080/Spring/rest", "/bookmarks");
Api api = apiDeclaration.addApi("/bookmarks");//the request url that is being called
Operation operation = api.addOperation("getBookmarks",Operation.Method.GET);
operation.setSummary("bookmarks list");
operation.addProduces("application/atom+xml");
resourceListing.addApi( apiDeclaration, "/bookmarks" );
Swagger.writeSwagger(resourceListing, "src/main/webapp");
now, after performing Swagger.writeSwagger I do get api-docs.json and bookmarks.json files under "src/main/webapp" as, But- when I access in the Swagger-ui to the resource "http://localhost:8080/Spring/rest/api-docs" I can't get the bookmarks resource. so my question is how to integrate the jsons file I got from swaggerWriter into the api-docs resource that is generated by the swagger-core.
I will really appreciate your help here!!!
Pom.xml is missing in the smartbear maven repo.
Repository location:
http://smartbearsoftware.com/repository/maven2/com/smartbear/swagger4j/1.0.0/
I am unable to run SoapuiPro tests using ReadyAPI maven plugin 2.4 because of the misssing pom.
Hi,
I tried to parse the following Swagger description: https://dweet.io/play/definition/
Unfortunately, Swagger4J returns this exception:
java.lang.AssertionError: Can not add API to Resource Listing; path already exists at com.smartbear.swagger4j.impl.ResourceListingImpl.addApi(ResourceListingImpl.java:85) at com.smartbear.swagger4j.impl.SwaggerReaderImpl.readResourceListing(SwaggerReaderImpl.java:68) at com.smartbear.swagger4j.impl.SwaggerReaderImpl.readResourceListing(SwaggerReaderImpl.java:43) at com.smartbear.swagger4j.Swagger.readSwagger(Swagger.java:81)
This is the source code:
ResourceListing resourceListing = Swagger.readSwagger("https://dweet.io/play/definition/");
Am I doing something wrong?
Thank you.
Hi Ole,
kudos for the great library! Are you planning to support v2.0 swagger spec parsing in the near future?
Cheers,
Chris
When a swagger json file has an empty set for Authorization the cod is throwing an ClassCastException
org.glassfish.json.JsonArrayBuilderImpl$JsonArrayImpl cannot be cast to javax.json.JsonObject
This is within SwaggerReaderImpl.
child1 = parser.getChild("authorizations");
if(child1 != null) {
this.readAuthorizations(resourceListing, child1);
}
I am trying to create swagger doc using swagger4j.A resource level I am able to add Authorization block but at Operation level this logic of adding Authorization is missing....Please help me resolving this issue..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.