zio / zio-http

A next-generation Scala framework for building scalable, correct, and efficient HTTP clients and servers
https://zio.dev/zio-http
Apache License 2.0
785 stars 396 forks source link

Implement a code generator that takes Smithy spec and generates zio.http.api.EndpointSpec values #1522

Open jdegoes opened 2 years ago

jdegoes commented 2 years ago

Is your feature request related to a problem? Please describe.

Some companies begin with Smithy specifications, and then proceed to implement a server that satisfies a given Smithy specification; then they will modify the Smithy specification when a change is necessary, and then re-implement the server.

Describe the solution you'd like

In order to support this spec-first driven approach to API development (rather than code-first, which is the paradigm already implemented within the zio.http.api package), we will need a code generator, which can read in a Smithy specification, and generate the corresponding zio.http.api.EndpointSpec values that declaratively describe the APIs.

Then a user can implement handlers based on the code-generated EndpointSpec values.

jdegoes commented 1 year ago

Possibly, this could be done as a plug-in to smithy4s.

jdegoes commented 1 year ago

/bounty $500

algora-pbc[bot] commented 1 year ago

💎 $500 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #1522 with your implementation plan
  2. Submit work: Create a pull request including /claim #1522 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to zio/zio-http!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🔴 @promisingcoder Jul 9, 2024, 8:00:50 AM WIP
🔴 @987Nabil Jul 23, 2024, 9:16:27 AM WIP
🔴 @YanisOUALAN Aug 20, 2024, 11:17:02 AM WIP
yisraelU commented 1 year ago

I can take on creating a PR in this repo, to have a zio-http interpreter(Smithy4s terminology). I would wait until Smithy4s 0.18 version is released as it will make it a lot easier. Happy to discuss further

saadhashmi91 commented 1 year ago

Hi, I was looking into option of using a recursion scheme(s)/fix-point parser for Smithy IDL using its ABNF spec. In particular skeuomorph has an implementation of transforming protobuf schemas. If a similar approach can be used for the parser and also leveraging smithy4s for the spec. implementation.

adamgfraser commented 1 year ago

@saadhashmi91 We would like to do this without any third party dependencies.

sideeffffect commented 1 year ago

@adamgfraser just to be clear, do you allow other ZIO Organization dependencies, like zio-schema?

adamgfraser commented 1 year ago

@sideeffffect If that functionality is necessary for something we are trying to do. For example ZIO Schema is already a dependency since it is necessary to describe arbitrary types as values as part of the endpoints API and we would basically have to implement it ourselves otherwise. But in general would not want to bring in an additional dependency if it was merely a "nice to have".

yisraelU commented 1 year ago

Hi, I was looking into option of using a recursion scheme(s)/fix-point parser for Smithy IDL using its ABNF spec. In particular skeuomorph has an implementation of transforming protobuf schemas. If a similar approach can be used for the parser and also leveraging smithy4s for the spec. implementation.

What would be the point of implementing a parser if you are trying to leverage smithy4s codegen? Also Smithy already has a parser and AST to represent it. I would recommend using that

saadhashmi91 commented 1 year ago

@yisraelU Cool, I didn't look into it in detail.

googley42 commented 10 months ago

@yisraelU I know you did some work on a smithy interpreter for zio-http - but were waiting for a new smithy 0.18 release for some extra functionality - did the release happen? were you able to use it? If so then we may be in a position to start evaluating soon

yisraelU commented 10 months ago

@googley42 yes. It was released not too long ago. Unfortunately it is taking a bit longer as I need to refactor for the rc3 version of ziohttp which has quite a few breaking changes

yisraelU commented 7 months ago

I just wanted to drop a note that I have published https://yisraelu.github.io/smithy4s-zio/

promisingcoder commented 2 months ago

/attempt

promisingcoder commented 2 months ago

/attempt #1522

987Nabil commented 2 months ago

@promisingcoder I will implement this ticket or at least find a strategy to do so together with @jdegoes on stream on the 26.07.

In general, this is not an easy task and I think you wrote in discord that you are a Scala beginner. Maybe you should try to pick some smaller issues first to get some experience.

promisingcoder commented 2 months ago

@987Nabil I currently made a parser it is still in the beginning that takes in the smithy file and generates specs for a zio server and the server is running !! it's simple and in the beginning I intend to implement this feature I understand your concern but I intend to carry on

algora-pbc[bot] commented 2 months ago

@promisingcoder: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

algora-pbc[bot] commented 2 months ago

The bounty is up for grabs! Everyone is welcome to /attempt #1522 🙌

987Nabil commented 2 months ago

/attempt 1522

Algora profile Completed bounties Tech Active attempts Options
@987Nabil    56 ZIO bounties
+ 1 bounty from 1 project
Scala
Cancel attempt
algora-pbc[bot] commented 2 months ago

@987Nabil: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

987Nabil commented 1 month ago

@jivanic-demystdata yes. I'll be on the zymposium on Friday and take a look with John on how to translate the formal syntax to code.

algora-pbc[bot] commented 1 month ago

The bounty is up for grabs! Everyone is welcome to /attempt #1522 🙌

yanisoln commented 1 month ago

/attempt #1522

Algora profile Completed bounties Tech Active attempts Options
@YanisOUALAN 1 bounty from 1 project
Cancel attempt
987Nabil commented 1 month ago

@YanisOUALAN I already started and am half way through. That's why this task is assigned to me

soujiro32167 commented 1 week ago

Reminder: this project already produces servers and clients in zio-http from Smithy spec