Git Product home page Git Product logo

Comments (8)

Bosn avatar Bosn commented on June 2, 2024

应该是toJSONSchema吧

from mock.

nuysoft avatar nuysoft commented on June 2, 2024

@Bosn

from mock.

nuysoft avatar nuysoft commented on June 2, 2024

2014.12.24 纪要

@nuysoft @Bosn @蒋壮

  1. RAP 输出的 JSON Schema 需要把数据的规则结构化

    完善输出的 JSON Schema,对应的 Java 代码在 这里

    常用类型:Number,String

  2. 占位符(标签)

    1. RAP 原封不动的输出

    2. IF-Test 和 Mock 共建占位符(标签)基础库

    3. IF-Test 扩展的占位符(标签)可以共用在 RAP 和 IF-Test(包括验证)

    4. IF-Test 建立占位符(标签)的验证规则

      Mock.js 也会扩展和建立占位符(标签)的验证规则,但是不用在 Mock-RAP-IFTest 的生态里。参考 river/mock/blob/master/lib/river-mock.js

      优先保证占位符(标签)基础库的一致。

  3. Mock Service 验证

占位符(标签)基础库

2014.12.24

Type Method
Basics boolean, natural, integer, float, character, string
Date date, time, datetime
Image image
Web url, domain, email, ip

DDDeadLine

2014.12.26

  1. 确定占位符(标签)基础库的方法签名和行为
  2. 前面的第 1 条

from mock.

paolier avatar paolier commented on June 2, 2024

占位符标签的基础库,已经开发完成尽办。简单举个例子:
如下是是个jsonchema:

{
    "title": "custom format attribute demonstration",
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "naturalNum": {
                "type": "number",
                "iftest": "@natural(5,10)"
            },
            "isSuccess": {
                "type": "boolean",
                "iftest": "@boolean(5,10)"
            },
            "userMock": {
                "type": "string",
                "iftest": "@mock=sdff"
            }
        }
    }
}

下面是data:

[
    {
        "naturalNum":456
    },
    {
        "isSuccess":false
    },
    {
        "userMock":"sdff"
    }
]

结果是:

--- BEGIN MESSAGES ---
error: 超出范围
    level: "error"
    schema: {"loadingURI":"#","pointer":"/items/properties/naturalNum"}
    instance: {"pointer":"/0/naturalNum"}
    domain: "validation"
    keyword: "iftest"
    argumentList: ["5","10"]
    failed: ["456"]
---  END MESSAGES  ---

rap这边需要调整的是querySchema接口,对于原本

"format":"MOCKJS|A-PART|B-PART"

的输出要更改为:

"iftest":"A-PART|B-PART"

@Bosn @nuysoft 明天找个15分钟我们电话会议下

from mock.

paolier avatar paolier commented on June 2, 2024

会议纪要:
1、@Bosn 按照如上修改querySchema接口
2、DEADLINE为:1月23日(周五)完成,包括开发机部署

感谢!么么哒!

from mock.

paolier avatar paolier commented on June 2, 2024

type:web的情况要扩种一种方法
@url(host,path,query)
例如:要mock 天猫宝贝详情的detail:
http://detail.tmall.com/item.htm?id=41156775172&spm=a1z09.5.0.0.otr1cg
则为:@url('detail.tmall.com','item.htm','id')
大概是这个意思,不是很严禁,里面的参数可以再细化

@nuysoft 你看呢?

from mock.

paolier avatar paolier commented on June 2, 2024

我想了下改成这样易用性会更好
@url()
@url(example)
@url(example,type)
type=protocal/host/path/query/all,缺省是all
例如:@url('http://detail.tmall.com/item.htm?id=41156775172&spm=a1z09.5.0.0.otr1cg', 'query')
那么仅仅会验证data是url,同时,有两个参数,且为id和spm

from mock.

paolier avatar paolier commented on June 2, 2024

目前if-validator已经支持了mockjs方法如下:

Type Method
Basics boolean, natural, integer, float, character, string
Date date, time, datetime
Image image
Web url
Other (data)

Other 的example:

{
   "type":"string",
   "iftest:"data"
}

yes:

   "data"

no:

   "sdf"

from mock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.