Name collisions with new RingCentral OpenAPI 2.0 spec and OpenAPI Generator 4.0.0
Closed this issue · 3 comments
grokify commented
Attempting to build the SDK using the new RingCentral OpenAPI 2.0 spec and OpenAPI Generator 4.0.0 SNAPSHOT (openapi-generator-cli-4.0.0-20190302.141844-340.jar) results in the following collisions.
$ go run get_me.go
../../ringcentral/api_sms_and_mms.go:42:6: DeleteMessageOpts redeclared in this block
previous declaration at ../../ringcentral/api_internal_messages.go:135:6
../../ringcentral/api_sms_and_mms.go:128:6: DeleteMessagesByFilterOpts redeclared in this block
previous declaration at ../../ringcentral/api_internal_messages.go:221:6
../../ringcentral/api_sms_and_mms.go:218:6: GetMessageAttachmentByIdOpts redeclared in this block
previous declaration at ../../ringcentral/api_internal_messages.go:311:6
../../ringcentral/api_sms_and_mms.go:314:6: ListMessagesOpts redeclared in this block
previous declaration at ../../ringcentral/api_internal_messages.go:407:6
../../ringcentral/api_sms_and_mms.go:657:6: SyncMessagesOpts redeclared in this block
previous declaration at ../../ringcentral/api_internal_messages.go:657:6
../../ringcentral/api_sms_and_mms.go:657:6: too many errors
This occurs because the API endpoint is tagged with multiple tags and OpenAPI Generator creates a non-namespaced options struct for each namespaced endpoint.
/restapi/v1.0/account/{accountId}/extension/{extensionId}/message-store/{messageId}:
get:
tags:
- Fax
- SMS and MMS
- Internal Messages
grokify commented
Possible solutions:
- only create models once if multiple tags exist. This will allow existing naming conventions to stay the same. This seems reasonable given that the multiple tags indicate the auto-generated parameter structs can be exactly the same. This is backward compatible.
- add a namespace to the opts. This is not backward compatible.
grokify commented
Some investigation into tags. If we can identify and map API service to the tag, then we can only write the Opts
struct with the first tag.
Adding the following to api.mustache
{{#tags}}
{{tags}}
{{/tags}}
Results in the following being written out in the API go
file:
[class Tag {
name: Fax
description: null
externalDocs: null
}, class Tag {
name: SMS and MMS
description: null
externalDocs: null
}, class Tag {
name: Internal Messages
description: null
externalDocs: null
}]
[class Tag {
name: Fax
description: null
externalDocs: null
}, class Tag {
name: SMS and MMS
description: null
externalDocs: null
}, class Tag {
name: Internal Messages
description: null
externalDocs: null
}]
[class Tag {
name: Fax
description: null
externalDocs: null
}, class Tag {
name: SMS and MMS
description: null
externalDocs: null
}, class Tag {
name: Internal Messages
description: null
externalDocs: null
}]
grokify commented
Closing due to new tagging approach.