Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Having the UI, we must decide which path we want to go down.

Sumit Rawal answered on May 24, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers


Having the UI, we must decide which path we want to go down.

0

Write a swagger.yml file describing our API, create JSON from it, and deliver that as an asset.

Create the JSON dynamically via some library at runtime.

Which path should we take?

Let’s now compare the pros and cons of both these approaches.

Using swagger.yml Using a library

Provides a description that is more or less set in stone Provides a description that reflects our actual code

Avoids possible performance impacts and other quirks at runtime Results in generating “funny” deduced data types like Future1 and so on

We have to figure out a way to test that the service delivers what it describes Makes extensive use of annotations to make our API description usable

Tightly bounds the code and description Decouples the code and description

A common tool for the first approach is the Swagger Editor.

For those favoring the impure approach, there is the swagger-akka-http library.

But can’t we do better than this?

The answer is yes! We can describe our API using static typing, have the compiler check it, and deduce server and client code.

To be fair, Swagger is also intended to auto-generate code from it, but often (if not always), these are one-shot throw-away solutions because we lose our modifications if the code needs to be re-generated. 

Popularity 1/10 Helpfulness 1/10 Language go
Source: Grepper
Tags: go having path
Link to this answer
Share Copy Link
Contributed on May 24 2023
Sumit Rawal
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.