apache / openwhisk-wskdeploy

Apache OpenWhisk utility for deploying and managing OpenWhisk projects and packages
https://openwhisk.apache.org/
Apache License 2.0
77 stars 74 forks source link

Support for Swagger 3.x #1103

Open robertoyoc opened 4 years ago

robertoyoc commented 4 years ago

Subject of the issue

Does wskdeploy support using Swagger 3.x file? Is OpenWhisk compatible with this OAS?

Your environment Local computer where trying to deploy: OpenWhisk CLI 1.0.0 wskdeploy 1.0.0 go version go1.14.7 linux/amd64

Host: Ubuntu 18.04.4 LTS (GNU/Linux 5.3.0-1032-aws x86_64) Kubernetes Version 1.18.6 Helm version v3.2.4

Steps to reproduce I'm using the following OAS:

open_api3_spec.yaml

openapi: '3.0.0'
info:
  version: '1.0'
  title: Hello World API
servers:
  - url: 'https://<my_ip>/api'
    description: Development server

paths:
  /hello/world:
    get:
      summary: Returns greeting
      description: Returns a greeting to the user!
      parameters:
        - in: query
          name: name
          description: The name of the user
          schema:
            type: string
        - in: query
          name: place
          description: The place where the user is at
          schema:
            type: string
      responses:
        '200':
          description: Returns the greeting.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GreetingResponse'          
      operationId: getHello
      x-openwhisk:
        namespace: itio
        action: hello_world
        package: devops
        url: 'https://<my_ip>/api/v1/web/itio/devops/hello_world.json'

components:
  schemas:
    GreetingResponse:
      type: object
      properties:
        greeting:
          type: string
          description: Greeting response

x-ibm-configuration:
  assembly:
    execute:
      - operation-switch:
          title: whisk-invoke
          case:
            - operations:
                - getHello
              execute:
                - invoke:
                    target-url: 'https://<my_ip>/api/v1/web/itio/devops/hello_world.json'
                    verb: keep
          otherwise: []

manifest.json

project:
  config: 'open_api3_spec.yaml'
  packages:
    devops:
      version: 1.0
      license: Apache-2.0
      actions:
        hello_world:
          function: src/hello.js
          annotations:
            web-export: true

Then executing wskdeploy with these files.

Expected behaviour API to be created with the OAS.

Actual behaviour

Error: manifestreader.go [118]: [ERROR_YAML_FILE_FORMAT_ERROR]: File: [manifest.yaml]:
==> Unable to parse swagger file: {{.err}}

Also tried exporting a Swagger 3.0 file from Swagger Hub: swagger-export.yaml

openapi: 3.0.0
info:
  title: OpenAPIv3
  version: '1.0'
servers:
  - url: 'http://<my_ip>/api'
paths:
  /users:
    get:
      summary: Get Users
      tags: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/User'
      operationId: get-users
components:
  schemas:
    User:
      title: User
      type: object
      properties:
        id:
          type: string
        name:
          type: string

Error changed to:

error: Unable to parse swagger file: Swagger file is invalid (missing basePath, info, paths, or swagger fields)

From the error message, it says missing basePath, but this requirement is obsolete in OpenAPI 3.0.

rabbah commented 4 years ago

My guess is there are a few schema alignments necessary both in the cli/go client and in the route management package in the openwhisk repo.

Are you interested in submitting a pull request to support openapi?