Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anonymous swagger definitions generate subpar code #431

Open
tomasherman opened this issue Nov 2, 2019 · 6 comments
Open

Anonymous swagger definitions generate subpar code #431

tomasherman opened this issue Nov 2, 2019 · 6 comments
Labels
enhancement Functionality that has never existed in guardrail good first issue Does not require deep knowledge of the codebase and is easily testable help wanted Easy to moderately difficult issues that don't require deep knowledge or architectural thought question A question about usage, not necessarily requiring code changes. May involve documentation.

Comments

@tomasherman
Copy link
Contributor

Hello!

Following swagger code:

swagger: '2.0'
paths:  
  /dummy:
    post:
      operationId: dummy
      responses:
        200:
          schema:
            type: object
            properties:
              foo:
                type: string
              bar:
                type: string

generate this code:

sealed abstract class DummyResponse {
  def fold[A](handleOk: io.circe.Json => A): A = this match {
    case x: DummyResponse.Ok =>
      handleOk(x.value)
  }
}
object DummyResponse { case class Ok(value: io.circe.Json) extends DummyResponse }

I think we can do better - thoughts? I will try to tackle this myself, just want to check if there is a good reason for the code above to be generated in such a shape, without strict definition

@sbrunk
Copy link
Contributor

sbrunk commented Nov 2, 2019

I think it just hasn't been implemented yet. As discussed in #424, the same is true for anonymous request body definitions.

Since anonymous objects can be nested, it could make sense to reuse some of the machinery for generating classes from nested definitions added in #356.

@tomasherman
Copy link
Contributor Author

i see, for some reason i thought this should be supported as @hanny24 worked on it for some of our code but maybe he worked on something slightly different

@blast-hardcheese blast-hardcheese added question A question about usage, not necessarily requiring code changes. May involve documentation. help wanted Easy to moderately difficult issues that don't require deep knowledge or architectural thought good first issue Does not require deep knowledge of the codebase and is easily testable enhancement Functionality that has never existed in guardrail labels Oct 27, 2021
@blast-hardcheese
Copy link
Member

Need to circle back to confirm this is still an issue. There was a bit of work done to make nested anonymous structures work.

@tomasherman
Copy link
Contributor Author

Hello. Thanks for getting back to this. To be honest, I'm not quite sure. I don't work on a project at that would use guardrail at work anymore so it would be difficult for me to find the time to test it. Considering that, we can probably close the issue.

@blast-hardcheese
Copy link
Member

@tomasherman Considering your original issue message includes a way to reproduce, my comment was more of an intent for resolution for this issue.

I went back to categorize all open issues, this being one of them, so feel free to unsubscribe if it's too noisy, I'll do the assessment and investigation.

Thanks for your interest and contributions in the past, all the best for the future.

@tomasherman
Copy link
Contributor Author

No worries, many teams still benefit from Guardrail here in Avast and it was a lifesafer when I personally needed it. I'm glad we had a chance to (hopefully) make it better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Functionality that has never existed in guardrail good first issue Does not require deep knowledge of the codebase and is easily testable help wanted Easy to moderately difficult issues that don't require deep knowledge or architectural thought question A question about usage, not necessarily requiring code changes. May involve documentation.
Projects
None yet
Development

No branches or pull requests

3 participants