Does gcp api gateway validate request body against OpenAPI spec before calling x-google-backend?

Google doesn't appear to be validating my request body schema or even that the request has a body when I use postman. Am I missing something? To me it's implied that google validates this sort of thing before calling the x-google-backend, but it always passes the request through to my cloud function, regardless if I pass valid data.

I'm using this question here as a guide.

/users:
    post:
      summary: Creates a new user.
      operationId: createUser
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          description: The user to create.
          required: true
          schema:
            $ref: './schemas/user.yaml'
      x-google-backend:
        address: https://us-central1-blablabla.cloudfunctions.net/blabla
      responses:
        201:
          description: Created

user.yaml:

type: object
required:
- username
- password
- repeatPassword
- email
properties:
  username:
    type: string
    minLength: 3
    maxLength: 50
  password:
    type: string
    minLength: 6
    maxLength: 64
  repeatPassword:
    type: string
    minLength: 6
    maxLength: 64
  email:
    type: string
    minLength: 3
    maxLength: 50
Solved Solved
0 1 982
1 ACCEPTED SOLUTION

As mentioned here, no. Api gateway doesn't implement any logic, OpenAPI is just a way of describing the API.

View solution in original post

1 REPLY 1

As mentioned here, no. Api gateway doesn't implement any logic, OpenAPI is just a way of describing the API.