Put type mapping into its own function because API generation will need this too