Open JustinGrote opened 1 year ago
Hi @JustinGrote. Thanks for your interest in Kiota and for reaching out. We're using OpenAPI.net to parse OpenAPI descriptions and the issue comes from here
"user": {
"$ref": "#/components/schemas/CreateCompletionRequest/properties/user"
}
This property defined in one component schema is referencing another component schema property. I'm not sure whether this is a valid reference or not and I'm trying to get clarity with @darrelmiller. Either it's a valid reference and OpenAPI.net doesn't support it. In which case I'll transfer the issue over there to address it. Or it's invalid in which case the description would need to be updated. Spectral doesn't seem to be complaining about it, which would lead me to think it's valid.
Also as a side note, I believe you meant to mention the generate command and not the download one as the download one doesn't do any kind of parsing.
Also as a side note, I believe you meant to mention the generate command and not the download one as the download one doesn't do any kind of parsing.
You are correct, thanks, and nswag generates a client properly including these property references.
Follow up, @darrelmiller do you know where this needs to land? Again nswag handles it just fine, I'm using it here but would be open to trying Kiota if I can get this item fixed because it's fairly pervasive in the spec, and the swagger.io editor doesn't show any errors when opening it so I assume that it is to spec. https://github.com/JustinGrote/PowerShellAssistant/tree/main/src/OpenAI.Client
EDIT: A newer spec has been published here that removes the property references: https://github.com/openai/openai-openapi/blob/master/openapi.yaml
This one also does not generate due to the following error, but that's a separate issue.
crit: Kiota.Builder.KiotaBuilder[0]
error generating the client: One or more errors occurred. (Error creating property expand for model CreateClassificationRequest in API path \classifications, the schema is invalid.) (Error creating property expand for model CreateAnswerRequest in API path \answers, the schema is invalid.)
Excluding the \classifications
and \answers
endpoints with --exclude-path
seems to allow the client to build fine at that point.
The OpenAPI specification states that $ref can be used to point to components. OpenAPI.net has interpreted that to mean that $ref cannot point to sub-schemas of components.
We still have issues with the oneOf in the completion response of the OpenAI api and the schemas that define an array of empty schemas. I'm thinking of doing a PR to their OpenAPI to fix that.
Thanks for the context @darrelmiller . Should we transfer this to the openapi.net for further discussion and potential resolution?
@baywet We don't have plans to support non-component $refs in OpenAPI.Net. I would like to keep an issue open related to being able to support OpenAI API. The issue that @JustinGrote is experiencing has been resolved in the latest build. However, now we have this issue https://github.com/microsoft/kiota/issues/2462
I will create a new issue that is a meta issue for supporting OpenAI.
@darrelmiller where are we with this issue? Do we have enhancements that improved this situation?
Attempting to use the OpenAI specification here:
kiota download apisguru::openai.com -o openai.spec.json
Fails with
I believe this is because it is a reference to a property and maybe kiota doesn't support that yet? Works just fine in other generators.