This is a follow up of a recent post I made (Making sense of stationary phase method for the path integral), but here I will work in Euclidean space, i.e. a Wick rotation has been performed.
Let $$Z[J] = \int D[\phi] e^{\frac1\hbar(S[\phi]-\int J\phi)}$$ denote the generating functional for a source $J(x)$. Letting $W[J]$ denote the generating functional for the connected diagrams, we know that $$Z[J] = e^{\frac1\hbar W[J]}. \tag{1}$$
To compute $W[J]$ we perform a loop expansion, which means expanding (1) in $\hbar$: $$W[J] = W_0[J] + \hbar W_1[J] + \frac{\hbar^2}{2}W_2[J] + \mathcal{O}(h^3) \tag{2}.$$
I am not sure how (2) is obtained. Does this follow from (1) or is this something we would like to express $W[J]$ as? If it is the latter, what ensures we can always do this?