Has anyone configured swagger with spring-data-rest. I know swagger has DocumentationConfig class which scans for all spring-mvc request mappings. But, how to use that for spring-data-rest as there are no explicit request mappings defined. Any help in this regard is greatly appreciated. Also, like to know, if there are any other documentation framework which supports Spring-Data-Rest.
In version greater than 2.6.0 of SpringFox, support for spring data rest was added (but it's still in incubation). In order to add support for Spring Data Rest, you need to include the dependency below:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-data-rest</artifactId>
<version>2.6.1</version>
</dependency>
This has been lingering out there a while, but as others have mentioned, there are (still) no Swagger implementations that support Spring Data Rest. However, Spring Data Rest does follow the HAL specification, and the HAL Browser integrated really seamlessly with any SDR project. Coupled together with the newer versions of SDR that expose ALPS metadata, this should be very sufficient for your documentation goals.
Answer for your second question:
AsciiDoctor combined with Spring REST Docs/RestAssured can be neat way of documenting SDR endpoints. It does require a bit of manual effort though, as the only automated part will be the creation of snippets. These can then be loaded into your AsciiDoc files.
Related
I want to showcase all my endpoints of an API Gateway in Swagger. For gateway, I have used Ocelot with Asp.Net Core 2.1 but Ocelot's documentation says it does not support Swagger. Anyhow, if anyone can give suggestion on this?
I have already investigated the approaches to achieve this. For now if you are not going to re-invent the wheel with custom your own implementations, then the MMLib.SwaggerForOcelot package is the option to go with. Please follow readme file provided by link above. It covers all aspects of using that package.
This is my understanding:
Swagger is a notation/rules to write documentation. But why is it called a framework (like Angular/MVC)?
Swashbuckle is a program (JavaScript?) that generates the documentation (based on Swagger rules).
Swagger UI displays the documentation. It uses Swashbuckle to do this.
Is this information correct? If not can someone explain in simple terms what Swagger, Swashbuckle, and Swashbuckle UI mean?
Also, what do I lose as an API developer if I do not use this?
Swagger is a notation/rules to write documentation. But why is it called a framework(Like angular/MVC)?
It is probably called a "framework" because its' purpose is to offer a systematic way of notating the interface of any RESTful service under the OpenAPI Specification. This is a big deal to developers because the spec is overseen by the Open API Initiative under the reputable Linux Foundation.
Swashbuckle is a program(javascript ?) that generates the documentation(based on Swagger rules)
Swashbuckle is more of a package (or a library) that you can make use of in your .NET Web API projects. It's purpose, as you have correctly indicated, is to generate the Swagger spec for your project. Additionally, the Swagger UI is contained within Swashbuckle so if you are developing an API in .NET it's really a nice one-stop shop of a package. It is almost entirely written in C#, not JavaScript.
Swagger UI displays the documentation. It uses Swashbuckle to do this.
Yes, it does display the Swagger spec in a nice, human-friendly manner. However, Swashbuckle is not a necessary component for this. They are, aside from what I just said previously, completely mutually-exclusive.
Also what do I lose as an API developer, if I do not use this.
This is now entering into the realm of opinion but I'll try to be objective about it. I use Swashbuckle to assist in the creation of clients for my application APIs. After getting past the implementation learning curve (which wasn't much), this package has saved me quite a bit of time of writing the clients myself. Writing a web client is a trivial thing for small applications but enterprise-level applications have a tendency to keep growing and/or changing in complexity so it is nice to have the creation/updating of these clients completely automated.
In short, if you decide not to use it you must either resort on an alternative method of API client generation or write/update the clients yourself. If you are only developing the back end this may be completely pointless to you but it would certainly help whoever is responsible for creating the client apps that will consume your API services.
I hope these answers have been helpful. Cheers!
I'm little confuse that if my project is on Spring and I want to use neo4j with java not with Spring Data .
what is a good practice ?
Thanks
You have another options for your Java app. I assume you are talking about client application, not about extension for Neo4j.
One option is to use REST API from your application. As a client you can use Jersey client and another REST client, which you like.
Another option is to use OGM, which is Object Graph Mapping Library, like Hibernate for rdbms. https://github.com/neo4j/neo4j-ogm
OGM for Neo4j is now separated from Spring : https://github.com/neo4j/neo4j-ogm. So you don't have to use Spring Data and can still use OGM (or even stick with Core Java API if you want). But Spring Data has some nice features (i.e. repositories) so if I were you I would give it a try.
If you're using spring, best practice would probably be to use spring-data-neo4j, because its integration with the rest of spring is quite nice. That being said, of course you don't have to. You have the options listed by others, and of course you can use the native Java API.
If you've already taken the step to use spring, in general I'd recommend using spring-data-neo4j unless you have a compelling specific requirement not to.
As far as I know Spring Integration has out of the box JMX support. What documentation says is that I can obtain numerous statistics regarding channels, routers, etc.
I have the following configuration added to Spring context file:
<context:mbean-server />
<context:mbean-export/>
However, only one element has been auto detected for JMX exposure. It is a simple delayer.
I have multiple flows defined and no more elements are exposed through JMX.
I have no clue what is wrong.
Are there any other configuration changes I need to make?
Thank you for any help.
You need to use <int-jmx:mbean-export> instead.
Sorry for the short answer, but there is no more to say, if already have taken a look into Docs.
However here is a sample on the matter.
UPDATE
H-m. No, wrong sample. See Spring Integration tests.
UPDATE2
<context:mbean-export/> registers MBeans for those Spring Beans which are #ManagedResource. The <int-jmx:mbean-export> goes a bit further and wraps to MBeans almost all Spring Integration components: channels, MessageHandlers, MessageSources.
And yes, adds for them #ManagedMetrics.
was wondering if I can use the Neo4j Java API for connecting to remote DBs or is REST the only way for me to access a remote DB ? Was looking to use something like
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(NEO_4J_REMOTE_DB_ENDPOINT);
If I can use, what would my endpoint look like ? '/db/data ?
Or is it the case where I have to use REST ?
I have my server running in GAE and have a Neo4j instance in Heroku.
Thanks guys.
REST is the only communication protocol with the server version at the moment. There have been talks about a binary protocol but that does not exist atm.
However, there are several layers for different languages over this REST API. For Java, you can find it here :
https://github.com/neo4j/java-rest-binding
This allows you to use the same API as the embedded version, but in the background it is translated to REST. There are some limitations on the functionality, and it's not up to date with all the latest versions but never the less, it works pretty darn good and I always use it with Heroku.
EDIT: If you're using maven, add this repository http://m2.neo4j.org/index.html and then add these lines to your POM
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-rest-graphdb</artifactId>
<version>2.0.1</version>
</dependency>