When $(M_1,\omega_1)$ and $(M_2,\omega_2)$ are symplectic manifolds then we endow $M_1\times M_2$ with the symplectic form $\omega_1\ominus\omega_2:=\pi_1^\ast\omega_1-\pi_2^\ast\omega_2,$ (where $\pi_i:M_1\times M_2\to M_i$ denotes the projection on the $i$-th factor.)

Let $\Lambda$ be an arbitrary Lagrangian submanifold of $M_1\times M_2,\omega_1\ominus\omega_2),$ and $i:\Lambda\to M_1\times M_2$ the inclusion map.

Fixed $p\in\Lambda$, for any primitive $\theta$ of $\omega_1\ominus\omega_2$ in a neighborhood of $p,$ there exists a smooth local function $S$ around $p$ such that $dS=i^\ast\theta.$ (Because of Poincaré Lemma and $0=i^\ast(\omega_1\ominus\omega_2)=i^\ast d\theta=d(i^\ast\theta).$)

Such a function $S$ is called generating function for $\Lambda,$ and, being only locally defined, it depends on the choice of $\theta.$

To be more specific:

In your context $\omega_i=d\xi_i\wedge dx_i$ is the canonical $2$-form on $M_i=\mathbb{R}^{2n},$ for $i=1,2,$ and $\Lambda$ is the image of $i:(u,f(u,v),g(u,v),v)\in\mathbb{R}^{2n}\to(u,v)\in\mathbb{R}^{4n}.$

As remarked above the local generating functions for $\Lambda$ are sensitive to our choice of the local primitive $\theta_i$ of $\omega_i.$

Let us choose $\theta_1=\xi_1 dx_1$ and $\theta_2=-x_2d\xi_2.$

Then the corresponding generating function is determined (up to a constant) by $dS=i^\ast(\theta_1\ominus\theta_2)=fdu+gdv,$ i.e.: $f=\frac{\partial S}{\partial u},\ g=\frac{\partial S}{\partial v}.$