[NETCONF-996] OpenAPI: Fix invalid swagger schema Created: 20/Apr/23  Updated: 31/May/23  Resolved: 31/May/23

Status: Resolved
Project: netconf
Component/s: restconf-openapi
Affects Version/s: None
Fix Version/s: 6.0.0, 4.0.7, 5.0.7

Type: Bug Priority: Medium
Reporter: Ivan Hrasko Assignee: Yaroslav Lastivka
Resolution: Done Votes: 0
Labels: pt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Blocks
is blocked by NETCONF-1022 OpenApi: Missing required parameters ... Resolved

 Description   

In DefinitionNames we are trying to pick a number discriminator when we have the same parameters in path. Unfortunately, this logic produces invalid schemas.

It means that we have pair-key1 in URL but pair-key in parameters. The most probable reason is that logic is not taking into account that it has to be executed for each request separately.

The error:

Semantic error at paths./rests/data/aaa-app-config:shiro-configuration/urls={pair-key1}.patch.parameters.0.name
Path parameter "pair-key" must have the corresponding {pair-key} segment in the "/rests/data/aaa-app-config:shiro-configuration/urls={pair-key1}" path
Jump to line 1589

The corresponding fragment:

 /rests/data/aaa-app-config:shiro-configuration/urls={pair-key1}:
    patch:
      description: The urls section of shiro.ini.
      summary: PATCH - aaa-app-config - urls
      tags:
        - controller aaa-app-config
      requestBody:
        content:
          application/yang-data+json:
            schema:
              $ref: '#/components/schemas/aaa-app-config_shiro-configuration_config_urls_TOP'
          application/yang-data+xml:
            schema:
              $ref: '#/components/schemas/aaa-app-config_shiro-configuration_config_urls'
        description: urls_config
      parameters:
        - name: pair-key
          description: The key.
          schema:
            type: string
          in: path
          required: true
        - name: pair-key1
          description: The key.
          schema:
            type: string
          in: path
          required: true
      responses:
        '200':
          description: OK
        '204':
          description: Updated

If you scroll up in full schema you can see at line 1452:

/rests/data/aaa-app-config:shiro-configuration/main={pair-key}:

The full schema can be seen when you insert content of http://localhost:8181/apidoc/openapi3/apis/single into https://editor.swagger.io/.


Generated at Wed Feb 07 20:16:25 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.