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

Testing http-Specs with oas3 emitter #5635

Open
wants to merge 56 commits into
base: main
Choose a base branch
from

Conversation

skywing918
Copy link
Member

1 . Verify that all http-specs cases can be converted to the OpenAPI 3 without any errors/warnings

describe("http-specs convert", () => {
  defineSpecTests(config);
});

image

  1. Check information for a http-specs case.
it("authentication/api-key", async () => {
      const curr = {
        name: "authentication/api-key",
        fullPath: resolvePath(specsRoot, "authentication/api-key"),
      };
      const results = await openApiForFile(curr);
      const res = Object.values(results)[0] as any;
      const getThing = res.paths["/authentication/api-key/invalid"].get;
      strictEqual(getThing.operationId, "invalid");
    });
  1. support 3.1.0

@skywing918
Copy link
Member Author

@lirenhe pls review

@skywing918 skywing918 requested a review from lirenhe January 23, 2025 09:33
@skywing918 skywing918 marked this pull request as ready for review February 18, 2025 08:47
@skywing918 skywing918 changed the title [WIP]Testing http-Specs with oas3 emitter.Do Not Review Testing http-Specs with oas3 emitter Feb 18, 2025
describe("AuthApiKeyClient Rest Client", () => {
beforeAll(async () => {
exec("pnpm spector-serve", { cwd: pkgRoot });
await checkServe();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to start the server

Copy link
Member

@wanlwanl wanlwanl Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timotheeguerin, we use the response as ground truth:

          await validataDataWithSchema(response.body, invalidAuthSchemas);

execSync("pnpm spector-stop", { stdio: "inherit", cwd: pkgRoot });
});
worksFor(["3.0.0", "3.1.0"], ({ openApiForFile }) => {
describe("AuthApiKeyClient Rest Client", () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fail to see the real value in this PR. Do we really need this? You go and reimplement everything to validate pretty much nothing. This is a lot of wasted effort.

What is the motivation behind this?

Copy link
Member

@lirenhe lirenhe Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to leverage the full test specs in Spector to verify various scenarios for the OAS3 emitter and display the results on the Spector dashboard for scenario coverage. This way, any changes in TypeSpec/Emitter can be quickly identified for potential breakings.

But I am not quite get the point in this PR about how we validate the result. Are we using snapshot for testing?

Copy link
Member

@timotheeguerin timotheeguerin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fail to see why we need this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants