-
Notifications
You must be signed in to change notification settings - Fork 13
counterfact does not support $ref with external yaml files #1244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Found a couple issues on
I did some digging and the bundled schema has some weird {
type: 'array',
items: {
'$ref': '#/paths/~1metrics/get/responses/200/content/application~1json/schema/allOf/0/properties/data/items'
}
} |
For anyone having the same problem, my workaround was to bundle my openapi spec using package.json {
"scripts": {
"openapi:bundle": "bunx redocly bundle api-spec/openapi.yaml -o api-spec/openapi.json",
"serve:mock": "bun run openapi:bundle && counterfact api-spec/openapi.json lib/server/mock"
}
} |
Thanks! Is there a problem in Counterfact itself or just Swagger? I thought I'd worked around by merging external files at runtime but may have missed something. |
It works if I use
These are the files it generates: import type { items } from "../../../../../../../../~1metrics/get/responses/200/content/application~1json/schema/allOf/0/properties/data/items.js";
export type _0 = {
data: Array<items>;
meta?: { total?: number; next?: string; prev?: string };
}; |
Thanks, I'll have a look. If can you share the relevant sections from |
Sure! openapi.yaml: paths:
/metrics:
get:
operationId: getMetrics
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: 'components/metrics.yaml#/components/schemas/MetricsResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: 'components/errors.yaml#/components/schemas/ErrorResponse' metrics.yaml: components:
schemas:
MetricAttributes:
type: object
required: [value]
properties:
value:
type: integer
example: 20
title:
type: string
description:
type: string
MetricResource:
allOf:
- type: object
properties:
type:
type: string
enum: [metric]
example: metric
attributes:
$ref: '#/components/schemas/MetricAttributes'
MetricsResponse:
allOf:
- type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/MetricResource' errors.yaml components:
schemas:
ErrorResponse:
type: object
required: [status, statusCode, message]
properties:
title:
type: string
code:
type: string
example: ERR_PERMISSION
message:
type: string
name:
type: string
example: BadRequestError |
As the title says, counterfact does not seem to support referencing yaml files in the openapi specification.
Example:
When opening the swagger docs, I see the following error:
Response schema
When using a single openapi spec file, it works as expected
The text was updated successfully, but these errors were encountered: