Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

gcloud endpoints service deploy failed to deploy

The error:
> location: "openapi-appengine.yaml: Operation \'post\' in path \'/{group_id}/bulkvisitconditions\'"
message: "Operation does not require an API key; callers may invoke the method without specifying an associated API-consuming project. To enable API key all the SecurityRequirement Objects (https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#security-requirement-object) inside security definition must reference at least one SecurityDefinition of type : \'apiKey\'."

What I am trying to do is deploy my project using pydantic 2.0 version because it is a pre-requisite for openapi library. As it is updated, our fastapi version also gets updated to a newer version (0.115.1) which generates openapi 3.1 scheme.

I know EPSv2 does not support openapi 3.1 and 3.0.
So we downgraded it via:
```
npm i -g @apiture/openapi-down-convert
openapi-down-convert --input openapi.json --output openapi-3.0.json
npm install -g api-spec-converter --unsafe-perm=true --allow-root
api-spec-converter --from=openapi_3 --to=swagger_2 --syntax=yaml --order=alpha openapi-3.0.json | sed "s/securitySchemes/securityDefinitions/g" > openapi-appengine.yaml
```

Below is the generated yaml for deployment:
```
<redacted top>
'/{group_id}/bulkvisitconditions':
post:
consumes:
- application/json
description: |-
Create visit conditions by the combination of conditions.

Visit condition names will be automatically generated.

Date range name, if provided, will be part of visit condition name.
operationId: bulk_visit_conditions__group_id__bulkvisitconditions_post
parameters:
- in: path
name: group_id
required: true
type: string
- in: header
name: X-Endpoint-API-UserInfo
required: false
type: string
- in: body
name: body
required: true
schema:
$ref: '#/definitions/BulkVisitConditionInput'
produces:
- application/json
responses:
'200':
description: Result messages
schema:
items:
$ref: '#/definitions/ReturnVisitCondition'
title: Response Bulk Visit Conditions Group Id Bulkvisitconditions Post
type: array
'400':
description: Some issues with input
schema:
$ref: '#/definitions/ResponseDetail'
'402':
description: Contract expired
schema:
$ref: '#/definitions/ResponseDetail'
'403':
description: Operation unauthorized
schema:
$ref: '#/definitions/ResponseDetail'
'422':
description: Validation Error
schema:
$ref: '#/definitions/HTTPValidationError'
'429':
description: Quota exceeded
schema:
$ref: '#/definitions/ResponseDetail'
'500':
description: Internal error
schema:
$ref: '#/definitions/ResponseDetail'
summary: Group creation by the combination of input
tags:
- General
security:
- firebase: []
- xl-api-user: []
securityDefinitions:
firebase:
authorizationUrl: ''
flow: implicit
type: oauth2
x-google-audiences: <redacted>
x-google-issuer: <redacted>
x-google-jwks_uri: <redacted>
xl-api-user:
authorizationUrl: ''
flow: implicit
type: oauth2
x-google-issuer: <redacted>
x-google-jwks_uri: <redacted>
swagger: '2.0'
x-components: {}
x-google-backend:
address: <redacted>
deadline: 300
jwt_audience: <redacted>
```

I added the api-key in the `security` and `securityDefinitions` because of the error but it is still the same.

So now I have come to ask for help why is it still failing?

I also compared our master version output of the deployment yaml file and there's no difference aside from the api-key. It deploys fine.

I wonder why it now needs a security definition of at least one type of `apiKey` when the previous yaml didn't have one and it was fine.

0 0 22