sdk-codegen
sdk-codegen copied to clipboard
openapi-generator validation error in API v4 json files
When running validate on the 4.0 spec files it fails with the error
openapi-generator validate -i spec/Looker.4.0.oas.json
Validating spec (spec/Looker.4.0.oas.json)
Errors:
- attribute
paths.'/models/{model_name}/views/{view_name}/fields/{field_name}/suggestions'(get).parameters.[filters].additionalProperties
is unexpected
[error] Spec has 1 errors.
This error occurs for both the swagger 2 and oas files.
I am using v5.4.0 of the generator
openapi-generator-cli 5.4.0
commit : 4a36be7
built : 2022-01-31T05:31:36Z
source : https://github.com/openapitools/openapi-generator
docs : https://openapi-generator.tech/
This is the error can be fixed by moving the additionalProperties under schema
{
"name": "filters",
"in": "query",
"description": "Suggestion filters with field name keys and comparison expressions",
"required": false,
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
I can create a PR for this fix if this issue is accepted
Thanks for documenting this issue so clearly. That's an interesting change.
Unfortunately, there's upstream changes (on the Looker API server) that would need to be changed to address this.
More background is provided below, but what is the goal that this validation error is blocking for you? Is some language generator failing now?
These spec files are pulled directly from the Looker server, which provides only Swagger 2.x specs with some custom Looker-specific attributes which are then converted by the spec converter we wrote to make it compatible OpenAPI 3.x, so your PR would get overwritten whenever we pull the latest spec. Treat them as read-only. So there's changes that need to be made upstream from this repository for Swagger 2.x to pass. Do you know when this validation issue started appearing? The original work on this spec conversion had not validation errors so I'm curious.
I'm not sure when this issue first appeared. I noticed it the day I created the issue which was the first day I started looking a this repo.
I was trying to use the spec file with the openapi-generator to create php files. It was failing with that creation and creating some invalid models. I can provide more details on those specific errors later if you'd like.
I was hoping to raise this issue again since we have an upcoming deadline to upgrade from Looker API v3.1 to v4.0 by June. It would be really helpful if the Looker dev team could address this as soon as possible.
Our application heavily relies on Looker's API for scheduled plans, so resolving this issue is critical for us. If there are any updates or workarounds that you could provide, we would greatly appreciate it.
Thanks a ton for your attention to this matter. We're eagerly awaiting your response and looking forward to getting this sorted out before the June deadline.
@alyceJake you can use swagger-codegen to generate SDK for API 4.0 https://github.com/swagger-api/swagger-codegen#getting-started
To use yarn legacy php
You can turn off the spec validation and complete the PHP gen by adding skip validation to the call to generate PHP
with the added --skip-validate-spec below.
return run('openapi-generator-cli', [
'generate',
'--skip-validate-spec',
'-i',
fileName,
'-g',
language,
'-o',
apiPath,
'--enable-post-process-file',
options,
])