How to configure open drain output pin on STM32

How to configure Output GPIO to be Open Drain (Nucleo32 F303). All examplse found on the web seens not to work.

The following one did not work, its remains 3.3V push-pull output.

DigitalInOut LED_Green(PA_3, PIN_OUTPUT, OpenDrain, 1);

DigitalInOut LED_Blue(PA_1);
/* Set LED pins for open Drain Output */
LED_Blue.output();
LED_Blue.mode(OpenDrain);
LED_Blue.mode(PullNone);
if(LED_Blue.is_connected()) {
DEBUG("- Blue LED Connected -\n\r");
}

Hello Francois,
When the mode method is called again with different argument then it overrides the previous settings. So rather than:

LED_Blue.mode(OpenDrain);
LED_Blue.mode(PullNone);

try:

LED_Blue.mode(OpenDrainNoPull);

For the STM targets the PullMode is defined in mbed-os\targets\TARGET_STM\PinNamesTypes.h:

typedef enum {
    PullNone          = 0,
    PullUp            = 1,
    PullDown          = 2,
    OpenDrainPullUp   = 3,
    OpenDrainNoPull   = 4,
    OpenDrainPullDown = 5,
    PushPullNoPull    = PullNone,
    PushPullPullUp    = PullUp,
    PushPullPullDown  = PullDown,
    OpenDrain         = OpenDrainPullUp,
    PullDefault       = PullNone
} PinMode;

Thanks a lot, you comment are more than welcome!
I used DigitalInOut LED_Green(PA_8, PIN_OUTPUT, OpenDrainNoPull, 1);
/* Set LED pins for open Drain Output */
LED_Blue.output();
LED_Blue.mode(OpenDrainNoPull);
if(LED_Blue.is_connected()) {
DEBUG("- Blue LED Connected -\n\r");
}

I was also using pin (AnalogIn) which does not support 5 Volst (FF) but 3.3V Only (TT).
I have move my signals form
PA_0/PA_1/PA_3 to PA_8/PA_11/PA_12 which are 5V Tolerant (FF).
And it works fine.

Regards,
fbd38