open-api
open-api copied to clipboard
$ref cannot refer to schema under the top-level `paths` section
Framework: express
I want to reuse the schema defined with the specific content type. If I put the schema I want to reuse under the top-level components section, it works properly. However, $ref cannot work on the destination under the paths section.
apiDoc.yaml
openapi: 3.0.2
info:
version: 1.0.0
title: API Server
x-express-openapi-disable-response-validation-middleware: true
servers:
- url: /api
paths:
/list/post:
post:
summary: Get the list of the posts
requestBody:
content:
application/json:
schema:
type: object
required:
- page
properties:
page:
type: string
application/x-www-form-urlencoded:
schema:
$ref: '#/paths/~1list~1post/post/requestBody/content/application~1json/schema'
responses: {}
The error message I got.
{
"message": "can't resolve reference #/paths/~1list~1post/post/requestBody/content/application~1json/schema",
"location": "body",
"schema": {
"$ref": "#/paths/~1list~1post/post/requestBody/content/application~1json/schema",
},
}
/list/post.js
module.exports.post = (req, res, next) => {
next();
};
not sure how we'd support this. feel free to open a pr