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(cli): Correctly support readOnly query parameters in PATCH endpoint generation. #5481

Merged
merged 6 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions fern/pages/changelogs/cli/2024-12-26.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 0.46.13
**`(fix):`** Correctly omits readOnly query parameters during openapi to fern definition generation.


Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
import { ExampleTypeFactory } from "../../../schema/examples/ExampleTypeFactory";
import { convertSchemaToSchemaWithExample } from "../../../schema/utils/convertSchemaToSchemaWithExample";
import { isSchemaRequired } from "../../../schema/utils/isSchemaRequired";
import { shouldSkipReadOnly } from "../../../utils/shouldSkipReadOnly";
import { hasIncompleteExample } from "../hasIncompleteExample";
import { OpenAPIV3ParserContext } from "../OpenAPIV3ParserContext";

Expand Down Expand Up @@ -56,7 +57,7 @@ export class ExampleEndpointFactory {

if (requestSchemaIdResponse.examples.length === 0) {
const example = this.exampleTypeFactory.buildExample({
skipReadonly: endpoint.method === "POST" || endpoint.method === "PUT",
skipReadonly: shouldSkipReadOnly(endpoint.method),
schema: requestSchemaIdResponse.schema,
exampleId: undefined,
example: undefined,
Expand All @@ -73,7 +74,7 @@ export class ExampleEndpointFactory {
} else {
for (const { name: exampleId, value: rawExample } of requestSchemaIdResponse.examples) {
const example = this.exampleTypeFactory.buildExample({
skipReadonly: endpoint.method === "POST" || endpoint.method === "PUT",
skipReadonly: shouldSkipReadOnly(endpoint.method),
schema: requestSchemaIdResponse.schema,
exampleId,
example: rawExample,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { FernOpenapiIr } from "@fern-api/openapi-ir";

export function shouldSkipReadOnly(method: FernOpenapiIr.HttpMethod): boolean | undefined {
return method === "POST" || method === "PUT" || method === "PATCH";
}
Original file line number Diff line number Diff line change
Expand Up @@ -13187,16 +13187,12 @@ service:
},
"request": {
"cmsLocaleId": "653ad57de882f528b32e810e",
"createdOn": "2022-11-17T17:11:57.148Z",
"fieldData": {
"name": "Pan Galactic Gargle Blaster Recipe",
"slug": "pan-galactic-gargle-blaster",
},
"id": "42b720ef280c7a7a3be8cabe",
"isArchived": false,
"isDraft": false,
"lastPublished": "2022-11-29T16:22:43.159Z",
"lastUpdated": "2022-11-17T17:19:43.282Z",
},
"response": {
"body": {
Expand Down Expand Up @@ -13235,15 +13231,7 @@ service:
"docs": "Identifier for the locale of the CMS item",
"type": "optional<string>",
},
"createdOn": {
"docs": "The date the item was created",
"type": "optional<string>",
},
"fieldData": "optional<ItemsUpdateItemRequestFieldData>",
"id": {
"docs": "Unique identifier for the Item",
"type": "string",
},
"isArchived": {
"default": false,
"docs": "Boolean determining if the Item is set to archived",
Expand All @@ -13254,14 +13242,6 @@ service:
"docs": "Boolean determining if the Item is set to draft",
"type": "optional<boolean>",
},
"lastPublished": {
"docs": "The date the item was last published",
"type": "optional<string>",
},
"lastUpdated": {
"docs": "The date the item was last updated",
"type": "optional<string>",
},
},
},
"content-type": "application/json",
Expand Down Expand Up @@ -13297,16 +13277,12 @@ service:
},
"request": {
"cmsLocaleId": "653ad57de882f528b32e810e",
"createdOn": "2022-11-17T17:11:57.148Z",
"fieldData": {
"name": "Pan Galactic Gargle Blaster Recipe",
"slug": "pan-galactic-gargle-blaster",
},
"id": "42b720ef280c7a7a3be8cabe",
"isArchived": false,
"isDraft": false,
"lastPublished": "2022-11-29T16:22:43.159Z",
"lastUpdated": "2022-11-17T17:19:43.282Z",
},
"response": {
"body": {
Expand Down Expand Up @@ -13345,15 +13321,7 @@ service:
"docs": "Identifier for the locale of the CMS item",
"type": "optional<string>",
},
"createdOn": {
"docs": "The date the item was created",
"type": "optional<string>",
},
"fieldData": "optional<ItemsUpdateItemLiveRequestFieldData>",
"id": {
"docs": "Unique identifier for the Item",
"type": "string",
},
"isArchived": {
"default": false,
"docs": "Boolean determining if the Item is set to archived",
Expand All @@ -13364,14 +13332,6 @@ service:
"docs": "Boolean determining if the Item is set to draft",
"type": "optional<boolean>",
},
"lastPublished": {
"docs": "The date the item was last published",
"type": "optional<string>",
},
"lastUpdated": {
"docs": "The date the item was last updated",
"type": "optional<string>",
},
},
},
"content-type": "application/json",
Expand Down Expand Up @@ -15195,21 +15155,9 @@ service:
name: ItemsUpdateItemRequest
body:
properties:
id:
type: string
docs: Unique identifier for the Item
cmsLocaleId:
type: optional<string>
docs: Identifier for the locale of the CMS item
lastPublished:
type: optional<string>
docs: The date the item was last published
lastUpdated:
type: optional<string>
docs: The date the item was last updated
createdOn:
type: optional<string>
docs: The date the item was created
isArchived:
type: optional<boolean>
docs: Boolean determining if the Item is set to archived
Expand All @@ -15234,11 +15182,7 @@ service:
collection_id: 580e63fc8c9a982ac9b8b745
item_id: 580e64008c9a982ac9b8b754
request:
id: 42b720ef280c7a7a3be8cabe
cmsLocaleId: 653ad57de882f528b32e810e
lastPublished: '2022-11-29T16:22:43.159Z'
lastUpdated: '2022-11-17T17:19:43.282Z'
createdOn: '2022-11-17T17:11:57.148Z'
isArchived: false
isDraft: false
fieldData:
Expand Down Expand Up @@ -15369,21 +15313,9 @@ service:
name: ItemsUpdateItemLiveRequest
body:
properties:
id:
type: string
docs: Unique identifier for the Item
cmsLocaleId:
type: optional<string>
docs: Identifier for the locale of the CMS item
lastPublished:
type: optional<string>
docs: The date the item was last published
lastUpdated:
type: optional<string>
docs: The date the item was last updated
createdOn:
type: optional<string>
docs: The date the item was created
isArchived:
type: optional<boolean>
docs: Boolean determining if the Item is set to archived
Expand All @@ -15408,11 +15340,7 @@ service:
collection_id: 580e63fc8c9a982ac9b8b745
item_id: 580e64008c9a982ac9b8b754
request:
id: 42b720ef280c7a7a3be8cabe
cmsLocaleId: 653ad57de882f528b32e810e
lastPublished: '2022-11-29T16:22:43.159Z'
lastUpdated: '2022-11-17T17:19:43.282Z'
createdOn: '2022-11-17T17:11:57.148Z'
isArchived: false
isDraft: false
fieldData:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16003,41 +16003,13 @@
"headers": [],
"request": {
"properties": {
"id": {
"value": {
"value": "42b720ef280c7a7a3be8cabe",
"type": "string"
},
"type": "primitive"
},
"cmsLocaleId": {
"value": {
"value": "653ad57de882f528b32e810e",
"type": "string"
},
"type": "primitive"
},
"lastPublished": {
"value": {
"value": "2022-11-29T16:22:43.159Z",
"type": "string"
},
"type": "primitive"
},
"lastUpdated": {
"value": {
"value": "2022-11-17T17:19:43.282Z",
"type": "string"
},
"type": "primitive"
},
"createdOn": {
"value": {
"value": "2022-11-17T17:11:57.148Z",
"type": "string"
},
"type": "primitive"
},
"isArchived": {
"value": {
"value": false,
Expand Down Expand Up @@ -17800,41 +17772,13 @@
"headers": [],
"request": {
"properties": {
"id": {
"value": {
"value": "42b720ef280c7a7a3be8cabe",
"type": "string"
},
"type": "primitive"
},
"cmsLocaleId": {
"value": {
"value": "653ad57de882f528b32e810e",
"type": "string"
},
"type": "primitive"
},
"lastPublished": {
"value": {
"value": "2022-11-29T16:22:43.159Z",
"type": "string"
},
"type": "primitive"
},
"lastUpdated": {
"value": {
"value": "2022-11-17T17:19:43.282Z",
"type": "string"
},
"type": "primitive"
},
"createdOn": {
"value": {
"value": "2022-11-17T17:11:57.148Z",
"type": "string"
},
"type": "primitive"
},
"isArchived": {
"value": {
"value": false,
Expand Down
Loading
Loading