flux-eco / json-schema-instance
为传输的值和模式生成JSON模式实例
1.0.0
2022-04-08 23:56 UTC
Requires
- php: >=8.0
- ext-json: *
- ext-yaml: *
README
该组件旨在为传输的值和模式生成JSON模式实例。
非常欢迎提供帮助和支持以进行开发 :-)
https://json-schema.fullstack.org.cn/specification.html
以下示例应用程序演示了用法: https://github.com/flux-caps/todo-app
用法
account.yaml
title: account
type: object
aggregateRootNames:
- account
properties:
personId:
type: number
firstname:
type: string
lastname:
type: string
email:
type: string
type:
type: string
lastChanged:
type: string
getAndPrintSchemaInstance.php
$schema = yaml_parse(file_get_contents('account.yaml'));
$schemaInstance = fluxJsonSchemaInstance\getSchemaInstance('Emmett', $schema['properties']['firstname']);
print_r($schemaInstance);
$schemaInstance = fluxJsonSchemaInstance\getSchemaInstance('123', $schema['properties']['personId']);
print_r($schemaInstance);
输出
Array
(
[value] => Emmett
[describedBy] => {"type":"string"}
)
Array
(
[value] => 123
[describedBy] => {"type":"number"}
)
贡献 💜
请 ...
- ... 在 https://git.fluxlabs.ch 注册一个账户
- ... 创建拉取请求 🔥
调整建议/错误报告 🐾
请 ...
- ... 在 https://git.fluxlabs.ch 注册一个账户
- ... 向我们请求服务水平协议: support@fluxlabs.ch 😘
- ... 阅读和创建问题