Can I generate client code using SpringFox? - jhipster

I am trying to determine if it is possible to generate client code / stubs (in C#) for my API. The API back-end has largely been generated using JHipster, and is Spring based. It is already configured to use SpringFox for generating documentation (and that works nicely).
I admit that I don't have a good understanding of how all these pieces and parts fit together. A lot of this is new to me. As I understand it, SpringFox builds its documentation from the API itself by interrogating the code. And I understand that Swagger/OpenAPI is able to generate client code using the CodeGen projects. So it seems it should be possible to combine SpringFox and CodeGen to generate client code from the server code, but I haven't been able to work out how to do this.
Can someone give me some pointers on how to make this work? Thanks!

Related

How to develop an API which reads Qr Codes in node.js

I am working on microservice, creating a REST API in node.js using express, I cannot figure out a way to read Qr Codes. How am I supposed to work it out?
P.S I am using zxing library but unable to successfully implement it in my code.
I have tried various solutions including working with alternative libraries but main problem is implementing it.
As I am using my company's system I am not allowed to show all the data here, but I will update the questions with errors soon.
But in simple words whenever I send a Qr code image it fails to read it.

Where should we provide the RestAPI details while using cucumber

What is the appropriate place to provide RestAPI details while using cucumber? i.e. In Feature file or Step Definition file?
The RestAPI is not really part of the business problem you are solving. Rest is not your core functionality. It is just one, technical, way of using the real functionality you are building.
I would therefore not describe a RestAPI in the feature files using Gherkin. I would hide these implementation details in the glue code connecting the examples written in Gherkin with the system under test.
Cucumber is a tool all about communication between groups of people throughout the business you are working with.
If you're working on a project alone, there is less of the need to describe features in business language (although, it is useful for drafting up ideas using a BDD mindset).
My advice, keep the feature files without code, CSS or any other things that could throw off a layperson. Move these to the step definition file instead, and describe what you're doing in terms that a layperson can understand.
You should store it in the step_definitions file. Keep all the coding tagged to the gherkin steps in the feature file to the step_definitons folder inside which you create a file.
Its always better to keep feature files without the code, they are mainly for better understanding of the testing process and business scenarios and best practise when you view it from BDD perspective.
In case your API values are frequently changing, you can also, mention the values in the cucumber gherkin steps, and pass it as an argument to the step_definitions file. So that any change in the values can be handled in the feature file itself, within the "double quotes" instead of going to the code every-time
On a side note, what gem are you using to test on the REST API? Airborne?

Type Script Decorators for Authorization in Nodejs

I am developing server side nodejs application using typescript.I have to implement authorization in my nodejs application. I was planning to use Type script "Method and Class Decorators" for the same.But below post states, "Decorators are an experimental feature that may change in future releases".
https://www.typescriptlang.org/docs/handbook/decorators.html
Can someone please suggest, what is the best cleaner way to implement authorization?
If I go with decorators, How much will future VSCode releases impact its functionality.
IMHO using decorators is fine. TypeScript will not drop them and there is also a TC39 proposal for them (currently stage 2).
If you're using the power of the internet, I am sure you'll find plenty of example that use decorators to do authentication. A quick search gave me this express lib: https://github.com/Romakita/ts-express-decorators
But you do not need to limit your search to TypeScript. People, who are using Babel, are also already using decorators.
Not quite sure what your editor (VSCode) has to do with this language feature.

Combining SailsJS and EmberJS (routing)

I've been using SailsJS for a while now and find it a perfect REST API solution. I'm currently building an app for both Web & Mobile (native) so I need the REST part of SailsJS. I want to build a frontend for my API right now, and I found EmberJS which looks like a promising framework. I've a question about combining those two, they both have their own Routing system, and SailsJS seems to overrule Ember's one.
My guesses would be:
The most easy approach looks like building Sails in a subdirectory
eg. /api/ but I think that's not the nicest way to get this fixed.
I could choose one framework for routing and let the other delegating it's routes. For example passing parameters from SailsJS through EmberJS
How can I use those together correctly?
Think of your backand as something you can't control, like a 3rd party API. The reason is that the optimal routing for a user may differ greatly from what's considered to be good API semantics. It's also not easy to share the route declarations, but it's not a good practice anyway.
My advice:
Use ember-cli to build the frontend. It's a great tool, you'll enjoy it a lot.
Build your Sails-based API in a different repository, using the /api namespace for your API endpoints.
Try to follow the JSON API standard as closely as possible. That'll make easier to connect your backend & frontend, as most data libraries (Ember Data for eg.) tries to adhere those standards as well.
Watch Luke Melia's excellent guide on lighning fast deployment. It'll be the same concept for you but in Sails intead of Ruby/Rails.
All in all, I think if you'll have a great dev experience if you do roughly what I've outlined above. Happy coding!

Any libraries that can make accessing Google APIs as a service account simpler for NodeJS?

Background: My idea is to create a primarily content-heavy website (think news articles or blog posts) written entirely in nodejs. Since creating content on Google Drive (Google Docs) in particular is very simple, what I would like to do is have Nodejs retrieve the website's content from Google Docs.
Challenge: As far as I can tell, the correct way to do this according to Google is to create a Service Account so that the application can access the files stored on Google Drive without requiring user-intervention in the form of a confirmation. Google provides three libraries--java, python, and php--for server-to-server requests. Does anyone know of anything similar already written by the Node community? I am aware of node-oauth but I've searched through it's source and haven't found anything referencing private keys, which are required for server-to-server interaction, which I'm taking to mean it's not supported. Writing one is also an option, but I'd like to avoid that if at all possible. Looking at the Google-written Java Oauth2 client library makes it pretty clear that it's not an easy task.
Thanks in advance!
This is one library I've found that looks pretty thorough and complete for creating JSON Web Tokens: JWCrypto
I know this thread is old, but in the event others arrive here looking for an answer:
Google is working on an official module to access all of their API's. Its alpha so be careful but it looks very nice- github repository

Resources