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

vendor extension inside "items" #738

Open
nickfun opened this issue Jul 24, 2020 · 1 comment
Open

vendor extension inside "items" #738

nickfun opened this issue Jul 24, 2020 · 1 comment
Labels
enhancement Functionality that has never existed in guardrail

Comments

@nickfun
Copy link
Contributor

nickfun commented Jul 24, 2020

Hey guardrail is a super great project and I love it but I'm here to report a bug:

Generating clients for akka-http. Using the maven plugin 0.59.0.

In my spec file I choose a x-jvm-type nested inside some request paramters on a Post. The generated client ends up taking String instead of the type I specified.

Example snippet:

  /v1/Services/{ServerlessServiceSid}/Builds:
    post:
      tags:
        - "Builds"
      x-jvm-package: "Serverless"
      summary: "Create a build of the service"
      operationId: "createBuild"
      parameters:
        - $ref: "#/components/parameters/ServerlessServiceSid"
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              required:
                - AssetVersions
                - FunctionVersions
                - Dependencies
              properties:
                AssetVersions:
                  type: array
                  items:
                    x-jvm-type: ServerlessFileVersionSid         # !
                    example: ZN00000000000000000000000000000000  # !
                    type: string                                 # !
                FunctionVersions:
                  type: array
                  items:
                    x-jvm-type: ServerlessFileVersionSid         # !
                    example: ZN00000000000000000000000000000000  # !
                    type: string                                 # !
                Dependencies:
                  type: string
      responses:
        201:
          description: "Created"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ServerlessBuildResource"
        400:
          $ref: '#/components/responses/BadRequest'
        404:
          $ref: '#/components/responses/NotFound'
        500:
          $ref: '#/components/responses/InternalServerError'

The generated client has this:

def createBuild(serverlessServiceSid: ServerlessServiceSid, assetVersions: Iterable[String], functionVersions: Iterable[String], dependencies: String, headers: List[HttpHeader] = Nil): EitherT[Future, ServiceClientError, CreateBuildResponse]

I expected the two Iterable[String] to be Vector[ServerlessFileVersionSid]

Have attempted a workaround of moving the #! lines above to a $ref but generated client didn't change.

@kelnos
Copy link
Member

kelnos commented Jun 3, 2021

Just some further info so I don't forget, because I got confused about this:

  • This does work for array properties in an object specified in components/schemas (or definitions for Swagger v2).
  • This does not work for array parameters specified on a request.
  • This does not work for array properties in an object specified in-line in a requestBody.

Ultimately we want to unify these things so we don't need this code in three places; they are separate because the Swagger v2 used different model representations, but the OAPI v3 parser does actually model these things the same way.

@blast-hardcheese blast-hardcheese added the enhancement Functionality that has never existed in guardrail label Oct 27, 2021
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
Projects
None yet
Development

No branches or pull requests

3 participants