Skip to content

Commit

Permalink
(fix): OpenAPI converter only adds unique error examples (#3556)
Browse files Browse the repository at this point in the history
* only add unique error examples

* (fix): openapi importer only adds unique examples
  • Loading branch information
dsinghvi authored May 7, 2024
1 parent b379bd8 commit f070e44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 177 deletions.
10 changes: 8 additions & 2 deletions packages/cli/openapi-ir-to-fern/src/FernDefnitionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FERN_PACKAGE_MARKER_FILENAME, ROOT_API_FILENAME } from "@fern-api/confi
import { AbsoluteFilePath, dirname, relative, RelativeFilePath } from "@fern-api/fs-utils";
import { OpenApiIntermediateRepresentation } from "@fern-api/openapi-ir-sdk";
import { RawSchemas, RootApiFileSchema, visitRawEnvironmentDeclaration } from "@fern-api/yaml-schema";
import { camelCase } from "lodash-es";
import { camelCase, isEqual } from "lodash-es";
import { basename, extname } from "path";

export interface FernDefinitionBuilder {
Expand Down Expand Up @@ -284,7 +284,13 @@ export class FernDefinitionBuilderImpl implements FernDefinitionBuilder {
if (errorDeclaration.examples == null) {
errorDeclaration.examples = [];
}
errorDeclaration.examples?.push(example);
const alreadyAdded =
errorDeclaration.examples.some((existingExample) => {
return isEqual(existingExample, example);
}) ?? false;
if (!alreadyAdded) {
errorDeclaration.examples?.push(example);
}
}

public addEndpoint(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6675,171 +6675,6 @@ to the value of the \`check_URL_duplicates\` parameter.
"name": "signature-invalid",
"value": "Invalid signature.",
},
{
"docs": undefined,
"name": "public-key-is-required",
"value": "UPLOADCARE_PUB_KEY is required.",
},
{
"docs": undefined,
"name": "public-key-is-invalid",
"value": "UPLOADCARE_PUB_KEY is invalid.",
},
{
"docs": undefined,
"name": "auto-store-is-disabled",
"value": "Autostore is disabled.",
},
{
"docs": undefined,
"name": "project-public-key-removed",
"value": "Project 39e3eb895fdada95e7a9 is marked as removed.",
},
{
"docs": undefined,
"name": "account-blocked",
"value": "Account has been blocked.",
},
{
"docs": undefined,
"name": "account-unpaid",
"value": "Account has been blocked for non payment.",
},
{
"docs": undefined,
"name": "upload-failed",
"value": "Upload failed.",
},
{
"docs": undefined,
"name": "account-limits-exceeded",
"value": "Account has reached its limits.",
},
{
"docs": undefined,
"name": "signature-expiration",
"value": "Expired signature.",
},
{
"docs": undefined,
"name": "signature-invalid",
"value": "Invalid signature.",
},
{
"docs": undefined,
"name": "public-key-is-required",
"value": "UPLOADCARE_PUB_KEY is required.",
},
{
"docs": undefined,
"name": "public-key-is-invalid",
"value": "UPLOADCARE_PUB_KEY is invalid.",
},
{
"docs": undefined,
"name": "public-key-is-required",
"value": "pub_key is required.",
},
{
"docs": undefined,
"name": "public-key-is-invalid",
"value": "pub_key is invalid.",
},
{
"docs": undefined,
"name": "auto-store-is-disabled",
"value": "Autostore is disabled.",
},
{
"docs": undefined,
"name": "project-public-key-removed",
"value": "Project 39e3eb895fdada95e7a9 is marked as removed.",
},
{
"docs": undefined,
"name": "account-blocked",
"value": "Account has been blocked.",
},
{
"docs": undefined,
"name": "account-unpaid",
"value": "Account has been blocked for non payment.",
},
{
"docs": undefined,
"name": "upload-failed",
"value": "Upload failed.",
},
{
"docs": undefined,
"name": "account-limits-exceeded",
"value": "Account has reached its limits.",
},
{
"docs": undefined,
"name": "signature-expiration",
"value": "Expired signature.",
},
{
"docs": undefined,
"name": "signature-invalid",
"value": "Invalid signature.",
},
{
"docs": undefined,
"name": "public-key-is-required",
"value": "pub_key is required.",
},
{
"docs": undefined,
"name": "public-key-is-invalid",
"value": "pub_key is invalid.",
},
{
"docs": undefined,
"name": "public-key-is-required",
"value": "pub_key is required.",
},
{
"docs": undefined,
"name": "public-key-is-invalid",
"value": "pub_key is invalid.",
},
{
"docs": undefined,
"name": "project-public-key-removed",
"value": "Project 39e3eb895fdada95e7a9 is marked as removed.",
},
{
"docs": undefined,
"name": "account-blocked",
"value": "Account has been blocked.",
},
{
"docs": undefined,
"name": "account-unpaid",
"value": "Account has been blocked for non payment.",
},
{
"docs": undefined,
"name": "upload-failed",
"value": "Upload failed.",
},
{
"docs": undefined,
"name": "account-limits-exceeded",
"value": "Account has reached its limits.",
},
{
"docs": undefined,
"name": "signature-expiration",
"value": "Expired signature.",
},
{
"docs": undefined,
"name": "signature-invalid",
"value": "Invalid signature.",
},
{
"docs": undefined,
"name": "public-key-is-required",
Expand Down Expand Up @@ -6873,16 +6708,6 @@ to the value of the \`check_URL_duplicates\` parameter.
"name": undefined,
"value": "Request was throttled.",
},
{
"docs": undefined,
"name": undefined,
"value": "Request was throttled.",
},
{
"docs": undefined,
"name": undefined,
"value": "Request was throttled.",
},
],
"status-code": 429,
"type": "string",
Expand Down

0 comments on commit f070e44

Please sign in to comment.