Skip to content

Commit

Permalink
fix(cli): respect x-fern-ignore on openapi parameters (#4994)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Oct 24, 2024
1 parent 4ffd130 commit d3692f7
Show file tree
Hide file tree
Showing 8 changed files with 778 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import {
Source
} from "@fern-api/openapi-ir";
import { OpenAPIV3 } from "openapi-types";
import { getExtension } from "../../../../getExtension";
import { convertAvailability } from "../../../../schema/convertAvailability";
import { convertSchema } from "../../../../schema/convertSchemas";
import { getExamplesString } from "../../../../schema/examples/getExample";
import { getGeneratedTypeName } from "../../../../schema/utils/getSchemaName";
import { isReferenceObject } from "../../../../schema/utils/isReferenceObject";
import { AbstractOpenAPIV3ParserContext } from "../../AbstractOpenAPIV3ParserContext";
import { FernOpenAPIExtension } from "../../extensions/fernExtensions";
import { getParameterName } from "../../extensions/getParameterName";
import { getVariableReference } from "../../extensions/getVariableReference";

Expand Down Expand Up @@ -45,6 +47,14 @@ export function convertParameters({
headers: []
};
for (const parameter of parameters) {
const shouldIgnore = getExtension<boolean>(parameter, FernOpenAPIExtension.IGNORE);
if (shouldIgnore != null && shouldIgnore) {
context.logger.debug(
`${httpMethod.toUpperCase()} ${path} has a parameter marked with x-fern-ignore. Skipping.`
);
continue;
}

const resolvedParameter = isReferenceObject(parameter)
? context.resolveParameterReference(parameter)
: parameter;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{
"absoluteFilePath": "/DUMMY_PATH",
"importedDefinitions": {},
"namedDefinitionFiles": {
"__package__.yml": {
"absoluteFilepath": "/DUMMY_PATH",
"contents": {
"service": {
"auth": false,
"base-path": "",
"endpoints": {
"list": {
"auth": false,
"display-name": "List",
"docs": "",
"examples": [
{
"response": {
"body": {
"meta": {
"hasMore": true,
},
"users": [
{
"age": 1,
"email": "email",
"id": "id",
"name": "name",
},
],
},
},
},
],
"method": "GET",
"pagination": undefined,
"path": "/list",
"request": {
"name": "ListRequest",
"query-parameters": {
"limit": "optional<integer>",
"pageNumber": "optional<integer>",
},
},
"response": {
"docs": "Success",
"type": "UsersResponse",
},
},
},
"source": {
"openapi": "../openapi.yml",
},
},
"types": {
"Meta": {
"docs": undefined,
"properties": {
"hasMore": "optional<boolean>",
},
"source": {
"openapi": "../openapi.yml",
},
},
"User": {
"docs": undefined,
"properties": {
"age": "optional<integer>",
"email": "optional<string>",
"id": {
"type": "optional<string>",
"validation": {
"format": "uuid",
"maxLength": undefined,
"minLength": undefined,
"pattern": undefined,
},
},
"name": "optional<string>",
},
"source": {
"openapi": "../openapi.yml",
},
},
"UsersResponse": {
"docs": undefined,
"properties": {
"meta": "optional<Meta>",
"users": "optional<list<User>>",
},
"source": {
"openapi": "../openapi.yml",
},
},
},
},
"rawContents": "service:
auth: false
base-path: ''
endpoints:
list:
path: /list
method: GET
auth: false
docs: ''
display-name: List
request:
name: ListRequest
query-parameters:
pageNumber: optional<integer>
limit: optional<integer>
response:
docs: Success
type: UsersResponse
examples:
- response:
body:
meta:
hasMore: true
users:
- id: id
name: name
email: email
age: 1
source:
openapi: ../openapi.yml
types:
Meta:
properties:
hasMore: optional<boolean>
source:
openapi: ../openapi.yml
UsersResponse:
properties:
meta: optional<Meta>
users: optional<list<User>>
source:
openapi: ../openapi.yml
User:
properties:
id:
type: optional<string>
validation:
format: uuid
name: optional<string>
email: optional<string>
age: optional<integer>
source:
openapi: ../openapi.yml
",
},
},
"packageMarkers": {},
"rootApiFile": {
"contents": {
"display-name": "Test extension `x-fern-ignore`",
"error-discrimination": {
"strategy": "status-code",
},
"name": "api",
},
"defaultUrl": undefined,
"rawContents": "name: api
error-discrimination:
strategy: status-code
display-name: Test extension `x-fern-ignore`
",
},
}
Loading

0 comments on commit d3692f7

Please sign in to comment.