kubernetes-client / gen

Common generator scripts for all client libraries
Apache License 2.0
148 stars 146 forks source link

preprocesing swagger.json makes operationId duplicated #145

Closed tomplus closed 4 years ago

tomplus commented 4 years ago

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

https://github.com/kubernetes-client/gen/blob/09f7470cab46c32e2e3458e6c98161829db88c44/openapi/preprocess_spec.py#L102

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

roycaihw commented 4 years ago

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"
fejta-bot commented 4 years ago

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

fejta-bot commented 4 years ago

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

fejta-bot commented 4 years ago

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 commented 4 years ago

@fejta-bot: Closing this issue.

In response to [this](https://github.com/kubernetes-client/gen/issues/145#issuecomment-656976593): >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](https://github.com/fejta). >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.