j-d-carmichael / boats

Beautiful Open Api Template System
MIT License
57 stars 8 forks source link

Sort the path attributes to a standard order after injection #82

Closed j-d-carmichael closed 10 months ago

j-d-carmichael commented 1 year ago

main index might look like this:

{{
  inject([
    {
      toAllOperations: {
        excludePaths: [
          '/health'
        ],
        content: {
          tags: [ '{{ autoTag() }}' ],
          summary: '{{ autoSummary() }}',
          operationId: '{{ uniqueOpId() }}',
          'x-permission': '{{ routePermission() }}',
          security: [{
            jwtToken: []
          }],
          responses: {
            '200': {
              description: 'OK'
            },
            '400': {
              description: 'Bad Request'
            },
            '401': {
              description: 'Unauthorized'
            },
            '403': {
              description: 'Forbidden'
            },
            '406': {
              description: 'Not Acceptable'
            }
          }
        }
      }
    },
    {
      toAllOperations: {
        includeMethods: ['post', 'patch'],
        content: {
          responses: {
            '422': {
              description: 'Not Acceptable'
            }
          }
        }
      }
    }
  ])
}}

A path file like this:

parameters:
  - $ref: ../../../components/parameters/pathId.yml
responses:
  '200':
    content:
      application/json:
        schema:
          $ref: ../../../components/schemas/user/model.yml

The final output results in the order being non-standard:

parameters:
  - $ref: ../../../components/parameters/pathId.yml
responses:
  '200':
    content:
      application/json:
        schema:
          $ref: ../../../components/schemas/user/model.yml
    description: OK
  '400':
    description: Bad Request
  '401':
    description: Unauthorized
  '403':
    description: Forbidden
  '406':
    description: Not Acceptable
tags:
  - Users
summary: Get users based on {id}
operationId: usersIdGet
x-permission: userRolePermissionsReadUsersIdGet
security:
  - jwtToken: []
j-d-carmichael commented 10 months ago

resolved in 4.11.0