Closed astrid-eai closed 1 year ago
@astrid-eai
When I generate an SDK from that Swagger above I am getting a model testApi.Models.Test
.
One frequent confusion point is that the IGetTestResponse
interface won't have a GetBodyAsync()
method with a model on it. You must us .AsOk()
or typecast to GetTestOkResponse
to ensure that the response was successful. This is because errors may often have a different schema. .AsOk()
will throw an exception if it was not a 200 response. Or you can use a switch statement to test for GetTestOkResponse
and use different logic depending on the type. With version 3.0.1 you can also typecast to IOperationResponse<Test>
as another approach.
If this isn't your problem, hopefully we can keep looking for other possible causes for the difference.
That was it. Thank you for finding what I was missing.
I'm having an issue where the client is generating, but when I use it for a get request, it's not including any models for the response. I'm sorry that description feels vague. I'm not sure what the right words are to describe it.
When I open the nuget package as a zip file, and look at the xml in lib/net6.0, it doesn't include any models at testApi.Models, but the models are there if I use the centeredge-cardsystemapi.yaml in the comandLine project. I'm probably just missing something obvious.
Here's the generate command I'm using:
generate -i swagger.json -n testApi -f net6.0 -x Yardarm.SystemTextJson Yardarm.MicrosoftExtensionsHttp -v 1.0.0 --nupkg output/directory/ --embed
Here's an minimized example swagger that I'm seeing the issue with.{ "openapi": "3.0.1", "info": { "title": "test.api", "version": "1.0" }, "paths": { "/api/Test/{id}": { "get": { "tags": [ "Test" ], "operationId": "GetTest", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "integer", "format": "int32" } } ], "responses": { "200": { "description": "Success", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Test" } } } } }, "security": [ { "JWT": [ ] } ] } } }, "components": { "schemas": { "Test": { "type": "object", "properties": { "testId": { "type": "integer", "format": "int32" }, "stateId": { "type": "integer", "format": "int32" }, "region": { "type": "string", "nullable": true }, "county": { "type": "string", "nullable": true }, "title": { "type": "string", "nullable": true }, "city": { "type": "string", "nullable": true }, "state": { "type": "string", "nullable": true }, "modDate": { "type": "string", "format": "date-time", "nullable": true }, "modAdminId": { "type": "string", "format": "uuid", "nullable": true }, "accountType": { "type": "integer", "format": "int32" }, "status": { "type": "integer", "format": "int32" }, "demoAccount": { "type": "boolean" }, "timezoneId": { "type": "integer", "format": "int32", "nullable": true } }, "additionalProperties": false } }, "securitySchemes": { "JWT": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } } } }