I have created a nodejs 'Hello World' project and I was trying to reorganize the swagger.yaml
taking the paths out of the main yaml file into a sepparate paths.yam
file:
This is my api/swagger/swagger.yaml
:
swagger: "2.0"
info:
version: "0.0.1"
title: Hello World App
# during dev, should point to your local machine
host: localhost:10010
# basePath prefixes all resource paths
basePath: /
#
schemes:
# tip: remove http to make production-grade
- http
- https
# format of bodies a client can send (Content-Type)
consumes:
- application/json
# format of the responses to the client (Accepts)
produces:
- application/json
paths:
$ref: './paths.yaml'
/swagger:
x-swagger-pipe: swagger_raw
# complex objects have schema definitions
definitions:
HelloWorldResponse:
required:
- message
properties:
message:
type: string
ErrorResponse:
required:
- message
properties:
message:
type: string
and this is the api/swagger/paths.yaml
that I'm referencing to:
/hello:
# binds a127 app logic to a route
x-swagger-router-controller: hello_world
get:
description: Returns 'Hello' to the caller
# used as the method name of the controller
operationId: hello
parameters:
- name: name
in: query
description: The name of the person to whom to say hello
required: false
type: string
responses:
"200":
description: Success
schema:
# a pointer to a definition
$ref: "#/definitions/HelloWorldResponse"
# responses may fall through to errors
default:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
I get the following Swagger error:
Relative paths to the individual endpoints. They must be relative to the 'basePath'.
Reference could not be resolved: ./paths.yaml
Both files 'swagger.yaml' and 'paths.yaml' are placed in the same directory 'api/swagger/'. I've tried to reference paths.yaml
in different ways:
paths:
$ref: 'paths.yaml'
or
paths:
$ref: './api/swagger/paths.yaml'
But I get the same error. Is it possible to reference the paths in a sepparate yaml file?
via rodrunner
No comments:
Post a Comment