Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preprocesing swagger.json makes operationId duplicated #145

Closed
tomplus opened this issue Feb 8, 2020 · 8 comments
Closed

preprocesing swagger.json makes operationId duplicated #145

tomplus opened this issue Feb 8, 2020 · 8 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@tomplus
Copy link
Member

tomplus commented Feb 8, 2020

The script preprocess_spec.py removes "tags" from operationId downloaded from K8s spec:

operation_id = operation_id.replace(_to_camel_case(t), '')

and it makes that some operationId's become duplicated but they should be unique.

The latest version of openapi-generator (>4.x) has additional validations which complains about that:

-attribute paths.'/apis/node.k8s.io/v1beta1/runtimeclasses/{name}'(delete).operationId is repeated
-attribute paths.'/apis/rbac.authorization.k8s.io/'(get).operationId is repeated
-attribute paths.'/apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}'(put).operationId is repeated
[~300 similar errors]

We can disable this validation or fix our script by removing this replacing step - is this replacement necessary?

@tomplus
Copy link
Member Author

tomplus commented Feb 9, 2020

It looks like this behavior is crucial. OperationId is used to build method name and we have the same name in different API versions (beta, alpha etc).

@roycaihw
Copy link
Member

Have you tried removing the replacing step?

It looks like this behavior is crucial. OperationId is used to build method name and we have the same name in different API versions (beta, alpha etc).

Yes, that's what I though it does. Without the replacing step we would have the API versions in the method names, which would be a breaking change and a more verbose UX.

Having the same method name in different API versions worked for us. Is there any reason that openapi-generator enforces unique operationID across all modules?

@tomplus
Copy link
Member Author

tomplus commented Feb 12, 2020

It's required by the OpenAPI spec: https://swagger.io/specification/#operationObject

@roycaihw
Copy link
Member

It's required by the OpenAPI spec: https://swagger.io/specification/#operationObject

Fair enough. I think keeping the old method names is a better UX and is also backwards compatible. In the meantime, I'm not sure what signals does the openapi-generator spec validation give us. If it adds value on top of the other testing we have (e.g. client e2e tests), we may consider doing things like

  1. dry-run the validation before preprocessing, and then disable validation for the processed spec
  2. remove the replacing step in preprocessing, and add a replacing step in a "postprocessing"

palnabarun added a commit to palnabarun/gen that referenced this issue Apr 27, 2020
Use v4.3.0 by default now using the OPENAPI_GENERATOR_COMMIT
variable. This can be overriden by specifying the same variable
in the SETTINGS_FILE

Also, set the `skipValidateSpec` parameter in `openapi/python.xml`
to work around
[this](kubernetes-client#145) bug.
k8s-ci-robot pushed a commit that referenced this issue Apr 28, 2020
Use v4.3.0 by default now using the OPENAPI_GENERATOR_COMMIT
variable. This can be overriden by specifying the same variable
in the SETTINGS_FILE

Also, set the `skipValidateSpec` parameter in `openapi/python.xml`
to work around
[this](#145) bug.
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 12, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 11, 2020
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

4 participants