diff --git a/fern/products/openapi-def/openapi-def.yml b/fern/products/openapi-def/openapi-def.yml index 419d75e5b..a843620a7 100644 --- a/fern/products/openapi-def/openapi-def.yml +++ b/fern/products/openapi-def/openapi-def.yml @@ -4,7 +4,7 @@ navigation: - page: Authentication path: ./pages/auth.mdx - page: Servers - path: ./pages/servers.mdx + path: ./pages/servers.mdx - section: Endpoints slug: endpoints contents: @@ -17,6 +17,9 @@ navigation: - page: Server-Sent Events path: ./pages/endpoints/sse.mdx slug: sse + - page: others + title: Other + path: ./pages/extensions/others.mdx - section: Extensions slug: extensions contents: @@ -38,7 +41,7 @@ navigation: - page: Overlay Customizations path: ./pages/overrides.mdx - page: Sync your OpenAPI Specification - path: ./pages/automation.mdx + path: ./pages/automation.mdx - section: Integrate your Server Framework slug: frameworks contents: diff --git a/fern/products/openapi-definition/pages/extensions/others.mdx b/fern/products/openapi-definition/pages/extensions/others.mdx new file mode 100644 index 000000000..16e32d15b --- /dev/null +++ b/fern/products/openapi-definition/pages/extensions/others.mdx @@ -0,0 +1,79 @@ +--- +title: 'Other OpenAPI Extensions' +description: 'Reference of Fern-supported OpenAPI extensions' +--- + +# Fern OpenAPI Extensions + +Below is a comprehensive list of all OpenAPI extensions supported by Fern: + +## x-fern-sdk-variables + +Defines variables that can be passed into SDK client constructors. Variables defined here can be referenced in operation paths. + +```yaml +x-fern-sdk-variables: + project_id: + type: string + description: The ID of the project + pattern: "^proj_[a-zA-Z0-9]+$" +``` + +## x-fern-sdk-group-name + +Groups operations together in generated SDKs under a common namespace/class. + +```yaml +x-fern-sdk-group-name: accounts +``` + +## x-fern-sdk-method-name + +Specifies the method name to use in generated SDKs. + +```yaml +x-fern-sdk-method-name: retrieve +``` + +## x-fern-sdk-return-value + +Indicates which part of the response should be returned from SDK methods. + +```yaml +x-fern-sdk-return-value: data +``` + +## x-fern-pagination + +Configures pagination for list endpoints. + +```yaml +x-fern-pagination: + cursor: "$request.after" + next_cursor: "$response.page_info.end_cursor" + results: "$response.data" +``` + +## x-fern-ignore + +Excludes an operation from SDK generation. + +```yaml +x-fern-ignore: true +``` + +## x-fern-sdk-variable + +References a variable defined in x-fern-sdk-variables. + +```yaml +x-fern-sdk-variable: project_id +``` + + +All extensions are optional. Only include the ones needed for your specific use case. + + + +Extensions must be properly formatted according to OpenAPI specification rules. Invalid extension formatting may cause SDK generation to fail. + \ No newline at end of file diff --git a/fern/products/sdks/overview/python/configuration.mdx b/fern/products/sdks/overview/python/configuration.mdx index 1c0eb6af7..ecb5042d3 100644 --- a/fern/products/sdks/overview/python/configuration.mdx +++ b/fern/products/sdks/overview/python/configuration.mdx @@ -15,7 +15,30 @@ groups: config: package_name: "your_package" client: - class_name: "YourClient" + class_name: "YourClient" +``` + +## Extension Headers + +You can configure SDK variables in your OpenAPI spec using the `x-fern-sdk-variables` extension. These variables will be injected into the SDK client constructor. + +For example, to add a `project_id` variable that gets automatically injected into path parameters: + +```yaml +components: + x-fern-sdk-variables: + project_id: + type: string + description: The ID of the project + pattern: "^proj_[a-zA-Z0-9]+$" +``` + +The variable will be available in the client constructor: + +```python +from my_package import Client + +client = Client(project_id="proj_123") ``` ## SDK Configuration Options @@ -72,7 +95,6 @@ groups: - Specifies the Python package name that users will import your generated client from. @@ -112,8 +134,8 @@ groups: # Visit every case in the union shape = get_shape() shape.visit( - circle: lambda circle: do_something_with_circle(circle), - triangle: lambda triangle: do_something_with_triangle(triangle), + circle=lambda circle: do_something_with_circle(circle), + triangle=lambda triangle: do_something_with_triangle(triangle), ) ```