-
目標 独自のConfigを設定する際に候補が出るようになってほしい
-
なぜほしいのか
- 書き方を覚えるのがつらい
- 自身を含めユーザーが簡単に使えるようにしたい
- 作業環境は
VisualStudio Code
を前提とする - Language Serverを利用する YAML Language Server
- 補間の定義を
settings.json
を通して渡すことができるのでProjectに定義ファイルを含める
設定パラメータはSettingsに書いてある。
ここでは以下のように使う
yaml.schemas
はkeyにJSON Schemaのpath(local or remote)を指定しvalueには設定を有効にするファイル名のglobpatternを入力する。
{
"yaml.format.enable": true,
"yaml.completion": true,
"yaml.validate": true,
"yaml.hover": true,
"yaml.schemas": {
"http://json.schemastore.org/swagger-2.0": ["*swagger.yaml", "*swagger.yml"],
},
}
- Describes youe existing data format
- Provides clear hunam- and machine- readable documentation
- Validates data which is useful for
- automated testing
- Ensuring quality of client submitted data
$schema
keyword states$id
keyword defines a URItitle
anddescription
annotation keywords are descriptive onlytype
validation keyword defines the first constraint
properties
validation keyworddescription
type
minLength
maxLength
pattern
format
exclusiveMinimum
minimum
maximum
items
type
minItems
numberuniqueItems
bool
type
= objectproperties
recrusive
This is configure of connect to DataBase with considing timezone location.
type DBConfig struct {
Name string `yaml:"name"`
Driver string `yaml:"driver"`
Hostname string `yaml:"host"`
Username string `yaml:"user"`
Password string `yaml:"pass"`
Database string `yaml:"database"`
Timezone string `yaml:"tz"`
MaxConnection int `yaml:"max_conn"`
}
- Format the JSON on VS Code
- focus the window and
RightClick -> FormatDocument(Shift+Alt+F)
- focus the window and
- Suggestion yaml
Ctrl+Space