DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

3 1

Do you use Swagger, or document your API?

Not sure if it is needed for GraphQL as well, as you already have GraphQL playground.

Swagger is a way of documenting REST API.

Recently, I have been using fastify (which validates schema with ajv), and integrate with OpenAPI v3 via fastify-oas. Still, I feel that it needs some more validation layers.

  • Frontend layer
  • Database layer -- I had better use SQL / ODM (on top of NoSQL)?

Top comments (6)

Collapse
 
stefanvandevooren profile image
Stefan van de Vooren

GraphQL comes out of the box with a shema graphql.org/learn/schema/. This schema can both be used in your playground as for contract based testing. So I don't see the need combine Swagger when you have GraphQL. Otherwise think Swagger is outstanding. You can generate stubs from you api swagger.io/tools/swagger-codegen/ and generate Typescript definitions from you swagger files

Collapse
 
artoodeeto profile image
aRtoo

I use swagger to document my API. What do you mean by validation? OpenAPI has a security tag that you can use.

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

JSON validation means that the server will not accept any wrong JSON schema.

Also, I have to make sure my database, especially if it is NoSQL, will not break with bad data.

Never trust user inputs.

Collapse
 
artoodeeto profile image
aRtoo

if its a public API you can use ajv I guess. But if it's within a team OpenAPI will do because the team will have to create the payload from frontend to backend.

Collapse
 
fgriberi profile image
Franco Riberi
Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

Yes, that is how I learnt about easy-to-make Swagger in the first place.

But Python is not always compatible with WebView Desktop Applications...

Also, I love TypeScript, and I feel it is better than Python for IDE.

Billboard image

Try REST API Generation for Snowflake

DevOps for Private APIs. Automate the building, securing, and documenting of internal/private REST APIs with built-in enterprise security on bare-metal, VMs, or containers.

  • Auto-generated live APIs mapped from Snowflake database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay