Skip to content

Commit

Permalink
Fix workspace violation messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
amckinney committed Dec 9, 2024
1 parent 5983c2d commit 33d07c8
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 56 deletions.
7 changes: 0 additions & 7 deletions packages/cli/cli/src/commands/docs-dev/devDocsWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Project } from "@fern-api/project-loader";
import { CliContext } from "../../cli-context/CliContext";
import { validateAPIWorkspaceWithoutExiting } from "../validate/validateAPIWorkspaceAndLogIssues";
import { validateDocsWorkspaceWithoutExiting } from "../validate/validateDocsWorkspaceAndLogIssues";
import { validateGeneratorsWorkspaceWithoutExiting } from "../validate/validateGeneratorsWorkspaceAndLogIssues";

export async function previewDocsWorkspace({
loadProject,
Expand Down Expand Up @@ -48,12 +47,6 @@ export async function previewDocsWorkspace({
for (const apiWorkspace of project.apiWorkspaces) {
await cliContext.runTaskForWorkspace(apiWorkspace, async (apiWorkspaceContext) => {
const workspace = await apiWorkspace.toFernWorkspace({ context }, { preserveSchemaIds: true });
await validateGeneratorsWorkspaceWithoutExiting({
workspace,
context: apiWorkspaceContext,
logWarnings: false,
logSummary: false
});
await validateAPIWorkspaceWithoutExiting({
workspace,
context: apiWorkspaceContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { validateFernWorkspace } from "@fern-api/fern-definition-validator";
import { FernWorkspace } from "@fern-api/api-workspace-commons";
import validatePackageName from "validate-npm-package-name";
import { logViolations } from "./logViolations";
import { validateGeneratorsWorkspace } from "@fern-api/generators-validator";

export async function validateAPIWorkspaceWithoutExiting({
workspace,
Expand All @@ -15,8 +16,15 @@ export async function validateAPIWorkspaceWithoutExiting({
logWarnings: boolean;
logSummary?: boolean;
}): Promise<{ hasErrors: boolean }> {
const violations = validateFernWorkspace(workspace, context.logger);
const { hasErrors } = logViolations({ violations, context, logWarnings, logSummary });
const apiViolations = validateFernWorkspace(workspace, context.logger);
const generatorViolations = await validateGeneratorsWorkspace(workspace, context.logger);
const violations = [...apiViolations, ...generatorViolations];
const { hasErrors } = logViolations({
violations,
context,
logWarnings,
logSummary
});

return { hasErrors };
}
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions packages/cli/cli/src/commands/validate/validateWorkspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Project } from "@fern-api/project-loader";
import { CliContext } from "../../cli-context/CliContext";
import { validateAPIWorkspaceAndLogIssues } from "./validateAPIWorkspaceAndLogIssues";
import { validateDocsWorkspaceAndLogIssues } from "./validateDocsWorkspaceAndLogIssues";
import { validateGeneratorsWorkspaceAndLogIssues } from "./validateGeneratorsWorkspaceAndLogIssues";

export async function validateWorkspaces({
project,
Expand All @@ -29,7 +28,6 @@ export async function validateWorkspaces({
project.apiWorkspaces.map(async (workspace) => {
await cliContext.runTaskForWorkspace(workspace, async (context) => {
const fernWorkspace = await workspace.toFernWorkspace({ context });
await validateGeneratorsWorkspaceAndLogIssues({ workspace: fernWorkspace, context, logWarnings });
await validateAPIWorkspaceAndLogIssues({ workspace: fernWorkspace, context, logWarnings });
});
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`fern api update unioned > fern api update unioned 1`] = `
"openapi": "3.1.0",
"info": {
"title": "Train Travel API",
"description": "API for finding and booking train trips across Europe.\\n\\n## Run in Postman\\n\\nExperiment with this API in Postman, using our Postman Collection.\\n\\n[<img src=\\"https://run.pstmn.io/button.svg\\" alt=\\"Run In Postman\\" style=\\"width: 128px; height: 32px;\\">](https://app.getpostman.com/run-collection/9265903-7a75a0d0-b108-4436-ba54-c6139698dc08?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D9265903-7a75a0d0-b108-4436-ba54-c6139698dc08%26entityType%3Dcollection%26workspaceId%3Df507f69d-9564-419c-89a2-cb8e4c8c7b8f)\\n",
"description": "API for finding and booking train trips across Europe.\\n\\n## Run in Postman\\n\\nExperiment with this API in Postman, using our Postman Collection.\\n\\n[![Run In Postman](https://run.pstmn.io/button.svg =128pxx32px)](https://app.getpostman.com/run-collection/9265903-7a75a0d0-b108-4436-ba54-c6139698dc08?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D9265903-7a75a0d0-b108-4436-ba54-c6139698dc08%26entityType%3Dcollection%26workspaceId%3Df507f69d-9564-419c-89a2-cb8e4c8c7b8f)\\n",
"version": "1.0.0",
"contact": {
"name": "Train Support",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`fern api update > fern api update 1`] = `
"openapi": "3.1.0",
"info": {
"title": "Train Travel API",
"description": "API for finding and booking train trips across Europe.\\n\\n## Run in Postman\\n\\nExperiment with this API in Postman, using our Postman Collection.\\n\\n[<img src=\\"https://run.pstmn.io/button.svg\\" alt=\\"Run In Postman\\" style=\\"width: 128px; height: 32px;\\">](https://app.getpostman.com/run-collection/9265903-7a75a0d0-b108-4436-ba54-c6139698dc08?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D9265903-7a75a0d0-b108-4436-ba54-c6139698dc08%26entityType%3Dcollection%26workspaceId%3Df507f69d-9564-419c-89a2-cb8e4c8c7b8f)\\n",
"description": "API for finding and booking train trips across Europe.\\n\\n## Run in Postman\\n\\nExperiment with this API in Postman, using our Postman Collection.\\n\\n[![Run In Postman](https://run.pstmn.io/button.svg =128pxx32px)](https://app.getpostman.com/run-collection/9265903-7a75a0d0-b108-4436-ba54-c6139698dc08?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D9265903-7a75a0d0-b108-4436-ba54-c6139698dc08%26entityType%3Dcollection%26workspaceId%3Df507f69d-9564-419c-89a2-cb8e4c8c7b8f)\\n",
"version": "1.0.0",
"contact": {
"name": "Train Support",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ exports[`validate > no-api 1`] = `
exports[`validate > no-generator 1`] = `"Misconfigured fern directory: please see the docs at https://buildwithfern.com/learn/api-definition/introduction/what-is-the-fern-folder"`;

exports[`validate > simple 1`] = `
"[api]: ✓ All checks passed
[api]: Found 2 errors and 0 warnings. Run fern check --warnings to print out the warnings.
"[api]: Found 2 errors and 0 warnings. Run fern check --warnings to print out the warnings.
[api]: api.yml -> error-discrimination
error-discrimination is required because this API has declared errors.
[api]: other.yml -> types -> MyType
Expand Down

0 comments on commit 33d07c8

Please sign in to comment.