• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pmcelhaney / counterfact / 12473401777

23 Dec 2024 09:50PM UTC coverage: 82.49% (-0.01%) from 82.504%
12473401777

Pull #1139

github

web-flow
Merge branch 'main' into path-parameters-are-always-strings
Pull Request #1139: path parameters are always strings

1088 of 1212 branches covered (89.77%)

Branch coverage included in aggregate %.

28 of 33 new or added lines in 3 files covered. (84.85%)

3251 of 4048 relevant lines covered (80.31%)

59.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/server/openapi-middleware.ts
1
import yaml from "js-yaml";
×
2
import type Koa from "koa";
×
3

×
4
import { readFile } from "../util/read-file.js";
×
5

×
6
export function openapiMiddleware(openApiPath: string, url: string) {
×
7
  return async (ctx: Koa.ExtendableContext, next: Koa.Next) => {
×
8
    if (ctx.URL.pathname === "/counterfact/openapi") {
×
9
      const openApiDocument = (await yaml.load(
×
10
        await readFile(openApiPath),
×
11
      )) as {
×
12
        host?: string;
×
13
        servers?: { description: string; url: string }[];
×
14
      };
×
15

×
16
      openApiDocument.servers ??= [];
×
17

×
18
      openApiDocument.servers.unshift({
×
19
        description: "Counterfact",
×
20
        url,
×
21
      });
×
22

×
23
      // OpenApi 2 support:
×
24
      openApiDocument.host = url;
×
25

×
26
      ctx.body = yaml.dump(openApiDocument);
×
27

×
28
      return;
×
29
    }
×
30

×
31
    await next();
×
32
  };
×
33
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc