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

De-Serialization issue when calling /additions/vulnerabilities with generated Swagger Client #21294

Open
RudyBricks opened this issue Dec 8, 2024 · 0 comments
Assignees
Labels

Comments

@RudyBricks
Copy link

RudyBricks commented Dec 8, 2024

I use NSwag together with the Swagger API definition provided by Harbor.
The client can be generated just find, however, when I make a call to the Swagger API to this operation:

/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/vulnerabilities

It will cause a deserialization exception in the Newtonsoft JSON library behind the generated client. I think it has something to do with the fact that the schema of the response body is defined like this:

...
      responses:
        '200':
          description: Success
          headers:
            Content-Type:
              description: The content type of the vulnerabilities addition
              type: string
          schema:
            type: string

However, the actual response will never be a JSON string literal, but rather an arbitrary JSON object. I guess this confuses the Newtonsoft parser (and most likely any other parser that would expect a regular string instead.

I suggest to just introduce an any-type there instead:

...
      responses:
        '200':
          description: Success
          headers:
            Content-Type:
              description: The content type of the vulnerabilities addition
              type: string
          schema: {}
@stonezdj stonezdj self-assigned this Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants