CreateAPI / CreateAPI/CreateAPI

Sort Parameters/Refactor

Open
#149 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
447
Forks
42
PR merge metrics
No merged PRs in 30d

Description

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

```yaml
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).

```yaml
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.