apisprout
apisprout copied to clipboard
apisprout is rejecting perfecly valid json references
I have in my main spec document something like this:
components:
ListOfWidgets:
$ref: 'parts/widget/model.yaml#/ListOfWidgets`
Widget:
$ref: 'parts/widget/model.yaml#/Widget`
And parts/widget/model.yaml
looks something like this:
ListOfWidgets:
type: array
items:
$ref: '#/Widget'
Widget:
properties:
id:
type: string
description:
type: string
apisprout rejects this because:
2019/05/31 14:37:49 expected prefix '#/components/schemas/' in URI '#/ListOfWidgets'
That seems unreasonable. apisprout should not be enforcing restrictions on the organization of documents. These are not schemas because the path includes #/components/schemas
; they are schemas because they are included by reference in the schemas
section of the specification.
ok, i have the same problem,
in the openapi.yaml
paths:
/count:
get:
operationId: getCount
description: get count
tags:
- count
responses:
'200':
description: success response
content:
application/json:
schema:
$ref: 'models/Count.yaml'
and in the Count.yaml
title: Count
type: object
properties:
data:
type: object
properties:
count:
type: number
default: 1
minimum: 0
then
apisprout openapi.yaml
2019/09/11 10:41:03 expected prefix '#/components/schemas/' in URI '#'
i dont have any key like #/components/schemas/
, why?
and i check the OpenAPI Specification in here and here, i dont think my yaml is invalid.
I'm having the same issue. I prefer to break up my spec files to make them easier to maintain but APISprout doesn't seem to like refs in the file format like `$ref: ./models/myObject.yaml' but that is perfectly valid as defined here https://swagger.io/docs/specification/using-ref/#syntax
facing same issue. is there any update to fix this issue??
Facing the same issue here. Looking to adopt this for a $ref
based schema and it is not working. My API is too large to write into a single schema file.
If anyone else is facing this, here's a workaround that I have for now which uses swagger-cli
to generate a single file after resolving all the references. However, this creates additional dependencies on node/npm
but lets you keep your project structure as is.
# Install swagger-cli using npm
npm install -g swagger-cli
# Bundle the modular OpenAPI spec into a single, condensed spec file.
swagger-cli bundle ./src/openapi.yaml --outfile ./build/openapi.yaml --type yaml
# Use ApiSprout to run the condensed file.
apisprout ./build/openapi.yaml
Using Docker:
FROM node:12.18.1 as build
WORKDIR /
COPY src/ /
RUN npm install -g swagger-cli && \
swagger-cli bundle /openapi.yaml --outfile /_build/openapi.yaml --type yaml
FROM danielgtaylor/apisprout
COPY --from=build /_build/openapi.yaml /openapi.yaml