Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-19888

Preserve openapi tags order while generating api-doc

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 4.0.0
    • 4.0.1, 4.1.0
    • camel-openapi-java
    • None
    • Novice

    Description

      In RestOpenApiReader.class, while aggregating the tags for api-doc, the HashMap is used instead of LinkedHashMap, which breaks the original order of the tags:

      if (openApi.getTags() != null) {
                  openApi.setTags(new ArrayList<>(
                          openApi.getTags()
                                  .stream()
                                  .collect(Collectors.toMap(
                                       Tag::getName, 
                                       Function.identity(), 
                                       (prev, current) -> prev))
                                  .values()));
      }

      A LinkedHashMap could be used instead:

      if (openApi.getTags() != null) {             
                  openApi.setTags(new ArrayList<>(
                          openApi.getTags()
                                 .stream()
                                 .collect(Collectors.toMap(
                                     Tag::getName, 
                                     Function.identity(), 
                                     (prev, current) -> prev,
                                     LinkedHashMap::new)
                                 .values()));
      } 

       

      There is no way of sorting the tags after that, and their order influences, for example, the UI of the swagger.

      Attachments

        Activity

          People

            Unassigned Unassigned
            marbom94 Jakub
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 10m
                10m
                Remaining:
                Remaining Estimate - 10m
                10m
                Logged:
                Time Spent - Not Specified
                Not Specified