Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Swagger to sf schema & st column in ng-alain

License

NotificationsYou must be signed in to change notification settings

ng-alain/sts

Repository files navigation

Convert Swagger API tosf Schema &st columns inng-alain projects.

如何使用

ng-alain-sts 是一个 Node 插件,你可以使用命令行或直接调用generator 方法来获取转换后的sf Schema 和st 列描述。

# via npmnpm i ng-alain-sts --save-dev# via yarnyarn add -D ng-alain-sts

ng-alain

ng-alain-sts 是专注于 NG-ALAIN,因此在 NG-ALAIN CLI 提供一个快捷命令:

ng g ng-alain:sts

它包含listedit 两个自定义模板,可以通过指令根据 Swagger API 接口来生成列表、编辑页。

ng g ng-alain:module tradeng g ng-alain:tpl swagger-list list -m=trade -t=trade --swaggerPath=/pet/findByStatus

更多请参考sts插件。

命令行

ng-alain-sts -t=sf -p=/pet swagger.json

参数

参数名类型默认描述
-t--typesf,stsf指定生成类型
-p--pathstring-必填 指定paths 路径
-m--methodstringget指定请求方法
-c--configstringswagger-config.json指定配置文件路径

调用

conststs=require('ng-alain-sts/src/generator');awaitsts.generator('https://petstore.swagger.io/v2/swagger.json',{type:'sf'},{descriptionIsTitle:true});

配置文件

Swagger API 接口对于每一个后端语言或企业风格有着统一的编码风格、约定,如何更好的利用这些约定使生成的结构更符合当前的开发风格,从而进一步提升开发体验;配置文件给予了一些更自由空间,我们建议针对自己的接口风格定制不同的配置信息。

Config

参数说明类型默认值
requestOptionsSwagger JSON 文件网络请求配置项any-
pathPrefix路径前缀string-
propertyMapNames自定义属性名称映射{ [name: string]: string }{ id: '编号', name: '名称' }
descriptionIsTitle指定descriptiontitle,并删除descriptionbooleantrue
sfsf 配置项SFConfig-
stst 配置项STConfig-

SFConfig

参数说明类型默认值
method指定默认方法名stringput
singleArray由于sf 并不支持这种类型,默认被转化为select 小部件SFSchema-
properties自定义属性的SchemaPathConfig[]-
xmlBlackNamesXML 属性白名单,这些信息会以优先级最高直接传递给uistring[]-
propertyCallback递归属性回调(optinos: SFPropertyCallbackOptions) => void-
finishedCallback完成时回调(optinos: SFFinishedCallbackOptions) => void-

singleArray

单类型数组默认被转化为select 小部件:

{type:'string',ui:{widget:'select',mode:'tags',},default:null,}

STConfig

参数说明类型默认值
method指定默认方法名stringget
properties自定义属性的SchemaPathConfig[]-
nameToType根据名称自定义类型{ [name: string]: STColumnType }-
xmlBlackNamesXML 属性白名单,这些信息会以优先级最高直接传递给STColumnstring[]['i18n']
propertyCallback递归属性回调(optinos: STPropertyCallbackOptions) => void-
finishedCallback完成时回调(optinos: STFinishedCallbackOptions) => void-

nameToType

定制根据名称自定义类型,默认值为:

{price:'currency',amount:'currency',num:'number',count:'number',avatar:'img',mp:'img',modified:'date',created:'date',}

PathConfig

参数说明类型默认值
name属性名称string-
path指定路径,若不指定则该属性名对所有 path 有效string-
value值分为SFSchemaSTColumn 类型`SFSchemaSTColumn`

License

MIT

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp