meshapi / grpc-api-gateway

Flexible and fast gRPC to HTTP and OpenAPI interface
https://meshapi.github.io/grpc-api-gateway/
GNU General Public License v3.0
11 stars 0 forks source link

Unable to parse YAML config as Json #16

Open WizMe-M opened 2 weeks ago

WizMe-M commented 2 weeks ago

Context

I use local plugin from last release and buf.gen.yaml my config is:

inputs:
- directory: .
  paths:
  - module\api\service\ 

plugins:
  - local: ../../third_party/protoc-gen-openapiv3.exe # current dir is proto root
    out: gen/swagger/v3
    opt:
      - openapi_config=my_api_config.yaml

Actual behavior

When I call buf generate --template my_buf.gen.yaml (from proto root dir) openapi plugin responds with error:

protoc-gen-openapiv3.exe: failed to load global OpenAPI config file: failed to JSON marshal content: json: unsupported type: map[interface {}]interface {}

Expected behavior

No error and merged swagger for all services in module/api/service was generated

peymanmortazavi commented 2 weeks ago

@WizMe-M could I possibly see your my_api_config.yaml.

I think this is something we need to resolve but I want to first ensure the problem is what I think it is. I bet when we load the YAML file, we get any as the key but JSON does NOT allow any or interface{} as the JSON keys, thus the issue.

WizMe-M commented 2 weeks ago

Ah... I'm so sorry, I can't reproduce this issue. I fixed it by accident and don't know what was the problem. Pretty sure that it was located somewhere

services:
  selector: '.v1.FooService'
    methods:
      FooBar:
        responses: # there

I was trying to add docs for default (200) response. iirc, it was either ref option, or name of response code (I named it without quotes at first).

I guess the root of the problem was in quotes for response code

peymanmortazavi commented 2 weeks ago

@WizMe-M Ah yeah that makes sense. I'd like to, at some point, improve that. I'll keep this issue open so we can track it.