Skip to content

Commit

Permalink
fix(cli): openapi parser handles example generation for 204 status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi committed Jan 29, 2025
1 parent 58b59d7 commit 27cac98
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ export class ExampleEndpointFactory {
if (responseSchemaIdResponse != null && responseSchemaIdResponse.type === "present") {
const required = this.isSchemaRequired(responseSchemaIdResponse.schema);

if (endpoint.response?.type === "json" && endpoint.response.statusCode === 204) {
responseExamples.push([
undefined,
EndpointResponseExample.withoutStreaming(FullExample.object({
properties: {}
}))
]);
}

if (responseSchemaIdResponse.examples.length === 0) {
const example = this.exampleTypeFactory.buildExample({
skipReadonly: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23783,6 +23783,14 @@ docs: The Contracts resource lets you create, amend and, retrieve Deel contracts
"root.ArchiveContractRequestInternalServerError",
],
"examples": [
{
"path-parameters": {
"contract_id": "37nex2x",
},
"response": {
"body": {},
},
},
{
"path-parameters": {
"contract_id": "37nex2x",
Expand Down Expand Up @@ -25080,6 +25088,10 @@ service:
- root.ArchiveContractRequestNotFoundError
- root.ArchiveContractRequestInternalServerError
examples:
- path-parameters:
contract_id: 37nex2x
response:
body: {}
- path-parameters:
contract_id: 37nex2x
response:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11571,6 +11571,31 @@
"method": "PATCH",
"path": "/contracts/{contract_id}/archive",
"examples": [
{
"pathParameters": [
{
"name": "contract_id",
"value": {
"value": {
"value": "37nex2x",
"type": "string"
},
"type": "primitive"
}
}
],
"queryParameters": [],
"headers": [],
"response": {
"value": {
"properties": {},
"type": "object"
},
"type": "withoutStreaming"
},
"codeSamples": [],
"type": "full"
},
{
"pathParameters": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14153,6 +14153,14 @@ docs: The Contracts resource lets you create, amend and, retrieve Deel contracts
"root.InternalServerError",
],
"examples": [
{
"path-parameters": {
"contract_id": "37nex2x",
},
"response": {
"body": {},
},
},
{
"path-parameters": {
"contract_id": "37nex2x",
Expand Down Expand Up @@ -15450,6 +15458,10 @@ service:
- root.NotFoundError
- root.InternalServerError
examples:
- path-parameters:
contract_id: 37nex2x
response:
body: {}
- path-parameters:
contract_id: 37nex2x
response:
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
- changelogEntry:
- summary: |
The OpenAPI parser generates response examples that are `{}` for 204 response types.
type: fix
irVersion: 55
version: 0.51.10

- changelogEntry:
- summary: |
Fixed OpenAPI importer to properly handle response status codes in documentation by propagating
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`help > no arguments 1`] = `
"(node:76082) [DEP0040] DeprecationWarning: The \`punycode\` module is deprecated. Please use a userland alternative instead.
(Use \`node --trace-deprecation ...\` to show where the warning was created)
fern-dev
"fern-dev

Commands:
fern-dev init Initialize a Fern API
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`jsonschema > works with latest version 1`] = `
{
"additionalProperties": false,
"definitions": {
"imdb.MovieId": {
"type": "string",
},
},
"properties": {
"id": {
"$ref": "#/definitions/imdb.MovieId",
},
"rating": {
"type": "number",
},
"title": {
"type": "string",
},
},
"required": [
"id",
"title",
"rating",
],
"type": "object",
}
`;

0 comments on commit 27cac98

Please sign in to comment.