{"id":495979,"date":"2026-09-24T17:50:21","date_gmt":"2026-09-24T17:50:21","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=495979"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=495979","title":{"rendered":"\u041a\u0430\u043a \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0442\u044c \u0438\u0441\u043a\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 YAML \u0433\u043b\u0430\u0437\u0430\u043c\u0438: \u043f\u0438\u0448\u0435\u043c \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440 \u0434\u043b\u044f Go"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u041c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c YAML. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441 JSON Schema<\/h2>\n<p>\u041a\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0447\u0438\u043d\u0430\u043b \u043f\u0438\u0441\u0430\u0442\u044c <code>go-yamlvalidator<\/code>, \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u0434\u0435\u0438 \u0437\u0430 \u044d\u0442\u0438\u043c \u043d\u0435 \u0431\u044b\u043b\u043e. \u041c\u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0431\u044b\u043b \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c YAML-\u043a\u043e\u043d\u0444\u0438\u0433.<\/p>\n<p>\u042f \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e <a href=\"https:\/\/github.com\/easyp-tech\/easyp\" rel=\"noopener nofollow\">EasyP<\/a> \u2014 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Protobuf-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u043c\u0438, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043a\u043e\u0434\u0430. \u041a\u043e\u0433\u0434\u0430 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u043e\u043d\u0438 \u0447\u0430\u0441\u0442\u043e \u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0430\u043c \u0432 \u0447\u0430\u0442 EasyP \u0438 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u043b\u0438 \u0441\u0432\u043e\u0438 YAML-\u043a\u043e\u043d\u0444\u0438\u0433\u0438. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043d\u0430\u043c \u0441\u0430\u043c\u0438\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0433\u043b\u0430\u0437\u0430\u043c\u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0439 \u043e\u0442\u0441\u0442\u0443\u043f, \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0443 \u0432 \u043a\u043b\u044e\u0447\u0435 \u0438\u043b\u0438 \u0435\u0449\u0451 \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c \u043c\u0435\u043b\u043e\u0447\u044c.<\/p>\n<p>\u041f\u0440\u0438\u0447\u0451\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u0447\u0430\u0441\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u043f\u043e\u0447\u0442\u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e:<\/p>\n<pre><code class=\"yaml\">generate:  plugins:    - name: go     out: .\/gen<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0434 <code>out<\/code> \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0431\u0435\u043b\u0430.<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043e\u0448\u0438\u0431\u0438\u0442\u044c\u0441\u044f \u0438 \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443:<\/p>\n<pre><code class=\"yaml\">generate:  plugins:    - name: go        out: .\/gen<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432 \u0443\u0436\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e.<\/p>\n<p>\u0412 \u0434\u043b\u0438\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0435, \u043f\u0440\u0438\u0441\u043b\u0430\u043d\u043d\u043e\u043c \u0432 \u0447\u0430\u0442, \u0442\u0430\u043a\u0438\u0435 \u0432\u0435\u0449\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0438\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0433\u043b\u0430\u0437\u0430\u043c\u0438. YAML parser \u043e\u0448\u0438\u0431\u043a\u0443 \u043d\u0430\u0439\u0434\u0451\u0442, \u043d\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0432 \u0444\u0430\u0439\u043b\u0435, \u0430 \u043d\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u043e\u043d\u0444\u0438\u0433 \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<p>\u0411\u044b\u043b\u0438 \u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0440\u043e\u0434\u0430:<\/p>\n<pre><code class=\"yaml\">generate:  plugin:    - name: go      out: .\/gen<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e\u0442 YAML \u0443\u0436\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0430\u043b\u0438\u0434\u0435\u043d. \u0422\u043e\u043b\u044c\u043a\u043e EasyP \u043e\u0436\u0438\u0434\u0430\u0435\u0442 <code>plugins<\/code>, \u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043b <code>plugin<\/code>.<\/p>\n<p>\u0415\u0441\u0442\u044c \u0438 \u043e\u0448\u0438\u0431\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0430: \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043d\u0435\u0442, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f, \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0434\u0432\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438.<\/p>\n<p>\u041c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0432\u0441\u0451 \u044d\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0447\u0442\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0438 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0441 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0443\u0442\u0451\u043c, \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u043e\u0439.<\/p>\n<p>\u0422\u0430\u043a \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f <code>go-yamlvalidator<\/code>.<\/p>\n<h3>\u042f \u043d\u0435 \u0445\u043e\u0442\u0435\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c yaml.Unmarshal<\/h3>\n<p>\u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0434\u0435\u043b\u0430\u0442\u044c <code>yaml.Unmarshal<\/code> \u0432 Go-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<p>\u041c\u043d\u0435 \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b.<\/p>\n<p>\u042f \u0445\u043e\u0442\u0435\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u0415\u0441\u043b\u0438 \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u043c \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u0432\u0430\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 YAML \u0438 \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c.<\/p>\n<p>\u0415\u0449\u0451 \u043c\u043d\u0435 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0436\u0451\u0441\u0442\u043a\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0430 \u0441 Go-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438. \u0412 YAML \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 map, \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u0444\u043e\u0440\u043c \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 <code>yaml.Node<\/code>.<\/p>\n<p>\u0423 \u043d\u0435\u0433\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c YAML.<\/p>\n<h3>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0445\u0435\u043c\u0430<\/h3>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0440\u043e\u0438\u043b\u0430\u0441\u044c \u0432\u043e\u043a\u0440\u0443\u0433 <code>FieldSchema<\/code>.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0445\u043e\u0442\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<pre><code class=\"yaml\">name: backendport: 8080<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0434\u043b\u044f \u043d\u0435\u0433\u043e:<\/p>\n<pre><code class=\"go\">schema := &amp;yamlvalidator.FieldSchema{    Type: yamlvalidator.TypeMap,    AllowedKeys: map[string]*yamlvalidator.FieldSchema{        \"name\": {            Type:     yamlvalidator.TypeString,            Required: true,        },        \"port\": {            Type: yamlvalidator.TypeInt,        },    },}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0435\u0451:<\/p>\n<pre><code class=\"go\">validator, err := yamlvalidator.CompileFieldSchema(schema)if err != nil {    return err}result := validator.ValidateBytes(data)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u0442:<\/p>\n<pre><code class=\"yaml\">name: backendprt: 8080<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0443\u0432\u0438\u0434\u0438\u0442 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447.<\/p>\n<p>\u0415\u0441\u043b\u0438:<\/p>\n<pre><code class=\"yaml\">port:  value: 8080<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0442\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e integer \u043f\u0440\u0438\u0448\u0451\u043b map.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443\u0431\u0440\u0430\u0442\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 <code>name<\/code>, \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0434\u043b\u044f \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044f.<\/p>\n<p>\u041f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0443 <code>FieldSchema<\/code> \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c nullable-\u043f\u043e\u043b\u044f, \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u044f\u043c\u0438.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>file<\/code> \u0438 <code>url<\/code>:<\/p>\n<pre><code class=\"go\">schema.MutuallyExclusive = []string{\"file\", \"url\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u043b\u0438 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0432\u0430 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"go\">schema.OneOfRequired = [][]string{    {\"token\"},    {\"username\", \"password\"},}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0443\u0436\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f\u044b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043d\u043e \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0430 \u0446\u0435\u043b\u0438\u043a\u043e\u043c.<\/p>\n<p>\u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e <code>FieldSchema<\/code> \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u044f\u0437\u044b\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0445\u0435\u043c.<\/p>\n<p>\u0410 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 JSON Schema.<\/p>\n<h3>JSON Schema \u0434\u043b\u044f YAML<\/h3>\n<p>\u042f \u043d\u0435 \u0441\u0442\u0430\u043b \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 JSON Schema engine. \u0412\u043d\u0443\u0442\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0430 <code>go-yamlvalidator<\/code> \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u044f\u0437\u043a\u043e\u0439 \u043c\u0435\u0436\u0434\u0443 JSON Schema \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c YAML.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u0435\u0440\u0451\u043c \u043e\u0431\u044b\u0447\u043d\u0443\u044e JSON Schema:<\/p>\n<pre><code class=\"json\">{  \"type\": \"object\",  \"properties\": {    \"name\": {      \"type\": \"string\"    },    \"port\": {      \"type\": \"integer\",      \"minimum\": 1    }  },  \"required\": [\"name\"],  \"additionalProperties\": false}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c:<\/p>\n<pre><code class=\"go\">schema, err := yamlvalidator.CompileJSONSchema(schemaData)if err != nil {    return err}validator := yamlvalidator.NewValidator(schema)result := validator.ValidateBytes(yamlData)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0439 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 YAML:<\/p>\n<pre><code class=\"yaml\">name: backendport: 8080<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"yaml\">name: backendport: wrong<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>JSON Schema \u0443\u0432\u0438\u0434\u0438\u0442 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430, \u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u044d\u0442\u0443 \u043e\u0448\u0438\u0431\u043a\u0443 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043a \u0441\u0442\u0440\u043e\u043a\u0435 <code>port<\/code> \u0432 YAML.<\/p>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code>YAML  |  vyaml.Node  |  vJSON data model  |  vJSON Schema engine<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>JSON Schema \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u0434\u0430\u043d\u043d\u044b\u0445: object, array, string, number, boolean \u0438 null. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 YAML \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0432 \u0440\u044f\u0434\u043e\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 <code>yaml.Node<\/code>.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 JSON Schema \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u043f\u043e \u043f\u0443\u0442\u0438:<\/p>\n<pre><code>[\"plugins\", \"0\", \"name\"]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e YAML \u0438 \u0437\u043d\u0430\u0435\u0442 \u0435\u0433\u043e \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0443.<\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0430 \u0441\u0432\u044f\u0437\u043a\u0430 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JSON Schema validator \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e.<\/p>\n<h3>\u0421\u0432\u043e\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 Go<\/h3>\n<p>\u0421\u0445\u0435\u043c\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u043b\u044e\u0431\u0443\u044e \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0435\u0441\u0442\u044c custom validators.<\/p>\n<p>\u0414\u043b\u044f \u0447\u0430\u0441\u0442\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, enum:<\/p>\n<pre><code class=\"go\">valuevalidator.EnumValidator{    Allowed: []string{\"dev\", \"stage\", \"prod\"},}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u043b\u0438 regexp:<\/p>\n<pre><code class=\"go\">valuevalidator.RegexValidator{    Pattern: regexp.MustCompile(`^[a-z0-9-]+$`),}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u043f\u043e\u043b\u044e:<\/p>\n<pre><code class=\"go\">\"environment\": {    Type: yamlvalidator.TypeString,    Validators: []yamlvalidator.ValueValidator{        valuevalidator.EnumValidator{            Allowed: []string{\"dev\", \"stage\", \"prod\"},        },    },},<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u043e\u0433\u043e validator \u043d\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439:<\/p>\n<pre><code class=\"go\">type MyValidator struct{}func (MyValidator) Validate(    node *yaml.Node,    path string,    ctx *yamlvalidator.ValidationContext,) {    if node.Value == \"forbidden\" {        ctx.AddError(yamlvalidator.ValidationError{            Level:   yamlvalidator.LevelError,            Path:    path,            Line:    node.Line,            Column:  node.Column,            Message: \"value is forbidden\",        })    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0435\u0441\u0442\u044c \u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043b\u044e\u0447\u0435\u0439 map.<\/p>\n<h3>\u0420\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0438 JSON Schema<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f JSON Schema \u043c\u043d\u0435 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 Go.<\/p>\n<p>\u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2014 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 <code>format<\/code>.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"go\">format := yamlvalidator.JSONSchemaFormat{    Name: \"module-name\",    Validate: func(value any) error {        name, ok := value.(string)        if ok &amp;&amp; !validModuleName(name) {            return errors.New(\"invalid module name\")        }        return nil    },}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0432 JSON Schema:<\/p>\n<pre><code class=\"json\">{  \"type\": \"string\",  \"format\": \"module-name\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u0435\u0441\u0442\u044c custom keywords.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 keyword:<\/p>\n<pre><code class=\"json\">{  \"x-require-property\": \"name\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0430 \u0435\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 Go.<\/p>\n<p>\u0415\u0441\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 extensions, \u0433\u0434\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 custom keyword \u0441\u0430\u043c\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 JSON Schema.<\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0438\u043f\u044b \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e JSON Schema engine \u043d\u0430\u0440\u0443\u0436\u0443 \u043d\u0435 \u0442\u043e\u0440\u0447\u0430\u0442: extension API \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u0441\u0430\u043c\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435.<\/p>\n<h3>$ref<\/h3>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 JSON Schema.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"json\">{  \"$ref\": \"common.json\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 schemas \u043b\u0435\u0436\u0430\u0442 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <code>Resources<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0445 \u0441 \u0434\u0438\u0441\u043a\u0430, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c file resolver:<\/p>\n<pre><code class=\"go\">resolver, err := yamlvalidator.NewJSONSchemaFileResolver(schemaDir)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438:<\/p>\n<pre><code class=\"go\">schema, err := yamlvalidator.CompileJSONSchemaWithOptions(    schemaData,    yamlvalidator.JSONSchemaCompileOptions{        Resolver: resolver,    },)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u0430\u043c <code>CompileJSONSchema<\/code> \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0441 \u0434\u0438\u0441\u043a\u0430 \u043d\u0435 \u0447\u0438\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0423 CLI \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u0440\u044f\u0434\u043e\u043c \u043b\u0435\u0436\u0430\u0442:<\/p>\n<pre><code>schema.jsoncommon.json<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439:<\/p>\n<pre><code class=\"json\">{  \"$ref\": \"common.json\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 schema-\u0444\u0430\u0439\u043b\u0430.<\/p>\n<h3>\u041e\u0448\u0438\u0431\u043a\u0430 \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 validation<\/h3>\n<p>\u041e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0441\u0442\u0430\u043b\u043e \u043c\u0430\u043b\u043e.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u0443 diagnostic \u0435\u0441\u0442\u044c \u043a\u043e\u0434, \u043f\u0443\u0442\u044c, \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"go\">type ValidationError struct {    Code       string    SchemaPath string    Path string    Line int    Column int    Message  string    Got      string    Expected string    Details any}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0417\u0430 \u0441\u0447\u0451\u0442 \u044d\u0442\u043e\u0433\u043e \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u043e\u0436\u043d\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432 CLI \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u044d\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code>config.yaml:17:5unknown key \"plugin\"did you mean \"plugins\"?<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410 \u0434\u043b\u044f \u043a\u043e\u0434\u0430 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 <code>Code<\/code>, <code>Path<\/code>, <code>Line<\/code>, <code>Column<\/code> \u0438 <code>Details<\/code>.<\/p>\n<h3>\u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 JSON Schema<\/h3>\n<p>\u041c\u043d\u0435 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u00abJSON Schema\u00bb, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 JSON Schema Test Suite.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b core tests \u0442\u0430\u043a\u0438\u0435:<\/p>\n<pre><code>draft-04:   618 \/ 618draft-06:   841 \/ 841draft-07:   929 \/ 9292019-09:   1261 \/ 12612020-12:   1301 \/ 1301total:     4950 \/ 4950<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 3884 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u044b\u0445 optional tests.<\/p>\n<p>\u041e\u0434\u0438\u043d optional test draft-04 \u0438\u0441\u043a\u043b\u044e\u0447\u0451\u043d \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e: \u043e\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 <code>1<\/code> \u0438 <code>1.0<\/code> \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u0430\u043a \u043c\u0435\u0436\u0434\u0443 \u0442\u0438\u043f\u0430\u043c\u0438 host language, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 JSON Schema engine \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.<\/p>\n<p>\u0414\u043b\u044f \u043c\u0435\u043d\u044f \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441 \u00ab\u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0430\u044f JSON Schema\u00bb \u0432 \u0446\u0435\u043b\u043e\u043c \u0437\u0430\u043a\u0440\u044b\u043b\u0441\u044f.<\/p>\n<h3>\u0427\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c<\/h3>\n<p>\u0412\u0441\u0451 \u043d\u0430\u0447\u0430\u043b\u043e\u0441\u044c \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432, \u0433\u0434\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043c\u0438\u043d\u0443\u0442\u0443 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a YAML, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 <code>out<\/code> \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0431\u0435\u043b\u0430.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 Go:<\/p>\n<pre><code class=\"go\">schema := &amp;yamlvalidator.FieldSchema{    Type: yamlvalidator.TypeMap,    AllowedKeys: map[string]*yamlvalidator.FieldSchema{        \"name\": {            Type:     yamlvalidator.TypeString,            Required: true,        },    },}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u043b\u0438\u0431\u043e \u0432\u0437\u044f\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u0443\u044e JSON Schema:<\/p>\n<pre><code class=\"go\">schema, err := yamlvalidator.CompileJSONSchema(schemaData)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 YAML \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443.<\/p>\n<p>\u0415\u0441\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438, custom validators, JSON Schema extensions \u0438 <code>$ref<\/code>.<\/p>\n<p>\u0418 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0442\u044c \u043d\u0430\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u0432 \u0447\u0430\u0442, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u0433\u043b\u0430\u0437\u0430\u043c\u0438 \u0438\u0441\u043a\u0430\u043b\u0438 \u0432 \u043d\u0451\u043c \u0434\u0432\u0430 \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0440\u043e\u0431\u0435\u043b\u0430.<\/p>\n<p>\u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0440\u0430\u0437\u0443 \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0433\u0434\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0448\u0438\u0431\u0441\u044f.<\/p>\n<p>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:<\/p>\n<p><a href=\"https:\/\/github.com\/Yakwilik\/go-yamlvalidator\" rel=\"noopener nofollow\">github.com\/Yakwilik\/go-yamlvalidator<\/a><\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430:<\/p>\n<pre><code class=\"bash\">go get github.com\/Yakwilik\/go-yamlvalidator@v1.0.0<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1086386\/\">https:\/\/habr.com\/ru\/articles\/1086386\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c YAML. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441 JSON Schema\u041a\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0447\u0438\u043d\u0430\u043b \u043f\u0438\u0441\u0430\u0442\u044c go-yamlvalidator, \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u0434\u0435\u0438 \u0437\u0430 \u044d\u0442\u0438\u043c \u043d\u0435 \u0431\u044b\u043b\u043e. \u041c\u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0431\u044b\u043b \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c YAML-\u043a\u043e\u043d\u0444\u0438\u0433.\u042f \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e EasyP \u2014 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Protobuf-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u043c\u0438, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043a\u043e\u0434\u0430. \u041a\u043e\u0433\u0434\u0430 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u043e\u043d\u0438 \u0447\u0430\u0441\u0442\u043e \u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0430\u043c \u0432 \u0447\u0430\u0442 EasyP \u0438 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u043b\u0438 \u0441\u0432\u043e\u0438 YAML-\u043a\u043e\u043d\u0444\u0438\u0433\u0438. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043d\u0430\u043c \u0441\u0430\u043c\u0438\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0433\u043b\u0430\u0437\u0430\u043c\u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0439 \u043e\u0442\u0441\u0442\u0443\u043f, \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0443 \u0432 \u043a\u043b\u044e\u0447\u0435 \u0438\u043b\u0438 \u0435\u0449\u0451 \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c \u043c\u0435\u043b\u043e\u0447\u044c.\u041f\u0440\u0438\u0447\u0451\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u0447\u0430\u0441\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u043f\u043e\u0447\u0442\u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e:generate:  plugins:    &#8212; name: go     out: .\/gen\u041f\u0435\u0440\u0435\u0434 out \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0431\u0435\u043b\u0430.\u041c\u043e\u0436\u043d\u043e \u043e\u0448\u0438\u0431\u0438\u0442\u044c\u0441\u044f \u0438 \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443:generate:  plugins:    &#8212; name: go        out: .\/gen\u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432 \u0443\u0436\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e.\u0412 \u0434\u043b\u0438\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0435, \u043f\u0440\u0438\u0441\u043b\u0430\u043d\u043d\u043e\u043c \u0432 \u0447\u0430\u0442, \u0442\u0430\u043a\u0438\u0435 \u0432\u0435\u0449\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0438\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0433\u043b\u0430\u0437\u0430\u043c\u0438. YAML parser \u043e\u0448\u0438\u0431\u043a\u0443 \u043d\u0430\u0439\u0434\u0451\u0442, \u043d\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0432 \u0444\u0430\u0439\u043b\u0435, \u0430 \u043d\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u043e\u043d\u0444\u0438\u0433 \u0432\u0440\u0443\u0447\u043d\u0443\u044e.\u0411\u044b\u043b\u0438 \u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0440\u043e\u0434\u0430:generate:  plugin:    &#8212; name: go      out: .\/gen\u042d\u0442\u043e\u0442 YAML \u0443\u0436\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0430\u043b\u0438\u0434\u0435\u043d. \u0422\u043e\u043b\u044c\u043a\u043e EasyP \u043e\u0436\u0438\u0434\u0430\u0435\u0442 plugins, \u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043b plugin.\u0415\u0441\u0442\u044c \u0438 \u043e\u0448\u0438\u0431\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0430: \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043d\u0435\u0442, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f, \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0434\u0432\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438.\u041c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0432\u0441\u0451 \u044d\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0447\u0442\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0438 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0441 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0443\u0442\u0451\u043c, \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u043e\u0439.\u0422\u0430\u043a \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f go-yamlvalidator.\u042f \u043d\u0435 \u0445\u043e\u0442\u0435\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c yaml.Unmarshal\u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0434\u0435\u043b\u0430\u0442\u044c yaml.Unmarshal \u0432 Go-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442.\u041c\u043d\u0435 \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b.\u042f \u0445\u043e\u0442\u0435\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u0415\u0441\u043b\u0438 \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u043c \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u0432\u0430\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 YAML \u0438 \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c.\u0415\u0449\u0451 \u043c\u043d\u0435 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0436\u0451\u0441\u0442\u043a\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0430 \u0441 Go-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438. \u0412 YAML \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 map, \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u0444\u043e\u0440\u043c \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438.\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 yaml.Node.\u0423 \u043d\u0435\u0433\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c YAML.\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0445\u0435\u043c\u0430\u041f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0440\u043e\u0438\u043b\u0430\u0441\u044c \u0432\u043e\u043a\u0440\u0443\u0433 FieldSchema.\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0445\u043e\u0442\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430:name: backendport: 8080\u0421\u0445\u0435\u043c\u0430 \u0434\u043b\u044f \u043d\u0435\u0433\u043e:schema := &amp;yamlvalidator.FieldSchema{    Type: yamlvalidator.TypeMap,    AllowedKeys: map[string]*yamlvalidator.FieldSchema{        &#171;name&#187;: {            Type:     yamlvalidator.TypeString,            Required: true,        },        &#171;port&#187;: {            Type: yamlvalidator.TypeInt,        },    },}\u0414\u0430\u043b\u044c\u0448\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0435\u0451:validator, err := yamlvalidator.CompileFieldSchema(schema)if err != nil {    return err}result := validator.ValidateBytes(data)\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u0442:name: backendprt: 8080\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0443\u0432\u0438\u0434\u0438\u0442 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447.\u0415\u0441\u043b\u0438:port:  value: 8080\u0442\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e integer \u043f\u0440\u0438\u0448\u0451\u043b map.\u0415\u0441\u043b\u0438 \u0443\u0431\u0440\u0430\u0442\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 name, \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0434\u043b\u044f \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044f.\u041f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0443 FieldSchema \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c nullable-\u043f\u043e\u043b\u044f, \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u044f\u043c\u0438.\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 file \u0438 url:schema.MutuallyExclusive = []string{&#171;file&#187;, &#171;url&#187;}\u0418\u043b\u0438 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0432\u0430 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438:schema.OneOfRequired = [][]string{    {&#171;token&#187;},    {&#171;username&#187;, &#171;password&#187;},}\u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0443\u0436\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f\u044b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043d\u043e \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0430 \u0446\u0435\u043b\u0438\u043a\u043e\u043c.\u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e FieldSchema \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u044f\u0437\u044b\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0445\u0435\u043c.\u0410 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 JSON Schema.JSON Schema \u0434\u043b\u044f YAML\u042f \u043d\u0435 \u0441\u0442\u0430\u043b \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 JSON Schema engine. \u0412\u043d\u0443\u0442\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0430 go-yamlvalidator \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u044f\u0437\u043a\u043e\u0439 \u043c\u0435\u0436\u0434\u0443 JSON Schema \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c YAML.\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u0435\u0440\u0451\u043c \u043e\u0431\u044b\u0447\u043d\u0443\u044e JSON Schema:{  &#171;type&#187;: &#171;object&#187;,  &#171;properties&#187;: {    &#171;name&#187;: {      &#171;type&#187;: &#171;string&#187;    },    &#171;port&#187;: {      &#171;type&#187;: &#171;integer&#187;,      &#171;minimum&#187;: 1    }  },  &#171;required&#187;: [&#171;name&#187;],  &#171;additionalProperties&#187;: false}\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c:schema, err := yamlvalidator.CompileJSONSchema(schemaData)if err != nil {    return err}validator := yamlvalidator.NewValidator(schema)result := validator.ValidateBytes(yamlData)\u0410 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0439 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 YAML:name: backendport: 8080\u0418\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:name: backendport: wrongJSON Schema \u0443\u0432\u0438\u0434\u0438\u0442 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430, \u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u044d\u0442\u0443 \u043e\u0448\u0438\u0431\u043a\u0443 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043a \u0441\u0442\u0440\u043e\u043a\u0435 port \u0432 YAML.\u0412\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:YAML  |  vyaml.Node  |  vJSON data model  |  vJSON Schema engineJSON Schema \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u0434\u0430\u043d\u043d\u044b\u0445: object, array, string, number, boolean \u0438 null. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 YAML \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0432 \u0440\u044f\u0434\u043e\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 yaml.Node.\u041a\u043e\u0433\u0434\u0430 JSON Schema \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u043f\u043e \u043f\u0443\u0442\u0438:[&#171;plugins&#187;, &#171;0&#187;, &#171;name&#187;]\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e YAML \u0438 \u0437\u043d\u0430\u0435\u0442 \u0435\u0433\u043e \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0443.\u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0430 \u0441\u0432\u044f\u0437\u043a\u0430 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JSON Schema validator \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e.\u0421\u0432\u043e\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 Go\u0421\u0445\u0435\u043c\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u043b\u044e\u0431\u0443\u044e \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0435\u0441\u0442\u044c custom validators.\u0414\u043b\u044f \u0447\u0430\u0441\u0442\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435.\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, enum:valuevalidator.EnumValidator{    Allowed: []string{&#171;dev&#187;, &#171;stage&#187;, &#171;prod&#187;},}\u0418\u043b\u0438 regexp:valuevalidator.RegexValidator{    Pattern: regexp.MustCompile(`^[a-z0-9-]+$`),}\u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u043f\u043e\u043b\u044e:&#187;environment&#187;: {    Type: yamlvalidator.TypeString,    Validators: []yamlvalidator.ValueValidator{        valuevalidator.EnumValidator{            Allowed: []string{&#171;dev&#187;, &#171;stage&#187;, &#171;prod&#187;},        },    },},\u0415\u0441\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u043e\u0433\u043e validator \u043d\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439:type MyValidator struct{}func (MyValidator) Validate(    node *yaml.Node,    path string,    ctx *yamlvalidator.ValidationContext,) {    if node.Value == &#171;forbidden&#187; {        ctx.AddError(yamlvalidator.ValidationError{            Level:   yamlvalidator.LevelError,            Path:    path,            Line:    node.Line,            Column:  node.Column,            Message: &#171;value is forbidden&#187;,        })    }}\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0435\u0441\u0442\u044c \u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043b\u044e\u0447\u0435\u0439 map.\u0420\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0438 JSON Schema\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f JSON Schema \u043c\u043d\u0435 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 Go.\u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2014 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 format.\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:format := yamlvalidator.JSONSchemaFormat{    Name: &#171;module-name&#187;,    Validate: func(value any) error {        name, ok := value.(string)        if ok &amp;&amp; !validModuleName(name) {            return errors.New(&#171;invalid module name&#187;)        }        return nil    },}\u041f\u043e\u0441\u043b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0432 JSON Schema:{  &#171;type&#187;: &#171;string&#187;,  &#171;format&#187;: &#171;module-name&#187;}\u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u0435\u0441\u0442\u044c custom keywords.\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 keyword:{  &#171;x-require-property&#187;: &#171;name&#187;}\u0430 \u0435\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 Go.\u0415\u0441\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 extensions, \u0433\u0434\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 custom keyword \u0441\u0430\u043c\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 JSON Schema.\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0438\u043f\u044b \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e JSON Schema engine \u043d\u0430\u0440\u0443\u0436\u0443 \u043d\u0435 \u0442\u043e\u0440\u0447\u0430\u0442: extension API \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u0441\u0430\u043c\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435.$ref\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 JSON Schema.\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:{  &#171;$ref&#187;: &#171;common.json&#187;}\u0415\u0441\u043b\u0438 schemas \u043b\u0435\u0436\u0430\u0442 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 Resources.\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0445 \u0441 \u0434\u0438\u0441\u043a\u0430, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c file resolver:resolver, err := yamlvalidator.NewJSONSchemaFileResolver(schemaDir)\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438:schema, err := yamlvalidator.CompileJSONSchemaWithOptions(    schemaData,    yamlvalidator.JSONSchemaCompileOptions{        Resolver: resolver,    },)\u0421\u0430\u043c CompileJSONSchema \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0441 \u0434\u0438\u0441\u043a\u0430 \u043d\u0435 \u0447\u0438\u0442\u0430\u0435\u0442.\u0423 CLI \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u0440\u044f\u0434\u043e\u043c \u043b\u0435\u0436\u0430\u0442:schema.jsoncommon.json\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439:{  &#171;$ref&#187;: &#171;common.json&#187;}\u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 schema-\u0444\u0430\u0439\u043b\u0430.\u041e\u0448\u0438\u0431\u043a\u0430 \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 validation\u041e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0441\u0442\u0430\u043b\u043e \u043c\u0430\u043b\u043e.\u0421\u0435\u0439\u0447\u0430\u0441 \u0443 diagnostic \u0435\u0441\u0442\u044c \u043a\u043e\u0434, \u043f\u0443\u0442\u044c, \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:type ValidationError struct {    Code       string    SchemaPath string    Path string    Line int    Column int    Message  string    Got      string    Expected string    Details any}\u0417\u0430 \u0441\u0447\u0451\u0442 \u044d\u0442\u043e\u0433\u043e \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u043e\u0436\u043d\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432 CLI \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435.\u0414\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u044d\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:config.yaml:17:5unknown key &#171;plugin&#187;did you mean &#171;plugins&#187;?\u0410 \u0434\u043b\u044f \u043a\u043e\u0434\u0430 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 Code, Path, Line, Column \u0438 Details.\u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 JSON Schema\u041c\u043d\u0435 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u00abJSON Schema\u00bb, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445.\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 JSON Schema Test Suite.\u0421\u0435\u0439\u0447\u0430\u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b core tests \u0442\u0430\u043a\u0438\u0435:draft-04:   618 \/ 618draft-06:   841 \/ 841draft-07:   929 \/ 9292019-09:   1261 \/ 12612020-12:   1301 \/ 1301total:     4950 \/ 4950\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 3884 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u044b\u0445 optional tests.\u041e\u0434\u0438\u043d optional test draft-04 \u0438\u0441\u043a\u043b\u044e\u0447\u0451\u043d \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e: \u043e\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 1 \u0438 1.0 \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u0430\u043a \u043c\u0435\u0436\u0434\u0443 \u0442\u0438\u043f\u0430\u043c\u0438 host language, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 JSON Schema engine \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.\u0414\u043b\u044f \u043c\u0435\u043d\u044f \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441 \u00ab\u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0430\u044f JSON Schema\u00bb \u0432 \u0446\u0435\u043b\u043e\u043c \u0437\u0430\u043a\u0440\u044b\u043b\u0441\u044f.\u0427\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c\u0412\u0441\u0451 \u043d\u0430\u0447\u0430\u043b\u043e\u0441\u044c \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432, \u0433\u0434\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043c\u0438\u043d\u0443\u0442\u0443 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a YAML, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 out \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0431\u0435\u043b\u0430.\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 Go:schema := &amp;yamlvalidator.FieldSchema{    Type: yamlvalidator.TypeMap,    AllowedKeys: map[string]*yamlvalidator.FieldSchema{        &#171;name&#187;: {            Type:     yamlvalidator.TypeString,            Required: true,        },    },}\u043b\u0438\u0431\u043e \u0432\u0437\u044f\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u0443\u044e JSON Schema:schema, err := yamlvalidator.CompileJSONSchema(schemaData)\u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 YAML \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443.\u0415\u0441\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438, custom validators, JSON Schema extensions \u0438 $ref.\u0418 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0442\u044c \u043d\u0430\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u0432 \u0447\u0430\u0442, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u0433\u043b\u0430\u0437\u0430\u043c\u0438 \u0438\u0441\u043a\u0430\u043b\u0438 \u0432 \u043d\u0451\u043c \u0434\u0432\u0430 \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0440\u043e\u0431\u0435\u043b\u0430.\u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0440\u0430\u0437\u0443 \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0433\u0434\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0448\u0438\u0431\u0441\u044f.\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:github.com\/Yakwilik\/go-yamlvalidator\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430:go get&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-495979","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/495979","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=495979"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/495979\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=495979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=495979"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=495979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}