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

Incomplete OpenApiResponse #1315

Closed
LucGenetier opened this issue Aug 17, 2023 · 4 comments · Fixed by #1316
Closed

Incomplete OpenApiResponse #1315

LucGenetier opened this issue Aug 17, 2023 · 4 comments · Fixed by #1316
Assignees
Labels
type:bug A broken experience

Comments

@LucGenetier
Copy link
Contributor

LucGenetier commented Aug 17, 2023

Describe the bug
OpenApiResponse object doesn't include the schema that is included in the swagger file.

    "responses": {
      "200": {
        "description": "OK",
        "schema": {
          "format": "binary",
          "description": "The content of the file.",
          "type": "string",
          "x-ms-summary": "File Content"
        }
      },
      "default": {
        "description": "Operation Failed."
      }
    }, ...

To Reproduce

string swaggerFile = @"https://raw.githubusercontent.com/microsoft/Power-Fx/main/src/tests/Microsoft.PowerFx.Connectors.Tests/Swagger/AzureBlobStorage.json";
using HttpClient client = new HttpClient();
HttpResponseMessage webResponse = await client.GetAsync(swaggerFile).ConfigureAwait(false);
string swagger = await webResponse.Content.ReadAsStringAsync().ConfigureAwait(false);	
OpenApiDocument doc = new OpenApiStringReader().Read(swagger, out OpenApiDiagnostic diag);
OpenApiOperation op = doc.Paths["/{connectionId}/datasets/default/GetFileContentByPath"].Operations[OperationType.Get];
OpenApiResponse response = op.Responses["200"];	

Look at the response object and compare it with the swagger file
All fields/props are either null or empty.

Expected behavior
Have a way to access the schema, via Content or any other means.

Screenshots/Code Snippets
See code snippet

Additional context
It's likely related to "Produces" item which is not defined, neither locally, nor globally.
Per Swagger/OpenAPI spec, in Response object, schema SHOULD be accompanied by a relevant produces mime-type.
... but it's not mandatory.

@darrelmiller
Copy link
Member

We had an issue in a previous version where produces was required to properly read the schema. That should be fixed in the latest version of the library. What version are you using?

@LucGenetier
Copy link
Contributor Author

Latest, 1.6.6.

@darrelmiller
Copy link
Member

darrelmiller commented Aug 17, 2023

I was able to repro with this snippet

{
  "swagger": "2.0",
  "info": {
    "version": "1.0",
    "title": "Azure Blob Storage",
     },
  "host": "localhost:23340",
  "basePath": "/apim/azureblob",
  "schemes": [
    "https"
  ],
  "paths": {
    "/{connectionId}/datasets/default/GetFileContentByPath": {
      "get": {
        "tags": [
          "AzureBlobSingletonFileTransferFileData"
        ],
        "summary": "Get blob content using path",
        "description": "This operation retrieves blob contents using path.",
        "operationId": "GetFileContentByPath",
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "format": "binary",
              "description": "The content of the file.",
              "type": "string",
              "x-ms-summary": "File Content"
            }
          },
          "default": {
            "description": "Operation Failed."
          }
        },
        "deprecated": true,
        "x-ms-api-annotation": {
          "status": "Production",
          "family": "GetFileContentByPath",
          "revision": 1
        }
      }
    }
  }
}

The workaround is to add the following into the operation:

        "produces": ["application/octet-stream"],

I thought this had been fixed by #842 but apparently not. @MaggieKimani1 could you take a look at this and consider it for a 1.6.7 patch release.

@MaggieKimani1
Copy link
Contributor

@darrelmiller yeah sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug A broken experience
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants