Connor Lloyd's try was the difference between the sides, his second half score part of an improved performance for Richard Lancaster's men after half time.
It meant Swansea atoned for last year's crushing defeat but it was far from one way traffic.
Cardiff had deservedly led 10-0 at the break, Arthur Ellis scoring the only try with Charles Simpson converting and adding a penalty.
The second half was much more even, Sam Soul replying for Swansea with Ianto Griffiths kicking a conversion and a penalty. Simpson had responded in kind for Cardiff but a second try for Swansea, scored by replacement Lloyd, proved vital.
Two late penalties from Griffiths only put the nail in Cardiff's coffin.
It had been scrappy stuff in the early exchanges, Cardiff fly-half Jack Neville kicking a ball dead to sum up the first 10 minutes. His side though, were making most of the running but when the chance for the first points arose, full back Simpson put a penalty effort wide of the posts.
A successful kick would have been a fair reward for Cardiff's fast start, Bryn Phillips looking particularly lively. One break from the Cardiff scrum half saw Martyn Fowler's side gain momentum but when a try for Jack Phillips looked on, the pass failed to arrive and the chance was lost.
Simpson finally got the scoreboard moving with his second penalty effort but it was the defences who remained on top. With a strong pack featuring a number of players who have played Premiership rugby this season, Swansea would have fancied their chances of bullying the Cardiff forwards. It was not the case though and Swansea were struggling for any real parity up front.
And things soon got worse for them, Reuben Tucker yellow carded following persistent Cardiff pressure. With a man advantage and camped on the Swansea line, Cardiff then opted to put a kickable penalty into the corner.
It proved to be the correct decision as following a line-out to the tail, the Cardiff forwards rumbled over, Ellis emerging with the ball to claim the first try of the day. Simpson added the conversion via an upright and after half an hour, Cardiff led 10-0.
If the score was perhaps surprising, it was no less than deserved. Cardiff were dominating possession, retaining the ball impressively and barely letting Swansea out of their own half. The only negative for Fowler would have been that his side didn't lead by more, Rhys Howell knocking on when a pass inside could have led to a second try.
There were no further scores though and at the break, Cardiff could have been further clear.
After barely getting going in the first period, Swansea came out firing in the second half and were soon back in the game, Soul going over in the corner. The conversion was missed but there was now little between the teams, both on the scoreboard and on the field.
With chances few and far between, both sides opted to kick at goal when given the chance. Simpson and Griffiths exchanged monster penalties for either side but with an hour played, Cardiff still held the advantage.
It was one that didn't last though as Swansea took the lead for the first time. Replacement Lloyd was the scorer, picking up a loose ball to dive over to the right of the posts. Griffiths converted and going into the final 10 minutes, Swansea led, albeit narrowly.
But when Griffiths knocked over two late penalties, it left Cardiff wondering what might have been.