oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

Add support for the x-order extension.

Open psyhatter opened this issue 3 years ago • 2 comments

Fix for #458. Can be used when you need to set the order of fields in the model:

    NewPet:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          x-order: 1
        tag:
          type: string
          x-order: 2

psyhatter avatar Jun 13 '22 14:06 psyhatter

I am think readme must be updated too...

funvit avatar Jun 13 '22 16:06 funvit

While this works, could it be simplified to just an x-ordered e.g.

    NewPet:
      type: object
      required:
        - name
      properties:
        x-ordered: true    
        name:
          type: string
        tag:
          type: string

This then uses the order of the properties, without having to put a flag on every field?

Alternatively a configuration flag might be nice, so you don't have to scatter x-order... throughout specs.

stevenh avatar Nov 12 '22 11:11 stevenh

Hi, all those referenced commits don't seem to exists anymore? Will this make it into master soon or any way to check the commits out directly? Is there maybe an alternative way to get ordered properties?

Pe-te avatar Jun 19 '23 08:06 Pe-te

I created this PR https://github.com/deepmap/oapi-codegen/pull/1190 based off this one, resolving issues with master and minor refactors

filintod avatar Aug 09 '23 18:08 filintod

Closed by #1190

jamietanna avatar Jan 25 '24 14:01 jamietanna