创建rest api

lb4 appdemo

参考提示即可

安装 OASGraph

git clone https://github.com/strongloop/oasgraph.git
cd oasgraph
npm link
或者 npm install -g oasgraph
如果提示权限问题,使用sudo 或者加上 --unsafe-perm
这部分有点慢

启动rest api

cd appdemo
yarn && yarn start
默认openapi 地址是:http://127.0.0.1:3000/openapi.json

配置服务

oasgraph http://127.0.0.1:3000/openapi.json

graphql api 访问

http://127.0.0.1:3001/graphql


说明

因为OASGraph 是基于express 以及graphql、openapi 解析运行的,建议的方式是clone 代码,或者使用api 调用
模块调用格式

const express = require('express')
const graphqlHTTP = require('express-graphql')
const OASGraph = require('oasgraph') // use real name here
const app = express() OASGraph.createGraphQlSchema(oas)
.then(({schema}) => {
app.use('/graphql', graphqlHTTP({
schema,
graphiql: true
}))
app.listen(3001)
})
.catch(err => {
// handle errors when creating the schema
})

参考资料

https://www.npmjs.com/package/oasgraph
https://github.com/strongloop/oasgraph
http://v4.loopback.io/getting-started-oasgraph.html

 
 
 
 

OASGraph 转换rest api graphql 试用的更多相关文章

  1. 实验03——java十进制转二、八、十六进制;打印'中'的十六进制;进制转换的api

    package cn.tedu.demo; /** * @author 赵瑞鑫 E-mail:1922250303@qq.com * @version 创建时间:2020年7月16日 上午10:22: ...

  2. sofa graphql 2 rest api webhook 试用

    sofa 的webhook实际上就是将graphql 的subscription 进行了扩展,当接受到sub 请求的时候 再做一次http 的转发处理,方便rest api 的访问 环境准备 环境还是 ...

  3. 进制转换及API接口中的转换

    //十进制转二进制Console.WriteLine("十进制166的二进制表示: "+Convert.ToString(166, 2));//十进制转八进制Console.Wri ...

  4. Gravitee.io api gateway 试用

    以前写过几篇关于整体介绍的以及 使用docker 运行的简单说明,有了docker-compose 环境我们可以 方便的进行测试使用了. 环境准备 docker-compose 文件   versio ...

  5. sqler sql 转rest api javascript 试用

    sqler 内嵌了一个js 引擎的实现(基于goja,当我们配置了exec的配置之后 调用宏(redis 接口)或者rest api 的时候会有一个全局变量$result ,保存了执行的结果,我们可以 ...

  6. sofa graphql 2 rest api 试用

      大部分代码还是来自sofa 的官方文档,同时添加了docker && docker-compose集成 备注: 代码使用typescript 同时运行的时候为了方便直接运行使用ts ...

  7. GraphQL & REST API

    GraphQL & REST API GraphQL https://mp.weixin.qq.com/s/X-jm7jLXWmMmLBVgHfkRiQ https://webapplog.c ...

  8. ASP.NET Core中使用GraphQL - 第二章 中间件

    前文:ASP.NET Core中使用GraphQL - 第一章 Hello World 中间件 如果你熟悉ASP.NET Core的中间件,你可能会注意到之前的博客中我们已经使用了一个中间件, app ...

  9. 高效的后端API开发模板-illuminant

    概要 整体介绍 补充说明 Q. 有了 prisma 自动生成的 graphql 接口, 为什么还要 rest 接口和 websocket 接口? Q. 为什么要通过 illuminant 加一层反向代 ...

随机推荐

  1. English trip -- MC(情景课)3 D

    xu言: have a nice weekend... sentences How many people are there in you family? they are 3 people in ...

  2. 3-15 《元编程》第6章 3-16 hook method

    Code That Writes Code 6.1 Coding your way to the weekend 6.2 Kernel#eval, Binding#eval Binding: Obje ...

  3. hdu3068 manacher模板题

    给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度. 回文就是正反读都是一样的字符串,如aba, abba等 Input输入有多组case,不超过120组,每组输入为 ...

  4. 应用多种变形CSS3

    <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>    < ...

  5. OC 内存管理之自动内存管理ARC

    一.基本简介 ARC是自iOS 5之后增加的新特性,完全消除了手动管理内存的烦琐,编译器会自动在适当的地方插入适当的retain.release.autorelease语句.你不再需要担心内存管理,因 ...

  6. CNN autoencoder 进行异常检测——TODO,使用keras进行测试

    https://sefiks.com/2018/03/23/convolutional-autoencoder-clustering-images-with-neural-networks/ http ...

  7. idea破解更新

    idea破解教程: https://www.cnblogs.com/jpfss/p/8872358.html JetbrainsCrack-3.1-release-enc.jar下载:http://i ...

  8. winform窗体程序运行后怎样隐藏?

    运行winform窗体,我们是怎样隐藏的呢? 例子: 1)创建简单winform窗体 2)编写隐藏窗体程序的代码 3)效果演示 1)创建一个简单的winform窗体MainForm,

  9. PHP parse_url 一个好用的函数

    array parse_url ( string $url ) 本函数解析一个 URL 并返回一个关联数组,包含在 URL 中出现的各种组成部分. 对严重不合格的 URL,parse_url() 可能 ...

  10. main方法原来只要放在public static类中就能跑,涨知识了

    接口中可以装在嵌套类对象. public interface ClassInterface { void howdy(); class Test implements ClassInterface { ...