Skip to content

Commit

Permalink
Remove inline types from error declarations (#813)
Browse files Browse the repository at this point in the history
* Remove inline types from error declarations

* Fix json schema

* Add migration

* Add comments to tests
  • Loading branch information
zachkirsch authored Oct 12, 2022
1 parent 3f20fb2 commit ad0f881
Show file tree
Hide file tree
Showing 40 changed files with 379 additions and 214 deletions.
16 changes: 8 additions & 8 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"search.exclude": {
"**/.pnp.*": true,
"**/.yarn": true,
"**/.pnp.*": true
"packages/cli/migrations/src/**/*.ts": true
},
"eslint.nodePath": ".yarn/sdks",
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": ["source.fixAll", "source.organizeImports", "source.sortMembers"],
"go.inferGopath": false
"editor.codeActionsOnSave": ["source.fixAll", "source.organizeImports", "source.sortMembers"]
}
Binary file not shown.
29 changes: 8 additions & 21 deletions fern.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -354,27 +354,14 @@
"errors": {
"type": "object",
"additionalProperties": {
"anyOf": [
{ "type": "string" },
{
"type": "object",
"properties": {
"docs": { "$ref": "#/properties/types/additionalProperties/anyOf/1/anyOf/0/properties/docs" },
"http": {
"type": "object",
"properties": {
"docs": { "$ref": "#/properties/types/additionalProperties/anyOf/1/anyOf/0/properties/docs" },
"name": { "type": "string" },
"statusCode": { "type": "number" }
},
"required": ["statusCode"],
"additionalProperties": false
},
"type": { "$ref": "#/properties/types/additionalProperties" }
},
"additionalProperties": false
}
]
"type": "object",
"properties": {
"docs": { "$ref": "#/properties/types/additionalProperties/anyOf/1/anyOf/0/properties/docs" },
"status-code": { "type": "number" },
"type": { "type": "string" }
},
"required": ["status-code"],
"additionalProperties": false
}
}
},
Expand Down
8 changes: 6 additions & 2 deletions fern/ir-types/definition/errors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ types:
name: DeclaredErrorName
discriminantValue: commons.WireStringWithAllCasings
type:
docs: this is deprecated. use typeV2 instead.
docs: this is deprecated. use typeV3 instead.
type: types.Type
typeV2: optional<types.Type>
typeV2:
docs: this is deprecated. use typeV3 instead.
type: optional<types.Type>
typeV3: optional<types.TypeReference>
http: optional<HttpErrorConfiguration>
statusCode: integer
DeclaredErrorName:
properties:
fernFilepath: commons.FernFilepath
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@fern-api/validator": "workspace:*",
"@fern-api/workspace-loader": "workspace:*",
"@fern-fern/fiddle-client": "^0.0.49",
"@fern-fern/ir-model": "0.0.227",
"@fern-fern/ir-model": "0.0.237",
"ansi-escapes": "^5.0.0",
"boxen": "^7.0.0",
"chalk": "^5.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ services:
errors:
NotFoundError:
http:
statusCode: 404",
status-code: 404",
"name": "imdb.yml",
"type": "file",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ types:
rating: double
errors:
NotFoundError:
http:
statusCode: 404
status-code: 404
services:
http:
MoviesService:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ types:
rating: double
errors:
NotFoundError:
http:
statusCode: 404
status-code: 404
services:
http:
MoviesService:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ services:
errors:
NotFoundError:
http:
statusCode: 404",
status-code: 404",
"name": "imdb.yml",
"type": "file",
},
Expand Down
51 changes: 48 additions & 3 deletions packages/cli/ete-tests/src/tests/ir/__snapshots__/ir.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -744,14 +744,32 @@ exports[`ir simple 1`] = `
"http": {
"statusCode": 404
},
"statusCode": 404,
"type": {
"aliasOf": {
"_type": "void"
"primitive": "STRING",
"_type": "primitive"
},
"resolvedType": {
"_type": "void"
"primitive": "STRING",
"_type": "primitive"
},
"_type": "alias"
},
"typeV2": {
"aliasOf": {
"primitive": "STRING",
"_type": "primitive"
},
"resolvedType": {
"primitive": "STRING",
"_type": "primitive"
},
"_type": "alias"
},
"typeV3": {
"primitive": "STRING",
"_type": "primitive"
}
}
],
Expand Down Expand Up @@ -1036,7 +1054,34 @@ exports[`ir simple 1`] = `
"wireValue": "NotFoundError"
},
"shape": {
"type": "noProperties"
"name": {
"originalValue": "content",
"camelCase": "content",
"snakeCase": "content",
"pascalCase": "Content",
"screamingSnakeCase": "CONTENT",
"wireValue": "content"
},
"error": {
"name": "NotFoundError",
"nameV2": {
"originalValue": "NotFoundError",
"camelCase": "notFoundError",
"snakeCase": "not_found_error",
"pascalCase": "NotFoundError",
"screamingSnakeCase": "NOT_FOUND_ERROR"
},
"fernFilepath": [
{
"originalValue": "imdb",
"camelCase": "imdb",
"snakeCase": "imdb",
"pascalCase": "Imdb",
"screamingSnakeCase": "IMDB"
}
]
},
"type": "singleProperty"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ types:
selfRefrencing: list<RecursiveType>
errors:
NotFoundError:
http:
statusCode: 404
status-code: 404
type: string
services:
http:
MoviesService:
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/generation/ir-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@fern-api/core-utils": "workspace:*",
"@fern-api/workspace-loader": "workspace:*",
"@fern-api/yaml-schema": "workspace:*",
"@fern-fern/ir-model": "0.0.227",
"@fern-fern/ir-model": "0.0.237",
"lodash-es": "^4.17.21"
},
"devDependencies": {
Expand Down

This file was deleted.

Loading

0 comments on commit ad0f881

Please sign in to comment.