버전 관리 JSON Schema
7121 단어 JSONjsonschematech
이미지 사용
1행은 schemaVersion을 쓰고 발리 모드의 버전을 전환합니다.
나는 파리에 가고 싶다.yml
schemaVersion: 1.0.1
hogehoge: fugafuga
...以下略
디렉토리 구조
root
├── meta.yml
└── schemas
├── v1.0.0
│ └── config.yml
├── v1.0.1
│ └── config.yml
└── v1.1.0
└── config.yml
의 인상.meta.yml
모든 버전의 schema를 이 파일에 결합합니다. (이것은prmd로 표시된 원본 파일입니다.)
meta.yml
---
$schema: http://json-schema.org/draft-07/schema#
title: meta schema
description: バージョン管理するためのスキーマの枠
id: meta
allOf:
- if:
properties:
schemaVersion:
const: 1.0.0
then:
allOf:
- $ref: "#/definitions/v1.0.0"
- if:
properties:
schemaVersion:
const: 1.0.1
then:
allOf:
- $ref: "#/definitions/v1.0.1"
- if:
properties:
schemaVersion:
const: 1.1.0
then:
allOf:
- $ref: "#/definitions/v1.1.0"
required:
- schemaVersion
properties:
schemaVersion:
type: string
enum:
- 1.0.0
- 1.0.1
- 1.1.0
description: スキーマのバージョン
allOf
등을 사용하여 결합 후 버전을 지정할 때 이 버전의 모델을 강제한다.또한 버전 번호
1.0
등으로 사용하면 부동 소수점 수치로 간주되기 때문에 "1.0"
로 기록해야 한다.config.yml
위에 있는
meta.yml
에 연결합니다.파일 이름은 용도에 맞게 하십시오.아무거나 괜찮아요.
v1.0.0/config.yml
id: v1.0.0
title: ...
definitions:
foo: ...
bar:
type: object
properties:
foo:
$ref: "#/v1.0.0/definitions/foo" # バージョンをベタ書きする必要がある。改良したい
required: ...
additionalProperties: false
type: object
properties:
schemaVersion: # ここでも定義しないとエラーが出る。JSON Schemaの限界
type: string
...
생성 명령
JSON Schema 결합 등에 쓰이는gem, prmd(Rubby 필요).더 나은 CLI를 개발할 수 있습니다.
prmd combine -m meta.yml schemas/ -o combined.json
이로써 combined.json
에서 버전을 관리할 수 있는 JSON Schema를 결합하여 생성한다.
Reference
이 문제에 관하여(버전 관리 JSON Schema), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/ttttkkkkk/articles/6014c98d3075f3텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)