Коммит
9310126ef5
270
README.md
270
README.md
|
@ -173,275 +173,5 @@ cli:
|
|||
constant: 'pascal'
|
||||
```
|
||||
|
||||
# Available Configurations for CLI Common:
|
||||
|
||||
> **snake_naming_convention** is used as standardized naming convention in clicommon,
|
||||
> so please use snake naming convention for the new name you provided so that clicommon can
|
||||
> convert it properly according to your naming convention settings.
|
||||
|
||||
## Flatten support:
|
||||
|
||||
Sample:
|
||||
``` $(sample-cli-directive)
|
||||
modelerfour:
|
||||
# clicommon flatten depends on modelerfour's flatten
|
||||
# so please make sure modelerfour's flatten is turned on
|
||||
group-parameters: true
|
||||
flatten-models: true
|
||||
flatten-payloads: true
|
||||
cli:
|
||||
flatten:
|
||||
# turn all the flatten features on/off
|
||||
cli-flatten-set-enabled: true
|
||||
# set to true to set flatten flag for
|
||||
# - all the object schemas except has discriminator (base class)
|
||||
# - all the body parameters of operation
|
||||
cli-flatten-all: true
|
||||
# whether to overwrite the flag in swagger when cli-flatten-all is true
|
||||
cli-flatten-all-overwrite-swagger: false
|
||||
# whether to flatten the body parameters of peration
|
||||
cli-flatten-payload : true
|
||||
# whether to flatten the object schemas except has discriminator (base class)
|
||||
cli-flatten-schema: false
|
||||
# further customizatoin on flatten
|
||||
# refer to the where caluse in the directive section below fore more details
|
||||
# flatten: true|false to set selectedNode.extensions['x-ms-client-flatten'] = true|false
|
||||
cli-flatten-directive:
|
||||
- where:
|
||||
type: ResourceProviderOperation
|
||||
prop: display
|
||||
flatten: true
|
||||
|
||||
```
|
||||
|
||||
## Naming Convention:
|
||||
|
||||
> Naming convention to be used in the output of clicommon.
|
||||
> Please make sure **snake_naming_convention** is used for the name provided.
|
||||
> Samples as below:
|
||||
|
||||
``` $(sample-cli-directive)
|
||||
cli:
|
||||
naming:
|
||||
# the naming convention used for language.cli
|
||||
cli:
|
||||
appliedTo:
|
||||
- name
|
||||
- alias
|
||||
singularize:
|
||||
- operationGroup
|
||||
- operation
|
||||
override:
|
||||
cmyk : CMYK
|
||||
$host: $host
|
||||
LRO: LRO
|
||||
glossary:
|
||||
- insights
|
||||
parameter: 'camel'
|
||||
operation: 'pascal'
|
||||
operationGroup: 'pascal'
|
||||
property: 'camel'
|
||||
type: 'pascal'
|
||||
choice: 'pascal'
|
||||
choiceValue: 'pascal'
|
||||
# the naming convention used for language.default
|
||||
default:
|
||||
override:
|
||||
cmyk : CMYK
|
||||
$host: $host
|
||||
LRO: LRO
|
||||
parameter: 'camel'
|
||||
operation: 'pascal'
|
||||
operationGroup: 'pascal'
|
||||
property: 'camel'
|
||||
type: 'pascal'
|
||||
choice: 'pascal'
|
||||
choiceValue: 'pascal'
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Directive
|
||||
|
||||
> so please make sure **snake_naming_convention** is used for 'name' and 'alias' clause in directive
|
||||
> so that the naming convention configured in clicommon can be applied correctly
|
||||
> when generating the output
|
||||
|
||||
#### Supported clause in directive
|
||||
- select:
|
||||
- the target object type of directive
|
||||
- optional (then will be figured out automatically from where clause)
|
||||
- possible value: 'operationGroup' | 'operation' | 'parameter' | 'objectSchema' | 'property' | 'choiceSchema' | 'choiceValue'
|
||||
- where:
|
||||
- conditions to locate the object to apply directive
|
||||
- required
|
||||
- regex is supported in the value
|
||||
- possible search condition, refer to sample below for more detail usage:
|
||||
- search for operatoinGroup, operation or parameter
|
||||
- 'operationGroup' | 'group' | 'resource': 'operationGroupName'
|
||||
- 'operation' | 'op': 'operationName'
|
||||
- 'parameter' | 'param': 'parameterName'
|
||||
- search for schema or properties
|
||||
- 'schemaObject' | 'type' | 'object': 'schemaName'
|
||||
- 'property' | 'prop': 'propertyName'
|
||||
- search for enum or enumValue
|
||||
- 'choiceSchema' | 'enum': 'choiceName'
|
||||
- 'choiceValue' | 'value': 'choiceName'
|
||||
- set:
|
||||
- set anything property in the selected object(s)
|
||||
- optional
|
||||
- name:
|
||||
- add 'name: ...' under 'language->cli'. Please make sure **snake_naming_convention** is used
|
||||
- optional
|
||||
- description:
|
||||
- add 'description: ...' under 'language->cli'.
|
||||
- optional
|
||||
- default-value:
|
||||
- add 'default-value: ...' under 'language->cli'
|
||||
- optional
|
||||
- hidden:
|
||||
- add 'hidden: ...' under 'language->cli'.
|
||||
- optional
|
||||
- removed:
|
||||
- add 'removed: ...' under 'language->cli'.
|
||||
- optional
|
||||
- required:
|
||||
- add 'required: ...' under 'language->cli'.
|
||||
- optional
|
||||
- alias:
|
||||
- add 'alias: ...' under 'language->cli'. Please make sure **snake_naming_convention** is used
|
||||
- optional
|
||||
- json:
|
||||
- add 'json: ...' under 'language->cli'.
|
||||
- add 'x-ms-client-flatten: false' under 'extensions' if 'json: true'
|
||||
- flatten:
|
||||
- add 'x-ms-client-flatten: ..." under 'extensions'
|
||||
- formatTable:
|
||||
- add properties information under 'language->cli'.
|
||||
- optional
|
||||
- value format:
|
||||
- properties:
|
||||
- prop1Name
|
||||
- prop2Name
|
||||
- ...
|
||||
- replace:
|
||||
- do replacement
|
||||
- optional
|
||||
- value format:
|
||||
- field: 'name'
|
||||
- old: 'old_value'
|
||||
- new: 'new_value'
|
||||
- isRegex: true | false
|
||||
|
||||
#### How to troubleshooting
|
||||
> Add --debug in your command line to have more intermedia output files for troubleshooting
|
||||
|
||||
#### Samples
|
||||
|
||||
``` $(sample-cli-directive)
|
||||
cli:
|
||||
cli-directive:
|
||||
# directive on operationGroup
|
||||
- select: 'operationGroup'
|
||||
where:
|
||||
operationGroup: 'OldName'
|
||||
name: 'new_name'
|
||||
description: 'new description'
|
||||
- where:
|
||||
resource: 'OldName'
|
||||
hidden: true
|
||||
- where:
|
||||
group: 'OldName'
|
||||
removed: 'true
|
||||
# add hidden property for operation
|
||||
- where:
|
||||
group: 'GroupName'
|
||||
operation: 'OperationName'
|
||||
hidden: true
|
||||
- where:
|
||||
group: 'groupName'
|
||||
op: 'OperationName'
|
||||
hidden: true
|
||||
# add removed property for parameter
|
||||
- where:
|
||||
group: 'groupName'
|
||||
op: 'OperationName'
|
||||
parameter: 'ParameterName'
|
||||
removed: true
|
||||
- where:
|
||||
group: 'groupName'
|
||||
op: 'OperationName'
|
||||
param: 'ParameterName'
|
||||
required: true
|
||||
default-value: 'default value of the param'
|
||||
# add hidden property for all parameter start with 'abc'
|
||||
- where:
|
||||
parameter: '^abc.*$'
|
||||
hidden: true
|
||||
# set table format under for schema
|
||||
- where:
|
||||
schemaObject: 'SchemaName'
|
||||
tableFormat:
|
||||
properties:
|
||||
- 'p1'
|
||||
- 'p2'
|
||||
- where:
|
||||
type: 'SchemaName'
|
||||
tableFormat:
|
||||
properties:
|
||||
- 'p1'
|
||||
- 'p2'
|
||||
- where:
|
||||
object: 'SchemaName'
|
||||
tableFormat:
|
||||
properties:
|
||||
- 'p1'
|
||||
- 'p2'
|
||||
# set anything for schema property
|
||||
- where:
|
||||
type: 'SchemaName'
|
||||
property: 'PropertyName'
|
||||
set:
|
||||
key1: 'value1'
|
||||
key2: true
|
||||
key3:
|
||||
- v1
|
||||
- v2
|
||||
- where:
|
||||
type: 'SchemaName'
|
||||
prop: 'PropertyName'
|
||||
set:
|
||||
key1: 'value1'
|
||||
key2: true
|
||||
key3:
|
||||
- v1
|
||||
- v2
|
||||
# replac 'name_a' with 'name_b' (whole word match) in operation's name
|
||||
- where:
|
||||
group: 'GroupName'
|
||||
op: 'OperationName'
|
||||
replace:
|
||||
field: 'name'
|
||||
old: 'name_a'
|
||||
new: 'name_b'
|
||||
isRegex: false
|
||||
# replace with regex
|
||||
- where:
|
||||
group: 'GroupName'
|
||||
op: 'OperationName'
|
||||
replace:
|
||||
field: 'description'
|
||||
old: '(startByThis)(.*)'
|
||||
new: 'startByThat$2'
|
||||
isRegex: true
|
||||
# add alias for enum value
|
||||
- where:
|
||||
choiceSchema: 'choiceType'
|
||||
choiceValue: 'choiceValue'
|
||||
alias: NewAlias
|
||||
- where:
|
||||
enum: 'enumTyp'
|
||||
value: 'enumValue'
|
||||
alias: NewAlias
|
||||
```
|
||||
|
||||
|
|
|
@ -0,0 +1,194 @@
|
|||
# About cli-directive
|
||||
|
||||
## How to figure out the name for group, operation, parameter, type and property in cli directives
|
||||
For groupName, operationName, parameterName, typeName, propertyName, usually you can find them at swagger at:
|
||||
* Usually the operationId is in format {groupName}_{operationName}, and the parameterName is the parameters->name
|
||||
![group, operation and parameter's name](images/cli-directive-name1.png)
|
||||
* TypeName is the name under definitions, and the propertyName is the name under properties
|
||||
![group, operation and parameter's name](images/cli-directive-name2.png)
|
||||
|
||||
|
||||
## Name convention used in directive
|
||||
|
||||
> so please make sure **snake_naming_convention** is used for 'name' and 'alias' clause in directive
|
||||
> so that the naming convention configured in clicommon can be applied correctly
|
||||
> when generating the output
|
||||
|
||||
## Supported clause in directive
|
||||
- select:
|
||||
- the target object type of directive
|
||||
- optional (then will be figured out automatically from where clause)
|
||||
- possible value: 'operationGroup' | 'operation' | 'parameter' | 'objectSchema' | 'property' | 'choiceSchema' | 'choiceValue'
|
||||
- where:
|
||||
- conditions to locate the object to apply directive
|
||||
- required
|
||||
- regex is supported in the value
|
||||
- possible search condition, refer to sample below for more detail usage:
|
||||
- search for operatoinGroup, operation or parameter
|
||||
- 'operationGroup' | 'group' | 'resource': 'operationGroupName'
|
||||
- 'operation' | 'op': 'operationName'
|
||||
- 'parameter' | 'param': 'parameterName'
|
||||
- search for schema or properties
|
||||
- 'schemaObject' | 'type' | 'object': 'schemaName'
|
||||
- 'property' | 'prop': 'propertyName'
|
||||
- search for enum or enumValue
|
||||
- 'choiceSchema' | 'enum': 'choiceName'
|
||||
- 'choiceValue' | 'value': 'choiceName'
|
||||
- set:
|
||||
- set anything property in the selected object(s)
|
||||
- optional
|
||||
- name:
|
||||
- add 'name: ...' under 'language->cli'. Please make sure **snake_naming_convention** is used
|
||||
- optional
|
||||
- description:
|
||||
- add 'description: ...' under 'language->cli'.
|
||||
- optional
|
||||
- default-value:
|
||||
- add 'default-value: ...' under 'language->cli'
|
||||
- optional
|
||||
- hidden:
|
||||
- add 'hidden: ...' under 'language->cli'.
|
||||
- optional
|
||||
- removed:
|
||||
- add 'removed: ...' under 'language->cli'.
|
||||
- optional
|
||||
- required:
|
||||
- add 'required: ...' under 'language->cli'.
|
||||
- optional
|
||||
- alias:
|
||||
- add 'alias: ...' under 'language->cli'. Please make sure **snake_naming_convention** is used
|
||||
- optional
|
||||
- json:
|
||||
- add 'json: ...' under 'language->cli'.
|
||||
- add 'x-ms-client-flatten: false' under 'extensions' if 'json: true'
|
||||
- flatten:
|
||||
- add 'x-ms-client-flatten: ..." under 'extensions'
|
||||
- formatTable:
|
||||
- add properties information under 'language->cli'.
|
||||
- optional
|
||||
- value format:
|
||||
- properties:
|
||||
- prop1Name
|
||||
- prop2Name
|
||||
- ...
|
||||
- replace:
|
||||
- do replacement
|
||||
- optional
|
||||
- value format:
|
||||
- field: 'name'
|
||||
- old: 'old_value'
|
||||
- new: 'new_value'
|
||||
- isRegex: true | false
|
||||
|
||||
## How to troubleshooting
|
||||
> Add --debug in your command line to have more intermedia output files for troubleshooting
|
||||
|
||||
## Samples
|
||||
|
||||
``` $(sample-cli-directive)
|
||||
cli:
|
||||
cli-directive:
|
||||
# directive on operationGroup
|
||||
- select: 'operationGroup'
|
||||
where:
|
||||
operationGroup: 'OldName'
|
||||
name: 'new_name'
|
||||
description: 'new description'
|
||||
- where:
|
||||
resource: 'OldName'
|
||||
hidden: true
|
||||
- where:
|
||||
group: 'OldName'
|
||||
removed: 'true
|
||||
# add hidden property for operation
|
||||
- where:
|
||||
group: 'GroupName'
|
||||
operation: 'OperationName'
|
||||
hidden: true
|
||||
- where:
|
||||
group: 'groupName'
|
||||
op: 'OperationName'
|
||||
hidden: true
|
||||
# add removed property for parameter
|
||||
- where:
|
||||
group: 'groupName'
|
||||
op: 'OperationName'
|
||||
parameter: 'ParameterName'
|
||||
removed: true
|
||||
- where:
|
||||
group: 'groupName'
|
||||
op: 'OperationName'
|
||||
param: 'ParameterName'
|
||||
required: true
|
||||
default-value: 'default value of the param'
|
||||
# add hidden property for all parameter start with 'abc'
|
||||
- where:
|
||||
parameter: '^abc.*$'
|
||||
hidden: true
|
||||
# set table format under for schema
|
||||
- where:
|
||||
schemaObject: 'SchemaName'
|
||||
tableFormat:
|
||||
properties:
|
||||
- 'p1'
|
||||
- 'p2'
|
||||
- where:
|
||||
type: 'SchemaName'
|
||||
tableFormat:
|
||||
properties:
|
||||
- 'p1'
|
||||
- 'p2'
|
||||
- where:
|
||||
object: 'SchemaName'
|
||||
tableFormat:
|
||||
properties:
|
||||
- 'p1'
|
||||
- 'p2'
|
||||
# set anything for schema property
|
||||
- where:
|
||||
type: 'SchemaName'
|
||||
property: 'PropertyName'
|
||||
set:
|
||||
key1: 'value1'
|
||||
key2: true
|
||||
key3:
|
||||
- v1
|
||||
- v2
|
||||
- where:
|
||||
type: 'SchemaName'
|
||||
prop: 'PropertyName'
|
||||
set:
|
||||
key1: 'value1'
|
||||
key2: true
|
||||
key3:
|
||||
- v1
|
||||
- v2
|
||||
# replac 'name_a' with 'name_b' (whole word match) in operation's name
|
||||
- where:
|
||||
group: 'GroupName'
|
||||
op: 'OperationName'
|
||||
replace:
|
||||
field: 'name'
|
||||
old: 'name_a'
|
||||
new: 'name_b'
|
||||
isRegex: false
|
||||
# replace with regex
|
||||
- where:
|
||||
group: 'GroupName'
|
||||
op: 'OperationName'
|
||||
replace:
|
||||
field: 'description'
|
||||
old: '(startByThis)(.*)'
|
||||
new: 'startByThat$2'
|
||||
isRegex: true
|
||||
# add alias for enum value
|
||||
- where:
|
||||
choiceSchema: 'choiceType'
|
||||
choiceValue: 'choiceValue'
|
||||
alias: NewAlias
|
||||
- where:
|
||||
enum: 'enumTyp'
|
||||
value: 'enumValue'
|
||||
alias: NewAlias
|
||||
```
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
## Flatten support:
|
||||
|
||||
Sample:
|
||||
``` $(sample-cli-directive)
|
||||
modelerfour:
|
||||
# clicommon flatten depends on modelerfour's flatten
|
||||
# so please make sure modelerfour's flatten is turned on
|
||||
group-parameters: true
|
||||
flatten-models: true
|
||||
flatten-payloads: true
|
||||
cli:
|
||||
flatten:
|
||||
cli-flatten-set-enabled: true
|
||||
cli-flatten-all: true
|
||||
cli-flatten-payload: true
|
||||
cli-flatten-schema: false
|
||||
cli-flatten-all-overwrite-swagger: false
|
||||
cli-flatten-directive:
|
||||
- where:
|
||||
type: SchemaType
|
||||
prop: propertyName
|
||||
flatten: true
|
||||
# max properties allowed from flatten
|
||||
cli-flatten-payload-max-prop: 32
|
||||
# max complexity allowed from flatten
|
||||
# a required json argument counted as 1
|
||||
# an optional json argument counted as 0.5
|
||||
cli-flatten-payload-max-complexity: 1
|
||||
# max depth of flatten
|
||||
cli-flatten-payload-max-level: 5
|
||||
# max properties allowed from flatten of object in array to avoid json
|
||||
cli-flatten-payload-max-array-object-prop-count: 8
|
||||
# max properties allowed from flatten of sub-class as resource
|
||||
cli-flatten-payload-max-poly-as-resource-prop-count: 8
|
||||
# max properties allowed from flatten of sub-class as param
|
||||
cli-flatten-payload-max-poly-as-param-prop-count: 8
|
||||
|
||||
```
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 331 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 121 KiB |
|
@ -0,0 +1,44 @@
|
|||
## Naming Convention:
|
||||
|
||||
> Naming convention to be used in the output of clicommon.
|
||||
> Please make sure **snake_naming_convention** is used for the name provided.
|
||||
> Samples as below:
|
||||
|
||||
``` $(sample-cli-directive)
|
||||
cli:
|
||||
naming:
|
||||
# the naming convention used for language.cli
|
||||
cli:
|
||||
appliedTo:
|
||||
- name
|
||||
- alias
|
||||
singularize:
|
||||
- operationGroup
|
||||
- operation
|
||||
override:
|
||||
cmyk : CMYK
|
||||
$host: $host
|
||||
LRO: LRO
|
||||
glossary:
|
||||
- insights
|
||||
parameter: 'camel'
|
||||
operation: 'pascal'
|
||||
operationGroup: 'pascal'
|
||||
property: 'camel'
|
||||
type: 'pascal'
|
||||
choice: 'pascal'
|
||||
choiceValue: 'pascal'
|
||||
# the naming convention used for language.default
|
||||
default:
|
||||
override:
|
||||
cmyk : CMYK
|
||||
$host: $host
|
||||
LRO: LRO
|
||||
parameter: 'camel'
|
||||
operation: 'pascal'
|
||||
operationGroup: 'pascal'
|
||||
property: 'camel'
|
||||
type: 'pascal'
|
||||
choice: 'pascal'
|
||||
choiceValue: 'pascal'
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
## Other configurations
|
||||
|
||||
``` yaml
|
||||
cli:
|
||||
polymorphism:
|
||||
# if true, polymorphism parameter with 'poly-resource' marked as true will be
|
||||
# expanded into multiple operations for each subclasses
|
||||
expand-as-resource: true
|
||||
# add hidden=true to all the parameters whose properties are all hidden or constant
|
||||
auto-parameter-hidden: false
|
||||
```
|
Загрузка…
Ссылка в новой задаче