microsoft / dev-proxy

Dev Proxy is an API simulator that helps you effortlessly test your app beyond the happy path.
https://aka.ms/devproxy
MIT License
457 stars 53 forks source link

[BUG]: OpenApiSpecGeneratorPlugin generated docs don't appear valid #811

Closed andrewconnell closed 2 weeks ago

andrewconnell commented 2 weeks ago

Description

The description document created using the OpenAPI spec generator plugin doesn't appear to create valid documents as it's using an invalid data type. The generated document doesn't pass multiple validators (such as this one and this one).

Expected behaviour

Actual behaviour

When repeating the process above...

Summary:
1 failed.
(×) Error: No supported API found in the OpenAPI document.
For more information visit: "https://aka.ms/build-api-based-message-extension". 
Reasons for API incompatibility are listed below:
GET /mars-photos/api/v1/rovers/curiosity/photos: response json is empty

Steps to reproduce

Noted above in Expected behavior process

Dev Proxy Version

0.19.0

Operating system (environment)

macOS

Shell

zsh

Configuration file

{
  "$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v0.19.0/rc.schema.json",
  "plugins": [
    {
      "name": "RetryAfterPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll"
    },
    {
      "name": "GenericRandomErrorPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll",
      "configSection": "genericRandomErrorPlugin"
    },
    {
      "name": "OpenApiSpecGeneratorPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll"
    }
  ],
  "urlsToWatch": [
    "https://jsonplaceholder.typicode.com/*",
    "https://api.nasa.gov/*"
  ],
  "genericRandomErrorPlugin": {
    "errorsFile": "devproxy-errors.json"
  },
  "rate": 0,
  "logLevel": "information",
  "newVersionNotification": "stable"
}

Additional Info

No response

waldekmastykarz commented 2 weeks ago

Thanks for letting us know. I'll check it out asap

waldekmastykarz commented 2 weeks ago

I just tried reproing the issue you mentioned. The generated spec validates fine in https://apitools.dev/swagger-parser/online/:

image

But validation fails in https://www.panoptica.app/tools/api-spec. Unfortunately, beyond saying that the spec file is invalid, it doesn't tell what's wrong so it's hard to know what to fix.

I can repro the issue with TTK. I'll reach out to the team to see why it's rejecting the spec and will share an update as soon as I know more.

waldekmastykarz commented 2 weeks ago

Got a short update: it seems that TTK is looking for application/json while the generated spec includes encoding application/json; charset=utf-8. I'm going to find out more if it's something that should be adjusted in Dev Proxy or in TTK. Stay tuned

waldekmastykarz commented 2 weeks ago

Bug fixed in v0.19.1 available on Homebrew and shortly on winget