Zaid-Ajaj / Hawaii

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

Microsoft Graph OpenAPI schema produces invalid code (compile errors) #52

Open varon opened 5 months ago

varon commented 5 months ago

https://github.com/microsoftgraph/msgraph-metadata/tree/master/openapi/beta

This builds a project successfully, but that project fails to compile... after 15 minutes of turning my computer into a space heater:

3>Types.fs(21895,31): Error FS1219 : The union case named 'Tags' conflicts with the generated type 'Tags'
3>Types.fs(24405,31): Error FS1219 : The union case named 'Tags' conflicts with the generated type 'Tags'
3>Client.fs(12,6): Error FS0883 : Invalid namespace, module, type or union case name
3>Client.fs(89972,71): Error FS0001 : This expression was expected to have type
    'microsoftgraphchromeOSOnboardingStatus'    
but here has type
    'string'
3>Client.fs(89989,74): Error FS0001 : This expression was expected to have type
    'microsoftgraphchromeOSOnboardingStatus'    
but here has type
    'string'
3>Client.fs(109192,82): Error FS0001 : This expression was expected to have type
    'microsoftgraphglobalDeviceHealthScriptState'    
but here has type
    'string'
3>------- Finished building project: Integrations.MicrosoftGraph. Succeeded: False. Errors: 6. Warnings: 3194
Build completed in 00:15:24.498

Schema was acquired using wget, jq and yj to get it into a suitable form:

wget https://github.com/microsoftgraph/msgraph-metadata/raw/master/openapi/beta/default.yaml
cat default.yaml | yj -yj | jq > default.json

The config is something like:

{
  "schema": "./default.json",
  "output": "../../gen/Integrations.MicrosoftGraph",
  "project": "Integrations.MicrosoftGraph",
  "synchronous": true,
  "emptyDefinitions": "free-form",
  "asyncReturnType": "task",
  "target": "fsharp"
}

Thank you for making this project as well!

Zaid-Ajaj commented 5 months ago

Hi there @varon thanks for filing the issue! Is there any chance you could provide a subset of the schema that repro the issue? I think Tags being not supported is known and the fix should be doable but the other two errors, I am not sure about.

varon commented 5 months ago

Thank you for the quick answer.

Really happy to help - but unfortunately the schema is ~58mb - it may take considerable amounts of time to do that - even editing the file is relatively painful.

Perhaps you could try the wget commands I shared?

there's an honestly insane amount of errors with it - however Kiota works - at least insofar as MSoft is able to generate their Microsoft Graph NuGet package. https://www.nuget.org/packages/Microsoft.Graph/

varon commented 5 months ago

Any thoughts? Opened up a few smaller PRs - but would love to get the Microsoft schema working with this.

Also tried to upload the schema, but it's too large: File size too big: 25 MB are allowed, 73 MB were attempted to upload.

Zaid-Ajaj commented 5 months ago

Hi @varon unfortunately I haven't had the time to dig into this properly. These days I have my hands full with my day job. I do try prioritize PR reviews and publishing new packages. Contributions are always welcome 🙏

I will keep you posted if/when I can debug this schema

varon commented 5 months ago

@Zaid-Ajaj - if you can give me some steps on how I can even go about testing/fixing this - I'm happy to give it a go - just need some guidance here.

Zaid-Ajaj commented 5 months ago

@varon the easiest way to develop with this tool is to change the contents of ./src/hawaii.config and then run the tool in debug mode (it is just an executable, no magic here)