Open stevenvolckaert opened 3 years ago
I could pinpoint the issue to the following:
'/esig/webportalapi/v4/packages/{packageId}/stakeholders/{stakeholderId}/actors':
post:
tags:
- Actors
summary: Creates an actor for a stakeholder
description: >
Creates an actor for a stakeholder and adds it in the first process step
that has an actor with the same type.
If no such step exists a new one is created.
**_Note_:** _all_ approvers have to come in the first step, all
receivers in the last. With no other actor types in those groups.
operationId: Actors_CreateForStakeholderWithId
parameters:
- $ref: '#/components/parameters/packageIdPathParam'
- $ref: '#/components/parameters/stakeholderIdPathParam'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CreateActor'
responses:
'201':
description: Actor was created
headers:
Location:
schema:
$ref: '#/components/headers/Location'
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/SignerActor'
- $ref: '#/components/schemas/ApproverActor'
- $ref: '#/components/schemas/ReceiverActor'
'400':
$ref: '#/components/responses/ValidationFailed'
'401':
$ref: '#/components/responses/UnAuthorized'
'404':
description: Target package or stakeholder with id could not be found
# content:
# application/json:
# schema:
# oneOf:
# - $ref: '#/components/responses/NotFound.Package'
# - $ref: '#/components/responses/NotFound.Stakeholder'
'409':
description: Actor could not be added to the stakeholder
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Error'
So your API can reply with one of the two types? How is a strong-typed language like C# supposed to work with that? What would be the return type?
For these kind of jobs, I'd try the "wrap response" option in NSwag, it seems to allow for multiple types to be returned, but I never used it.
Thanks for the suggestion. I've forwarded this error to the owners of this API (I didn't make it myself); it seems to be an error according to their support department.
It seems that the schema references a response which is not a schema and then you get the cast exception... spec seems to be wrong.
Thanks for the feedback @RicoSuter!
When I execute NSwag (
"runtime": "NetCore31"
) via NSwag.MSBuild v13.7.0 on the following file, I get a System.InvalidCastException:Any ideas what could be wrong?
The OpenAPI spec can be found in this gist: Connective.ESignatures.OpenApiSpec.v4.yaml
Many thanks for your help!
nswag.json