zio-http icon indicating copy to clipboard operation
zio-http copied to clipboard

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

Open jdegoes opened this issue 3 years ago • 25 comments

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 avatar Sep 19 '22 18:09 jdegoes

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

jdegoes avatar Oct 14 '22 11:10 jdegoes

/bounty $500

jdegoes avatar Apr 18 '23 09:04 jdegoes

💎 $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

algora-pbc[bot] avatar Apr 18 '23 09:04 algora-pbc[bot]

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

yisraelU avatar Apr 19 '23 15:04 yisraelU

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.

saadhashmi91 avatar May 13 '23 18:05 saadhashmi91

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

adamgfraser avatar May 13 '23 20:05 adamgfraser

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

sideeffffect avatar May 13 '23 22:05 sideeffffect

@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".

adamgfraser avatar May 13 '23 23:05 adamgfraser

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

yisraelU avatar May 14 '23 01:05 yisraelU

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

saadhashmi91 avatar May 14 '23 02:05 saadhashmi91

@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

googley42 avatar Nov 22 '23 11:11 googley42

@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 avatar Nov 22 '23 13:11 yisraelU

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

yisraelU avatar Feb 21 '24 03:02 yisraelU

/attempt

promisingcoder avatar Jul 09 '24 08:07 promisingcoder

/attempt #1522

Options

promisingcoder avatar Jul 09 '24 08:07 promisingcoder

@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.

987Nabil avatar Jul 09 '24 14:07 987Nabil

@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

promisingcoder avatar Jul 12 '24 21:07 promisingcoder

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

algora-pbc[bot] avatar Jul 16 '24 08:07 algora-pbc[bot]