Kuadrant / kuadrantctl

Kuadrant configuration command line utility
Apache License 2.0
6 stars 13 forks source link

Add ability to specify top-level backendRefs #93

Open pehala opened 3 months ago

pehala commented 3 months ago

Based on https://docs.kuadrant.io/0.7.0/kuadrantctl/doc/openapi-kuadrant-extensions/, backendRefs need to specified in either path or operation, this makes it cumbersome to use in APIs that have a lot of paths but only one backend, since you need to copy the same backendRefs to every path.

I propose adding top-level backendRefs to the route to remove repetition to act as a default, if path/operation do not specify any backend.

Example:

openapi: "3.1.0"
info:
  title: "Pet Store API"
  version: "1.0.0"
  x-kuadrant:
    route:
      name: "petstore"
      namespace: "petstore"
      hostnames:
        - example.com
      parentRefs:
        - name: istio-ingressgateway
          namespace: istio-system
      backendRefs:
        - name: petstore
          port: 80
          namespace: petstore
servers:
  - url: https://example.io/api/v1
paths:
  /cat:
    get:
      operationId: "getCat"
      responses:
        405:
          description: "invalid input"
    post:  # API key
      operationId: "postCat"
      responses:
        405:
          description: "invalid input"
  /dog:
    x-kuadrant:
      backendRefs:
        - name: dogstore
          port: 80
          namespace: dogstore
    get:  # OIDC
      operationId: "getDog"
      responses:
        405:
          description: "invalid input"