Zaid-Ajaj / Hawaii

dotnet CLI tool to generate type-safe F# and Fable clients from OpenAPI/Swagger or OData services
MIT License
140 stars 15 forks source link

Object reference not set to an instance of an object. in create type abbreviation for array type #17

Closed tforkmann closed 3 years ago

tforkmann commented 3 years ago

Hi Zaid,

i tried out Hawaii! Pretty cool stuff.

I found one bug in a special OpenAPI from cumulocity (https://cumulocity.com/api/dist/c8y-oas.json)

If you don't have a items inside the topLevelObject if the type is array then Hawaii will fail with a Object reference not set to an instance of an object error.

Hawaii will fail here: https://github.com/Zaid-Ajaj/Hawaii/blob/0fd4e30d05a48bf238d365025a94f58617cd3190/src/Program.fs#L1569

I just wrapped a try with arround that and ignored that issue.

Could you have look into that? Maybe you have a better solution.

Thanks!

Zaid-Ajaj commented 3 years ago

Hi there Tim, I will take a look at the schema. It seems like sometimes the schema says "this is an array" without telling what the type of the underlying elements are 😞 so it has to be something generic like JArray (dotnet) or obj array (Fable)

Is this the only issue you have? I see in the schema that it uses a schema media type "application/vnd.com.nsn.cumulocity.retentionrule+json" when defining request body contents. Hawaii doesn't know about this type so some operations will probably won't have the proper request body. Can you please check that in putRetentionRuleResource operation for example?

tforkmann commented 3 years ago

Will do!

Zaid-Ajaj commented 3 years ago

Fixed as of Hawaii v0.43 🚀 @tforkmann can you give it a try? Let me know how it goes

tforkmann commented 3 years ago

Amazing!! Works :D 🚀 Thanks, Zaid!