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]: OpenApiSpecGeneratorPlugin generated docs don't appear valid #811

Closed
andrewconnell opened this issue Jun 28, 2024 · 4 comments · Fixed by #812
Closed

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

andrewconnell opened this issue Jun 28, 2024 · 4 comments · Fixed by #812
Assignees
Labels
bug Something isn't working work in progress

Comments

@andrewconnell
Copy link

andrewconnell commented Jun 28, 2024

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

  • Update the Dev Proxy config to add support for the OpenApiSpecGeneratorPlugin.
  • Record a request using the following URL: https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?api_key=DEMO_KEY&sol=1000&camera=MAST
  • Load the generated JSON file generated by the Dev Proxy into one of the validators - it should pass.
  • Using the VSCode Teams Toolkit, create a new project using the following options:
    • Message Extension > Custom Search Results > Start with an OpenAPI Description Document
    • When prompted, select the JSON file generated by the Dev Proxy.
    • Select the only path in the description document & let the TTK wizard complete the project creation process.

Actual behaviour

When repeating the process above...

  • when validating the JSON file generated by the Dev Proxy, it fails
  • when selecting the JSON file generated by the Dev Proxy during the process of creating a new project using the TTK, it fails and displays errors in the terminal:
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

@andrewconnell andrewconnell added the bug Something isn't working label Jun 28, 2024
@waldekmastykarz
Copy link
Collaborator

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

@waldekmastykarz
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

waldekmastykarz commented Jul 1, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants