PoweredLocal / vrata

API gateway implemented in PHP and Lumen
MIT License
471 stars 116 forks source link

Example with a simple microservice #1

Open alejogutierrez opened 7 years ago

alejogutierrez commented 7 years ago

Hi I was looking to the implementation but still don't know how to interact with a service. It is possible to see an example with a simple service? Also a license would be awesome, thanks

dusterio commented 7 years ago

I've just added a license - thanks for noticing this! :)

Sure, we can provide an example. Does your simple microservice have Swagger documentation?

alejogutierrez commented 7 years ago

Well not really, in fact I found your repo because right now I'm moving from a monolitic Laravel app to microsevices written in Lumen. So does it mean that you have to use an specific modeling lang like swagger o RAML? Thanks again

dusterio commented 7 years ago

You can either do it manually by providing your API gateway routes in GATEWAY_ROUTES environment variable, or you could parse Swagger JSON automatically. Swagger is just a nice way

alejogutierrez commented 7 years ago

Fine I'm going to take a look using swagger.

reindeer77 commented 7 years ago

I agree that it would be awesome to have some configuration examples (in my case swagger based microservice, but any further hint would be really appreciated) Thanks!.

dusterio commented 7 years ago

Sure, you are right. Will add some examples tomorrow!

moon0326 commented 7 years ago

@dusterio Hi Dusterio, where you able to add examples? The doc really does not make sense. I'm pretty sure that no one can run the full example, especially Swagger parts. It would be nice to have working examples with Swagger support.

dusterio commented 7 years ago

@moon0326 I did but perhaps it wasn't enough :) I will review the documentation today and make sure it's comprehensive!

moon0326 commented 7 years ago

@dusterio Thank you so much!

spacecomx commented 7 years ago

@moon0326 Have you managed to use swagger with the api gateway. I don't get how this works. Any help will be appreciated. What does the routes.json file do?

dusterio commented 7 years ago

@spacecomx your microservices are expected to expose Swagger documentation endpoints (version 1), all actions will be imported upon start. routes.json is an internal, auto-generated file - a result of parsing of those Swagger endpoints.

spacecomx commented 7 years ago

@dusterio Thats where I'm hitting a stone wall. The gateway set config file provided with the package endpoint are local? I get an error no "apis" with petstore for example? It that related to swagger version. I did drop you an email yesterday, please can you check it out. Thanks :)

dusterio commented 7 years ago

@spacecomx I've just checked and Petstore is only provided in Swagger v2, it didn't exist till v2 I suppose. I guess it's time to add Swagger v2 support to Vrata.

The reason I stuck with v1 only originally is - all major frameworks I checked at that time (~6 months ago) only had packages for v1.

spacecomx commented 7 years ago

@dusterio Oh you a Star. When creating apis with swagger it defaults to v2.0. Trying to change it to v1 runs an error in the UI. I saw you mentioned v1.0 in your docs, but did not expect that to be an issue at the time. Any time frame on the support for v2? Thanks for the quick responses, wow!

dusterio commented 7 years ago

@spacecomx I'll check tomorrow! if it's something simple (the difference is not too big) - I will add a v2 parser tomorrow :)

spacecomx commented 7 years ago

Thank your attention and addressing enquiries so quickly. Please can you include an example the petstore setup in the gateway config or docs. Most will look at swagger docs and reference the petstore api to understand the workflow. Look forward to the update to v2.

spacecomx commented 7 years ago

@dusterio Just a side note. Swagger 3.0 is planned to be released by the end of July. The name will be changing to OpenAPI, but the tooling will continue to have the Swagger name.

spacecomx commented 7 years ago

@dusterio Do you have any feedback on the swagger v2.0 requirements. I was hoping to get the gateway up an running the weekend. If not ready, is there anyway to manually set the api endpoints without swagger so I can get up an running. I have two services that must be pushed into the gateway. Please help, thank you.

rizwanmcs commented 6 years ago

where we will define routes mapping in this project?

harunnryd commented 6 years ago

@dusterio Hi, where you able to add examples? :(

agungsugiarto commented 4 years ago

no example with swagger :(

eddycastillon commented 4 years ago

Thank you so much for this awesome gateway.  I am trying to use this one however I have a couple questions about swagger. Until I know there are two ways to generate documentation for an API using swagger.

1 - Using the public swagger editor: https://swagger.io/. It  generates API documentation and lets you share and collaborate  with people. I am able to export my documentation but I do not know how to use  the exported  documentation ( swagger.json ) to discover it. through the gateway.  I think I need to create a controller, route ,etc.

2 - Using some composer packages that generates that documentation. To generate the documentation , basically you need to use the swagger notation in each controller and function. The package exposes your documentation so the gateway can discover the service.

Based on your experience, what is the best approach to document an API.  If you use some composer package for lumen,  Could you share the name please.

Thank you

harunnryd commented 4 years ago

@eddycastillon you can use my api gateway bro :) https://github.com/harunnryd/gateid