Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpha ordering of elements in components.schemas #60

Closed
jayvdb opened this issue May 21, 2020 · 3 comments
Closed

Alpha ordering of elements in components.schemas #60

jayvdb opened this issue May 21, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@jayvdb
Copy link
Contributor

jayvdb commented May 21, 2020

Describe the bug
The new alpha ordering in components.schemas is very nice, albeit I now need to find a way to verify a very large re-ordered diff, but it will be worth the pain if the new order is stable. It is a great problem to have, and im sure helpful tools abound for it.

However, I have a dejected BundleTypeEnum that has been pushed out of place to the end of the array for no apparent reason, coming from the API exposed by https://pypi.org/project/django-oscar-bundles/ . Note I am not using that API atm, so this is extremely low priority for me, and an isolated case, but it would be great to have the whole alpha ordering thing fully solved.

    ...
    BundleGroup:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        bundle_type:
          $ref: '#/components/schemas/BundleTypeEnum'
        name:
          type: string
          maxLength: 200
        headline:
          type: string
          description: CTA headline in cart display
        description:
          type: string
        image:
          type: string
          nullable: true
        triggering_parents:
          type: array
          items:
            type: integer
        suggested_parents:
          type: array
          items:
            type: integer
        concrete_bundles:
          type: array
          items:
            $ref: '#/components/schemas/InlineConcreteBundle'
        user_configurable_bundles:
          type: array
          items:
            $ref: '#/components/schemas/InlineUserConfigurableBundle'
      required:
      - concrete_bundles
      - id
      - triggering_parents
      - user_configurable_bundles
    Category:
      type: object
      properties:
        ...
    ...
    TitleEnum:
      enum:
      - Mr
      - Miss
      - Mrs
      - Ms
      - Dr
      type: string
    BundleTypeEnum:
      enum:
      - default
      type: string
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
    ...
@tfranzel
Copy link
Owner

tfranzel commented May 21, 2020

sry about that but it had to be fixed at some point.

if you want to have an easier time with the diff, temporarily change this line back for comparison:
2bdd1ab#diff-8afca2a1d5f76a5302b8d61db58a6907

honestly i didn't go all the way. components are properly sorted now, but the enums are just appended at the end in order of occurrence. i found it to be visually easier in swagger ui, but you are right. it is not 100% consistent. we should probably just sort them all flat out and be done with it forever. do you agree?

@tfranzel tfranzel added the enhancement New feature or request label May 21, 2020
@jayvdb
Copy link
Contributor Author

jayvdb commented May 22, 2020

I agree; good data docs have stable structures. Either it preserves existing ordering as found in the pre-existing doc (doable with ruamel.yaml, but painful, brittle, time consuming whackamole approach), or force sane sorting algorithm throughout. Otherwise algorithm changes cause elements to jump around.

@jayvdb
Copy link
Contributor Author

jayvdb commented May 22, 2020

Fixed on master. Thx

@jayvdb jayvdb closed this as completed May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants