Eric Pugh created SOLR-18701:
--------------------------------

             Summary: Prevent duplicate v2 operation ids, which the OpenAPI 
generator suffixes with _1
                 Key: SOLR-18701
                 URL: https://issues.apache.org/jira/browse/SOLR-18701
             Project: Solr
          Issue Type: Improvement
          Components: v2 API, Build, SolrJ
            Reporter: Eric Pugh


Each v2 API interface method name becomes its OpenAPI {{operationId}}, which 
names the generated SolrJ request class and JS client method. When two 
interfaces share a method name, the generator quietly appends {{_1}} to 
whichever it sees second. As a result:

* Names like {{QueryingApi.Query1}}, {{ListSnapshots1}}, {{FetchFile1}} and 
{{CreateBackup1}} (and {{query1()}}, {{listSnapshots1()}} in the JS client) are 
part of the public client API.
* Adding an unrelated endpoint can rename an existing operation. In PR #5420 
(SOLR-18700), new Schema Designer 
{{deleteField}}/{{deleteDynamicField}}/{{deleteFieldType}} methods renamed the 
Schema API's to {{deleteField_1}} etc., which broke the Admin UI Schema screen 
({{AdminUiSchemaScreenTest.testAddAndDeleteFieldViaUi}}) and would have renamed 
SolrJ classes. Fixed there by renaming the designer methods.

Current collisions on main:
||operationId||endpoint||collides with||
|query_1|GET /\{indexType\}/\{indexName\}/select|Schema Designer query|
|listSnapshots_1|GET /cores/\{coreName\}/snapshots|collection listSnapshots|
|fetchFile_1|GET /cores/\{coreName\}/replication/files/\{filePath\}|file store 
fetchFile|
|createBackup_1|POST /cores/\{coreName\}/replication/backups|core createBackup|

Proposal:
# Add an "Operation Names" section to {{dev-docs/apis-v2-conventions.adoc}}: 
method names must be unique across all v2 interfaces, and should include the 
resource (e.g. {{deleteDesignerField}}, {{listCoreSnapshots}}).
# Rename the four colliding methods. This changes SolrJ class and JS client 
method names, so it needs upgrade notes and is probably main-only.
# Add a build check that fails when any operationId in the generated spec ends 
in {{_<n>}}.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to