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

Is this Support AWS API gateway integrations? #113

Open
yasirub opened this issue Apr 19, 2023 · 6 comments
Open

Is this Support AWS API gateway integrations? #113

yasirub opened this issue Apr 19, 2023 · 6 comments

Comments

@yasirub
Copy link

yasirub commented Apr 19, 2023

Hi, Is there any way to add these https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions.html extensions to the source code, so that generated API spec will have these extensions

@fredmaggiowski
Copy link
Collaborator

Hi @yasirub I don't think proprietary extension would fit with the code of the library as we would have to map them all.

With that said, extension support should be currently available on the main branch thanks to this PR. I think that with the next version tag you should be able to define the extensions you need yourself :)

@davidebianchi
Copy link
Owner

davidebianchi commented Apr 19, 2023

It's already released with 0.9.0.
You can see the example usage in this test:

gswagger/route_test.go

Lines 455 to 469 in e4154d1

{
name: "schema with extension",
routes: func(t *testing.T, router *TestRouter) {
_, err := router.AddRoute(http.MethodGet, "/users", okHandler, Definitions{
Extensions: map[string]interface{}{
"x-extension-field": map[string]string{
"foo": "bar",
},
},
})
require.NoError(t, err)
},
testPath: "/users",
fixturesPath: "testdata/extension.json",
},

@yasirub
Copy link
Author

yasirub commented Apr 20, 2023

@fredmaggiowski by source code i meant my project's code. @davidebianchi I think what you mentioned is what i was looking for. I will try it and see.

@fredmaggiowski
Copy link
Collaborator

Sounds great

@yasirub
Copy link
Author

yasirub commented Apr 21, 2023

Hi, extensions worked and I was able to generate spec.

paths:
  /users:
    get:
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  additionalProperties: false
                  properties:
                    address:
                      title: user address
                      type: string
                    groups:
                      default:
                        - users
                      items:
                        type: string
                      title: groups of the user
                      type: array
                    name:
                      example: Jane
                      title: The user name
                      type: string
                    phone:
                      title: mobile number of user
                      type: integer
                  required:
                    - name
                    - phone
                    - address
                  type: object
                type: array
          description: ''
      x-amazon-apigateway-integration:
        connectionId: $${stageVariables.dev_vpc_link}
        connectionType: VPC_LINK
        httpMethod: GET
        type: http
        uri: http://gosvc-tenant-management.elb.eu-central-1.amazonaws.com/tenants/

But I would like if there is way to sperate out schemas into component section and add a ref to it, like below

components:
  schemas:
     user:
        items:
            additionalProperties: false
            properties:
                address:
                      title: user address
                      type: string
                groups:
                      default:
                        - users
                      items:
                        type: string
                      title: groups of the user
                      type: array
                name:
                      example: Jane
                      title: The user name
                      type: string
                phone:
                      title: mobile number of user
                      type: integer
                required:
                    - name
                    - phone
                    - address
                type: object
            type: array
paths:
  /users:
    get:
      responses:
        '200':
          content:
            application/json:
              schema:
                  $ref: '#/components/schemas/user'  
          description: ' '
      x-amazon-apigateway-integration:
        connectionId: $${stageVariables.dev_vpc_link}
        connectionType: VPC_LINK
        httpMethod: GET
        type: http
        uri: http://gosvc-tenant-management.elb.eu-central-1.amazonaws.com/tenants/```

is there a way to do this?

@davidebianchi
Copy link
Owner

Ad the moment, it is only possible manually using the AddRawRoute method. With this, it is possible to write the spec on your own.
We could see to add support to components in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants