Skip to content
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

Fix bug: Unable to use {service-name} interpolation for filenames with openapi3-emitter when only one service is defined #6182

Merged
merged 12 commits into from
Mar 3, 2025
Prev Previous commit
Next Next commit
add change
  • Loading branch information
albertxavier100 committed Feb 27, 2025
commit 993727d8d2cd65b31f119c3254693b00fbd2cad0
7 changes: 7 additions & 0 deletions .chronus/changes/wanl-service-name-2025-1-27-19-40-32.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/openapi3"
---

Fix bug of unable to use `{service-name}` interpolation for filenames with openapi3-emitter when only one service is defined
4 changes: 1 addition & 3 deletions packages/openapi3/test/emit-openapi.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { resolveVirtualPath } from "@typespec/compiler/testing";
import { describe, expect, it } from "vitest";
import { EmitterOptions } from "../../compiler/src/config/types.js";
import { OpenAPI3EmitterOptions } from "../src/lib.js";
import { worksFor } from "./works-for.js";

describe("Scalar formats of serialized document in YAML", () => {
@@ -119,7 +117,7 @@ describe("Scalar formats of serialized document in YAML", () => {
expectedOutputFiles: [resolveVirtualPath("AAA.yaml"), resolveVirtualPath("BBB.yaml")],
},
])("$description", async (c: ServiceNameCase) => {
const options: OpenAPI3EmitterOptions & EmitterOptions = {
const options = {
"output-file": c.outputFilePattern,
"emitter-output-dir": "{output-dir}",
};
Original file line number Diff line number Diff line change
@@ -102,14 +102,14 @@ Here's what would be produced:

#### Built-in variables

| Variable name | Scope | Description |
| -------------------------- | -------------------------- | ------------------------------------------------------------------------------------ |
| `cwd` | \* | Points to the current working directory |
| `project-root` | \* | Points to the the tspconfig.yaml file containing folder. |
| `output-dir` | emitter options | Common `output-dir` See [output-dir](#output-dir---configure-the-default-output-dir) |
| `emitter-name` | emitter options | Name of the emitter |
| `service-name` | service name | Name of the service |
| `service-name-if-multiple` | service name if multiple | Name of the service if multiple, undefined for single service |
| Variable name | Scope | Description |
| -------------------------- | ------------------------ | ------------------------------------------------------------------------------------ |
| `cwd` | \* | Points to the current working directory |
| `project-root` | \* | Points to the the tspconfig.yaml file containing folder. |
| `output-dir` | emitter options | Common `output-dir` See [output-dir](#output-dir---configure-the-default-output-dir) |
| `emitter-name` | emitter options | Name of the emitter |
| `service-name` | service name | Name of the service |
| `service-name-if-multiple` | service name if multiple | Name of the service if multiple, undefined if one |

#### Project Parameters

Loading
Oops, something went wrong.