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

[BUG] OpenAPI 3.1 Validation is Skipped and Spec Not uploaded to Proxy #640

Open
jenfredwell opened this issue Feb 13, 2025 · 4 comments
Open

Comments

@jenfredwell
Copy link

Describe the bug
Based on this issue I would expect to not get a "OpenAPI 3.1 detected. Skipping policy validation." warning when creating an OpenAPI based proxy. I also expected the spec to be uploaded to the Resources directory.

Version
apigeecli version 2.9.0 date: 2025-01-22T22:34:55Z [commit: 4d20467]

To Reproduce

apigeecli apis create oas --wait=true --validate -f . --env "$APIGEE_ENV"  -t $(gcloud auth print-access-token)  --org "$PROJECT" -n openapi-3-1 --oas-name openapi-3-1.yaml --add-cors=true --target-server-name test-target

Expected behavior
I would expect the spec to be validated and uploaded to the Resources directory.

Additional context
Add any other context about the problem here.

Example openapi-3-1.yaml:

openapi: 3.1.0
info:
  title: ExampleAPI
  version: 0.1.0
servers:
- url: https://example.com/openapi_spec
paths:
  /post_endpoint:
    post:
      summary: A post endpoint
      operationId: post_endpoint_post_endpoint_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LineString'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    LineString:
      properties:
        coordinates:
          items:
            anyOf:
            - items:
              - anyOf:
                - type: number
                - type: integer
              - anyOf:
                - type: number
                - type: integer
              type: array
              maxItems: 2
              minItems: 2
            - items:
              - anyOf:
                - type: number
                - type: integer
              - anyOf:
                - type: number
                - type: integer
              - anyOf:
                - type: number
                - type: integer
              type: array
              maxItems: 3
              minItems: 3
          type: array
          minItems: 2
          title: Coordinates
        type:
          type: string
          const: LineString
          title: Type
          default: LineString
      type: object
      required:
      - coordinates
      title: LineString
      description: LineString Model
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
@srinandan
Copy link
Collaborator

The default setting for validate is false. Can you please try with --validate=true?

@srinandan
Copy link
Collaborator

I tried the same with the flag enable, you should see the following warning:

WARNING: 2025/02/14 17:49:50 generateapiv2.go:90: found references in the spec. disabling validation.
WARNING: 2025/02/14 17:49:50 oascrtapisv2.go:88: OpenAPI 3.1 detected. Skipping policy validation.

At this time apigeecli doesn't not validate OAS 3.1

@jenfredwell
Copy link
Author

Ok thanks for letting me know. Did I misunderstand this issue then?

@srinandan
Copy link
Collaborator

I suspect apigeecli will generate an API proxy if you leave validation turned off.

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

2 participants