Open abcfy2 opened 5 years ago
Of course we could also map the example request/response also to example values for each field in the schema. I find this a little bit redundant. It is also not adding too much value.
So I would rather shy away from adding this myself.
Thanks @mduesterhoeft . Or maybe we can render example
outside schema
is better. See: https://swagger.io/docs/specification/adding-examples/
And this also works:
openapi: 3.0.1
info:
title: Grails-rest-seed API
description: Grails-rest-seed API文档
version: "1.0"
servers:
- url: http://localhost:8080
tags: []
paths:
/api/getUploadAuthority:
get:
tags:
- operation
summary: OSS接口
description: 阿里云OSS获取上传权限
operationId: AliyunOSS
parameters:
- name: Authorization
in: header
description: JWT
required: true
schema:
type: string
responses:
200:
description: "200"
content:
application/json:
schema:
$ref: '#/components/schemas/api-getUploadAuthority2026114897'
example:
accessKeyId: 'mock'
signature: '1slIn7u/Ruoptc+Hn6xBDOjNLWo='
cdnUrl: 'mock'
expire: 1553619329503
host: 'https://mock.oss-cn-hangzhou.aliyuncs.com'
dir: '1553619329503'
policy: 'eyJleHBpcmF0aW9uIjoiMjAxOS0wMy0yNlQxNjo1NToyOS41MDNaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF0sWyJzdGFydHMtd2l0aCIsIiRrZXkiLCIxMzUwMDAwMDAwMSJdXX0='
components:
schemas:
api-getUploadAuthority2026114897:
type: object
required:
- accessKeyId
- signature
- expire
- host
- dir
- policy
properties:
accessKeyId:
type: string
description: OSS的access key id
signature:
type: string
description: OSS认证成功后的签名
cdnUrl:
type: string
description: 用于外部访问的CDN URL(可空)
expire:
type: number
description: 授权过期时间
host:
type: string
description: OSS访问主机
example: https://mock.oss-cn-hangzhou.aliyuncs.com
dir:
type: string
description: 有权限上传的目录
policy:
type: string
description: OSS的权限矩阵
Maybe related to #58
In my case, The generated openapi3.yaml looks like this:
But I want to see like this:
Map the response examples to schemas.