CreateAPI icon indicating copy to clipboard operation
CreateAPI copied to clipboard

Sort Parameters/Refactor

Open LePips opened this issue 3 years ago • 0 comments

Allow sorting of the parameters from generated Parameter structs for requests.

paths:
  sortQueryParameters: true || false

However, the above title poses an ambiguous problem for whether it sorts the inlined, Parameter object properties, or both. So, ignore this and refactor this entire behavior.

Taking a look at the mixture of config options paths.inlineSimpleRequests, paths.inlineSimpleQueryParameters, paths.simpleQueryParametersThreshold I think that these can be expanded and become a lot more clear with the following, mirroring the way that we do object type overrides (and soon enums).

paths:
   # default inline, which inlines all properties
  parameterType: inline || object
  # sorts all parameters
  sortParameters: true || false
  # options for defining an object parameter, but can also have some inlined parameters as well
  objectParameter: 
    # default false?
    inlineRequiredParameters: true || false
    # inlines the first n parameters, *after* sorting if true, and the rest are part of the parameter object
    inlineThreshold: 2
  parameterTypeOverrides:
    # use the operationID or eventually the JSON pointers for individual customization
    myOperation: inline
    myOtherOperation: object

I don't know how inlineRequiredParameters and inlineThreshold would work together exactly, I just thought that these options separately worked well. We can probably remove inlineThreshold and simplify to just inlineRequiredParameters, also removing the objectParameter object.

LePips avatar Aug 18 '22 19:08 LePips